Search in sources :

Example 6 with Comment

use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.

the class JavadocUtilTest method testInvalidTags.

@Test
public void testInvalidTags() {
    final String[] text = { "/** @fake block", " * {@bogus inline}", " * {@link List valid}" };
    final Comment comment = new Comment(text, 1, 3, text[2].length());
    final JavadocTags allTags = JavadocUtil.getJavadocTags(comment, JavadocUtil.JavadocTagType.ALL);
    assertWithMessage("Unexpected invalid tags size").that(allTags.getInvalidTags()).hasSize(2);
    assertTag("Unexpected invalid tag", new InvalidJavadocTag(1, 4, "fake"), allTags.getInvalidTags().get(0));
    assertTag("Unexpected invalid tag", new InvalidJavadocTag(2, 4, "bogus"), allTags.getInvalidTags().get(1));
    assertWithMessage("Unexpected valid tags size").that(allTags.getValidTags()).hasSize(1);
    assertTag("Unexpected valid tag", new JavadocTag(3, 4, "link", "List valid"), allTags.getValidTags().get(0));
}
Also used : Comment(com.puppycrawl.tools.checkstyle.api.Comment) InvalidJavadocTag(com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocTag) InvalidJavadocTag(com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocTag) JavadocTag(com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTag) JavadocTags(com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTags) Test(org.junit.jupiter.api.Test)

Example 7 with Comment

use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.

the class JavadocUtilTest method testBlockTag.

@Test
public void testBlockTag() {
    final String[] text = { "/** @see elsewhere ", " */" };
    final Comment comment = new Comment(text, 1, 4, text[1].length());
    final JavadocTags allTags = JavadocUtil.getJavadocTags(comment, JavadocUtil.JavadocTagType.ALL);
    assertWithMessage("Invalid valid tags size").that(allTags.getValidTags()).hasSize(1);
}
Also used : Comment(com.puppycrawl.tools.checkstyle.api.Comment) JavadocTags(com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTags) Test(org.junit.jupiter.api.Test)

Example 8 with Comment

use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.

the class JavadocUtilsTest method testInlineTagLinkText.

@Test
public void testInlineTagLinkText() {
    final String[] text = { "/** {@link List link text }" };
    final Comment comment = new Comment(text, 1, 1, text[0].length());
    final List<JavadocTag> tags = JavadocUtils.getJavadocTags(comment, JavadocUtils.JavadocTagType.ALL).getValidTags();
    assertEquals("List link text", tags.get(0).getFirstArg());
}
Also used : Comment(com.puppycrawl.tools.checkstyle.api.Comment) JavadocTag(com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTag) Test(org.junit.Test)

Example 9 with Comment

use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.

the class JavadocUtilsTest method testTagType.

@Test
public void testTagType() {
    final String[] text = { "/** @see block", " * {@link List inline}, {@link List#add(Object)}" };
    final Comment comment = new Comment(text, 1, 2, text[1].length());
    final JavadocTags blockTags = JavadocUtils.getJavadocTags(comment, JavadocUtils.JavadocTagType.BLOCK);
    final JavadocTags inlineTags = JavadocUtils.getJavadocTags(comment, JavadocUtils.JavadocTagType.INLINE);
    assertEquals(1, blockTags.getValidTags().size());
    assertEquals(2, inlineTags.getValidTags().size());
}
Also used : Comment(com.puppycrawl.tools.checkstyle.api.Comment) JavadocTags(com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTags) Test(org.junit.Test)

Example 10 with Comment

use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.

the class JavadocUtilsTest method testInvalidTags.

@Test
public void testInvalidTags() {
    final String[] text = { "/** @fake block", " * {@bogus inline}", " * {@link List valid}" };
    final Comment comment = new Comment(text, 1, 3, text[2].length());
    final JavadocTags allTags = JavadocUtils.getJavadocTags(comment, JavadocUtils.JavadocTagType.ALL);
    assertEquals(2, allTags.getInvalidTags().size());
    assertEquals(1, allTags.getValidTags().size());
}
Also used : Comment(com.puppycrawl.tools.checkstyle.api.Comment) JavadocTags(com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTags) Test(org.junit.Test)

Aggregations

Comment (com.puppycrawl.tools.checkstyle.api.Comment)18 Test (org.junit.jupiter.api.Test)11 JavadocTag (com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTag)8 JavadocTags (com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTags)7 Test (org.junit.Test)7 InvalidJavadocTag (com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocTag)5