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
When using the FixtureMonkey library to generate fixtures for a Kotlin sealed class, the process fails if the sealed class contains an object declaration. The error message indicates that a primary constructor is not provided for the object class, which leads to fixture generation failure.
Your environment
version of Fixture Monkey: 1.1.6
version of Java/Kotlin : kotlin, 2.0.20
Steps to reproduce
classFixtureMonkeyTest {
@Test
fun`test fixtureMonkey`() {
val sampled =FixtureMonkeyBuilder()
.plugin(KotlinPlugin())
.build()
.giveMeKotlinBuilder<MyData>()
.set(MyData::name, "my_name")
.sample()
println("sampled: $sampled")
}
data classMyData(
valid:Int,
valname:String,
valscheme:Scheme,
)
sealedclassScheme {
data classUrl(valscheme:String) : Scheme()
data objectNone : Scheme()
}
}
Expected behaviour
scheme property in MyData class could be initialized with arbitrarily one of Scheme.Url(String). Scheme.None
Actual behaviour
No kotlin primary constructor provided for class com.fixturetest.FixtureMonkeyTest$Scheme$None
java.lang.IllegalArgumentException: No kotlin primary constructor provided for class com.fixturetest.FixtureMonkeyTest$Scheme$None
at com.navercorp.fixturemonkey.kotlin.type.KotlinTypeCacheKt$kotlinPrimaryConstructor$1.invoke(KotlinTypeCache.kt:51)
at com.navercorp.fixturemonkey.kotlin.type.KotlinTypeCacheKt$kotlinPrimaryConstructor$1.invoke(KotlinTypeCache.kt:49)
at com.navercorp.fixturemonkey.kotlin.type.KotlinTypeCacheKt.kotlinPrimaryConstructor$lambda$4(KotlinTypeCache.kt:49)
at java.base/java.util.Map.computeIfAbsent(Map.java:1054)
at com.navercorp.fixturemonkey.kotlin.type.KotlinTypeCacheKt.kotlinPrimaryConstructor(KotlinTypeCache.kt:49)
at com.navercorp.fixturemonkey.kotlin.introspector.PrimaryConstructorArbitraryIntrospector$Companion$PROPERTY_GENERATOR$1.invoke(PrimaryConstructorArbitraryIntrospector.kt:87)
at com.navercorp.fixturemonkey.kotlin.introspector.PrimaryConstructorArbitraryIntrospector$Companion$PROPERTY_GENERATOR$1.invoke(PrimaryConstructorArbitraryIntrospector.kt:86)
at com.navercorp.fixturemonkey.kotlin.property.KotlinConstructorParameterPropertyGenerator$generateChildProperties$1.invoke(KotlinConstructorParameterPropertyGenerator.kt:45)
at com.navercorp.fixturemonkey.kotlin.property.KotlinConstructorParameterPropertyGenerator$generateChildProperties$1.invoke(KotlinConstructorParameterPropertyGenerator.kt:44)
at com.navercorp.fixturemonkey.kotlin.property.KotlinConstructorParameterPropertyGenerator.generateChildProperties$lambda$0(KotlinConstructorParameterPropertyGenerator.kt:44)
at java.base/java.util.Map.computeIfAbsent(Map.java:1054)
at com.navercorp.fixturemonkey.kotlin.property.KotlinConstructorParameterPropertyGenerator.generateChildProperties(KotlinConstructorParameterPropertyGenerator.kt:44)
at com.navercorp.fixturemonkey.api.property.CompositePropertyGenerator.generateChildProperties(CompositePropertyGenerator.java:57)
at com.navercorp.fixturemonkey.builder.ArbitraryBuilderContext.lambda$initializeResolvedPropertyGenerator$2(ArbitraryBuilderContext.java:310)
at com.navercorp.fixturemonkey.api.property.LazyPropertyGenerator.lambda$null$0(LazyPropertyGenerator.java:50)
at com.navercorp.fixturemonkey.api.lazy.UnSafeLazyArbitraryImpl.getValue(UnSafeLazyArbitraryImpl.java:53)
at com.navercorp.fixturemonkey.api.property.LazyPropertyGenerator.generateChildProperties(LazyPropertyGenerator.java:51)
at com.navercorp.fixturemonkey.api.tree.TreeProperty.lambda$toArbitraryProperty$0(TreeProperty.java:85)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
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.api.tree.TreeProperty.toArbitraryProperty(TreeProperty.java:87)
at com.navercorp.fixturemonkey.api.tree.DefaultTraverseNode.generateObjectNode(DefaultTraverseNode.java:335)
at com.navercorp.fixturemonkey.api.tree.DefaultTraverseNode.generateChildrenNodes(DefaultTraverseNode.java:464)
at com.navercorp.fixturemonkey.api.tree.DefaultTraverseNode.lambda$expand$1(DefaultTraverseNode.java:230)
at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:273)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
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.api.tree.DefaultTraverseNode.expand(DefaultTraverseNode.java:239)
at com.navercorp.fixturemonkey.tree.ObjectNode.expand(ObjectNode.java:70)
at com.navercorp.fixturemonkey.tree.MetadataCollector.collect(MetadataCollector.java:66)
at com.navercorp.fixturemonkey.tree.MetadataCollector.collect(MetadataCollector.java:54)
at com.navercorp.fixturemonkey.tree.ObjectTree.<init>(ObjectTree.java:48)
at com.navercorp.fixturemonkey.resolver.ArbitraryResolver.lambda$resolve$2(ArbitraryResolver.java:69)
at com.navercorp.fixturemonkey.api.lazy.UnSafeLazyArbitraryImpl.getValue(UnSafeLazyArbitraryImpl.java:53)
at com.navercorp.fixturemonkey.resolver.ResolvedCombinableArbitrary.lambda$new$0(ResolvedCombinableArbitrary.java:63)
at com.navercorp.fixturemonkey.api.lazy.UnSafeLazyArbitraryImpl.getValue(UnSafeLazyArbitraryImpl.java:53)
at com.navercorp.fixturemonkey.resolver.ResolvedCombinableArbitrary.combined(ResolvedCombinableArbitrary.java:75)
at com.navercorp.fixturemonkey.builder.DefaultArbitraryBuilder.sample(DefaultArbitraryBuilder.java:483)
at com.navercorp.fixturemonkey.kotlin.KotlinTypeDefaultArbitraryBuilder.sample(FixtureMonkeyExtensions.kt:245)
at com.fixturetest.FixtureMonkeyTest.test fixtureMonkey(FixtureMonkeyTest.kt:17)
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:569)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:112)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:40)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:54)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:53)
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:569)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:92)
at jdk.proxy1/jdk.proxy1.$Proxy4.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:181)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:130)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:101)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:61)
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:122)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:69)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
The text was updated successfully, but these errors were encountered:
Describe the bug
When using the FixtureMonkey library to generate fixtures for a Kotlin sealed class, the process fails if the sealed class contains an
object
declaration. The error message indicates that a primary constructor is not provided for theobject
class, which leads to fixture generation failure.Your environment
Steps to reproduce
Expected behaviour
scheme property in
MyData
class could be initialized with arbitrarily one ofScheme.Url(String)
.Scheme.None
Actual behaviour
The text was updated successfully, but these errors were encountered: