Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record fields still being generated even if randomizer is specified for field to set it to null #39

Open
jamfor352 opened this issue Nov 22, 2023 · 0 comments

Comments

@jamfor352
Copy link

jamfor352 commented Nov 22, 2023

Given a record like:

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant