-
Notifications
You must be signed in to change notification settings - Fork 236
Open
Description
Please can you give me an idea how to control overrideDefaultInitialization to certain fields by filter (like excludeField or randomize do), to achieve something like:
.overrideDefaultInitialization(
FieldPredicates.ofType(String.class).negate()
)
The problem is, that we are using generated classes, where generators often initialize collections right at the declaration point such as
List<Foo> bar = new ArrayList<>().
These are treated as already initialized and thus are not randomized.
I could set overrideDefaultInitialization(true), but there is a problem of randomizing other fields with useful initial value, most often String constants.
I was able to control this to some point by precisely finding them and excluding such fields, e.g.
.excludeField(
FieldPredicates.ofType(String.class)
.and(FieldPredicates.named("objectType")
.and(FieldPredicates.isAnnotatedWith(JsonProperty.class)))
)
but you understand this being very time consuming and tricky.
Thank you very much
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels