Skip to content

Commit

Permalink
Issue sevntu-checkstyle#734: Moved test input classes into src/test/r…
Browse files Browse the repository at this point in the history
…esources as required, fixed more PMD issues
  • Loading branch information
mbert committed Apr 15, 2019
1 parent 4c839de commit 33188fa
Show file tree
Hide file tree
Showing 14 changed files with 134 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@

import com.github.sevntu.checkstyle.checks.coding.Jsr305AnnotationsCheck.NullnessAnnotation;
import com.github.sevntu.checkstyle.checks.coding.Jsr305AnnotionsTestUtil.ExpectedWarning;
import com.github.sevntu.checkstyle.checks.coding.test.ArraysTestObject;
import com.github.sevntu.checkstyle.checks.coding.test.ClassTestObject;
import com.github.sevntu.checkstyle.checks.coding.test.ConstructorTestObject;
import com.github.sevntu.checkstyle.checks.coding.test.DefaultReturnValuesTestObject;
import com.github.sevntu.checkstyle.checks.coding.test.DefectConstructorTestObject;
import com.github.sevntu.checkstyle.checks.coding.test.EnumTestObject;
import com.github.sevntu.checkstyle.checks.coding.test.InheritanceTestObject;
import com.github.sevntu.checkstyle.checks.coding.test.LambdaTestObject;
import com.github.sevntu.checkstyle.checks.coding.test.ParameterTestObject;
import com.github.sevntu.checkstyle.checks.coding.test.PrimitivesTestObject;
import com.github.sevntu.checkstyle.checks.coding.test.RedundantClassLevelTestObject;
import com.github.sevntu.checkstyle.checks.coding.test.ReturnValueTestObject;
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.FullIdent;
Expand All @@ -61,151 +49,153 @@ public class Jsr305AnnotationsCheckTest {
@Test
public void testParameters() throws CheckstyleException {
Jsr305AnnotionsTestUtil.check(
new ExpectedWarning(ParameterTestObject.class, 37, 44),
new ExpectedWarning(ParameterTestObject.class, 42, 45),
new ExpectedWarning(ParameterTestObject.class, 42, 64),
new ExpectedWarning(ParameterTestObject.class, 75, 41),
new ExpectedWarning(ParameterTestObject.class, 81, 27),
new ExpectedWarning(ParameterTestObject.class, 99, 35)
new ExpectedWarning("InputJsr305AnnotationsCheckWithParameter.java", 37, 44),
new ExpectedWarning("InputJsr305AnnotationsCheckWithParameter.java", 42, 45),
new ExpectedWarning("InputJsr305AnnotationsCheckWithParameter.java", 42, 64),
new ExpectedWarning("InputJsr305AnnotationsCheckWithParameter.java", 75, 41),
new ExpectedWarning("InputJsr305AnnotationsCheckWithParameter.java", 81, 27),
new ExpectedWarning("InputJsr305AnnotationsCheckWithParameter.java", 99, 35)
);
}

@Test
public void testPrimitives() throws CheckstyleException {
Jsr305AnnotionsTestUtil.check(
new ExpectedWarning(PrimitivesTestObject.class, 29, 37),
new ExpectedWarning(PrimitivesTestObject.class, 34, 38),
new ExpectedWarning(PrimitivesTestObject.class, 39, 42),
new ExpectedWarning(PrimitivesTestObject.class, 44, 5),
new ExpectedWarning(PrimitivesTestObject.class, 50, 5),
new ExpectedWarning(PrimitivesTestObject.class, 56, 5),
new ExpectedWarning(PrimitivesTestObject.class, 62, 5),
new ExpectedWarning(PrimitivesTestObject.class, 69, 5),
new ExpectedWarning(PrimitivesTestObject.class, 116, 34)
new ExpectedWarning("InputJsr305AnnotationsCheckWithPrimitives.java", 29, 37),
new ExpectedWarning("InputJsr305AnnotationsCheckWithPrimitives.java", 34, 38),
new ExpectedWarning("InputJsr305AnnotationsCheckWithPrimitives.java", 39, 42),
new ExpectedWarning("InputJsr305AnnotationsCheckWithPrimitives.java", 44, 5),
new ExpectedWarning("InputJsr305AnnotationsCheckWithPrimitives.java", 50, 5),
new ExpectedWarning("InputJsr305AnnotationsCheckWithPrimitives.java", 56, 5),
new ExpectedWarning("InputJsr305AnnotationsCheckWithPrimitives.java", 62, 5),
new ExpectedWarning("InputJsr305AnnotationsCheckWithPrimitives.java", 69, 5),
new ExpectedWarning("InputJsr305AnnotationsCheckWithPrimitives.java", 116, 34)
);
}

@Test
public void testReturnValues() throws CheckstyleException {
Jsr305AnnotionsTestUtil.check(
new ExpectedWarning(ReturnValueTestObject.class, 49, 5),
new ExpectedWarning(ReturnValueTestObject.class, 55, 5),
new ExpectedWarning(ReturnValueTestObject.class, 76, 5),
new ExpectedWarning(ReturnValueTestObject.class, 83, 5),
new ExpectedWarning(ReturnValueTestObject.class, 103, 5),
new ExpectedWarning(ReturnValueTestObject.class, 106, 26),
new ExpectedWarning(ReturnValueTestObject.class, 106, 48),
new ExpectedWarning(ReturnValueTestObject.class, 111, 5),
new ExpectedWarning(ReturnValueTestObject.class, 118, 5),
new ExpectedWarning(ReturnValueTestObject.class, 124, 5)
new ExpectedWarning("InputJsr305AnnotationsCheckWithReturnValue.java", 49, 5),
new ExpectedWarning("InputJsr305AnnotationsCheckWithReturnValue.java", 55, 5),
new ExpectedWarning("InputJsr305AnnotationsCheckWithReturnValue.java", 76, 5),
new ExpectedWarning("InputJsr305AnnotationsCheckWithReturnValue.java", 83, 5),
new ExpectedWarning("InputJsr305AnnotationsCheckWithReturnValue.java", 103, 5),
new ExpectedWarning("InputJsr305AnnotationsCheckWithReturnValue.java", 106, 26),
new ExpectedWarning("InputJsr305AnnotationsCheckWithReturnValue.java", 106, 48),
new ExpectedWarning("InputJsr305AnnotationsCheckWithReturnValue.java", 111, 5),
new ExpectedWarning("InputJsr305AnnotationsCheckWithReturnValue.java", 118, 5),
new ExpectedWarning("InputJsr305AnnotationsCheckWithReturnValue.java", 124, 5)
);
}

@Test
public void testConstructors() throws CheckstyleException {
Jsr305AnnotionsTestUtil.check(
new ExpectedWarning(ConstructorTestObject.class, 38, 34),
new ExpectedWarning(ConstructorTestObject.class, 44, 34),
new ExpectedWarning(ConstructorTestObject.class, 58, 34),
new ExpectedWarning(ConstructorTestObject.class, 72, 54),
new ExpectedWarning(DefectConstructorTestObject.class)
new ExpectedWarning("InputJsr305AnnotationsCheckWithConstructor.java", 38, 55),
new ExpectedWarning("InputJsr305AnnotationsCheckWithConstructor.java", 44, 55),
new ExpectedWarning("InputJsr305AnnotationsCheckWithConstructor.java", 58, 55),
new ExpectedWarning("InputJsr305AnnotationsCheckWithConstructor.java", 72, 75),
new ExpectedWarning("InputJsr305AnnotationsCheckWithDefectConstructor.java")
);
}

@Test
public void testArrays() throws CheckstyleException {
Jsr305AnnotionsTestUtil.check(
new ExpectedWarning(ArraysTestObject.class, 43, 22),
new ExpectedWarning(ArraysTestObject.class, 58, 22),
new ExpectedWarning(ArraysTestObject.class, 73, 22),
new ExpectedWarning(ArraysTestObject.class, 88, 22),
new ExpectedWarning(ArraysTestObject.class, 102, 8),
new ExpectedWarning(ArraysTestObject.class, 117, 32),
new ExpectedWarning(ArraysTestObject.class, 132, 34)
new ExpectedWarning("InputJsr305AnnotationsCheckWithArrays.java", 43, 43),
new ExpectedWarning("InputJsr305AnnotationsCheckWithArrays.java", 58, 43),
new ExpectedWarning("InputJsr305AnnotationsCheckWithArrays.java", 73, 43),
new ExpectedWarning("InputJsr305AnnotationsCheckWithArrays.java", 88, 43),
new ExpectedWarning("InputJsr305AnnotationsCheckWithArrays.java", 102, 8),
new ExpectedWarning("InputJsr305AnnotationsCheckWithArrays.java", 117, 32),
new ExpectedWarning("InputJsr305AnnotationsCheckWithArrays.java", 132, 34)
);
}

@Test
public void testClasses() throws CheckstyleException {
Jsr305AnnotionsTestUtil.check(
new ExpectedWarning(ClassTestObject.class, 33, 5),
new ExpectedWarning(ClassTestObject.class, 47, 26),
new ExpectedWarning(ClassTestObject.class, 57, 29),
new ExpectedWarning(ClassTestObject.class, 79, 32),
new ExpectedWarning(ClassTestObject.class, 87, 36),
new ExpectedWarning(ClassTestObject.class, 141, 43),
new ExpectedWarning(ClassTestObject.class, 148, 9),
new ExpectedWarning(ClassTestObject.class, 152, 9),
new ExpectedWarning(ClassTestObject.class, 163, 9),
new ExpectedWarning(ClassTestObject.class, 169, 9),
new ExpectedWarning(ClassTestObject.class, 187, 9)
new ExpectedWarning("InputJsr305AnnotationsCheckWithClass.java", 33, 5),
new ExpectedWarning("InputJsr305AnnotationsCheckWithClass.java", 47, 26),
new ExpectedWarning("InputJsr305AnnotationsCheckWithClass.java", 57, 29),
new ExpectedWarning("InputJsr305AnnotationsCheckWithClass.java", 79, 32),
new ExpectedWarning("InputJsr305AnnotationsCheckWithClass.java", 87, 36),
new ExpectedWarning("InputJsr305AnnotationsCheckWithClass.java", 141, 43),
new ExpectedWarning("InputJsr305AnnotationsCheckWithClass.java", 148, 9),
new ExpectedWarning("InputJsr305AnnotationsCheckWithClass.java", 152, 9),
new ExpectedWarning("InputJsr305AnnotationsCheckWithClass.java", 163, 9),
new ExpectedWarning("InputJsr305AnnotationsCheckWithClass.java", 169, 9),
new ExpectedWarning("InputJsr305AnnotationsCheckWithClass.java", 187, 9)
);
}

@Test
public void testEnums() throws CheckstyleException {
Jsr305AnnotionsTestUtil.check(
new ExpectedWarning(EnumTestObject.class, 45, 32),
new ExpectedWarning(EnumTestObject.class, 54, 36),
new ExpectedWarning(EnumTestObject.class, 71, 9),
new ExpectedWarning(EnumTestObject.class, 77, 9),
new ExpectedWarning(EnumTestObject.class, 90, 5)
new ExpectedWarning("InputJsr305AnnotationsCheckWithEnum.java", 45, 32),
new ExpectedWarning("InputJsr305AnnotationsCheckWithEnum.java", 54, 36),
new ExpectedWarning("InputJsr305AnnotationsCheckWithEnum.java", 71, 9),
new ExpectedWarning("InputJsr305AnnotationsCheckWithEnum.java", 77, 9),
new ExpectedWarning("InputJsr305AnnotationsCheckWithEnum.java", 90, 5)
);
}

@Test
public void testInheritance() throws CheckstyleException {
Jsr305AnnotionsTestUtil.check(
new ExpectedWarning(InheritanceTestObject.class, 44, 47),
new ExpectedWarning(InheritanceTestObject.class, 81, 43)
new ExpectedWarning("InputJsr305AnnotationsCheckWithInheritance.java", 44, 47),
new ExpectedWarning("InputJsr305AnnotationsCheckWithInheritance.java", 81, 43)
);
}

@Test
public void testReturnValueDefaults() throws CheckstyleException {
Jsr305AnnotionsTestUtil.check(
new ExpectedWarning(DefaultReturnValuesTestObject.class, 37, 5)
new ExpectedWarning("InputJsr305AnnotationsCheckWithDefaultReturnValues.java",
37, 5)
);
}

@Test
public void testRedudantClassLevelAnnotations() throws CheckstyleException {
Jsr305AnnotionsTestUtil.check(
new ExpectedWarning(RedundantClassLevelTestObject.class, 28, 5)
new ExpectedWarning("InputJsr305AnnotationsCheckWithRedundantClassLevel.java",
28, 5)
);
}

@Test
public void testLambdas() throws CheckstyleException {
Jsr305AnnotionsTestUtil.check(
new ExpectedWarning(LambdaTestObject.class, 35, 10),
new ExpectedWarning(LambdaTestObject.class, 45, 5)
new ExpectedWarning("InputJsr305AnnotationsCheckWithLambda.java", 35, 10),
new ExpectedWarning("InputJsr305AnnotationsCheckWithLambda.java", 45, 5)
);
}

@Test
public void testAllowOverriding() throws CheckstyleException {
Jsr305AnnotionsTestUtil.checkAllowingOverriding(
new ExpectedWarning(ParameterTestObject.class, 37, 44),
new ExpectedWarning(ParameterTestObject.class, 42, 45),
new ExpectedWarning(ParameterTestObject.class, 42, 64),
new ExpectedWarning(ParameterTestObject.class, 75, 41),
new ExpectedWarning(ParameterTestObject.class, 99, 35),
new ExpectedWarning(LambdaTestObject.class, 45, 5),
new ExpectedWarning(InheritanceTestObject.class, 44, 47),
new ExpectedWarning(InheritanceTestObject.class, 81, 43)
new ExpectedWarning("InputJsr305AnnotationsCheckWithParameter.java", 37, 44),
new ExpectedWarning("InputJsr305AnnotationsCheckWithParameter.java", 42, 45),
new ExpectedWarning("InputJsr305AnnotationsCheckWithParameter.java", 42, 64),
new ExpectedWarning("InputJsr305AnnotationsCheckWithParameter.java", 75, 41),
new ExpectedWarning("InputJsr305AnnotationsCheckWithParameter.java", 99, 35),
new ExpectedWarning("InputJsr305AnnotationsCheckWithLambda.java", 45, 5),
new ExpectedWarning("InputJsr305AnnotationsCheckWithInheritance.java", 44, 47),
new ExpectedWarning("InputJsr305AnnotationsCheckWithInheritance.java", 81, 43)
);
}

// ------------------ Unit tests (test particular functions) ------------------

@Test
public void testExcludePackage() throws CheckstyleException {
Jsr305AnnotionsTestUtil.checkExcludingPackage(
new ExpectedWarning(ParameterTestObject.class)
new ExpectedWarning("InputJsr305AnnotationsCheckWithParameter.java")
);
}

// ------------------ Unit tests (test particular functions) ------------------

@Test
public void testIsPackageExcluded() {
// final String[] excludedPackages = new String[] {
Expand Down
Loading

0 comments on commit 33188fa

Please sign in to comment.