-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(processor): add test for record support
- Loading branch information
1 parent
2ebd260
commit 9cf5ff9
Showing
4 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
processor/src/test/resources/tests/RecordsAreBuildable/Expected_RecordsAreBuildable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
processor/src/test/resources/tests/RecordsAreBuildable/RecordsAreBuildable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
} |