use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressWarningsHolderTest method createAuditEvent.
private static AuditEvent createAuditEvent(String moduleId, int line, int column) {
final Checker source = new Checker();
final Violation violation = new Violation(line, column, null, null, null, moduleId, MemberNameCheck.class, "violation");
return new AuditEvent(source, "filename", violation);
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressWarningsHolderTest method testIsSuppressedByModuleId.
@Test
public void testIsSuppressedByModuleId() throws Exception {
populateHolder("check", 100, 100, 350, 350);
final AuditEvent event = createAuditEvent("check", 350, 350);
assertWithMessage("Event is not suppressed").that(SuppressWarningsHolder.isSuppressed(event)).isTrue();
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class XpathFileGeneratorAstFilterTest method testNoXpathQuery.
@Test
public void testNoXpathQuery() throws Exception {
final Violation violation = new Violation(10, 10, TokenTypes.LCURLY, "messages.properties", null, null, SeverityLevel.ERROR, null, LeftCurlyCheck.class, null);
final TreeWalkerAuditEvent event = createTreeWalkerAuditEvent("InputXpathFileGeneratorAstFilter.java", violation);
final XpathFileGeneratorAstFilter filter = new XpathFileGeneratorAstFilter();
assertWithMessage("filter accepted").that(filter.accept(event)).isTrue();
final AuditEvent auditEvent = new AuditEvent(this, getPath("InputXpathFileGeneratorAstFilter.java"), violation);
assertWithMessage("expected null").that(XpathFileGeneratorAstFilter.findCorrespondingXpathQuery(auditEvent)).isNull();
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class XpathFileGeneratorAstFilterTest method testAcceptNoToken.
@Test
public void testAcceptNoToken() {
final Violation violation = new Violation(0, 0, 0, null, null, null, null, null, XpathFileGeneratorAstFilterTest.class, null);
final TreeWalkerAuditEvent event = new TreeWalkerAuditEvent(null, null, violation, null);
final XpathFileGeneratorAstFilter filter = new XpathFileGeneratorAstFilter();
assertWithMessage("filter accepted").that(filter.accept(event)).isTrue();
final AuditEvent auditEvent = new AuditEvent(this, "Test.java", violation);
assertWithMessage("filter has no queries").that(XpathFileGeneratorAstFilter.findCorrespondingXpathQuery(auditEvent)).isNull();
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class XpathFileGeneratorAstFilterTest method testTabWidth.
@Test
public void testTabWidth() throws Exception {
final Violation violation = new Violation(6, 7, TokenTypes.LITERAL_RETURN, "messages.properties", null, null, SeverityLevel.ERROR, null, XpathFileGeneratorAstFilterTest.class, null);
final TreeWalkerAuditEvent event = createTreeWalkerAuditEvent("InputXpathFileGeneratorAstFilter.java", violation);
final XpathFileGeneratorAstFilter filter = new XpathFileGeneratorAstFilter();
filter.setTabWidth(6);
assertWithMessage("filter accepted").that(filter.accept(event)).isTrue();
final AuditEvent auditEvent = new AuditEvent(this, getPath("InputXpathFileGeneratorAstFilter.java"), violation);
assertWithMessage("expected xpath").that(XpathFileGeneratorAstFilter.findCorrespondingXpathQuery(auditEvent)).isEqualTo("/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text='InputXpathFileGeneratorAstFilter']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='tabMethod']]/SLIST/LITERAL_RETURN");
}
Aggregations