Search in sources :

Example 6 with SeverityLevel

use of com.puppycrawl.tools.checkstyle.api.SeverityLevel 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));
}
Also used : SeverityLevel(com.puppycrawl.tools.checkstyle.api.SeverityLevel) AuditEvent(com.puppycrawl.tools.checkstyle.api.AuditEvent) LocalizedMessage(com.puppycrawl.tools.checkstyle.api.LocalizedMessage) Test(org.junit.Test)

Aggregations

SeverityLevel (com.puppycrawl.tools.checkstyle.api.SeverityLevel)6 AuditEvent (com.puppycrawl.tools.checkstyle.api.AuditEvent)4 LocalizedMessage (com.puppycrawl.tools.checkstyle.api.LocalizedMessage)3 Test (org.junit.Test)3