File tree Expand file tree Collapse file tree
src/main/java/it/aboutbits/springboot/testing/testdata/base Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 <parent >
77 <groupId >org.springframework.boot</groupId >
88 <artifactId >spring-boot-starter-parent</artifactId >
9- <version >3.3.6 </version >
9+ <version >3.3.7 </version >
1010 <relativePath /> <!-- lookup parent from repository -->
1111 </parent >
1212
Original file line number Diff line number Diff line change 11package it .aboutbits .springboot .testing .testdata .base ;
22
3+ import it .aboutbits .springboot .toolbox .type .identity .EntityId ;
34import net .datafaker .Faker ;
45import net .datafaker .service .FakeValuesService ;
56import net .datafaker .service .FakerContext ;
67import net .datafaker .service .RandomService ;
78
89import java .util .Locale ;
910import java .util .Random ;
11+ import java .util .function .Function ;
12+ import java .util .function .LongFunction ;
1013
1114public class FakerExtended extends Faker {
1215 public FakerExtended () {
@@ -40,4 +43,16 @@ public <T extends Enum<?>> T randomEnumValue(Class<T> enumClass) {
4043 }
4144 return values [this .random ().nextInt (values .length )];
4245 }
46+
47+ public <T extends EntityId <Long >> T randomEntityId (LongFunction <T > constructor ) {
48+ return constructor .apply (
49+ super .random ().nextInt (99999 )
50+ );
51+ }
52+
53+ public <T extends EntityId <String >> T randomEntityId (Function <String , T > constructor ) {
54+ return constructor .apply (
55+ super .internet ().uuid ()
56+ );
57+ }
4358}
You can’t perform that action at this time.
0 commit comments