Skip to content

Commit

Permalink
chore(processor): add test for record support
Browse files Browse the repository at this point in the history
  • Loading branch information
JoranVanBelle committed Apr 24, 2024
1 parent 2ebd260 commit 9cf5ff9
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ jobs:
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B -ntp verify --file pom.xml
if: ${{ matrix.java }} == 11
run: mvn -B -ntp verify -Dtest=\!RecordsTest.java --file pom.xml
30 changes: 30 additions & 0 deletions processor/src/test/java/io/jonasg/bob/RecordsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.jonasg.bob;

import io.toolisticon.cute.Cute;
import io.toolisticon.cute.CuteApi;
import io.toolisticon.cute.JavaFileObjectUtils;
import org.junit.jupiter.api.Test;

import java.util.List;

public class RecordsTest {

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package io.jonasg.bob.test;

import java.lang.String;

public final class RecordsAreBuildableBuilder {
private String make;

private int year;

private double engineSize;

private boolean isElectric;

private float fuelEfficiency;

public RecordsAreBuildableBuilder() {
}

public RecordsAreBuildableBuilder make(String make) {
this.make = make;
return this;
}

public RecordsAreBuildableBuilder year(int year) {
this.year = year;
return this;
}

public RecordsAreBuildableBuilder engineSize(double engineSize) {
this.engineSize = engineSize;
return this;
}

public RecordsAreBuildableBuilder isElectric(boolean isElectric) {
this.isElectric = isElectric;
return this;
}

public RecordsAreBuildableBuilder fuelEfficiency(float fuelEfficiency) {
this.fuelEfficiency = fuelEfficiency;
return this;
}

public RecordsAreBuildable build() {
return new RecordsAreBuildable(make, year, engineSize, isElectric, fuelEfficiency);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.jonasg.bob.test;

import io.jonasg.bob.Buildable;
import java.lang.String;

@Buildable
public record RecordsAreBuildable(String make, int year, double engineSize, boolean isElectric, float fuelEfficiency) {
}

0 comments on commit 9cf5ff9

Please sign in to comment.