Package org.codenarc.rule
Class AbstractRuleTestCase<T extends Rule>
- java.lang.Object
-
- org.codenarc.test.AbstractTestCase
-
- org.codenarc.rule.AbstractRuleTestCase<T>
-
- All Implemented Interfaces:
groovy.lang.GroovyObject
public abstract class AbstractRuleTestCase<T extends Rule> extends AbstractTestCase
-
-
Field Summary
Fields Modifier and Type Field Description protected static Object
CONSTRUCTOR_METHOD_NAME
protected static Object
DEFAULT_TEST_CLASS_NAMES
protected static Object
DEFAULT_TEST_FILES
protected T
rule
protected String
sourceCodeName
protected String
sourceCodePath
-
Fields inherited from class org.codenarc.test.AbstractTestCase
CODENARC_PROPERTIES_FILE_PROP, LOG, testName
-
-
Constructor Summary
Constructors Constructor Description AbstractRuleTestCase()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected List
applyRuleTo(String source)
protected void
assertInlineViolations(String annotatedSource)
protected void
assertNoViolations(String source)
protected void
assertSingleViolation(String source)
protected void
assertSingleViolation(String source, groovy.lang.Closure closure)
protected void
assertSingleViolation(String source, Integer lineNumber)
protected void
assertSingleViolation(String source, Integer lineNumber, String sourceLineText)
protected void
assertSingleViolation(String source, Integer lineNumber, String sourceLineText, Object messageText)
protected void
assertTwoViolations(String source, Integer lineNumber1, String sourceLineText1, Integer lineNumber2, String sourceLineText2)
protected void
assertTwoViolations(String source, Integer lineNumber1, String sourceLineText1, Object msg1, Integer lineNumber2, String sourceLineText2, Object msg2)
protected void
assertViolation(Violation violation, Integer lineNumber, String sourceLineText)
protected void
assertViolation(Violation violation, Integer lineNumber, String sourceLineText, Object messageText)
protected void
assertViolations(String source, Map... violationMaps)
protected abstract T
createRule()
groovy.lang.MetaClass
getMetaClass()
Object
getProperty(String property)
protected static String
inlineViolation(String violationMessage)
Object
invokeMethod(String method, Object arguments)
protected List
manuallyApplyRule(String source)
protected static String
removeInlineViolations(String annotatedSource)
void
setMetaClass(groovy.lang.MetaClass mc)
void
setProperty(String property, Object value)
void
setUpAbstractRuleTestCase()
void
testThatApplyToFilesMatchingValuesAreValidRegex()
void
testThatInvalidCodeHasNoViolations()
void
testThatUnrelatedCodeHasNoViolations()
-
Methods inherited from class org.codenarc.test.AbstractTestCase
getName, log, setUpAbstractTestCase
-
-
-
-
Field Detail
-
CONSTRUCTOR_METHOD_NAME
protected static final Object CONSTRUCTOR_METHOD_NAME
-
DEFAULT_TEST_FILES
protected static final Object DEFAULT_TEST_FILES
-
DEFAULT_TEST_CLASS_NAMES
protected static final Object DEFAULT_TEST_CLASS_NAMES
-
sourceCodeName
protected String sourceCodeName
-
sourceCodePath
protected String sourceCodePath
-
-
Method Detail
-
assertSingleViolation
protected void assertSingleViolation(String source, Integer lineNumber, String sourceLineText)
-
assertSingleViolation
protected void assertSingleViolation(String source)
-
assertViolation
protected void assertViolation(Violation violation, Integer lineNumber, String sourceLineText)
-
getMetaClass
public groovy.lang.MetaClass getMetaClass()
- Specified by:
getMetaClass
in interfacegroovy.lang.GroovyObject
- Overrides:
getMetaClass
in classAbstractTestCase
-
setMetaClass
public void setMetaClass(groovy.lang.MetaClass mc)
- Specified by:
setMetaClass
in interfacegroovy.lang.GroovyObject
- Overrides:
setMetaClass
in classAbstractTestCase
-
invokeMethod
public Object invokeMethod(String method, Object arguments)
- Specified by:
invokeMethod
in interfacegroovy.lang.GroovyObject
- Overrides:
invokeMethod
in classAbstractTestCase
-
getProperty
public Object getProperty(String property)
- Specified by:
getProperty
in interfacegroovy.lang.GroovyObject
- Overrides:
getProperty
in classAbstractTestCase
-
setProperty
public void setProperty(String property, Object value)
- Specified by:
setProperty
in interfacegroovy.lang.GroovyObject
- Overrides:
setProperty
in classAbstractTestCase
-
testThatUnrelatedCodeHasNoViolations
public void testThatUnrelatedCodeHasNoViolations()
-
testThatInvalidCodeHasNoViolations
public void testThatInvalidCodeHasNoViolations()
-
testThatApplyToFilesMatchingValuesAreValidRegex
public void testThatApplyToFilesMatchingValuesAreValidRegex()
-
createRule
protected abstract T createRule()
-
assertTwoViolations
protected void assertTwoViolations(String source, Integer lineNumber1, String sourceLineText1, Integer lineNumber2, String sourceLineText2)
-
assertInlineViolations
protected void assertInlineViolations(String annotatedSource)
-
assertTwoViolations
protected void assertTwoViolations(String source, Integer lineNumber1, String sourceLineText1, Object msg1, Integer lineNumber2, String sourceLineText2, Object msg2)
-
assertSingleViolation
protected void assertSingleViolation(String source, Integer lineNumber, String sourceLineText, Object messageText)
-
assertSingleViolation
protected void assertSingleViolation(String source, groovy.lang.Closure closure)
-
assertNoViolations
protected void assertNoViolations(String source)
-
assertViolation
protected void assertViolation(Violation violation, Integer lineNumber, String sourceLineText, Object messageText)
-
setUpAbstractRuleTestCase
public void setUpAbstractRuleTestCase()
-
-