use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class SuppressionXpathFilterTest method testNonExistentSuppressionFileWithTrueOptional.
@Test
public void testNonExistentSuppressionFileWithTrueOptional() throws Exception {
final String fileName = "src/test/resources/com/puppycrawl/tools/checkstyle/filters/" + "non_existent_suppression_file.xml";
final boolean optional = true;
final SuppressionXpathFilter filter = createSuppressionXpathFilter(fileName, optional);
final TreeWalkerAuditEvent ev = new TreeWalkerAuditEvent(null, "AnyFile.java", null, null);
assertWithMessage("Should except event when suppression file does not exist").that(filter.accept(ev)).isTrue();
}
use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class SuppressionXpathFilterTest method testReject.
@Test
public void testReject() throws Exception {
final boolean optional = false;
final SuppressionXpathFilter filter = createSuppressionXpathFilter(getPath("InputSuppressionXpathFilterIdAndQuery.xml"), optional);
final File file = new File(getPath("InputSuppressionXpathFilter.java"));
final Violation message = new Violation(3, 0, TokenTypes.CLASS_DEF, "", "", null, null, "777", getClass(), null);
final TreeWalkerAuditEvent ev = new TreeWalkerAuditEvent(null, "file1.java", message, JavaParser.parseFile(file, JavaParser.Options.WITHOUT_COMMENTS));
assertWithMessage("TreeWalker audit event should be rejected").that(filter.accept(ev)).isFalse();
}
use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class SuppressionXpathSingleFilterTest method testNonMatchingColumnNumber.
@Test
public void testNonMatchingColumnNumber() throws Exception {
final String xpath = "//CLASS_DEF[@text='InputSuppressionXpathSingleFilter']";
final SuppressionXpathSingleFilter filter = createSuppressionXpathSingleFilter("InputSuppressionXpathSingleFilter", "Test", null, null, xpath);
final TreeWalkerAuditEvent ev = createEvent(3, 100, 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 testNonMatchingChecks.
@Test
public void testNonMatchingChecks() throws Exception {
final String xpath = "NON_MATCHING_QUERY";
final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "NonMatchingRegexp", 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 accepted").that(filter.accept(ev)).isTrue();
}
use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class XpathFilterElementTest method testNullViolation.
@Test
public void testNullViolation() {
final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "Test", null, null, null);
final TreeWalkerAuditEvent ev = new TreeWalkerAuditEvent(null, file.getName(), null, null);
assertWithMessage("Event should be accepted").that(filter.accept(ev)).isTrue();
}
Aggregations