Hi, I’ve been testing some things with regard to the CREATE_IF_MISSING aggregate feature. I’ve been trying several things in a running Spring boot application+dockerized Axon server and all works well, however I can not get the unittests to work when using the AggregateTestFixture.
The aggregate only has a default public constructor. This is the only commandhandler:
@CommandHandler @CreationPolicy(AggregateCreationPolicy.CREATE_IF_MISSING) public void handle(ImportOrganisationCommand cmd) { if (id == null) { apply(new OrganisationCreatedEvent(cmd.getOrganisation())); } else if (!cmd.getOrganisation().equals(organisation)) { apply(new OrganisationUpdatedEvent(cmd.getOrganisation())); } }
This is the test:
@Test void test1() { ImportOrganisationCommand cmd = new ImportOrganisationCommand(“1”, org1); OrganisationCreatedEvent organisationCreatedEvent = new OrganisationCreatedEvent(org1);
I don’t think this is currently an issue with the usage of the create-if-missing functionality.
It is true that this exact message will only occur if a create-or-update is in progress, but it is there to signal users that the aggregate identifier is required to be set after handling the creation.
So, I am pretty confident you might be missing an Event Sourcing Handler for the OrganisationCreatedEvent to actually set the aggregate identifier field in the aggregate.
Could you confirm this is the case?
If not, then we have some further investigating to do!
Cheers,
Steven
PS. It is important to note that this mailing list will be discontinued as specified in this thread.
Instead of this mailing list we have moved to use a forum style of communication, at https://discuss-next.axoniq.io/.
You are absolutely right, there is no issue. I did already use the Event Sourcing handler as you mentioned, but something was wrong with my testdata, which I kept overlooking. Sorry, my bad!