naver / fixture-monkey

Let Fixture Monkey generate test instances including edge cases automatically
https://naver.github.io/fixture-monkey
Apache License 2.0
561 stars 89 forks source link

Unable to generate Timestamp #786

Closed esfomeado closed 10 months ago

esfomeado commented 11 months ago

Describe the bug

Unable to generate Timestamp due to no primary constructor

Your environment

Steps to reproduce

https://github.com/esfomeado/fixture-monkey-bug/blob/master/src/test/java/com/example/bug/FixtureMonkeyTest.java#L116

Expected behaviour

Should generate Timestamp

Actual behaviour

It doesn't generate a Timestamp

seongahjo commented 11 months ago

@esfomeado You can address this issue by using experimental feature instantiate in 0.6.12.

Timestamp timestamp = fixtureMonkey.giveMeExperimentalBuilder(Timestamp.class)
            .instantiate(Instantiator.constructor())
            .sample();

You can use use set as well.

Timestamp timestamp = fixtureMonkey.giveMeExperimentalBuilder(Timestamp.class)
            .instantiate(Instantiator.constructor()
                .parameter(Long.class, "time")
            )
            .set("time", 1L)
            .sample();