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 f5a7b641ad..785642de02 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 a0f8242dfb..706a835de9 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 ad63927d6a..12276bc591 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 e3c9b9e924..150d386682 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 1b837e61b5..d4e7f1310b 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 e7a4bc6f10..e2bbf87a5d 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 be6e20306a..46be750780 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 3a8119a0ce..7afdf30ac3 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 a80414e18b..410993f614 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 @@ -1,7 +1,5 @@ package tech.picnic.errorprone.bugpatterns; -import static com.google.errorprone.BugCheckerRefactoringTestHelper.newInstance; - import com.google.errorprone.BugCheckerRefactoringTestHelper; import com.google.errorprone.BugCheckerRefactoringTestHelper.FixChoosers; import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; @@ -9,14 +7,9 @@ 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 +66,7 @@ void identification() { @Test void replacementFirstSuggestedFix() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(FluxFlatMapUsage.class, getClass()) .setFixChooser(FixChoosers.FIRST) .addInputLines( "A.java", @@ -108,7 +101,7 @@ void replacementFirstSuggestedFix() { @Test void replacementSecondSuggestedFix() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.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 3eac62e01c..cf300ebf4d 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 03d6c3fd72..9341c76433 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 3942c6de1e..b77767af84 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 3249f5a464..a6204c5abf 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 042a4e9d60..7d2ab28537 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 92f2e16b8f..b4c016da5f 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 b7a204c457..43fb54c0e2 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,22 +7,9 @@ import org.junit.jupiter.api.Test; final class LexicographicalAnnotationAttributeListingTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance( - LexicographicalAnnotationAttributeListing.class, getClass()); - private final CompilationTestHelper restrictedCompilationTestHelper = - CompilationTestHelper.newInstance(LexicographicalAnnotationAttributeListing.class, getClass()) - .setArgs( - ImmutableList.of( - "-XepOpt:LexicographicalAnnotationAttributeListing:Includes=pkg.A.Foo,pkg.A.Bar", - "-XepOpt:LexicographicalAnnotationAttributeListing:Excludes=pkg.A.Bar#value")); - 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;", @@ -165,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;", @@ -246,7 +234,11 @@ void replacement() { @Test void filtering() { /* Some violations are not flagged because they are not in- or excluded. */ - restrictedCompilationTestHelper + CompilationTestHelper.newInstance(LexicographicalAnnotationAttributeListing.class, getClass()) + .setArgs( + ImmutableList.of( + "-XepOpt:LexicographicalAnnotationAttributeListing:Includes=pkg.A.Foo,pkg.A.Bar", + "-XepOpt:LexicographicalAnnotationAttributeListing:Excludes=pkg.A.Bar#value")) .addSourceLines( "pkg/A.java", "package pkg;", 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 287a0e95f3..dd9722e77a 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 1ae63913ee..ca583d92e6 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 74b2fcbfa0..b3ca1fd0c9 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 a1725d4b02..7a806301e8 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 5cebca69e5..62c5fb35fb 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 c4e79c91a8..ff33c78d4a 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 276fb3633d..e205fb1c19 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,19 @@ 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. + /** + * @implNote The logic for {@code char} and {@code short} is exactly analogous to the {@code byte} + * case. + */ @Test void byteComparison() { - compilationTestHelper + CompilationTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addSourceLines( "A.java", "import java.util.Comparator;", @@ -120,7 +117,7 @@ void byteComparison() { @Test void intComparison() { - compilationTestHelper + CompilationTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addSourceLines( "A.java", "import java.util.Comparator;", @@ -227,7 +224,7 @@ void intComparison() { @Test void longComparison() { - compilationTestHelper + CompilationTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addSourceLines( "A.java", "import java.util.Comparator;", @@ -318,7 +315,7 @@ void longComparison() { @Test void floatComparison() { - compilationTestHelper + CompilationTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addSourceLines( "A.java", "import java.util.Comparator;", @@ -386,7 +383,7 @@ void floatComparison() { @Test void doubleComparison() { - compilationTestHelper + CompilationTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addSourceLines( "A.java", "import java.util.Comparator;", @@ -461,7 +458,7 @@ void doubleComparison() { @Test void stringComparison() { - compilationTestHelper + CompilationTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addSourceLines( "A.java", "import java.util.Comparator;", @@ -497,7 +494,7 @@ void stringComparison() { @Test void replacementWithPrimitiveVariants() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addInputLines( "A.java", "import java.util.Comparator;", @@ -577,7 +574,7 @@ void replacementWithPrimitiveVariants() { @Test void replacementWithBoxedVariants() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addInputLines( "A.java", "import java.util.Comparator;", @@ -643,7 +640,7 @@ void replacementWithBoxedVariants() { @Test void replacementWithPrimitiveVariantsUsingStaticImports() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addInputLines( "A.java", "import static java.util.Comparator.comparing;", @@ -682,7 +679,7 @@ void replacementWithPrimitiveVariantsUsingStaticImports() { @Test void replacementWithBoxedVariantsUsingStaticImports() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addInputLines( "A.java", "import static java.util.Comparator.comparingDouble;", @@ -723,7 +720,7 @@ void replacementWithBoxedVariantsUsingStaticImports() { @Test void replacementWithPrimitiveVariantsInComplexSyntacticalContext() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(PrimitiveComparison.class, getClass()) .addInputLines( "A.java", "import java.util.Comparator;", @@ -755,7 +752,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 62f82b3f5a..f3d6f018c6 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 @@ -12,13 +12,6 @@ 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() { @@ -416,7 +409,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 +505,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 20db60b0b6..c00458c7a0 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 c21a784925..c2e2f287a9 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 3859356558..947e06e677 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 97b4c3cc4b..38616e4ea0 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,16 +4,9 @@ import org.junit.jupiter.api.Test; final class RequestParamTypeTest { - private final CompilationTestHelper compilationTestHelper = - CompilationTestHelper.newInstance(RequestParamType.class, getClass()); - private final CompilationTestHelper restrictedCompilationTestHelper = - CompilationTestHelper.newInstance(RequestParamType.class, getClass()) - .setArgs( - "-XepOpt:RequestParamType:SupportedCustomTypes=com.google.common.collect.ImmutableSet,com.google.common.collect.ImmutableSortedMultiset"); - @Test void identification() { - compilationTestHelper + CompilationTestHelper.newInstance(RequestParamType.class, getClass()) .addSourceLines( "A.java", "import com.google.common.collect.ImmutableBiMap;", @@ -70,7 +63,9 @@ void identification() { @Test void identificationRestricted() { - restrictedCompilationTestHelper + CompilationTestHelper.newInstance(RequestParamType.class, getClass()) + .setArgs( + "-XepOpt:RequestParamType:SupportedCustomTypes=com.google.common.collect.ImmutableSet,com.google.common.collect.ImmutableSortedMultiset") .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 95478fe712..c61a99a8ca 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 5900a45071..bd03f35e2e 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 ee47ad2a7f..b28562c0a4 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 861ea8421d..d876f41082 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 caec7843c3..b1865d6089 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 @@ -1,7 +1,5 @@ package tech.picnic.errorprone.bugpatterns; -import static com.google.errorprone.BugCheckerRefactoringTestHelper.newInstance; - import com.google.errorprone.BugCheckerRefactoringTestHelper; import com.google.errorprone.BugCheckerRefactoringTestHelper.FixChoosers; import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; @@ -9,14 +7,9 @@ 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 +47,7 @@ void identification() { @Test void replacementFirstSuggestedFix() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(StringCaseLocaleUsage.class, getClass()) .setFixChooser(FixChoosers.FIRST) .addInputLines( "A.java", @@ -93,7 +86,7 @@ void replacementFirstSuggestedFix() { @Test void replacementSecondSuggestedFix() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.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 2dcd7ed510..379fc830ed 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 ad4e8a8b07..abca2d4ec6 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 782b5f77c9..62b6e66071 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/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 8ec4e5122c..11db1cd771 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 @@ -50,12 +50,6 @@ final class RefasterTest { "\\[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()); - private final BugCheckerRefactoringTestHelper restrictedRefactoringTestHelper = - BugCheckerRefactoringTestHelper.newInstance(Refaster.class, getClass()) - .setArgs( - "-XepOpt:Refaster:NamePattern=.*\\$(StringOfSizeZeroVerboseRule|StringOfSizeTwoRule)$"); @Test void identification() { @@ -220,7 +214,7 @@ private static SeverityLevel toSeverityLevel(String compilerDiagnosticsPrefix) { @Test void replacement() { - refactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(Refaster.class, getClass()) .addInputLines( "A.java", "class A {", @@ -246,7 +240,9 @@ void replacement() { @Test void restrictedReplacement() { - restrictedRefactoringTestHelper + BugCheckerRefactoringTestHelper.newInstance(Refaster.class, getClass()) + .setArgs( + "-XepOpt:Refaster:NamePattern=.*\\$(StringOfSizeZeroVerboseRule|StringOfSizeTwoRule)$") .addInputLines( "A.java", "class A {",