I need to test that two times creating the same aggregate fails.
Unfortunatly SimpleBus intercepts my assertion exception which is
basically this in
RecipeCommandHandler.java
try{
Recipe recipe = repository.load(recipeId);
Assert.isTrue(false, String.format("RecipeId <%1$s> already
in event store, when calling createRecipe", recipeId));
}catch(AggregateNotFoundException e){
Assert.isTrue(true);// not necessary, but i want to express
that you need to come here
}
IntegrationTest.java
@Test(expected=IllegalArgumentException.class)
public void a_new_Recipe_is_issued_two_times() {
CreateRecipe createRecipe = new CreateRecipe(expectedId,
recipeNameExpected, ownerId);
// When same create recipe 2x
cmdBus.dispatch(createRecipe);
cmdBus.dispatch(createRecipe);
}
Are such precondition failures testable?
Best Regards,
Roland