use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class AuditEventDefaultFormatterTest method testFormatFullyQualifiedModuleNameDoesNotContainCheckSuffix.
@Test
public void testFormatFullyQualifiedModuleNameDoesNotContainCheckSuffix() {
final AuditEvent mock = PowerMockito.mock(AuditEvent.class);
when(mock.getSourceName()).thenReturn("com.test.package.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 testAcceptOnNullFile.
@Test
public void testAcceptOnNullFile() throws CheckstyleException {
final String fileName = null;
final boolean optional = false;
final SuppressionFilter filter = createSupressionFilter(fileName, optional);
final AuditEvent ev = new AuditEvent(this, "AnyJava.java", null);
assertTrue(filter.accept(ev));
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressionFilterTest method testAccept.
@Test
public void testAccept() throws CheckstyleException {
final String fileName = "src/test/resources/com/puppycrawl/tools/checkstyle/filters/" + "suppressions_none.xml";
final boolean optional = false;
final SuppressionFilter filter = createSupressionFilter(fileName, optional);
final AuditEvent ev = new AuditEvent(this, "ATest.java", null);
assertTrue(filter.accept(ev));
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressionFilterTest method testExistingSuppressionFileWithTrueOptional.
@Test
public void testExistingSuppressionFileWithTrueOptional() throws Exception {
final String fileName = "src/test/resources/com/puppycrawl/tools/checkstyle/filters/" + "suppressions_none.xml";
final boolean optional = true;
final SuppressionFilter filter = createSupressionFilter(fileName, optional);
final AuditEvent ev = new AuditEvent(this, "AnyFile.java", null);
assertTrue(filter.accept(ev));
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressElementTest method testDecideByFileNameAndModuleMatchingRegExpNotMatch.
@Test
public void testDecideByFileNameAndModuleMatchingRegExpNotMatch() {
final LocalizedMessage message = new LocalizedMessage(10, 10, "", "", null, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, "T1est", message);
assertTrue(filter.accept(ev));
}
Aggregations