Skip to content

Commit

Permalink
#1046.Add test cases for generic parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
zCRUSADERz committed May 4, 2019
1 parent be80278 commit 0dc23f5
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 8 deletions.
Expand Up @@ -45,6 +45,8 @@
import org.apache.commons.lang3.StringUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.Mockito;
Expand All @@ -59,7 +61,34 @@
public final class ChecksTest {

/**
* Disabled test case.
*/
private static final String DISABLED = "ChecksTest/JavadocParameterOrderCheck";

/**
* Disabled JavadocParameterOrderCheck.
* Test checkstyle for true positive.
* @throws Exception If something goes wrong
*/
@Disabled
@Test
public void testJavadocParameterOrderCheckTruePositive() throws Exception {
this.testCheckstyleTruePositive(DISABLED);
}

/**
* Disabled JavadocParameterOrderCheck.
* Test checkstyle for true positive.
* @throws Exception If something goes wrong
*/
@Disabled
@Test
public void testJavadocParameterOrderCheckTrueNegative() throws Exception {
this.testCheckstyleTrueNegative(DISABLED);
}

/**
* Test checkstyle for true negative.
* @param dir Directory where test scripts are located.
* @throws Exception If something goes wrong
*/
Expand Down Expand Up @@ -180,7 +209,6 @@ private static Stream<String> checks() {
"NonStaticMethodCheck",
"ConstantUsageCheck",
"JavadocEmptyLineCheck",
"JavadocParameterOrderCheck",
"JavadocTagsCheck",
"ProhibitNonFinalClassesCheck"
).map(s -> String.format("ChecksTest/%s", s));
Expand Down
Expand Up @@ -6,8 +6,12 @@
/**
* This is not a real Java class. It won't be compiled ever. It is used
* only as a text resource in integration.ChecksIT.
*
* Wrong order of parameters.
* @param <V> - value.
* @param <K> - key.
*/
public final class Invalid {
public final class Invalid<K, V> {

/**
* A field.
Expand Down Expand Up @@ -51,4 +55,31 @@ public String method2(final String cparam, final String dparam) {
public String method3(final String hparam) {
return hparam;
}

/**
* Javadoc without generic parameter at the end.
* @param list
* @return Element.
*/
public <T> T first(final List<T> list) {
return list.get(0);
}

/**
* Javadoc with parameters in different order than the method signature.
* @param <T> - type.
* @param list - list.
* @param index - index.
* @return Element.
*/
public <T> T get(final List<T> list, final int index) {
return list.get(index);
}

/**
* Javadoc without generic parameters.
*/
public final static class InnerEntry<K, V> {

}
}
Expand Up @@ -32,4 +32,24 @@ public final class Valid {
public String method(final String bparam, final String aparam) {
return bparam + aparam;
}

/**
* Correct order of parameters.
* @param list List.
* @param index Index.
* @param <T> Type.
* @return Element.
*/
public <T> T get(final List<T> list, final int index) {
return list.get(index);
}

/**
* Correct order of parameters.
* @param <K> Key.
* @param <V> Value.
*/
public final static class Entry<K, V> {

}
}
@@ -1,6 +1,13 @@
20:Javadoc parameter order different than method signature
21:Javadoc parameter order different than method signature
29:Javadoc parameter order different than method signature
30:Javadoc parameter order different than method signature
43:Number of javadoc parameters different than method signature
51:Number of javadoc parameters different than method signature
11:Javadoc parameter order different than method signature
12:Javadoc parameter order different than method signature
24:Javadoc parameter order different than method signature
25:Javadoc parameter order different than method signature
33:Javadoc parameter order different than method signature
34:Javadoc parameter order different than method signature
47:Number of javadoc parameters different than method signature
55:Number of javadoc parameters different than method signature
64:Number of javadoc parameters different than method signature
70:Javadoc parameter order different than method signature
71:Javadoc parameter order different than method signature
72:Javadoc parameter order different than method signature
82:Number of javadoc parameters different than method signature

0 comments on commit 0dc23f5

Please sign in to comment.