Search in sources :

Example 41 with TreeWalkerAuditEvent

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

the class XpathFilterElementTest method testNoQuery.

@Test
public void testNoQuery() throws Exception {
    final TreeWalkerAuditEvent event = getEvent(15, 8, TokenTypes.VARIABLE_DEF);
    final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "Test", null, null, null);
    assertWithMessage("Event should be accepted").that(filter.accept(event)).isFalse();
}
Also used : TreeWalkerAuditEvent(com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent) Test(org.junit.jupiter.api.Test)

Example 42 with TreeWalkerAuditEvent

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

the class XpathFilterElementTest method testNonMatchingFileRegexp.

@Test
public void testNonMatchingFileRegexp() throws Exception {
    final XpathFilterElement filter = new XpathFilterElement("NonMatchingRegexp", "Test", null, null, null);
    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 43 with TreeWalkerAuditEvent

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

the class XpathFilterElementTest method testNullModuleIdAndNonMatchingChecks.

@Test
public void testNullModuleIdAndNonMatchingChecks() throws Exception {
    final String xpath = "NON_MATCHING_QUERY";
    final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "NonMatchingRegexp", 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 44 with TreeWalkerAuditEvent

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

the class XpathFilterElementTest method testNonMatchingColumnNumber.

@Test
public void testNonMatchingColumnNumber() throws Exception {
    final String xpath = "//CLASS_DEF[./IDENT[@text='InputXpathFilterElementSuppressByXpath']]";
    final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "Test", null, null, xpath);
    final TreeWalkerAuditEvent ev = getEvent(3, 100, 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 45 with TreeWalkerAuditEvent

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

the class XpathFilterElementTest method testNonMatchingCheckPattern.

@Test
public void testNonMatchingCheckPattern() throws Exception {
    final Pattern pattern = Pattern.compile("NonMatchingRegexp");
    final XpathFilterElement filter = new XpathFilterElement(null, pattern, null, null, null);
    final TreeWalkerAuditEvent ev = getEvent(3, 0, TokenTypes.CLASS_DEF);
    assertWithMessage("Event should be accepted").that(filter.accept(ev)).isTrue();
}
Also used : Pattern(java.util.regex.Pattern) 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