From 6d5b91f053d9fae86a8ed82daccccba6165bd2ee Mon Sep 17 00:00:00 2001
From: MANISH-K-07
Date: Mon, 5 Feb 2024 08:52:32 +0000
Subject: [PATCH] Issue #13345: Enabled AtClauseOrderCheckExamplesTest
---
.../AtclauseOrderCheckExamplesTest.java | 41 ++++-
.../javadoc/atclauseorder/Example1.java | 58 ++++++
.../checks/javadoc/atclauseorder/Example1.txt | 44 -----
.../javadoc/atclauseorder/Example2.java | 58 ++++++
.../javadoc/atclauseorder/Example3.java | 58 ++++++
src/xdocs/checks/javadoc/atclauseorder.xml | 172 +++++++++++++++---
.../checks/javadoc/atclauseorder.xml.template | 36 +++-
7 files changed, 394 insertions(+), 73 deletions(-)
create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example1.java
delete mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example1.txt
create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example2.java
create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example3.java
diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheckExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheckExamplesTest.java
index 2ff498392e5..da7eee0de15 100644
--- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheckExamplesTest.java
+++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheckExamplesTest.java
@@ -19,12 +19,12 @@
package com.puppycrawl.tools.checkstyle.checks.javadoc;
-import org.junit.jupiter.api.Disabled;
+import static com.puppycrawl.tools.checkstyle.checks.javadoc.AtclauseOrderCheck.MSG_KEY;
+
import org.junit.jupiter.api.Test;
import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
-@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345")
public class AtclauseOrderCheckExamplesTest extends AbstractExamplesModuleTestSupport {
@Override
protected String getPackageLocation() {
@@ -33,10 +33,45 @@ protected String getPackageLocation() {
@Test
public void testExample1() throws Exception {
+ final String tagOrder = "[@author, @version, @param, @return, @throws"
+ + ", @exception, @see,"
+ + " @since, @serial, @serialField, @serialData, @deprecated]";
+
final String[] expected = {
+ "42: " + getCheckMessage(MSG_KEY, tagOrder),
+ "44: " + getCheckMessage(MSG_KEY, tagOrder),
+ "52: " + getCheckMessage(MSG_KEY, tagOrder),
+ "54: " + getCheckMessage(MSG_KEY, tagOrder),
+ "55: " + getCheckMessage(MSG_KEY, tagOrder),
+ };
+
+ verifyWithInlineConfigParser(getPath("Example1.java"), expected);
+ }
+
+ @Test
+ public void testExample2() throws Exception {
+ final String tagOrder = "[@author, @since, @version, @param, @return"
+ + ", @throws, @exception,"
+ + " @deprecated, @see, @serial, @serialField, @serialData]";
+ final String[] expected = {
+ "29: " + getCheckMessage(MSG_KEY, tagOrder),
+ "55: " + getCheckMessage(MSG_KEY, tagOrder),
+ };
+
+ verifyWithInlineConfigParser(getPath("Example2.java"), expected);
+ }
+
+ @Test
+ public void testExample3() throws Exception {
+ final String tagOrder = "[@author, @since, @version, @param, @return"
+ + ", @throws, @exception,"
+ + " @deprecated, @see, @serial, @serialField, @serialData]";
+
+ final String[] expected = {
+ "55: " + getCheckMessage(MSG_KEY, tagOrder),
};
- verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example3.java"), expected);
}
}
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example1.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example1.java
new file mode 100644
index 00000000000..d64bbcfa38e
--- /dev/null
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example1.java
@@ -0,0 +1,58 @@
+/*xml
+
+
+
+
+
+*/
+
+
+
+
+
+
+package com.puppycrawl.tools.checkstyle.checks.javadoc.atclauseorder;
+
+import java.io.Serializable;
+
+// xdoc section -- start
+/**
+* Some javadoc.
+*
+* @author Some javadoc.
+* @version Some javadoc.
+* @param Some javadoc.
+* @return Some javadoc.
+* @throws Some javadoc.
+* @exception Some javadoc.
+* @see Some javadoc.
+* @since Some javadoc.
+* @serial Some javadoc.
+* @serialField
+* @serialData
+*/
+public class Example1 {}
+
+class Valid1 implements Serializable {}
+
+/**
+ * Some javadoc.
+ *
+ * @since Some javadoc.
+ * @version Some javadoc. // violation
+ * @deprecated
+ * @see Some javadoc. // violation
+ */
+class Invalid1 implements Serializable {}
+
+/**
+ * Some javadoc.
+ *
+ * @since Some javadoc.
+ * @version Some javadoc. // violation
+ * @deprecated
+ * @see Some javadoc. // violation
+ * @author max // violation
+ */
+enum Test1 {}
+// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example1.txt
deleted file mode 100644
index 707d711c678..00000000000
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example1.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-/*xml
-
-
-
-
-
-*/
-
-// xdoc section -- start
-/**
-* Some javadoc. // OK
-*
-* @author Some javadoc. // OK
-* @version Some javadoc. // OK
-* @param Some javadoc. // OK
-* @return Some javadoc. // OK
-* @throws Some javadoc. // OK
-* @exception Some javadoc. // OK
-* @see Some javadoc. // OK
-* @since Some javadoc. // OK
-* @serial Some javadoc. // OK
-* @serialField // OK
-* @serialData // OK
-* @deprecated Some javadoc. // OK
-*/
-
-class Valid implements Serializable
-{
-}
-
-/**
-* Some javadoc.
-*
-* @since Some javadoc. // OK
-* @version Some javadoc. // Violation - wrong order
-* @deprecated
-* @see Some javadoc. // Violation - wrong order
-* @author Some javadoc. // Violation - wrong order
-*/
-
-class Invalid implements Serializable
-{
-}
-// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example2.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example2.java
new file mode 100644
index 00000000000..542c4d9f0fd
--- /dev/null
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example2.java
@@ -0,0 +1,58 @@
+/*xml
+
+
+
+
+
+
+
+*/
+
+package com.puppycrawl.tools.checkstyle.checks.javadoc.atclauseorder;
+
+import java.io.Serializable;
+
+// xdoc section -- start
+/**
+* Some javadoc.
+*
+* @author Some javadoc.
+* @version Some javadoc.
+* @param Some javadoc.
+* @return Some javadoc.
+* @throws Some javadoc.
+* @exception Some javadoc.
+* @see Some javadoc.
+* @since Some javadoc. // violation
+* @serial Some javadoc.
+* @serialField
+* @serialData
+*/
+public class Example2 {}
+
+class Valid2 implements Serializable {}
+
+/**
+ * Some javadoc.
+ *
+ * @since Some javadoc.
+ * @version Some javadoc.
+ * @deprecated
+ * @see Some javadoc.
+ */
+class Invalid2 implements Serializable {}
+
+/**
+ * Some javadoc.
+ *
+ * @since Some javadoc.
+ * @version Some javadoc.
+ * @deprecated Some javadoc.
+ * @see Some javadoc.
+ * @author max // violation
+ */
+enum Test2 {}
+// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example3.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example3.java
new file mode 100644
index 00000000000..956c77a1581
--- /dev/null
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder/Example3.java
@@ -0,0 +1,58 @@
+/*xml
+
+
+
+
+
+
+
+
+*/
+package com.puppycrawl.tools.checkstyle.checks.javadoc.atclauseorder;
+
+import java.io.Serializable;
+
+// xdoc section -- start
+/**
+* Some javadoc.
+*
+* @author Some javadoc.
+* @version Some javadoc.
+* @param Some javadoc.
+* @return Some javadoc.
+* @throws Some javadoc.
+* @exception Some javadoc.
+* @see Some javadoc.
+* @since Some javadoc.
+* @serial Some javadoc.
+* @serialField
+* @serialData
+*/
+public class Example3 {}
+
+class Valid3 implements Serializable {}
+
+/**
+ * Some javadoc.
+ *
+ * @since Some javadoc.
+ * @version Some javadoc.
+ * @deprecated
+ * @see Some javadoc.
+ */
+class Invalid3 implements Serializable {}
+
+/**
+ * Some javadoc.
+ *
+ * @since Some javadoc.
+ * @version Some javadoc.
+ * @deprecated
+ * @see Some javadoc.
+ * @author Some javadoc. // violation
+ */
+enum Test3 {}
+// xdoc section -- end
diff --git a/src/xdocs/checks/javadoc/atclauseorder.xml b/src/xdocs/checks/javadoc/atclauseorder.xml
index 57f03960891..f676aac4b20 100644
--- a/src/xdocs/checks/javadoc/atclauseorder.xml
+++ b/src/xdocs/checks/javadoc/atclauseorder.xml
@@ -88,39 +88,163 @@
/**
-* Some javadoc. // OK
+* Some javadoc.
*
-* @author Some javadoc. // OK
-* @version Some javadoc. // OK
-* @param Some javadoc. // OK
-* @return Some javadoc. // OK
-* @throws Some javadoc. // OK
-* @exception Some javadoc. // OK
-* @see Some javadoc. // OK
-* @since Some javadoc. // OK
-* @serial Some javadoc. // OK
-* @serialField // OK
-* @serialData // OK
-* @deprecated Some javadoc. // OK
+* @author Some javadoc.
+* @version Some javadoc.
+* @param Some javadoc.
+* @return Some javadoc.
+* @throws Some javadoc.
+* @exception Some javadoc.
+* @see Some javadoc.
+* @since Some javadoc.
+* @serial Some javadoc.
+* @serialField
+* @serialData
*/
+public class Example1 {}
+
+class Valid1 implements Serializable {}
-class Valid implements Serializable
-{
-}
+/**
+ * Some javadoc.
+ *
+ * @since Some javadoc.
+ * @version Some javadoc. // violation
+ * @deprecated
+ * @see Some javadoc. // violation
+ */
+class Invalid1 implements Serializable {}
+/**
+ * Some javadoc.
+ *
+ * @since Some javadoc.
+ * @version Some javadoc. // violation
+ * @deprecated
+ * @see Some javadoc. // violation
+ * @author max // violation
+ */
+enum Test1 {}
+
+
+ To configure the check such that it checks in the custom order:
+