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 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 .LongFunction ;
1012
1113public class FakerExtended extends Faker {
1214 public FakerExtended () {
@@ -40,4 +42,10 @@ public <T extends Enum<?>> T randomEnumValue(Class<T> enumClass) {
4042 }
4143 return values [this .random ().nextInt (values .length )];
4244 }
45+
46+ public <T extends EntityId <Long >> T randomEntityId (LongFunction <T > constructor ) {
47+ return constructor .apply (
48+ super .random ().nextInt (99999 )
49+ );
50+ }
4351}
You can’t perform that action at this time.
0 commit comments