Replies: 1 comment 1 reply
-
|
Should be doable with List<String> quotes = Stream.concat(
gen().string().length(10).stream().limit(3),
gen().string().length(20).stream().limit(3))
.collect(Collectors.toList());
List<Quotations> quotations = Instancio.ofList(Quotations.class)
.size(10)
.generate(field(Quotations::getQuote), gen -> gen.emit()
.items(quotes) // use values from the given choices
.whenEmptyEmitRandom() // this can be omitted since it's the default behaviour
.shuffle()) // by default items are set in the order they are specified
.create();
quotations.forEach(System.out::println); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is it somehow possible to generate a collection of objects with multiple generators for the same attribute?
Let's say I have a POJO like this:
I want to generate a list of quotations with a size of 10, where 3 quotes have a max length of 10, 3 quotes have a min length of 20 and 4 quotes where I don't care about the length.
Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions