AggregateTestFixture with MetaDataCommandTargetResolver

Is there anyway to configure the AggregateTestFixture to use the MetaDataCommandTargetResolver?

Thanks for any help you can provide,

Hi Ron,

not a very straightforward way, I’m afraid. This feature is not use that much, apparently.
But it should be possible (unable to try at the moment).
You’ll need to create an AggregateAnnotationCommandHandler
AggregateAnnotationCommandHandler aach = new AggregateAnnotationCommandHandler(MyAggregate.class, fixture.getRepository(), myCommandTargetResolver)

Then, register the handler with the command bus of the fixture:
for(String commandName : aach.supportedCommandNames()) {
fixture.registerCommandHandler(commandName, aach);

Hope this helps.



That worked perfectly.

The reason that we are using the MetaDataCommandTargetResolver is that our domain design specifies triggering events, commands and replies for each domain. Instead of wrapping these classes with POJOs with the “@TargetAggregateIdentifier” for the aggregate identifier, we wanted to use the classes directly.and extract the identifier from the message payload. This prevents the need for having to expose an additional API.

Thanks for taking the time to answer my question. The solution was not obvious and I really like having the AggregateTestFixture for unit tests.