1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.puppycrawl.tools.checkstyle.checks.javadoc;
21
22 import static com.google.common.truth.Truth.assertThat;
23 import static com.google.common.truth.Truth.assertWithMessage;
24
25 import org.junit.jupiter.api.Test;
26
27 import com.puppycrawl.tools.checkstyle.utils.JavadocUtil;
28
29 public class JavadocTagTest {
30
31
32
33
34
35 @Test
36 public void testJavadocTagTypeValueOf() {
37 final JavadocUtil.JavadocTagType enumConst =
38 JavadocUtil.JavadocTagType.valueOf("ALL");
39 assertWithMessage("Invalid enum valueOf result")
40 .that(enumConst)
41 .isEqualTo(JavadocUtil.JavadocTagType.ALL);
42 }
43
44
45
46
47
48 @Test
49 public void testJavadocTagTypeValues() {
50 final JavadocUtil.JavadocTagType[] enumConstants =
51 JavadocUtil.JavadocTagType.values();
52 final JavadocUtil.JavadocTagType[] expected = {
53 JavadocUtil.JavadocTagType.BLOCK,
54 JavadocUtil.JavadocTagType.INLINE,
55 JavadocUtil.JavadocTagType.ALL,
56 };
57 assertWithMessage("Invalid enum constants")
58 .that(enumConstants)
59 .isEqualTo(expected);
60 }
61
62 @Test
63 public void testToString() {
64 final JavadocTag javadocTag = new JavadocTag(0, 1, "author", "firstArg");
65
66 final String result = javadocTag.toString();
67
68 assertWithMessage("Invalid toString result")
69 .that(result)
70 .isEqualTo("JavadocTag[tag='author' lineNo=0, columnNo=1, firstArg='firstArg']");
71 }
72
73 @Test
74 public void testJavadocTagReferenceImports() {
75 assertThat(new JavadocTag(0, 0, "see", null).canReferenceImports()).isTrue();
76 assertThat(new JavadocTag(0, 0, "link", null).canReferenceImports()).isTrue();
77 assertThat(new JavadocTag(0, 0, "value", null).canReferenceImports()).isTrue();
78 assertThat(new JavadocTag(0, 0, "linkplain", null).canReferenceImports()).isTrue();
79 assertThat(new JavadocTag(0, 0, "throws", null).canReferenceImports()).isTrue();
80 assertThat(new JavadocTag(0, 0, "exception", null).canReferenceImports()).isTrue();
81 }
82
83 @Test
84 public void testJavadocTagReferenceImportsInvalid() {
85 assertThat(new JavadocTag(0, 0, "author", null).canReferenceImports())
86 .isFalse();
87 }
88
89 @Test
90 public void testJavadocTagIsInlineTag() {
91 assertThat(new JavadocTag(0, 0, "link", null).isInlineTag()).isTrue();
92 assertThat(new JavadocTag(0, 0, "value", null).isInlineTag()).isTrue();
93 assertThat(new JavadocTag(0, 0, "see", null).isInlineTag()).isFalse();
94
95 }
96
97 }