use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class SuppressionCommentFilterTest method testFindNearestMatchDontAllowSameColumn.
@Test
public void testFindNearestMatchDontAllowSameColumn() {
final SuppressionCommentFilter suppressionCommentFilter = new SuppressionCommentFilter();
final FileContents contents = new FileContents(new FileText(new File("filename"), Arrays.asList("//CHECKSTYLE:OFF: ConstantNameCheck", "line2")));
contents.reportSingleLineComment(1, 0);
final TreeWalkerAuditEvent dummyEvent = new TreeWalkerAuditEvent(contents, "filename", new Violation(1, null, null, null, null, Object.class, null), null);
final boolean result = suppressionCommentFilter.accept(dummyEvent);
assertWithMessage("Filter should not accept event").that(result).isFalse();
}
use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class SuppressionCommentFilterTest method testAcceptNullViolation.
@Test
public void testAcceptNullViolation() {
final SuppressionCommentFilter filter = new SuppressionCommentFilter();
final FileContents contents = new FileContents(new FileText(new File("filename"), Arrays.asList("//CHECKSTYLE:OFF: ConstantNameCheck", "line2")));
contents.reportSingleLineComment(1, 0);
final TreeWalkerAuditEvent auditEvent = new TreeWalkerAuditEvent(contents, null, null, null);
assertWithMessage("Filter should accept audit event").that(filter.accept(auditEvent)).isTrue();
assertWithMessage("File name should not be null").that(auditEvent.getFileName()).isNull();
}
use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class SuppressionCommentFilterTest method testAcceptNullFileContents.
@Test
public void testAcceptNullFileContents() {
final SuppressionCommentFilter filter = new SuppressionCommentFilter();
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();
}
use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.
the class SuppressionXpathSingleFilterTest method testNonMatchingLineNumber.
@Test
public void testNonMatchingLineNumber() throws Exception {
final String xpath = "//CLASS_DEF[@text='InputSuppressionXpathSingleFilter']";
final SuppressionXpathSingleFilter filter = createSuppressionXpathSingleFilter("InputSuppressionXpathSingleFilter", "Test", null, null, xpath);
final TreeWalkerAuditEvent ev = createEvent(100, 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 SuppressionXpathSingleFilterTest method testNonMatchingFileRegexp.
@Test
public void testNonMatchingFileRegexp() throws Exception {
final String xpath = "NON_MATCHING_QUERY";
final SuppressionXpathSingleFilter filter = createSuppressionXpathSingleFilter("NonMatchingRegexp", "Test", null, null, xpath);
final TreeWalkerAuditEvent ev = createEvent(3, 0, TokenTypes.CLASS_DEF);
assertWithMessage("Event should be accepted").that(filter.accept(ev)).isTrue();
}
Aggregations