Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(processor): add test for record support #34

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
jonas-grgt marked this conversation as resolved.
Show resolved Hide resolved
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) {
}