JSR 303 Validation

Hey,

What’s the recommended approach to doing structural validation? I’ve added some @Size() constraints to my command, and I have the jsr303 interceptor wired in.

Should I be redoing this check in the AR? If not, is there a way to attach the jsr303 interceptor to the CommandBus used by the GivenWhenThenTestFixture so I can see things fail properly?

JAmes

Hi James,

my experience is that JSR-303 works best for this. The AR should not have to do this anymore, in my opinion. If anything is missing in the command at that point, you might as well fail loudly.

I’m not sure there is the possibility to add interceptors to the test fixtures. I’m also not sure if that’s the right place to test your interceptor. The fixtures are primarily mean to test command handling (aggregate and maybe a command handler). Since you ‘copy’ the wiring of the actual application in the fixture, you may want to do a proper integration test, using the actual application wiring.

Cheers,

Allard