diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AmbiguousJsonCreatorTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AmbiguousJsonCreatorTest.java index f5a7b641ad6..785642de02b 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AmbiguousJsonCreatorTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AmbiguousJsonCreatorTest.java @@ -3,21 +3,16 @@ import static com.google.common.base.Predicates.containsPattern; import com.google.errorprone.BugCheckerRefactoringTestHelper; +import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; final class AmbiguousJsonCreatorTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(AmbiguousJsonCreator.class, getClass()) - .expectErrorMessage( - "X", - containsPattern("`JsonCreator.Mode` should be set for single-argument creators")); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(AmbiguousJsonCreator.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(AmbiguousJsonCreator.class, getClass()) + .expectErrorMessage( + "X", containsPattern("`JsonCreator.Mode` should be set for single-argument creators")) .addSourceLines( "Container.java", "import com.fasterxml.jackson.annotation.JsonCreator;", @@ -118,7 +113,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(AmbiguousJsonCreator.class, getClass()) .addInputLines( "A.java", "import com.fasterxml.jackson.annotation.JsonCreator;", @@ -143,6 +138,6 @@ void replacement() { " return FOO;", " }", "}") - .doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH); + .doTest(TestMode.TEXT_MATCH); } } diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AssertJIsNullTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AssertJIsNullTest.java index a0f8242dfb4..706a835de91 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AssertJIsNullTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AssertJIsNullTest.java @@ -7,14 +7,9 @@ import org.junit.jupiter.api.Test; final class AssertJIsNullTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(AssertJIsNull.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(AssertJIsNull.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(AssertJIsNull.class, getClass()) .addSourceLines( "A.java", "import static org.assertj.core.api.Assertions.assertThat;", @@ -38,7 +33,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(AssertJIsNull.class, getClass()) .addInputLines( "A.java", "import static org.assertj.core.api.Assertions.assertThat;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AutowiredConstructorTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AutowiredConstructorTest.java index ad63927d6aa..12276bc5910 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AutowiredConstructorTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AutowiredConstructorTest.java @@ -6,14 +6,9 @@ import org.junit.jupiter.api.Test; final class AutowiredConstructorTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(AutowiredConstructor.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(AutowiredConstructor.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(AutowiredConstructor.class, getClass()) .addSourceLines( "Container.java", "import com.google.errorprone.annotations.Immutable;", @@ -71,7 +66,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(AutowiredConstructor.class, getClass()) .addInputLines( "Container.java", "import org.springframework.beans.factory.annotation.Autowired;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/CanonicalAnnotationSyntaxTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/CanonicalAnnotationSyntaxTest.java index e3c9b9e9242..150d3866824 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/CanonicalAnnotationSyntaxTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/CanonicalAnnotationSyntaxTest.java @@ -6,14 +6,9 @@ import org.junit.jupiter.api.Test; final class CanonicalAnnotationSyntaxTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(CanonicalAnnotationSyntax.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(CanonicalAnnotationSyntax.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(CanonicalAnnotationSyntax.class, getClass()) .addSourceLines( "pkg/A.java", "package pkg;", @@ -133,7 +128,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(CanonicalAnnotationSyntax.class, getClass()) .addInputLines( "pkg/A.java", "package pkg;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/CollectorMutabilityTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/CollectorMutabilityTest.java index 1b837e61b57..d4e7f1310b8 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/CollectorMutabilityTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/CollectorMutabilityTest.java @@ -8,14 +8,9 @@ import org.junit.jupiter.api.Test; final class CollectorMutabilityTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(CollectorMutability.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(CollectorMutability.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(CollectorMutability.class, getClass()) .addSourceLines( "A.java", "import static com.google.common.collect.ImmutableList.toImmutableList;", @@ -67,7 +62,7 @@ void identification() { @Test void identificationWithoutGuavaOnClasspath() { - compilationTestHelper + CompilationTestHelper.newInstance(CollectorMutability.class, getClass()) .withClasspath() .addSourceLines( "A.java", @@ -84,7 +79,7 @@ void identificationWithoutGuavaOnClasspath() { @Test void replacementFirstSuggestedFix() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(CollectorMutability.class, getClass()) .addInputLines( "A.java", "import static java.util.stream.Collectors.toList;", @@ -141,7 +136,7 @@ void replacementFirstSuggestedFix() { @Test void replacementSecondSuggestedFix() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(CollectorMutability.class, getClass()) .setFixChooser(SECOND) .addInputLines( "A.java", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/EmptyMethodTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/EmptyMethodTest.java index e7a4bc6f10f..e2bbf87a5df 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/EmptyMethodTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/EmptyMethodTest.java @@ -6,14 +6,9 @@ import org.junit.jupiter.api.Test; final class EmptyMethodTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(EmptyMethod.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(EmptyMethod.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(EmptyMethod.class, getClass()) .addSourceLines( "A.java", "class A {", @@ -69,7 +64,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(EmptyMethod.class, getClass()) .addInputLines( "A.java", "final class A {", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ErrorProneTestHelperSourceFormatTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ErrorProneTestHelperSourceFormatTest.java index be6e20306af..46be7507807 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ErrorProneTestHelperSourceFormatTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ErrorProneTestHelperSourceFormatTest.java @@ -6,15 +6,9 @@ import org.junit.jupiter.api.Test; final class ErrorProneTestHelperSourceFormatTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(ErrorProneTestHelperSourceFormat.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance( - ErrorProneTestHelperSourceFormat.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(ErrorProneTestHelperSourceFormat.class, getClass()) .addSourceLines( "A.java", "import com.google.errorprone.BugCheckerRefactoringTestHelper;", @@ -63,7 +57,7 @@ void replacement() { * Verifies that import sorting and code formatting is performed unconditionally, while unused * imports are removed unless part of a `BugCheckerRefactoringTestHelper` expected output file. */ - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(ErrorProneTestHelperSourceFormat.class, getClass()) .addInputLines( "A.java", "import com.google.errorprone.BugCheckerRefactoringTestHelper;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ExplicitEnumOrderingTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ExplicitEnumOrderingTest.java index 3a8119a0ce1..7afdf30ac3a 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ExplicitEnumOrderingTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ExplicitEnumOrderingTest.java @@ -4,12 +4,9 @@ import org.junit.jupiter.api.Test; final class ExplicitEnumOrderingTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(ExplicitEnumOrdering.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(ExplicitEnumOrdering.class, getClass()) .addSourceLines( "A.java", "import static java.lang.annotation.RetentionPolicy.CLASS;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/FluxFlatMapUsageTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/FluxFlatMapUsageTest.java index a80414e18bb..1dcb5b734e0 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/FluxFlatMapUsageTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/FluxFlatMapUsageTest.java @@ -2,21 +2,15 @@ import static com.google.errorprone.BugCheckerRefactoringTestHelper.newInstance; -import com.google.errorprone.BugCheckerRefactoringTestHelper; import com.google.errorprone.BugCheckerRefactoringTestHelper.FixChoosers; import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; final class FluxFlatMapUsageTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(FluxFlatMapUsage.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - newInstance(FluxFlatMapUsage.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(FluxFlatMapUsage.class, getClass()) .addSourceLines( "A.java", "import java.util.function.BiFunction;", @@ -73,7 +67,7 @@ void identification() { @Test void replacementFirstSuggestedFix() { - refactoringTestHelper + newInstance(FluxFlatMapUsage.class, getClass()) .setFixChooser(FixChoosers.FIRST) .addInputLines( "A.java", @@ -108,7 +102,7 @@ void replacementFirstSuggestedFix() { @Test void replacementSecondSuggestedFix() { - refactoringTestHelper + newInstance(FluxFlatMapUsage.class, getClass()) .setFixChooser(FixChoosers.SECOND) .addInputLines( "A.java", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/FormatStringConcatenationTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/FormatStringConcatenationTest.java index 3eac62e01cb..cf300ebf4de 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/FormatStringConcatenationTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/FormatStringConcatenationTest.java @@ -6,14 +6,9 @@ import org.junit.jupiter.api.Test; final class FormatStringConcatenationTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(FormatStringConcatenation.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(FormatStringConcatenation.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(FormatStringConcatenation.class, getClass()) .addSourceLines( "A.java", "import static com.google.common.base.Preconditions.checkArgument;", @@ -309,7 +304,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(FormatStringConcatenation.class, getClass()) .addInputLines( "A.java", "import static com.google.common.base.Preconditions.checkArgument;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IdentityConversionTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IdentityConversionTest.java index 03d6c3fd72d..9341c764333 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IdentityConversionTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IdentityConversionTest.java @@ -7,14 +7,9 @@ import org.junit.jupiter.api.Test; final class IdentityConversionTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(IdentityConversion.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(IdentityConversion.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(IdentityConversion.class, getClass()) .addSourceLines( "A.java", "import static com.google.errorprone.matchers.Matchers.instanceMethod;", @@ -184,7 +179,7 @@ void identification() { @Test void replacementFirstSuggestedFix() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(IdentityConversion.class, getClass()) .setFixChooser(FixChoosers.FIRST) .addInputLines( "A.java", @@ -291,7 +286,7 @@ void replacementFirstSuggestedFix() { @Test void replacementSecondSuggestedFix() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(IdentityConversion.class, getClass()) .setFixChooser(FixChoosers.SECOND) .addInputLines( "A.java", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ImmutablesSortedSetComparatorTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ImmutablesSortedSetComparatorTest.java index 3942c6de1e1..b77767af845 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ImmutablesSortedSetComparatorTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ImmutablesSortedSetComparatorTest.java @@ -6,14 +6,9 @@ import org.junit.jupiter.api.Test; final class ImmutablesSortedSetComparatorTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(ImmutablesSortedSetComparator.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(ImmutablesSortedSetComparator.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(ImmutablesSortedSetComparator.class, getClass()) .addSourceLines( "A.java", "import com.google.common.collect.ContiguousSet;", @@ -109,7 +104,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(ImmutablesSortedSetComparator.class, getClass()) .addInputLines( "A.java", "import com.google.common.collect.ImmutableSortedSet;", @@ -147,7 +142,7 @@ void replacement() { @Test void replacementWithImportClash() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(ImmutablesSortedSetComparator.class, getClass()) .addInputLines( "MySpringService.java", "import com.google.common.collect.ImmutableSortedSet;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IsInstanceLambdaUsageTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IsInstanceLambdaUsageTest.java index 3249f5a4645..a6204c5abf8 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IsInstanceLambdaUsageTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IsInstanceLambdaUsageTest.java @@ -6,14 +6,9 @@ import org.junit.jupiter.api.Test; final class IsInstanceLambdaUsageTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(IsInstanceLambdaUsage.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(IsInstanceLambdaUsage.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(IsInstanceLambdaUsage.class, getClass()) .addSourceLines( "A.java", "import java.util.stream.Stream;", @@ -46,7 +41,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(IsInstanceLambdaUsage.class, getClass()) .addInputLines( "A.java", "import java.util.stream.Stream;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitClassModifiersTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitClassModifiersTest.java index 042a4e9d609..7d2ab285370 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitClassModifiersTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitClassModifiersTest.java @@ -6,14 +6,9 @@ import org.junit.jupiter.api.Test; final class JUnitClassModifiersTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(JUnitClassModifiers.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(JUnitClassModifiers.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(JUnitClassModifiers.class, getClass()) .addSourceLines( "Container.java", "import org.junit.jupiter.api.Test;", @@ -98,7 +93,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(JUnitClassModifiers.class, getClass()) .addInputLines( "A.java", "import org.junit.jupiter.api.Test;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitMethodDeclarationTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitMethodDeclarationTest.java index 92f2e16b8f6..b4c016da5fa 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitMethodDeclarationTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitMethodDeclarationTest.java @@ -6,14 +6,9 @@ import org.junit.jupiter.api.Test; final class JUnitMethodDeclarationTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(JUnitMethodDeclaration.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(JUnitMethodDeclaration.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(JUnitMethodDeclaration.class, getClass()) .addSourceLines( "A.java", "import static org.junit.jupiter.params.provider.Arguments.arguments;", @@ -345,7 +340,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(JUnitMethodDeclaration.class, getClass()) .addInputLines( "A.java", "import static org.junit.jupiter.params.provider.Arguments.arguments;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java index 74a80cb8e3b..43fb54c0e20 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java @@ -7,16 +7,9 @@ import org.junit.jupiter.api.Test; final class LexicographicalAnnotationAttributeListingTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance( - LexicographicalAnnotationAttributeListing.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance( - LexicographicalAnnotationAttributeListing.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(LexicographicalAnnotationAttributeListing.class, getClass()) .addSourceLines( "A.java", "import static java.math.RoundingMode.DOWN;", @@ -159,7 +152,8 @@ void identification() { // `CanonicalAnnotationSyntax` checker correct the situation in a subsequent run. @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance( + LexicographicalAnnotationAttributeListing.class, getClass()) .addInputLines( "A.java", "import static java.math.RoundingMode.DOWN;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationListingTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationListingTest.java index 287a0e95f30..dd9722e77ab 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationListingTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationListingTest.java @@ -6,15 +6,9 @@ import org.junit.jupiter.api.Test; final class LexicographicalAnnotationListingTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(LexicographicalAnnotationListing.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance( - LexicographicalAnnotationListing.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(LexicographicalAnnotationListing.class, getClass()) .addSourceLines( "A.java", "import java.lang.annotation.ElementType;", @@ -133,7 +127,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(LexicographicalAnnotationListing.class, getClass()) .addInputLines( "A.java", "import java.lang.annotation.ElementType;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/MethodReferenceUsageTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/MethodReferenceUsageTest.java index 1ae63913eea..ca583d92e60 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/MethodReferenceUsageTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/MethodReferenceUsageTest.java @@ -6,14 +6,9 @@ import org.junit.jupiter.api.Test; final class MethodReferenceUsageTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(MethodReferenceUsage.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(MethodReferenceUsage.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(MethodReferenceUsage.class, getClass()) .addSourceLines( "A.java", "import com.google.common.collect.Streams;", @@ -323,7 +318,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(MethodReferenceUsage.class, getClass()) .addInputLines( "A.java", "import static java.util.Collections.emptyList;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/MissingRefasterAnnotationTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/MissingRefasterAnnotationTest.java index 74b2fcbfa01..b3ca1fd0c97 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/MissingRefasterAnnotationTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/MissingRefasterAnnotationTest.java @@ -6,16 +6,12 @@ import org.junit.jupiter.api.Test; final class MissingRefasterAnnotationTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(MissingRefasterAnnotation.class, getClass()) - .expectErrorMessage( - "X", - containsPattern( - "The Refaster rule contains a method without any Refaster annotations")); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(MissingRefasterAnnotation.class, getClass()) + .expectErrorMessage( + "X", + containsPattern("The Refaster rule contains a method without any Refaster annotations")) .addSourceLines( "A.java", "import com.google.errorprone.refaster.annotation.AfterTemplate;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/MockitoStubbingTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/MockitoStubbingTest.java index a1725d4b02f..7a806301e80 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/MockitoStubbingTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/MockitoStubbingTest.java @@ -6,14 +6,9 @@ import org.junit.jupiter.api.Test; final class MockitoStubbingTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(MockitoStubbing.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(MockitoStubbing.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(MockitoStubbing.class, getClass()) .addSourceLines( "A.java", "import static org.mockito.ArgumentMatchers.eq;", @@ -55,7 +50,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(MockitoStubbing.class, getClass()) .addInputLines( "A.java", "import static org.mockito.ArgumentMatchers.eq;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/NestedOptionalsTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/NestedOptionalsTest.java index 5cebca69e5c..62c5fb35fbc 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/NestedOptionalsTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/NestedOptionalsTest.java @@ -4,12 +4,9 @@ import org.junit.jupiter.api.Test; final class NestedOptionalsTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(NestedOptionals.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(NestedOptionals.class, getClass()) .addSourceLines( "A.java", "import java.util.Optional;", @@ -42,7 +39,7 @@ void identification() { @Test void identificationOptionalTypeNotLoaded() { - compilationTestHelper + CompilationTestHelper.newInstance(NestedOptionals.class, getClass()) .addSourceLines( "A.java", "import java.time.Duration;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/NonEmptyMonoTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/NonEmptyMonoTest.java index c4e79c91a84..ff33c78d4a7 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/NonEmptyMonoTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/NonEmptyMonoTest.java @@ -7,14 +7,9 @@ import org.junit.jupiter.api.Test; final class NonEmptyMonoTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(NonEmptyMono.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(NonEmptyMono.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(NonEmptyMono.class, getClass()) .addSourceLines( "A.java", "import static com.google.common.collect.ImmutableList.toImmutableList;", @@ -111,7 +106,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(NonEmptyMono.class, getClass()) .addInputLines( "A.java", "import static com.google.common.collect.ImmutableList.toImmutableList;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonTest.java index 276fb3633d6..e71720acca2 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonTest.java @@ -5,22 +5,16 @@ import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +// XXX: There are no tests for multiple replacements within the same expression: +// - Error Prone doesn't currently support this, it seems. +// - The `BugCheckerRefactoringTestHelper` throws an exception in this case. +// - During actual compilation only the first replacement is applied. +// XXX: Can we perhaps work-around this by describing the fixes in reverse order? final class PrimitiveComparisonTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(PrimitiveComparison.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(PrimitiveComparison.class, getClass()); - - // XXX: There are no tests for multiple replacements within the same expression: - // - Error Prone doesn't currently support this, it seems. - // - The `BugCheckerRefactoringTestHelper` throws an exception in this case. - // - During actual compilation only the first replacement is applied. - // XXX: Can we perhaps work-around this by describing the fixes in reverse order? - - // The logic for `char` and `short` is exactly analogous to the `byte` case. + /* The logic for `char` and `short` is exactly analogous to the `byte` case. */ @Test void byteComparison() { - compilationTestHelper + CompilationTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addSourceLines( "A.java", "import java.util.Comparator;", @@ -120,7 +114,7 @@ void byteComparison() { @Test void intComparison() { - compilationTestHelper + CompilationTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addSourceLines( "A.java", "import java.util.Comparator;", @@ -227,7 +221,7 @@ void intComparison() { @Test void longComparison() { - compilationTestHelper + CompilationTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addSourceLines( "A.java", "import java.util.Comparator;", @@ -318,7 +312,7 @@ void longComparison() { @Test void floatComparison() { - compilationTestHelper + CompilationTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addSourceLines( "A.java", "import java.util.Comparator;", @@ -386,7 +380,7 @@ void floatComparison() { @Test void doubleComparison() { - compilationTestHelper + CompilationTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addSourceLines( "A.java", "import java.util.Comparator;", @@ -461,7 +455,7 @@ void doubleComparison() { @Test void stringComparison() { - compilationTestHelper + CompilationTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addSourceLines( "A.java", "import java.util.Comparator;", @@ -497,7 +491,7 @@ void stringComparison() { @Test void replacementWithPrimitiveVariants() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addInputLines( "A.java", "import java.util.Comparator;", @@ -577,7 +571,7 @@ void replacementWithPrimitiveVariants() { @Test void replacementWithBoxedVariants() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addInputLines( "A.java", "import java.util.Comparator;", @@ -643,7 +637,7 @@ void replacementWithBoxedVariants() { @Test void replacementWithPrimitiveVariantsUsingStaticImports() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addInputLines( "A.java", "import static java.util.Comparator.comparing;", @@ -682,7 +676,7 @@ void replacementWithPrimitiveVariantsUsingStaticImports() { @Test void replacementWithBoxedVariantsUsingStaticImports() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addInputLines( "A.java", "import static java.util.Comparator.comparingDouble;", @@ -723,7 +717,7 @@ void replacementWithBoxedVariantsUsingStaticImports() { @Test void replacementWithPrimitiveVariantsInComplexSyntacticalContext() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addInputLines( "A.java", "import java.util.Comparator;", @@ -755,7 +749,7 @@ void replacementWithPrimitiveVariantsInComplexSyntacticalContext() { @Test void replacementWithBoxedVariantsInComplexSyntacticalContext() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addInputLines( "A.java", "import java.util.Comparator;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RedundantStringConversionTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RedundantStringConversionTest.java index 62f82b3f5aa..906a16229bc 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RedundantStringConversionTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RedundantStringConversionTest.java @@ -10,19 +10,9 @@ // `String.valueOf(null)` may not. That is because the latter matches `String#valueOf(char[])`. We // could special-case `null` arguments, but that doesn't seem worth the trouble. final class RedundantStringConversionTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(RedundantStringConversion.class, getClass()); - private final CompilationTestHelper customizedCompilationTestHelper = - CompilationTestHelper.newInstance(RedundantStringConversion.class, getClass()) - .setArgs( - ImmutableList.of( - "-XepOpt:RedundantStringConversion:ExtraConversionMethods=java.lang.Enum#name(),A#name(),A.B#toString(int)")); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(RedundantStringConversion.class, getClass()); - @Test void identificationOfIdentityTransformation() { - compilationTestHelper + CompilationTestHelper.newInstance(RedundantStringConversion.class, getClass()) .addSourceLines( "A.java", "class A {", @@ -45,7 +35,7 @@ void identificationOfIdentityTransformation() { @Test void identificationWithinMutatingAssignment() { - compilationTestHelper + CompilationTestHelper.newInstance(RedundantStringConversion.class, getClass()) .addSourceLines( "A.java", "import java.math.BigInteger;", @@ -106,7 +96,7 @@ void identificationWithinMutatingAssignment() { @Test void identificationWithinBinaryOperation() { - compilationTestHelper + CompilationTestHelper.newInstance(RedundantStringConversion.class, getClass()) .addSourceLines( "A.java", "import java.math.BigInteger;", @@ -201,7 +191,7 @@ void identificationWithinBinaryOperation() { @Test void identificationWithinStringBuilderMethod() { - compilationTestHelper + CompilationTestHelper.newInstance(RedundantStringConversion.class, getClass()) .addSourceLines( "A.java", "import java.math.BigInteger;", @@ -256,7 +246,7 @@ void identificationWithinStringBuilderMethod() { // XXX: Also test the other formatter methods. @Test void identificationWithinFormatterMethod() { - compilationTestHelper + CompilationTestHelper.newInstance(RedundantStringConversion.class, getClass()) .addSourceLines( "A.java", "import java.util.Formattable;", @@ -301,7 +291,7 @@ void identificationWithinFormatterMethod() { @Test void identificationWithinGuavaGuardMethod() { - compilationTestHelper + CompilationTestHelper.newInstance(RedundantStringConversion.class, getClass()) .addSourceLines( "A.java", "import static com.google.common.base.Preconditions.checkArgument;", @@ -361,7 +351,7 @@ void identificationWithinGuavaGuardMethod() { @Test void identificationWithinSlf4jLoggerMethod() { - compilationTestHelper + CompilationTestHelper.newInstance(RedundantStringConversion.class, getClass()) .addSourceLines( "A.java", "import java.util.Formattable;", @@ -416,7 +406,10 @@ void identificationWithinSlf4jLoggerMethod() { @Test void identificationOfCustomConversionMethod() { - customizedCompilationTestHelper + CompilationTestHelper.newInstance(RedundantStringConversion.class, getClass()) + .setArgs( + ImmutableList.of( + "-XepOpt:RedundantStringConversion:ExtraConversionMethods=java.lang.Enum#name(),A#name(),A.B#toString(int)")) .addSourceLines( "A.java", "import java.math.RoundingMode;", @@ -509,7 +502,7 @@ void identificationOfCustomConversionMethod() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(RedundantStringConversion.class, getClass()) .addInputLines( "A.java", "class A {", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RefasterAnyOfUsageTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RefasterAnyOfUsageTest.java index 20db60b0b66..c00458c7a06 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RefasterAnyOfUsageTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RefasterAnyOfUsageTest.java @@ -6,14 +6,9 @@ import org.junit.jupiter.api.Test; final class RefasterAnyOfUsageTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(RefasterAnyOfUsage.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(RefasterAnyOfUsage.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(RefasterAnyOfUsage.class, getClass()) .addSourceLines( "A.java", "import com.google.errorprone.refaster.Refaster;", @@ -38,7 +33,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(RefasterAnyOfUsage.class, getClass()) .addInputLines( "A.java", "import com.google.errorprone.refaster.Refaster;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RefasterRuleModifiersTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RefasterRuleModifiersTest.java index c21a784925b..c2e2f287a92 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RefasterRuleModifiersTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RefasterRuleModifiersTest.java @@ -6,14 +6,9 @@ import org.junit.jupiter.api.Test; final class RefasterRuleModifiersTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(RefasterRuleModifiers.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(RefasterRuleModifiers.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(RefasterRuleModifiers.class, getClass()) .addSourceLines( "A.java", "import com.google.errorprone.refaster.annotation.BeforeTemplate;", @@ -136,7 +131,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(RefasterRuleModifiers.class, getClass()) .addInputLines( "A.java", "import com.google.errorprone.refaster.annotation.BeforeTemplate;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestMappingAnnotationTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestMappingAnnotationTest.java index 38593565586..947e06e677f 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestMappingAnnotationTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestMappingAnnotationTest.java @@ -4,12 +4,9 @@ import org.junit.jupiter.api.Test; final class RequestMappingAnnotationTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(RequestMappingAnnotation.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(RequestMappingAnnotation.class, getClass()) .addSourceLines( "A.java", "import java.io.InputStream;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestParamTypeTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestParamTypeTest.java index eb9d6193bde..38616e4ea0f 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestParamTypeTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestParamTypeTest.java @@ -4,12 +4,9 @@ import org.junit.jupiter.api.Test; final class RequestParamTypeTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(RequestParamType.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(RequestParamType.class, getClass()) .addSourceLines( "A.java", "import com.google.common.collect.ImmutableBiMap;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ScheduledTransactionTraceTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ScheduledTransactionTraceTest.java index 95478fe7127..c61a99a8ca3 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ScheduledTransactionTraceTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ScheduledTransactionTraceTest.java @@ -7,14 +7,9 @@ import org.springframework.scheduling.annotation.Scheduled; final class ScheduledTransactionTraceTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(ScheduledTransactionTrace.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(ScheduledTransactionTrace.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(ScheduledTransactionTrace.class, getClass()) .addSourceLines( "A.java", "import com.newrelic.api.agent.Trace;", @@ -46,7 +41,7 @@ void identification() { @Test void identificationWithoutNewRelicAgentApiOnClasspath() { - compilationTestHelper + CompilationTestHelper.newInstance(ScheduledTransactionTrace.class, getClass()) .withClasspath(Scheduled.class) .addSourceLines( "A.java", @@ -61,7 +56,7 @@ void identificationWithoutNewRelicAgentApiOnClasspath() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(ScheduledTransactionTrace.class, getClass()) .addInputLines( "A.java", "import com.newrelic.api.agent.Trace;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/Slf4jLogStatementTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/Slf4jLogStatementTest.java index 5900a450716..bd03f35e2e2 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/Slf4jLogStatementTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/Slf4jLogStatementTest.java @@ -6,14 +6,9 @@ import org.junit.jupiter.api.Test; final class Slf4jLogStatementTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(Slf4jLogStatement.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(Slf4jLogStatement.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(Slf4jLogStatement.class, getClass()) .addSourceLines( "A.java", "import org.slf4j.Logger;", @@ -96,7 +91,7 @@ void identification() { // XXX: Drop what's unused. @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(Slf4jLogStatement.class, getClass()) .addInputLines( "A.java", "import org.slf4j.Logger;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/SpringMvcAnnotationTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/SpringMvcAnnotationTest.java index ee47ad2a7f0..b28562c0a4d 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/SpringMvcAnnotationTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/SpringMvcAnnotationTest.java @@ -6,14 +6,9 @@ import org.junit.jupiter.api.Test; final class SpringMvcAnnotationTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(SpringMvcAnnotation.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(SpringMvcAnnotation.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(SpringMvcAnnotation.class, getClass()) .addSourceLines( "A.java", "import static org.springframework.web.bind.annotation.RequestMethod.DELETE;", @@ -85,7 +80,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(SpringMvcAnnotation.class, getClass()) .addInputLines( "A.java", "import static org.springframework.web.bind.annotation.RequestMethod.PATCH;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportTest.java index 861ea8421da..d876f410825 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportTest.java @@ -8,11 +8,6 @@ import org.junit.jupiter.api.Test; final class StaticImportTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(StaticImport.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(StaticImport.class, getClass()); - @Test void candidateMethodsAreNotRedundant() { assertThat(StaticImport.STATIC_IMPORT_CANDIDATE_MEMBERS.keySet()) @@ -33,7 +28,7 @@ void exemptedMembersAreNotRedundant() { @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(StaticImport.class, getClass()) .addSourceLines( "A.java", "import static com.google.common.collect.ImmutableMap.toImmutableMap;", @@ -118,7 +113,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(StaticImport.class, getClass()) .addInputLines( "A.java", "import static java.util.function.Predicate.not;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StringCaseLocaleUsageTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StringCaseLocaleUsageTest.java index caec7843c37..035dd936b33 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StringCaseLocaleUsageTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StringCaseLocaleUsageTest.java @@ -2,21 +2,15 @@ import static com.google.errorprone.BugCheckerRefactoringTestHelper.newInstance; -import com.google.errorprone.BugCheckerRefactoringTestHelper; import com.google.errorprone.BugCheckerRefactoringTestHelper.FixChoosers; import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; final class StringCaseLocaleUsageTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(StringCaseLocaleUsage.class, getClass()); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - newInstance(StringCaseLocaleUsage.class, getClass()); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(StringCaseLocaleUsage.class, getClass()) .addSourceLines( "A.java", "import static java.util.Locale.ROOT;", @@ -54,7 +48,7 @@ void identification() { @Test void replacementFirstSuggestedFix() { - refactoringTestHelper + newInstance(StringCaseLocaleUsage.class, getClass()) .setFixChooser(FixChoosers.FIRST) .addInputLines( "A.java", @@ -93,7 +87,7 @@ void replacementFirstSuggestedFix() { @Test void replacementSecondSuggestedFix() { - refactoringTestHelper + newInstance(StringCaseLocaleUsage.class, getClass()) .setFixChooser(FixChoosers.SECOND) .addInputLines( "A.java", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StringJoinTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StringJoinTest.java index 2dcd7ed5102..379fc830ede 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StringJoinTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StringJoinTest.java @@ -8,17 +8,12 @@ import org.junit.jupiter.api.Test; final class StringJoinTest { - private final CompilationTestHelper compilationHelper = - CompilationTestHelper.newInstance(StringJoin.class, getClass()) - .expectErrorMessage( - "valueOf", containsPattern("Prefer `String#valueOf` over `String#format`")) - .expectErrorMessage("join", containsPattern("Prefer `String#join` over `String#format`")); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(StringJoin.class, getClass()); - @Test void identification() { - compilationHelper + CompilationTestHelper.newInstance(StringJoin.class, getClass()) + .expectErrorMessage( + "valueOf", containsPattern("Prefer `String#valueOf` over `String#format`")) + .expectErrorMessage("join", containsPattern("Prefer `String#join` over `String#format`")) .addSourceLines( "A.java", "import java.util.Formattable;", @@ -63,7 +58,7 @@ void identification() { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(StringJoin.class, getClass()) .addInputLines( "A.java", "class A {", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/TimeZoneUsageTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/TimeZoneUsageTest.java index ad4e8a8b07b..abca2d4ec66 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/TimeZoneUsageTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/TimeZoneUsageTest.java @@ -4,12 +4,9 @@ import org.junit.jupiter.api.Test; final class TimeZoneUsageTest { - private final CompilationTestHelper compilationHelper = - CompilationTestHelper.newInstance(TimeZoneUsage.class, getClass()); - @Test void identification() { - compilationHelper + CompilationTestHelper.newInstance(TimeZoneUsage.class, getClass()) .addSourceLines( "A.java", "import static java.time.ZoneOffset.UTC;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/MethodMatcherFactoryTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/MethodMatcherFactoryTest.java index 782b5f77c9b..62b6e660719 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/MethodMatcherFactoryTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/MethodMatcherFactoryTest.java @@ -40,9 +40,6 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState "com.example.A#m2(java.lang.String)", "com.example.sub.B#m3(int,int)")); - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(MatchedMethodsFlagger.class, getClass()); - @Test void createWithMalformedSignatures() { MethodMatcherFactory factory = new MethodMatcherFactory(); @@ -58,7 +55,7 @@ void createWithMalformedSignatures() { @Test void matcher() { - compilationTestHelper + CompilationTestHelper.newInstance(MatchedMethodsFlagger.class, getClass()) .addSourceLines( "com/example/A.java", "package com.example;", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/ThirdPartyLibraryTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/ThirdPartyLibraryTest.java index 8d888851288..090ef579b51 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/ThirdPartyLibraryTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/ThirdPartyLibraryTest.java @@ -18,12 +18,9 @@ import reactor.core.publisher.Flux; final class ThirdPartyLibraryTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(TestChecker.class, getClass()); - @Test void isIntroductionAllowed() { - compilationTestHelper + CompilationTestHelper.newInstance(TestChecker.class, getClass()) .addSourceLines( "A.java", "// BUG: Diagnostic contains: ASSERTJ: true, GUAVA: true, NEW_RELIC_AGENT_API: true, REACTOR: true", @@ -33,7 +30,7 @@ void isIntroductionAllowed() { @Test void isIntroductionAllowedWitnessClassesInSymtab() { - compilationTestHelper + CompilationTestHelper.newInstance(TestChecker.class, getClass()) .addSourceLines( "A.java", "import com.google.common.collect.ImmutableList;", @@ -55,7 +52,7 @@ void isIntroductionAllowedWitnessClassesInSymtab() { @Test void isIntroductionAllowedWitnessClassesPartiallyOnClassPath() { - compilationTestHelper + CompilationTestHelper.newInstance(TestChecker.class, getClass()) .withClasspath(ImmutableList.class, Flux.class) .addSourceLines( "A.java", @@ -66,7 +63,7 @@ void isIntroductionAllowedWitnessClassesPartiallyOnClassPath() { @Test void isIntroductionAllowedWitnessClassesNotOnClassPath() { - compilationTestHelper + CompilationTestHelper.newInstance(TestChecker.class, getClass()) .withClasspath() .addSourceLines( "A.java", @@ -79,7 +76,7 @@ void isIntroductionAllowedWitnessClassesNotOnClassPath() { @ParameterizedTest @ValueSource(booleans = {true, false}) void isIntroductionAllowedIgnoreClasspathCompat(boolean ignoreClassPath) { - compilationTestHelper + CompilationTestHelper.newInstance(TestChecker.class, getClass()) .setArgs("-XepOpt:ErrorProneSupport:IgnoreClasspathCompat=" + ignoreClassPath) .withClasspath(ImmutableList.class, Flux.class) .addSourceLines( diff --git a/refaster-runner/src/test/java/tech/picnic/errorprone/refaster/runner/RefasterTest.java b/refaster-runner/src/test/java/tech/picnic/errorprone/refaster/runner/RefasterTest.java index 6d2991bdf3b..2af0ea0271d 100644 --- a/refaster-runner/src/test/java/tech/picnic/errorprone/refaster/runner/RefasterTest.java +++ b/refaster-runner/src/test/java/tech/picnic/errorprone/refaster/runner/RefasterTest.java @@ -25,37 +25,32 @@ import tech.picnic.errorprone.refaster.ErrorProneFork; final class RefasterTest { - private final CompilationTestHelper compilationHelper = - CompilationTestHelper.newInstance(Refaster.class, getClass()) - .matchAllDiagnostics() - .expectErrorMessage( - "StringOfSizeZeroRule", - containsPattern( - "\\[Refaster Rule\\] FooRules\\.StringOfSizeZeroRule: Refactoring opportunity\\s+.+\\s+")) - .expectErrorMessage( - "StringOfSizeOneRule", - containsPattern( - "\\[Refaster Rule\\] FooRules\\.StringOfSizeOneRule: " - + "A custom description about matching single-char strings\\s+.+\\s+" - + "\\(see https://error-prone.picnic.tech/refasterrules/FooRules#StringOfSizeOneRule\\)")) - .expectErrorMessage( - "StringOfSizeTwoRule", - containsPattern( - "\\[Refaster Rule\\] FooRules\\.ExtraGrouping\\.StringOfSizeTwoRule: " - + "A custom subgroup description\\s+.+\\s+" - + "\\(see https://example.com/rule/FooRules#ExtraGrouping.StringOfSizeTwoRule\\)")) - .expectErrorMessage( - "StringOfSizeThreeRule", - containsPattern( - "\\[Refaster Rule\\] FooRules\\.ExtraGrouping\\.StringOfSizeThreeRule: " - + "A custom description about matching three-char strings\\s+.+\\s+" - + "\\(see https://example.com/custom\\)")); - private final BugCheckerRefactoringTestHelper refactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(Refaster.class, getClass()); - @Test void identification() { - compilationHelper + CompilationTestHelper.newInstance(Refaster.class, getClass()) + .matchAllDiagnostics() + .expectErrorMessage( + "StringOfSizeZeroRule", + containsPattern( + "\\[Refaster Rule\\] FooRules\\.StringOfSizeZeroRule: Refactoring opportunity\\s+.+\\s+")) + .expectErrorMessage( + "StringOfSizeOneRule", + containsPattern( + "\\[Refaster Rule\\] FooRules\\.StringOfSizeOneRule: " + + "A custom description about matching single-char strings\\s+.+\\s+" + + "\\(see https://error-prone.picnic.tech/refasterrules/FooRules#StringOfSizeOneRule\\)")) + .expectErrorMessage( + "StringOfSizeTwoRule", + containsPattern( + "\\[Refaster Rule\\] FooRules\\.ExtraGrouping\\.StringOfSizeTwoRule: " + + "A custom subgroup description\\s+.+\\s+" + + "\\(see https://example.com/rule/FooRules#ExtraGrouping.StringOfSizeTwoRule\\)")) + .expectErrorMessage( + "StringOfSizeThreeRule", + containsPattern( + "\\[Refaster Rule\\] FooRules\\.ExtraGrouping\\.StringOfSizeThreeRule: " + + "A custom description about matching three-char strings\\s+.+\\s+" + + "\\(see https://example.com/custom\\)")) .addSourceLines( "A.java", "class A {", @@ -165,7 +160,30 @@ void severityAssignment( ImmutableList arguments, ImmutableList expectedSeverities) { assertThatThrownBy( () -> - compilationHelper + CompilationTestHelper.newInstance(Refaster.class, getClass()) + .matchAllDiagnostics() + .expectErrorMessage( + "StringOfSizeZeroRule", + containsPattern( + "\\[Refaster Rule\\] FooRules\\.StringOfSizeZeroRule: Refactoring opportunity\\s+.+\\s+")) + .expectErrorMessage( + "StringOfSizeOneRule", + containsPattern( + "\\[Refaster Rule\\] FooRules\\.StringOfSizeOneRule: " + + "A custom description about matching single-char strings\\s+.+\\s+" + + "\\(see https://error-prone.picnic.tech/refasterrules/FooRules#StringOfSizeOneRule\\)")) + .expectErrorMessage( + "StringOfSizeTwoRule", + containsPattern( + "\\[Refaster Rule\\] FooRules\\.ExtraGrouping\\.StringOfSizeTwoRule: " + + "A custom subgroup description\\s+.+\\s+" + + "\\(see https://example.com/rule/FooRules#ExtraGrouping.StringOfSizeTwoRule\\)")) + .expectErrorMessage( + "StringOfSizeThreeRule", + containsPattern( + "\\[Refaster Rule\\] FooRules\\.ExtraGrouping\\.StringOfSizeThreeRule: " + + "A custom description about matching three-char strings\\s+.+\\s+" + + "\\(see https://example.com/custom\\)")) .setArgs(arguments) .addSourceLines( "A.java", @@ -216,7 +234,7 @@ private static SeverityLevel toSeverityLevel(String compilerDiagnosticsPrefix) { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(Refaster.class, getClass()) .addInputLines( "A.java", "class A {",