You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public record MyRecord(String fieldOne, AnotherRecord fieldTwo) {}
where AnotherRecord is a record
When I do:
easyRandomParameters.randomize(
field -> field.equals(fieldTwoField), () -> null
);
I would expect the value for fieldTwo to be null. This works with most primitives & other classes that are not records. However, with records, fieldTwo is not null and still subject to value generation.
I've sort of worked around this by also adding:
easyRandomParameters.randomize(AnotherRecord.class, new SkipRandomizer());
however if in my object I have more than one field that is AnotherRecord, ie:
public record SomeOtherRecord(AnotherRecord fieldOne, AnotherRecord fieldTwo) {}
naturally both fieldOne & fieldTwo would be skipped, so it doesn't work in those scenarios. The intention is just to null out that single field (fieldTwo).
The text was updated successfully, but these errors were encountered:
Given a record like:
where
AnotherRecord
is a recordWhen I do:
I would expect the value for
fieldTwo
to be null. This works with most primitives & other classes that are not records. However, with records,fieldTwo
is not null and still subject to value generation.I've sort of worked around this by also adding:
however if in my object I have more than one field that is AnotherRecord, ie:
naturally both fieldOne & fieldTwo would be skipped, so it doesn't work in those scenarios. The intention is just to null out that single field (fieldTwo).
The text was updated successfully, but these errors were encountered: