Database data generator. Based on Spring Data
This project is maintained by besok
Database data generator based on Spring Data Repository. This tool can be used in your spring data project for generating some data.
compile group: 'ru.generator.db.data', name: 'db-data-generator', version: '0.2'
generator.startId() // 0 by default
@Autowired
private DatabaseDataGeneratorFactory factory;
String report =
factory
.generator()
.generateAll()
.report();
String report =
factory
.generator()
.generateBy(Limit.class)
.generateBy(Customer.class)
.generateBy(Currency.class)
.generateBy(OrganizationUnit.class)
.report();
String report =
factory
.generator()
.generateBy("schema","table")
.report();
try {
InnerLog log =
factory
.generator()
.generateBy("schema", "table")
.withException()
.log;
} catch (DataGenerationException e) {
e.printStackTrace();
}
InnerLog log =
factory
.generator().repeate(10)
.generateBy(Limit.class)
.log;
InnerLog s =
factory
.generator().metronome(1, TimeUnit.SECONDS)
.predicate(countPredicate(10))
.generateBy(Customer.class)
.log();
InnerLog s =
factory
.generator()
.metronome(1, TimeUnit.SECONDS,ctx -> ctx.log.markerValue() < 10)
.generateBy(Customer.class)
.log();
InnerCache cache = factory
.generator()
.metronome(10,TimeUnit.MILLISECONDS,COUNT(10))
.generateBy(SimplePlainObject.class)
.cache();
factory
.generator().async()
.repeate(100)
.generateBy(SimplePlainObject1.class)
.generateBy(SimplePlainObject2.class)
.generateBy(SimplePlainObject3.class)
.finish();
import static ru.gpb.utils.db.data.generator.worker.Action.*;
import static ru.gpb.utils.db.data.generator.worker.ColumnPredicate.*;
...
NakedObject spo = factory
.generator()
.rule(FIELD("fieldWithCamel"), CONST("newValue"), String.class)
.generateBy(NakedObject.class)
.cache()
.getValueList(NakedObject.class)
.get(0);
assertEquals("newValue", spo.getFieldWithCamel());
NakedObject spo = factory
.generator()
.rule(
COMPOSE(CLASS(NakedObject.class), FIELD("fieldWithCamel")),
CONST("newValue"), String.class)
.generateBy(NakedObject.class)
.generateBy(NakedObject2.class)
.generateBy(NakedObject3.class)
List<SeqIncObject> list =
factory.generator()
.repeate(10)
.rule(FIELD("lRight"), INCREMENT_L(0), long.class)
.rule(FIELD("random"), RANDOM(10), int.class)
.rule(FIELD("random"), PEEK(System.out::println), int.class)
.generateBy(SeqIncObject.class)
.cache()
.getValueList(SeqIncObject.class);
This project is licensed under the terms of the MIT license.