use of com.puppycrawl.tools.checkstyle.api.Violation in project checkstyle by checkstyle.
the class DetailNodeTreeStringPrinterTest method testParseErrorMessage.
@Test
public void testParseErrorMessage() throws Exception {
final String actual = TestUtil.invokeStaticMethod(DetailNodeTreeStringPrinter.class, "getParseErrorMessage", new ParseErrorMessage(10, MSG_JAVADOC_PARSE_RULE_ERROR, 9, "no viable alternative at input ' xyz'", "SOME_JAVADOC_ELEMENT"));
final Violation violation = new Violation(10, "com.puppycrawl.tools.checkstyle.checks.javadoc.messages", MSG_JAVADOC_PARSE_RULE_ERROR, new Object[] { 9, "no viable alternative at input ' xyz'", "SOME_JAVADOC_ELEMENT" }, "", DetailNodeTreeStringPrinter.class, null);
final String expected = "[ERROR:10] " + violation.getViolation();
assertWithMessage("Javadoc parse error violation doesn't meet expectations").that(actual).isEqualTo(expected);
}
use of com.puppycrawl.tools.checkstyle.api.Violation in project checkstyle by checkstyle.
the class SuppressFilterElementTest method testDecideByFileNameAndModuleMatchingModuleEqual.
@Test
public void testDecideByFileNameAndModuleMatchingModuleEqual() {
final Violation violation = new Violation(10, 10, "", "", null, "MyModule", getClass(), null);
final AuditEvent ev = new AuditEvent(this, "ATest.java", violation);
final SuppressFilterElement myFilter = new SuppressFilterElement("Test", "Test", null, "MyModule", null, null);
assertWithMessage("Filter should not accept invalid event").that(myFilter.accept(ev)).isFalse();
}
use of com.puppycrawl.tools.checkstyle.api.Violation in project checkstyle by checkstyle.
the class SuppressFilterElementTest method testDecideByFileNameAndModuleMatchingRegExpMatch.
@Test
public void testDecideByFileNameAndModuleMatchingRegExpMatch() {
final Violation message = new Violation(10, 10, "", "", null, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, "TestSUFFIX", message);
final SuppressFilterElement myFilter = new SuppressFilterElement("Test", null, null, null, null, null);
assertWithMessage("Filter should not accept invalid event").that(myFilter.accept(ev)).isFalse();
}
use of com.puppycrawl.tools.checkstyle.api.Violation in project checkstyle by checkstyle.
the class SuppressFilterElementTest method testDecideByFileNameAndModuleMatchingFileNameNull.
@Test
public void testDecideByFileNameAndModuleMatchingFileNameNull() {
final Violation message = new Violation(10, 10, "", "", null, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, null, message);
assertWithMessage("Filter should accept valid event").that(filter.accept(ev)).isTrue();
}
use of com.puppycrawl.tools.checkstyle.api.Violation in project checkstyle by checkstyle.
the class SuppressWithNearbyCommentFilterTest method testAcceptNullFileContents.
@Test
public void testAcceptNullFileContents() {
final SuppressWithNearbyCommentFilter filter = new SuppressWithNearbyCommentFilter();
final FileContents contents = null;
final TreeWalkerAuditEvent auditEvent = new TreeWalkerAuditEvent(contents, null, new Violation(1, null, null, null, null, Object.class, null), null);
assertWithMessage("Filter should accept audit event").that(filter.accept(auditEvent)).isTrue();
}
Aggregations