use of com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseErrorMessage in project checkstyle by checkstyle.
the class DetailNodeTreeStringPrinterTest method testParseFileWithError.
@Test
public void testParseFileWithError() throws Exception {
final File file = new File(getPath("InputDetailNodeTreeStringPrinterJavadocWithError.javadoc"));
try {
DetailNodeTreeStringPrinter.printFileAst(file);
assertWithMessage("Javadoc parser didn't fail on missing end tag").fail();
} catch (IllegalArgumentException ex) {
final String expected = TestUtil.invokeStaticMethod(DetailNodeTreeStringPrinter.class, "getParseErrorMessage", new ParseErrorMessage(0, MSG_JAVADOC_MISSED_HTML_CLOSE, 1, "qwe"));
assertWithMessage("Generated and expected parse error messages don't match").that(ex.getMessage()).isEqualTo(expected);
}
}
use of com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseErrorMessage 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.JavadocDetailNodeParser.ParseErrorMessage in project checkstyle by checkstyle.
the class DetailNodeTreeStringPrinterTest method testOmittedStartTagForHtmlElement.
@Test
public void testOmittedStartTagForHtmlElement() throws Exception {
final File file = new File(getPath("InputDetailNodeTreeStringPrinterOmittedStartTagForHtmlElement.javadoc"));
try {
DetailNodeTreeStringPrinter.printFileAst(file);
assertWithMessage("Exception is expected").fail();
} catch (IllegalArgumentException ex) {
final String expected = TestUtil.invokeStaticMethod(DetailNodeTreeStringPrinter.class, "getParseErrorMessage", new ParseErrorMessage(0, MSG_JAVADOC_MISSED_HTML_CLOSE, 3, "a"));
assertWithMessage("Generated and expected parse error messages don't match").that(ex.getMessage()).isEqualTo(expected);
}
}
use of com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseErrorMessage in project checkstyle by checkstyle.
the class DetailNodeTreeStringPrinterTest method testWrongHtmlTagOrder.
@Test
public void testWrongHtmlTagOrder() throws Exception {
final File file = new File(getPath("InputDetailNodeTreeStringPrinterWrongHtmlTagOrder.javadoc"));
try {
DetailNodeTreeStringPrinter.printFileAst(file);
assertWithMessage("Exception is expected").fail();
} catch (IllegalArgumentException ex) {
final String expected = TestUtil.invokeStaticMethod(DetailNodeTreeStringPrinter.class, "getParseErrorMessage", new ParseErrorMessage(0, MSG_JAVADOC_MISSED_HTML_CLOSE, 10, "tag2"));
assertWithMessage("Generated and expected parse error messages don't match").that(ex.getMessage()).isEqualTo(expected);
}
}
use of com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseErrorMessage in project checkstyle by checkstyle.
the class DetailNodeTreeStringPrinterTest method testUnescapedJavaCodeWithGenericsInJavadoc.
@Test
public void testUnescapedJavaCodeWithGenericsInJavadoc() throws Exception {
final File file = new File(getPath("InputDetailNodeTreeStringPrinter" + "UnescapedJavaCodeWithGenericsInJavadoc.javadoc"));
try {
DetailNodeTreeStringPrinter.printFileAst(file);
assertWithMessage("Exception is expected").fail();
} catch (IllegalArgumentException ex) {
final String expected = TestUtil.invokeStaticMethod(DetailNodeTreeStringPrinter.class, "getParseErrorMessage", new ParseErrorMessage(35, MSG_JAVADOC_MISSED_HTML_CLOSE, 7, "parsing"));
assertWithMessage("Generated and expected parse error messages don't match").that(ex.getMessage()).isEqualTo(expected);
}
}
Aggregations