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

GIVEN.state() does not work #278

Open
jangalinski opened this issue May 8, 2023 · 0 comments
Open

GIVEN.state() does not work #278

jangalinski opened this issue May 8, 2023 · 0 comments

Comments

@jangalinski
Copy link
Contributor

Steps to reproduce

  • extension version: 0.4.0
  • Steps: (what exactly are you doing with the above reproducer?)

When I use given().state(...) to setup the internal state of the aggregate, the test fails with the exception below. As there where no events involved, this violates the "load aggregate" contract.

Expected behaviour

initialize the internal state directly, instead of applying a bunch of events.

Actual behaviour

failure, see below.

org.axonframework.test.FixtureExecutionException: Failed to execute givenCommands

	at org.axonframework.test.aggregate.AggregateTestFixture$ExecutionExceptionAwareCallback.onResult(AggregateTestFixture.java:1008)
	at org.axonframework.commandhandling.WrappedCommandCallback.onResult(WrappedCommandCallback.java:51)
	at org.axonframework.commandhandling.MonitorAwareCallback.onResult(MonitorAwareCallback.java:57)
	at org.axonframework.commandhandling.SimpleCommandBus.handle(SimpleCommandBus.java:204)
	at org.axonframework.commandhandling.SimpleCommandBus.doDispatch(SimpleCommandBus.java:165)
	at org.axonframework.commandhandling.SimpleCommandBus.lambda$dispatch$2(SimpleCommandBus.java:131)
	at org.axonframework.tracing.Span.run(Span.java:101)
	at org.axonframework.commandhandling.SimpleCommandBus.dispatch(SimpleCommandBus.java:125)
	at org.axonframework.test.aggregate.AggregateTestFixture.lambda$andGivenCommands$1(AggregateTestFixture.java:400)
	at org.axonframework.test.aggregate.AggregateTestFixture.executeAtSimulatedTime(AggregateTestFixture.java:413)
	at org.axonframework.test.aggregate.AggregateTestFixture.andGivenCommands(AggregateTestFixture.java:400)
	at io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven$commands$1.invoke(AggregateFixtureGiven.kt:62)
	at io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven$commands$1.invoke(AggregateFixtureGiven.kt:57)
	at io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven.execute(AggregateFixtureGiven.kt:119)
	at io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven.commands(AggregateFixtureGiven.kt:57)
	at io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven$ByteBuddy$Rkav65nZ.commands$accessor$CbQpRjs8(Unknown Source)
	at io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven$ByteBuddy$Rkav65nZ$auxiliary$zFricsMZ.call(Unknown Source)
	at com.tngtech.jgiven.impl.intercept.StepInterceptorImpl.doIntercept(StepInterceptorImpl.java:111)
	at com.tngtech.jgiven.impl.intercept.StepInterceptorImpl.intercept(StepInterceptorImpl.java:82)
	at com.tngtech.jgiven.impl.intercept.ByteBuddyMethodInterceptor.interceptSuper(ByteBuddyMethodInterceptor.java:37)
	at io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven$ByteBuddy$Rkav65nZ.commands(Unknown Source)
	at io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven.commands(AggregateFixtureGiven.kt:50)
	at io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven$ByteBuddy$Rkav65nZ.commands$accessor$CbQpRjs8(Unknown Source)
	at io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven$ByteBuddy$Rkav65nZ$auxiliary$5NzUNlV0.call(Unknown Source)
	at com.tngtech.jgiven.impl.intercept.StepInterceptorImpl.doIntercept(StepInterceptorImpl.java:111)
	at com.tngtech.jgiven.impl.intercept.StepInterceptorImpl.intercept(StepInterceptorImpl.java:82)
	at com.tngtech.jgiven.impl.intercept.ByteBuddyMethodInterceptor.interceptSuper(ByteBuddyMethodInterceptor.java:37)
	at io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven$ByteBuddy$Rkav65nZ.commands(Unknown Source)
	at io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven.command(AggregateFixtureGiven.kt:43)
	at io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven$ByteBuddy$Rkav65nZ.command$accessor$CbQpRjs8(Unknown Source)
	at io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven$ByteBuddy$Rkav65nZ$auxiliary$oYo2wzn9.call(Unknown Source)
	at com.tngtech.jgiven.impl.intercept.StepInterceptorImpl.doIntercept(StepInterceptorImpl.java:111)
	at com.tngtech.jgiven.impl.intercept.StepInterceptorImpl.intercept(StepInterceptorImpl.java:82)
	at com.tngtech.jgiven.impl.intercept.ByteBuddyMethodInterceptor.interceptSuper(ByteBuddyMethodInterceptor.java:37)
	at io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven$ByteBuddy$Rkav65nZ.command(Unknown Source)
	at com.fiege.oms.installationpartner.command.domain.model.aggregate.InstallationPartnerAggregateTest$InstallerEntityTest.remove a serviceArea from installer is idempotent(InstallationPartnerAggregateTest.kt:737)
	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 org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
	at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
	at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: org.axonframework.modelling.command.AggregateNotFoundException: No 'given' events were configured for this aggregate, nor have any events been stored.
	at org.axonframework.test.aggregate.AggregateTestFixture$RecordingEventStore.readEvents(AggregateTestFixture.java:913)
	at org.axonframework.eventsourcing.EventSourcingRepository.readEvents(EventSourcingRepository.java:169)
	at org.axonframework.eventsourcing.EventSourcingRepository.doLoadWithLock(EventSourcingRepository.java:129)
	at org.axonframework.eventsourcing.EventSourcingRepository.doLoadWithLock(EventSourcingRepository.java:55)
	at org.axonframework.modelling.command.LockingRepository.doLoad(LockingRepository.java:137)
	at org.axonframework.modelling.command.LockingRepository.doLoad(LockingRepository.java:60)
	at org.axonframework.modelling.command.AbstractRepository.lambda$null$6(AbstractRepository.java:141)
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220)
	at org.axonframework.modelling.command.AbstractRepository.lambda$load$8(AbstractRepository.java:140)
	at org.axonframework.tracing.Span.runSupplier(Span.java:163)
	at org.axonframework.modelling.command.AbstractRepository.load(AbstractRepository.java:137)
	at org.axonframework.test.aggregate.AggregateTestFixture$IdentifierValidatingRepository.load(AggregateTestFixture.java:768)
	at org.axonframework.modelling.command.AggregateAnnotationCommandHandler$AggregateCommandHandler.handle(AggregateAnnotationCommandHandler.java:568)
	at org.axonframework.modelling.command.AggregateAnnotationCommandHandler$AggregateCommandHandler.handle(AggregateAnnotationCommandHandler.java:557)
	at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:57)
	at org.axonframework.messaging.unitofwork.DefaultUnitOfWork.executeWithResult(DefaultUnitOfWork.java:77)
	at org.axonframework.commandhandling.SimpleCommandBus.lambda$handle$4(SimpleCommandBus.java:201)
	at org.axonframework.tracing.Span.runSupplier(Span.java:163)
	at org.axonframework.commandhandling.SimpleCommandBus.handle(SimpleCommandBus.java:192)
	... 111 more

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