Using BeanValidationInterceptor in GivenWhenThenTestFixture

Hi, Allard

I’m tried to test BeanValidationInterceptor that using JSR303 within GivenWhenThenTestFixture, but found it’s impossible to do so because GivenWhenThenTestFixture.when() will override handlerInterceptors with a single AggregateRegisteringInterceptor:

`

public ResultValidator when(Object command, Map<String, ?> metaData) {
try {
finalizeConfiguration();
final MatchAllFieldFilter fieldFilter = new MatchAllFieldFilter(fieldFilters);
ResultValidatorImpl resultValidator = new ResultValidatorImpl(storedEvents, publishedEvents,
fieldFilter);
commandBus.setHandlerInterceptors(Collections.singletonList(new AggregateRegisteringInterceptor()));

commandBus.dispatch(GenericCommandMessage.asCommandMessage(command).andMetaData(metaData), resultValidator);

detectIllegalStateChanges(fieldFilter);
resultValidator.assertValidRecording();
return resultValidator;
} finally {
FixtureResourceParameterResolverFactory.clear();
}
}

`

So I have to test command validation with full application context initialized or test bean validation separately… But IMHO, it will be great to test it within GivenWhenThenTestFixture.

Regards,
Nick

Hi Nick,

you’re right in that it would be a nice feature. I’ll put a feature request on our backlog.

Cheers,

Allard