use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class SuppressionXpathSingleFilterTest method testMatchingModuleId.
@Test
public void testMatchingModuleId() throws Exception {
final String xpath = "//CLASS_DEF[./IDENT[@text='InputSuppressionXpathSingleFilter']]";
final SuppressionXpathSingleFilter filter = createSuppressionXpathSingleFilter("InputSuppressionXpathSingleFilter", "Test", null, "id19", xpath);
final Violation message = new Violation(3, 0, TokenTypes.CLASS_DEF, "", "", null, null, "id19", getClass(), null);
final TreeWalkerAuditEvent ev = new TreeWalkerAuditEvent(fileContents, file.getName(), message, JavaParser.parseFile(file, JavaParser.Options.WITHOUT_COMMENTS));
assertWithMessage("Event should be rejected").that(filter.accept(ev)).isFalse();
}
use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class XpathFilterElementTest method testThrowException.
@Test
public void testThrowException() {
final String xpath = "//CLASS_DEF[@text='InputXpathFilterElementSuppressByXpath']";
final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "Test", null, null, xpath);
final Violation message = new Violation(3, 0, TokenTypes.CLASS_DEF, "", "", null, null, "id19", getClass(), null);
final TreeWalkerAuditEvent ev = new TreeWalkerAuditEvent(fileContents, file.getName(), message, null);
try {
filter.accept(ev);
assertWithMessage("Exception is expected").fail();
} catch (IllegalStateException ex) {
assertWithMessage("Exception message does not match expected one").that(ex.getMessage().contains("Cannot initialize context and evaluate query")).isTrue();
}
}
use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class XpathFilterElementTest method testMatchingModuleId.
@Test
public void testMatchingModuleId() throws Exception {
final String xpath = "//CLASS_DEF[./IDENT[@text='InputXpathFilterElementSuppressByXpath']]";
final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "Test", null, "id19", xpath);
final Violation message = new Violation(3, 0, TokenTypes.CLASS_DEF, "", "", null, null, "id19", getClass(), null);
final TreeWalkerAuditEvent ev = new TreeWalkerAuditEvent(fileContents, file.getName(), message, JavaParser.parseFile(file, JavaParser.Options.WITHOUT_COMMENTS));
assertWithMessage("Event should be rejected").that(filter.accept(ev)).isFalse();
}
use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class XpathFilterElementTest method testNonMatchingCheckRegexp.
@Test
public void testNonMatchingCheckRegexp() throws Exception {
final XpathFilterElement filter = new XpathFilterElement(null, "NonMatchingRegexp", null, null, null);
final TreeWalkerAuditEvent ev = getEvent(3, 0, TokenTypes.CLASS_DEF);
assertWithMessage("Event should be accepted").that(filter.accept(ev)).isTrue();
}
use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class XpathFilterElementTest method testNullFileName.
@Test
public void testNullFileName() {
final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "Test", null, null, null);
final TreeWalkerAuditEvent ev = new TreeWalkerAuditEvent(null, null, null, null);
assertWithMessage("Event should be accepted").that(filter.accept(ev)).isTrue();
}
Aggregations