Question about testing in Axon 2

What is the correct way to initialize a fixture with an aggregate command handler?

I do it like this:

fixture = Fixtures.newGivenWhenThenFixture(MyAggregate.class);

new AggregateAnnotationCommandHandler(MyAggregate.class, fixture.getRepository(), fixture.getCommandBus()).subscribe();

But this doesn’t work:

fixture = Fixtures.newGivenWhenThenFixture(MyAggregate.class).registerInjectableResource(templateConverter);
new AggregateAnnotationCommandHandler(MyAggregate.class, fixture.getRepository(), fixture.getCommandBus()).subscribe();

During tests I get an UnsupportedHandlerException saying: parameter 2 is invalid. It is not of any format supported by a providedParameterValueResolver.

Hi Jeroen,

all you need to do is:
fixture = Fixtures.newGivenWhenThenFixture(MyAggregate.class);

Further configuration is not necessary. The fixture automatically detects the @CommandHandler annotations.

Cheers,

Allard

Works! Thanks for the quick reply.