From 4d0b55bbe41589253f3d9780c7ad881dc700417e Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Fri, 28 Apr 2023 22:29:21 +0200 Subject: [PATCH] Fix the build --- .../bugpatterns/AutowiredConstructorTest.java | 3 +++ .../ImmutablesSortedSetComparatorTest.java | 3 +++ .../bugpatterns/JUnitClassModifiersTest.java | 3 +++ ...aphicalAnnotationAttributeListingTest.java | 3 +++ .../RequestMappingAnnotationTest.java | 3 +++ .../bugpatterns/RequestParamTypeTest.java | 3 +++ .../bugpatterns/SpringMvcAnnotationTest.java | 3 +++ .../bugpatterns/StaticImportTest.java | 4 ++++ .../refasterrules/RefasterRulesTest.java | 21 ++++++++++++++++++- pom.xml | 4 ++++ 10 files changed, 49 insertions(+), 1 deletion(-) 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 12276bc591..5f4f89b6e6 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 @@ -4,7 +4,10 @@ import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; +@DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) final class AutowiredConstructorTest { @Test void identification() { 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 b77767af84..47267ecfdc 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 @@ -4,6 +4,8 @@ import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; final class ImmutablesSortedSetComparatorTest { @Test @@ -140,6 +142,7 @@ void replacement() { .doTest(TestMode.TEXT_MATCH); } + @DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) @Test void replacementWithImportClash() { BugCheckerRefactoringTestHelper.newInstance(ImmutablesSortedSetComparator.class, getClass()) 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 7d2ab28537..5ead6045cd 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 @@ -4,7 +4,10 @@ import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; +@DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) final class JUnitClassModifiersTest { @Test void identification() { 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 da842fd92a..e2c2039de0 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 @@ -5,8 +5,11 @@ import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; final class LexicographicalAnnotationAttributeListingTest { + @DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) @Test void identification() { CompilationTestHelper.newInstance(LexicographicalAnnotationAttributeListing.class, getClass()) 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 baa62651db..12e3c7f956 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 @@ -2,7 +2,10 @@ import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; +@DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) final class RequestMappingAnnotationTest { @Test void identification() { 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 38616e4ea0..cc8e8d55b8 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 @@ -2,7 +2,10 @@ import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; +@DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) final class RequestParamTypeTest { @Test void identification() { 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 d0ae0c49ca..4c4b7ee8f1 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 @@ -4,7 +4,10 @@ import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; +@DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) final class SpringMvcAnnotationTest { @Test void identification() { 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 d876f41082..86884cc7d1 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 @@ -6,6 +6,8 @@ import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; final class StaticImportTest { @Test @@ -26,6 +28,7 @@ void exemptedMembersAreNotRedundant() { .doesNotContainAnyElementsOf(StaticImport.STATIC_IMPORT_EXEMPTED_IDENTIFIERS); } + @DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) @Test void identification() { CompilationTestHelper.newInstance(StaticImport.class, getClass()) @@ -111,6 +114,7 @@ void identification() { .doTest(); } + @DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) @Test void replacement() { BugCheckerRefactoringTestHelper.newInstance(StaticImport.class, getClass()) diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java index b7a7a017a6..33e33d8253 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java @@ -4,6 +4,8 @@ import com.google.common.collect.ImmutableSet; import java.util.stream.Stream; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -73,6 +75,11 @@ final class RefasterRulesTest { TimeRules.class, WebClientRules.class); + // XXX: Drop all logic related to this collection once we drop support for + // JDKs prior to version 17. + private static final ImmutableSet> JDK_17_PLUS_RULE_COLLECTIONS = + ImmutableSet.of(WebClientRules.class); + // XXX: Create a JUnit extension to automatically discover the rule collections in a given context // to make sure the list is exhaustive. private static Stream validateRuleCollectionTestCases() { @@ -80,12 +87,24 @@ private static Stream validateRuleCollectionTestCases() { // method with `@ValueSource(classes = {...})`. return RULE_COLLECTIONS.stream() .filter(not(AssertJRules.class::equals)) + .filter(not(WebClientRules.class::equals)) .map(Arguments::arguments); } @MethodSource("validateRuleCollectionTestCases") @ParameterizedTest void validateRuleCollection(Class clazz) { - RefasterRuleCollection.validate(clazz); + if (!JDK_17_PLUS_RULE_COLLECTIONS.contains(clazz)) { + RefasterRuleCollection.validate(clazz); + } + } + + @DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) + @MethodSource("validateRuleCollectionTestCases") + @ParameterizedTest + void validateRuleCollectionWithJdk17AndAbove(Class clazz) { + if (JDK_17_PLUS_RULE_COLLECTIONS.contains(clazz)) { + RefasterRuleCollection.validate(clazz); + } } } diff --git a/pom.xml b/pom.xml index 8784bedb41..d000ffb2e1 100644 --- a/pom.xml +++ b/pom.xml @@ -1034,6 +1034,10 @@ + + provided + test + ${version.jdk.target}