smartcat-labs / ranger

Ranger is contextual data generator used to make sensible data for integration tests or to play with it in the database
https://www.smartcat.io/products/ranger-contextual-data-and-load-generator
Apache License 2.0
59 stars 11 forks source link

Support for random length lists #175

Closed keremulutas closed 6 years ago

keremulutas commented 6 years ago

API documentation shows there is no support for this.

It would be really nice if we had the chance to, say, generate a list of Date objects with random length between 3 - 7

vajda commented 6 years ago

Yes, we have that idea in mind, but still thinking about proper syntax for it. Do you maybe have an idea how would you describe it through Ranger DSL?

keremulutas commented 6 years ago

Just thinking out loud. Given:

class MyObject {
    List<Integer> myRandomLengthList;
}

a nice to have syntax could be like this:

ObjectGenerator<MyObject> myObject = new ObjectGeneratorBuilder()
            .prop("myRandomLengthList", list(1, 3, random(range(1,255)))
            .build(MyObject.class);

where, 1 is the minimum element count, 3 is the maximum element count, random(...) is the generator for the list elements.

An overload could be added so exactly n instances generated by the list element generator would be added to the list.

vajda commented 6 years ago

@keremulutas Proposed solution seems nice, it would only need to include configuration based DSL with same functionality, do you care to implement it and create pull request?

keremulutas commented 6 years ago

Pull request opened (#177) - closing this issue.