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

Randomization parameters are not used for records #28

Closed
iceberk opened this issue May 18, 2023 · 0 comments · Fixed by #30
Closed

Randomization parameters are not used for records #28

iceberk opened this issue May 18, 2023 · 0 comments · Fixed by #30
Assignees

Comments

@iceberk
Copy link

iceberk commented May 18, 2023

When trying to generate random record, it seems that EasyRandomParameters are not used for generation.
Example:

import org.jeasy.random.EasyRandom;
import org.jeasy.random.EasyRandomParameters;
import org.jeasy.random.randomizers.text.StringRandomizer;
import org.junit.jupiter.api.Test;

import static org.jeasy.random.FieldPredicates.named;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class TestParameters {

    private final EasyRandom easyRandom = new EasyRandom(new EasyRandomParameters()
        .randomize(named("name"), new StringRandomizer(1))
    );

    @Test
    void test() {
        var result = easyRandom.nextObject(TestRecord.class);
        assertEquals(1, result.name().length());
    }

    record TestRecord(
        String name,
        String phone
    ){}
}

Result:

Expected :1
Actual   :23
@dvgaba dvgaba self-assigned this May 22, 2023
dvgaba added a commit that referenced this issue May 22, 2023
Fixed #28 and improved depth check and code refactoring.
@dvgaba dvgaba mentioned this issue May 22, 2023
dvgaba added a commit that referenced this issue May 22, 2023
Fixed #28 and improved depth check and code refactoring.
dvgaba added a commit that referenced this issue May 22, 2023
Fixed #28 and improved depth check and code refactoring.
dvgaba added a commit that referenced this issue May 22, 2023
Fixed #28 and improved depth check and code refactoring.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants