From 94e4403fd4e4745f56dd64e3ebf47602d9f8c06b Mon Sep 17 00:00:00 2001 From: Joran Van Belle Date: Mon, 6 May 2024 11:42:20 +0200 Subject: [PATCH] chore(processor): replace CI JRE condition by Junit conditions --- .github/workflows/maven.yml | 7 +---- .../src/test/java/io/jonasg/bob/BobTests.java | 27 +++++++++++++++++++ .../test/java/io/jonasg/bob/RecordsTest.java | 5 +++- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index a767ec8..4149b89 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -29,10 +29,5 @@ jobs: java-version: ${{ matrix.java }} distribution: 'temurin' cache: maven - - name: Build with Java 11 - if: ${{ matrix.java == 11 }} - run: mvn -B -ntp verify -Dtest=\!RecordsTest.java --file pom.xml - - - name: Build with Java higher than 11 - if: ${{ matrix.java > 11 }} + - name: Build with Maven run: mvn -B -ntp verify --file pom.xml diff --git a/processor/src/test/java/io/jonasg/bob/BobTests.java b/processor/src/test/java/io/jonasg/bob/BobTests.java index b9a1caf..8ad83de 100644 --- a/processor/src/test/java/io/jonasg/bob/BobTests.java +++ b/processor/src/test/java/io/jonasg/bob/BobTests.java @@ -2,11 +2,14 @@ import java.util.List; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import io.toolisticon.cute.Cute; import io.toolisticon.cute.CuteApi; import io.toolisticon.cute.JavaFileObjectUtils; +import org.junit.jupiter.api.condition.EnabledForJreRange; +import org.junit.jupiter.api.condition.JRE; public class BobTests { @@ -240,4 +243,28 @@ void allPublicSettersThatHaveCorrespondingFieldsAreBuildable() { "/tests/AllPublicSettersThatHaveCorrespondingFieldsAreBuildable/Expected_AllPublicSettersThatHaveCorrespondingFieldsAreBuildable.java")) .executeTest(); } + + @Nested + @EnabledForJreRange(min = JRE.JAVA_12, disabledReason = "Records do not exist yet") + class RecordTests { + + @Test + public void recordsAreBuildable() { + Cute.blackBoxTest() + .given() + .processors(List.of(BuildableProcessor.class)) + .andSourceFiles("/tests/RecordsAreBuildable/RecordsAreBuildable.java") + .whenCompiled() + .thenExpectThat() + .compilationSucceeds() + .andThat() + .generatedSourceFile("io.jonasg.bob.test.RecordsAreBuildableBuilder") + .matches( + CuteApi.ExpectedFileObjectMatcherKind.BINARY, + JavaFileObjectUtils.readFromResource( + "/tests/RecordsAreBuildable/Expected_RecordsAreBuildable.java")) + .executeTest(); + } + + } } diff --git a/processor/src/test/java/io/jonasg/bob/RecordsTest.java b/processor/src/test/java/io/jonasg/bob/RecordsTest.java index 1ed1d32..640ed79 100644 --- a/processor/src/test/java/io/jonasg/bob/RecordsTest.java +++ b/processor/src/test/java/io/jonasg/bob/RecordsTest.java @@ -4,13 +4,16 @@ import io.toolisticon.cute.CuteApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledForJreRange; +import org.junit.jupiter.api.condition.JRE; import java.util.List; public class RecordsTest { @Test - public void recordsAreBuildable() { + @EnabledForJreRange(min = JRE.JAVA_12, disabledReason = "Records do not exist yet") + public void recordsAreBuildableWithStepwise() { Cute.blackBoxTest() .given() .processors(List.of(BuildableProcessor.class))