Skip to content

Commit

Permalink
chore(processor): replace CI JRE condition by Junit conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
JoranVanBelle committed May 6, 2024
1 parent 4666a68 commit 85d4441
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 27 additions & 0 deletions processor/src/test/java/io/jonasg/bob/BobTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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();
}

}
}
5 changes: 4 additions & 1 deletion processor/src/test/java/io/jonasg/bob/RecordsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 85d4441

Please sign in to comment.