use of com.puppycrawl.tools.checkstyle.api.Violation in project checkstyle by checkstyle.
the class DetailNodeTreeStringPrinterTest method testWrongSingletonParseErrorMessage.
@Test
public void testWrongSingletonParseErrorMessage() throws Exception {
final String actual = TestUtil.invokeStaticMethod(DetailNodeTreeStringPrinter.class, "getParseErrorMessage", new ParseErrorMessage(100, MSG_JAVADOC_WRONG_SINGLETON_TAG, 9, "tag"));
final Violation violation = new Violation(100, "com.puppycrawl.tools.checkstyle.checks.javadoc.messages", MSG_JAVADOC_WRONG_SINGLETON_TAG, new Object[] { 9, "tag" }, "", DetailNodeTreeStringPrinter.class, null);
final String expected = "[ERROR:100] " + violation.getViolation();
assertWithMessage("Javadoc parse error violation for void elements with close tag " + "doesn't meet expectations").that(actual).isEqualTo(expected);
}
use of com.puppycrawl.tools.checkstyle.api.Violation in project checkstyle by checkstyle.
the class DetailNodeTreeStringPrinterTest method testMissedHtmlTagParseErrorMessage.
@Test
public void testMissedHtmlTagParseErrorMessage() throws Exception {
final String actual = TestUtil.invokeStaticMethod(DetailNodeTreeStringPrinter.class, "getParseErrorMessage", new ParseErrorMessage(35, MSG_JAVADOC_MISSED_HTML_CLOSE, 7, "xyz"));
final Violation violation = new Violation(35, "com.puppycrawl.tools.checkstyle.checks.javadoc.messages", MSG_JAVADOC_MISSED_HTML_CLOSE, new Object[] { 7, "xyz" }, "", DetailNodeTreeStringPrinter.class, null);
final String expected = "[ERROR:35] " + violation.getViolation();
assertWithMessage("Javadoc parse error violation for missed HTML tag " + "doesn't meet expectations").that(actual).isEqualTo(expected);
}
use of com.puppycrawl.tools.checkstyle.api.Violation in project checkstyle by checkstyle.
the class AuditEventDefaultFormatterTest method testFormatFullyQualifiedModuleNameDoesNotContainCheckSuffix.
@Test
public void testFormatFullyQualifiedModuleNameDoesNotContainCheckSuffix() {
final Violation violation = new Violation(1, 1, null, null, null, SeverityLevel.WARNING, null, TestModule.class, "Mocked violation.");
final AuditEvent event = new AuditEvent("", "InputMockFile.java", violation);
final AuditEventFormatter formatter = new AuditEventDefaultFormatter();
final String expected = "[WARN] InputMockFile.java:1:1: Mocked violation. " + "[AuditEventDefaultFormatterTest$TestModule]";
assertWithMessage("Invalid format").that(formatter.format(event)).isEqualTo(expected);
}
use of com.puppycrawl.tools.checkstyle.api.Violation in project checkstyle by checkstyle.
the class DefaultLoggerTest method testAddError.
@Test
public void testAddError() throws Exception {
final OutputStream infoStream = new ByteArrayOutputStream();
final OutputStream errorStream = new ByteArrayOutputStream();
final Method auditStartMessage = getAuditStartMessage();
final Method auditFinishMessage = getAuditFinishMessage();
final DefaultLogger dl = new DefaultLogger(infoStream, AutomaticBean.OutputStreamOptions.CLOSE, errorStream, AutomaticBean.OutputStreamOptions.CLOSE);
dl.finishLocalSetup();
dl.auditStarted(null);
dl.addError(new AuditEvent(this, "fileName", new Violation(1, 2, "bundle", "key", null, null, getClass(), "customViolation")));
dl.auditFinished(null);
auditFinishMessage.setAccessible(true);
auditStartMessage.setAccessible(true);
assertWithMessage("expected output").that(infoStream.toString()).isEqualTo(auditStartMessage.invoke(getAuditStartMessageClass()) + System.lineSeparator() + auditFinishMessage.invoke(getAuditFinishMessageClass()) + System.lineSeparator());
assertWithMessage("expected output").that(errorStream.toString()).isEqualTo("[ERROR] fileName:1:2: customViolation [DefaultLoggerTest]" + System.lineSeparator());
}
use of com.puppycrawl.tools.checkstyle.api.Violation in project checkstyle by checkstyle.
the class DefaultLoggerTest method testAddErrorModuleId.
@Test
public void testAddErrorModuleId() throws Exception {
final OutputStream infoStream = new ByteArrayOutputStream();
final OutputStream errorStream = new ByteArrayOutputStream();
final Method auditFinishMessage = getAuditFinishMessage();
final Method auditStartMessage = getAuditStartMessage();
final DefaultLogger dl = new DefaultLogger(infoStream, OutputStreamOptions.CLOSE, errorStream, OutputStreamOptions.CLOSE);
dl.finishLocalSetup();
dl.auditStarted(null);
dl.addError(new AuditEvent(this, "fileName", new Violation(1, 2, "bundle", "key", null, "moduleId", getClass(), "customViolation")));
dl.auditFinished(null);
auditFinishMessage.setAccessible(true);
auditStartMessage.setAccessible(true);
assertWithMessage("expected output").that(infoStream.toString()).isEqualTo(auditStartMessage.invoke(getAuditStartMessageClass()) + System.lineSeparator() + auditFinishMessage.invoke(getAuditFinishMessageClass()) + System.lineSeparator());
assertWithMessage("expected output").that(errorStream.toString()).isEqualTo("[ERROR] fileName:1:2: customViolation [moduleId]" + System.lineSeparator());
}
Aggregations