Search in sources :

Example 46 with TreeWalkerAuditEvent

use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.

the class XpathFilterElementTest method testNonMatchingFileNameModuleIdAndCheck.

@Test
public void testNonMatchingFileNameModuleIdAndCheck() throws Exception {
    final String xpath = "NON_MATCHING_QUERY";
    final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", null, null, null, xpath);
    final TreeWalkerAuditEvent ev = getEvent(3, 0, TokenTypes.CLASS_DEF);
    assertWithMessage("Event should be accepted").that(filter.accept(ev)).isTrue();
}
Also used : TreeWalkerAuditEvent(com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent) Test(org.junit.jupiter.api.Test)

Example 47 with TreeWalkerAuditEvent

use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.

the class SuppressionXpathFilterTest method testAcceptOne.

@Test
public void testAcceptOne() throws Exception {
    final boolean optional = false;
    final SuppressionXpathFilter filter = createSuppressionXpathFilter(getPath("InputSuppressionXpathFilterNone.xml"), optional);
    final TreeWalkerAuditEvent ev = new TreeWalkerAuditEvent(null, "ATest.java", null, null);
    assertWithMessage("TreeWalker audit event should be accepted when there are no suppressions").that(filter.accept(ev)).isTrue();
}
Also used : TreeWalkerAuditEvent(com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent) Test(org.junit.jupiter.api.Test)

Example 48 with TreeWalkerAuditEvent

use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.

the class SuppressionXpathFilterTest method testAcceptTwo.

@Test
public void testAcceptTwo() throws Exception {
    final boolean optional = false;
    final SuppressionXpathFilter filter = createSuppressionXpathFilter(getPath("InputSuppressionXpathFilterIdAndQuery.xml"), optional);
    final TreeWalkerAuditEvent ev = new TreeWalkerAuditEvent(null, "file1.java", null, null);
    assertWithMessage("TreeWalker audit event should be accepted").that(filter.accept(ev)).isTrue();
}
Also used : TreeWalkerAuditEvent(com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent) Test(org.junit.jupiter.api.Test)

Example 49 with TreeWalkerAuditEvent

use of com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent in project checkstyle by checkstyle.

the class SuppressionXpathFilterTest method testExistingSuppressionFileWithTrueOptional.

@Test
public void testExistingSuppressionFileWithTrueOptional() throws Exception {
    final boolean optional = true;
    final SuppressionXpathFilter filter = createSuppressionXpathFilter(getPath("InputSuppressionXpathFilterNone.xml"), optional);
    final TreeWalkerAuditEvent ev = new TreeWalkerAuditEvent(null, "AnyJava.java", null, null);
    assertWithMessage("Suppression file with true optional was not accepted").that(filter.accept(ev)).isTrue();
}
Also used : TreeWalkerAuditEvent(com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent) Test(org.junit.jupiter.api.Test)

Aggregations

TreeWalkerAuditEvent (com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent)49 Test (org.junit.jupiter.api.Test)47 Violation (com.puppycrawl.tools.checkstyle.api.Violation)17 FileContents (com.puppycrawl.tools.checkstyle.api.FileContents)8 File (java.io.File)6 FileText (com.puppycrawl.tools.checkstyle.api.FileText)5 Pattern (java.util.regex.Pattern)2