use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressFilterElementTest method testDecideByFileNameAndModuleMatchingMessageNull.
@Test
public void testDecideByFileNameAndModuleMatchingMessageNull() {
final AuditEvent ev = new AuditEvent(this, "ATest.java", null);
assertWithMessage("Filter should accept valid event").that(filter.accept(ev)).isTrue();
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressFilterElementTest method testDecideByFileNameAndModuleMatchingRegExpNotMatch.
@Test
public void testDecideByFileNameAndModuleMatchingRegExpNotMatch() {
final Violation message = new Violation(10, 10, "", "", null, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, "T1est", message);
assertWithMessage("Filter should accept valid event").that(filter.accept(ev)).isTrue();
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressFilterElementTest method testDecideByColumn.
@Test
public void testDecideByColumn() {
final Violation violation = new Violation(10, 10, "", "", null, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, "ATest.java", violation);
final SuppressFilterElement filter1 = new SuppressFilterElement("Test", "Test", null, null, null, "1-10");
final SuppressFilterElement filter2 = new SuppressFilterElement("Test", "Test", null, null, null, "1-9, 11");
// deny because there are matches on file name, check name, and column
assertWithMessage("In range 1-10").that(filter1.accept(ev)).isFalse();
assertWithMessage("Not in 1-9, 1)").that(filter2.accept(ev)).isTrue();
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class AuditEventDefaultFormatterTest method testFormatModuleNameDoesNotContainCheckSuffix.
@Test
public void testFormatModuleNameDoesNotContainCheckSuffix() {
final AuditEvent mock = PowerMockito.mock(AuditEvent.class);
when(mock.getSourceName()).thenReturn("TestModule");
when(mock.getSeverityLevel()).thenReturn(SeverityLevel.WARNING);
when(mock.getLine()).thenReturn(1);
when(mock.getColumn()).thenReturn(1);
when(mock.getMessage()).thenReturn("Mocked message.");
when(mock.getFileName()).thenReturn("InputMockFile.java");
final AuditEventFormatter formatter = new AuditEventDefaultFormatter();
final String expected = "[WARN] InputMockFile.java:1:1: Mocked message. [TestModule]";
assertEquals(expected, formatter.format(mock));
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressionFilterTest method testNonExistanceSuppressionUrlWithTrueOptional.
@Test
public void testNonExistanceSuppressionUrlWithTrueOptional() throws Exception {
final String fileName = "http://checkstyle.sourceforge.net/non_existing_suppression.xml";
final boolean optional = true;
final SuppressionFilter filter = createSupressionFilter(fileName, optional);
final AuditEvent ev = new AuditEvent(this, "AnyFile.java", null);
assertTrue(filter.accept(ev));
}
Aggregations