use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressElementTest method testDecideByLine.
@Test
public void testDecideByLine() {
final LocalizedMessage message = new LocalizedMessage(10, 10, "", "", null, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, "ATest.java", message);
//deny because there are matches on file name, check name, and line
filter.setLines("1-10");
assertFalse("In range 1-10", filter.accept(ev));
filter.setLines("1-9, 11");
assertTrue("Not in 1-9, 11", filter.accept(ev));
filter.setLines(null);
assertFalse("none", filter.accept(ev));
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressElementTest method testDecideByFileNameAndModuleMatchingModuleEqual.
@Test
public void testDecideByFileNameAndModuleMatchingModuleEqual() {
final LocalizedMessage message = new LocalizedMessage(10, 10, "", "", null, "MyModule", getClass(), null);
final AuditEvent ev = new AuditEvent(this, "ATest.java", message);
filter.setModuleId("MyModule");
assertFalse(filter.accept(ev));
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressionCommentFilterTest method testAcceptNullLocalizedMessage.
@Test
public void testAcceptNullLocalizedMessage() {
final SuppressionCommentFilter filter = new SuppressionCommentFilter();
final AuditEvent auditEvent = new AuditEvent(this);
Assert.assertTrue(filter.accept(auditEvent));
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SeverityMatchFilterTest method testAcceptOnMatch.
@Test
public void testAcceptOnMatch() {
filter.setSeverity(SeverityLevel.INFO);
filter.setAcceptOnMatch(false);
final AuditEvent ev = new AuditEvent(this, "Test.java");
// event with no message has severity level INFO
assertFalse("no message", filter.accept(ev));
final SeverityLevel errorLevel = SeverityLevel.ERROR;
final LocalizedMessage errorMessage = new LocalizedMessage(0, 0, "", "", null, errorLevel, null, getClass(), null);
final AuditEvent ev2 = new AuditEvent(this, "ATest.java", errorMessage);
assertTrue("level:" + errorLevel, filter.accept(ev2));
final SeverityLevel infoLevel = SeverityLevel.INFO;
final LocalizedMessage infoMessage = new LocalizedMessage(0, 0, "", "", null, infoLevel, null, getClass(), null);
final AuditEvent ev3 = new AuditEvent(this, "ATest.java", infoMessage);
assertFalse("level:" + infoLevel, filter.accept(ev3));
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressElementTest method testDecideByFileNameAndModuleMatchingRegExpMatch.
@Test
public void testDecideByFileNameAndModuleMatchingRegExpMatch() {
final LocalizedMessage message = new LocalizedMessage(10, 10, "", "", null, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, "TestSUFFIX", message);
final SuppressElement filterWithoutChecks = new SuppressElement("Test");
assertFalse(filterWithoutChecks.accept(ev));
}
Aggregations