@JvmInline
value class Value(val value: String)
class StringObject(val string: Value)
FixtureMonkey.builder()
.plugin(KotestPlugin())
.plugin(KotlinPlugin())
.build()
.giveMeArb<StringObject>().next()
Expected behaviour
Should generate values when type is a value class.
Actual behaviour
Error is thrown:
object is not an instance of declaring class
java.lang.IllegalArgumentException: object is not an instance of declaring class
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at kotlin.reflect.jvm.internal.calls.ValueClassAwareCaller.call(ValueClassAwareCaller.kt:179)
at kotlin.reflect.jvm.internal.KCallableImpl.callDefaultMethod$kotlin_reflection(KCallableImpl.kt:200)
at kotlin.reflect.jvm.internal.KCallableImpl.callBy(KCallableImpl.kt:112)
at com.navercorp.fixturemonkey.kotlin.introspector.PrimaryConstructorArbitraryIntrospector.introspect$lambda$3(PrimaryConstructorArbitraryIntrospector.kt:67)
at com.navercorp.fixturemonkey.api.arbitrary.ObjectCombinableArbitrary.combined(ObjectCombinableArbitrary.java:54)
at com.navercorp.fixturemonkey.api.arbitrary.NullInjectCombinableArbitrary.combined(NullInjectCombinableArbitrary.java:46)
at com.navercorp.fixturemonkey.api.arbitrary.TraceableCombinableArbitrary.combined(TraceableCombinableArbitrary.java:42)
at com.navercorp.fixturemonkey.api.arbitrary.FilteredCombinableArbitrary.combined(FilteredCombinableArbitrary.java:73)
at com.navercorp.fixturemonkey.resolver.ResolvedCombinableArbitrary.combined(ResolvedCombinableArbitrary.java:77)
at com.navercorp.fixturemonkey.resolver.DefaultArbitraryBuilder.sample(DefaultArbitraryBuilder.java:489)
at com.navercorp.fixturemonkey.FixtureMonkey.lambda$giveMe$3(FixtureMonkey.java:175)
at java.base/java.util.stream.StreamSpliterators$InfiniteSupplyingSpliterator$OfRef.tryAdvance(StreamSpliterators.java:1358)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at com.navercorp.fixturemonkey.FixtureMonkey.giveMe(FixtureMonkey.java:183)
at com.navercorp.fixturemonkey.FixtureMonkey.giveMeOne(FixtureMonkey.java:191)
Describe the bug
Fixture Monkey doesn't work with Kotlin value classes
Your environment
fixture-monkey-starter-kotlin:1.0.10 fixture-monkey-kotest:1.0.0 Kotlin 1.9.22
Steps to reproduce
Expected behaviour
Should generate values when type is a value class.
Actual behaviour
Error is thrown: