use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class XpathFilterElementTest method testNonMatchingFilePattern.
@Test
public void testNonMatchingFilePattern() throws Exception {
final Pattern pattern = Pattern.compile("NonMatchingRegexp");
final XpathFilterElement filter = new XpathFilterElement(pattern, null, 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 testNonMatchingModuleId.
@Test
public void testNonMatchingModuleId() throws Exception {
final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "Test", null, "id19", null);
final Violation message = new Violation(3, 0, TokenTypes.CLASS_DEF, "", "", null, null, "id20", 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 XpathQueryGeneratorTest method testConstructorWithTreeWalkerAuditEvent.
@Test
public void testConstructorWithTreeWalkerAuditEvent() {
final Violation violation = new Violation(12, 1, "messages.properties", null, null, null, null, null, null);
final TreeWalkerAuditEvent event = new TreeWalkerAuditEvent(new FileContents(fileText), "InputXpathQueryGenerator", violation, rootAst);
final XpathQueryGenerator queryGenerator = new XpathQueryGenerator(event, DEFAULT_TAB_WIDTH);
final List<String> actual = queryGenerator.generate();
final List<String> expected = Arrays.asList("/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathQueryGenerator']]", "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathQueryGenerator']]/MODIFIERS", "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathQueryGenerator']]/MODIFIERS" + "/LITERAL_PUBLIC");
assertWithMessage("Generated queries do not match expected ones").that(actual).isEqualTo(expected);
}
use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class SuppressWithNearbyCommentFilterTest method testAcceptNullViolation.
@Test
public void testAcceptNullViolation() {
final SuppressWithNearbyCommentFilter filter = new SuppressWithNearbyCommentFilter();
final FileContents contents = new FileContents(new FileText(new File("filename"), Collections.singletonList("//SUPPRESS CHECKSTYLE ignore")));
contents.reportSingleLineComment(1, 0);
final TreeWalkerAuditEvent auditEvent = new TreeWalkerAuditEvent(contents, null, null, null);
assertWithMessage("Filter should accept null violation").that(filter.accept(auditEvent)).isTrue();
}
use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class SuppressWithNearbyCommentFilterTest method testAcceptNullFileContents.
@Test
public void testAcceptNullFileContents() {
final SuppressWithNearbyCommentFilter filter = new SuppressWithNearbyCommentFilter();
final FileContents contents = null;
final TreeWalkerAuditEvent auditEvent = new TreeWalkerAuditEvent(contents, null, new Violation(1, null, null, null, null, Object.class, null), null);
assertWithMessage("Filter should accept audit event").that(filter.accept(auditEvent)).isTrue();
}
Aggregations