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 implements groovy.lang.GroovyObject
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.Object
CONSTRUCTOR_METHOD_NAME
protected static java.lang.Object
DEFAULT_TEST_CLASS_NAMES
protected static java.lang.Object
DEFAULT_TEST_FILES
protected T
rule
protected java.lang.String
sourceCodeName
protected java.lang.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 java.util.List
applyRuleTo(java.lang.String source)
protected void
assertInlineViolations(java.lang.String annotatedSource)
protected void
assertNoViolations(java.lang.String source)
protected void
assertSingleViolation(java.lang.String source)
protected void
assertSingleViolation(java.lang.String source, groovy.lang.Closure closure)
protected void
assertSingleViolation(java.lang.String source, java.lang.Integer lineNumber)
protected void
assertSingleViolation(java.lang.String source, java.lang.Integer lineNumber, java.lang.String sourceLineText)
protected void
assertSingleViolation(java.lang.String source, java.lang.Integer lineNumber, java.lang.String sourceLineText, java.lang.Object messageText)
protected void
assertTwoViolations(java.lang.String source, java.lang.Integer lineNumber1, java.lang.String sourceLineText1, java.lang.Integer lineNumber2, java.lang.String sourceLineText2)
protected void
assertTwoViolations(java.lang.String source, java.lang.Integer lineNumber1, java.lang.String sourceLineText1, java.lang.Object msg1, java.lang.Integer lineNumber2, java.lang.String sourceLineText2, java.lang.Object msg2)
protected void
assertViolation(Violation violation, java.lang.Integer lineNumber, java.lang.String sourceLineText)
protected void
assertViolation(Violation violation, java.lang.Integer lineNumber, java.lang.String sourceLineText, java.lang.Object messageText)
protected void
assertViolations(java.lang.String source, java.util.Map... violationMaps)
protected abstract T
createRule()
groovy.lang.MetaClass
getMetaClass()
java.lang.Object
getProperty(java.lang.String property)
protected static java.lang.String
inlineViolation(java.lang.String violationMessage)
java.lang.Object
invokeMethod(java.lang.String method, java.lang.Object arguments)
protected java.util.List
manuallyApplyRule(java.lang.String source)
protected static java.lang.String
removeInlineViolations(java.lang.String annotatedSource)
void
setMetaClass(groovy.lang.MetaClass mc)
void
setProperty(java.lang.String property, java.lang.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 java.lang.Object CONSTRUCTOR_METHOD_NAME
-
DEFAULT_TEST_FILES
protected static final java.lang.Object DEFAULT_TEST_FILES
-
DEFAULT_TEST_CLASS_NAMES
protected static final java.lang.Object DEFAULT_TEST_CLASS_NAMES
-
sourceCodeName
protected java.lang.String sourceCodeName
-
sourceCodePath
protected java.lang.String sourceCodePath
-
-
Method Detail
-
assertSingleViolation
protected void assertSingleViolation(java.lang.String source, java.lang.Integer lineNumber, java.lang.String sourceLineText)
-
assertSingleViolation
protected void assertSingleViolation(java.lang.String source, java.lang.Integer lineNumber)
-
assertSingleViolation
protected void assertSingleViolation(java.lang.String source)
-
assertViolation
protected void assertViolation(Violation violation, java.lang.Integer lineNumber, java.lang.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 java.lang.Object invokeMethod(java.lang.String method, java.lang.Object arguments)
- Specified by:
invokeMethod
in interfacegroovy.lang.GroovyObject
- Overrides:
invokeMethod
in classAbstractTestCase
-
getProperty
public java.lang.Object getProperty(java.lang.String property)
- Specified by:
getProperty
in interfacegroovy.lang.GroovyObject
- Overrides:
getProperty
in classAbstractTestCase
-
setProperty
public void setProperty(java.lang.String property, java.lang.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(java.lang.String source, java.lang.Integer lineNumber1, java.lang.String sourceLineText1, java.lang.Integer lineNumber2, java.lang.String sourceLineText2)
-
assertInlineViolations
protected void assertInlineViolations(java.lang.String annotatedSource)
-
inlineViolation
protected static java.lang.String inlineViolation(java.lang.String violationMessage)
-
removeInlineViolations
protected static java.lang.String removeInlineViolations(java.lang.String annotatedSource)
-
assertViolations
protected void assertViolations(java.lang.String source, java.util.Map... violationMaps)
-
assertTwoViolations
protected void assertTwoViolations(java.lang.String source, java.lang.Integer lineNumber1, java.lang.String sourceLineText1, java.lang.Object msg1, java.lang.Integer lineNumber2, java.lang.String sourceLineText2, java.lang.Object msg2)
-
assertSingleViolation
protected void assertSingleViolation(java.lang.String source, java.lang.Integer lineNumber, java.lang.String sourceLineText, java.lang.Object messageText)
-
assertSingleViolation
protected void assertSingleViolation(java.lang.String source, groovy.lang.Closure closure)
-
assertNoViolations
protected void assertNoViolations(java.lang.String source)
-
assertViolation
protected void assertViolation(Violation violation, java.lang.Integer lineNumber, java.lang.String sourceLineText, java.lang.Object messageText)
-
applyRuleTo
protected java.util.List applyRuleTo(java.lang.String source)
-
manuallyApplyRule
protected java.util.List manuallyApplyRule(java.lang.String source)
-
setUpAbstractRuleTestCase
public void setUpAbstractRuleTestCase()
-
-