Search in sources :

Example 1 with ParseErrorMessage

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);
    }
}
Also used : ParseErrorMessage(com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseErrorMessage) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 2 with ParseErrorMessage

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);
}
Also used : Violation(com.puppycrawl.tools.checkstyle.api.Violation) ParseErrorMessage(com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseErrorMessage) Test(org.junit.jupiter.api.Test)

Example 3 with ParseErrorMessage

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);
    }
}
Also used : ParseErrorMessage(com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseErrorMessage) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 4 with ParseErrorMessage

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);
    }
}
Also used : ParseErrorMessage(com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseErrorMessage) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 5 with ParseErrorMessage

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);
    }
}
Also used : ParseErrorMessage(com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseErrorMessage) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

ParseErrorMessage (com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseErrorMessage)10 Test (org.junit.jupiter.api.Test)9 File (java.io.File)6 Violation (com.puppycrawl.tools.checkstyle.api.Violation)3 ParseStatus (com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseStatus)1 LineColumn (com.puppycrawl.tools.checkstyle.api.LineColumn)1