use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SeverityMatchFilterTest method testSeverity.
@Test
public void testSeverity() {
filter.setSeverity(SeverityLevel.INFO);
final AuditEvent ev = new AuditEvent(this, "Test.java");
// event with no message has severity level INFO
assertTrue("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);
assertFalse("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);
assertTrue("level:" + infoLevel, filter.accept(ev3));
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SeverityMatchFilterTest method testDefault.
@Test
public void testDefault() {
final AuditEvent ev = new AuditEvent(this, "Test.java");
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 testDecideByFileNameAndModuleMatchingModuleNull.
@Test
public void testDecideByFileNameAndModuleMatchingModuleNull() {
final LocalizedMessage message = new LocalizedMessage(10, 10, "", "", null, "MyModule", getClass(), null);
final AuditEvent ev = new AuditEvent(this, "ATest.java", message);
filter.setModuleId(null);
assertFalse(filter.accept(ev));
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressElementTest method testDecideByFileNameAndModuleMatchingFileNameNull.
@Test
public void testDecideByFileNameAndModuleMatchingFileNameNull() {
final LocalizedMessage message = new LocalizedMessage(10, 10, "", "", null, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, null, message);
assertTrue(filter.accept(ev));
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressWithNearbyCommentFilterTest method testAcceptNullLocalizedMessage.
@Test
public void testAcceptNullLocalizedMessage() {
final SuppressWithNearbyCommentFilter filter = new SuppressWithNearbyCommentFilter();
final AuditEvent auditEvent = new AuditEvent(this);
Assert.assertTrue(filter.accept(auditEvent));
}
Aggregations