Currently when I try to configure my fixture so I can send a test prior events my tests fail (testDeleteSort). Currently the testCreateSort method works like a charm. Just a note the “delete” is only toggling a boolean in the aggregate. I currently believe that I must have configured my fixture incorrectly. Is this how I should properly configure it in Axon 3?
@Before
public void setup() throws Exception {
fixture = new AggregateTestFixture<>(Sort.class);
//TODO look into initializing testing with eventStores in Axon 3
AggregateAnnotationCommandHandler commandHandler = new AggregateAnnotationCommandHandler<>(Sort.class, fixture.getRepository());
fixture.registerAnnotatedCommandHandler(commandHandler);
}
//Success
@Test
public void testCreateSort() throws Exception {
CreateSortCommand createSortCommand = new CreateSortCommand("operationTypeId", SortType.LOCAL_SORT, new SortName("My Local Sort"));
fixture.givenNoPriorActivity()
.when(createSortCommand)
.expectEvents(new CreateSortEvent(createSortCommand.getId(), "operationTypeId", SortType.LOCAL_SORT, new SortName("My Local Sort")));
}
//Fail
@Test
public void testDeleteSort() throws Exception {
CreateSortCommand createSortCommand = new CreateSortCommand("operationTypeId", SortType.LOCAL_SORT, new SortName("My Local Sort"));
fixture.given(createSortCommand)
.when(new DeleteSortCommand(createSortCommand.getId()))
.expectEvents(new DeleteSortEvent(createSortCommand.getId()));
}