I have already used command dispatch and handler interceptors on AggregateTestFixture and they work perfectly fine. Recently, however, I had a use case where I wanted to add an event dispatch interceptor but this didn’t seem to do anything. I had a look at the implementation of AggregateTestFixture and found this:
public Registration registerDispatchInterceptor(MessageDispatchInterceptor<? super EventMessage<?>> dispatchInterceptor) {
return () -> {
return true;
};
}
Is there a reason why this is not implemented or is this an oversight?
it’s probably a bit of both. The fixture’s intent is to test the behavior of the aggregate, not so much of the interceptors.
However, I can imagine one could say the dispatch interceptor is part of the command handling component.
If you’d like to have this included, feel free to submit an issue (or better, a PR ).
If you check the AggregateTestFixture API, you can see there is a registerCommandDispatchInterceptor() method on it.
Thus, in your Aggregate test cases, you can configure your MessageDispatchInterceptor by utilizing that method.