@Test void willValidateCommandWithSuperClass() throws Exception { CreateUserSubclassCommand createUserSubclassCommand = mock(CreateUserSubclassCommand.class); when(createUserSubclassCommand.getOrganizationId()).thenReturn(ORGANIZATION_ID); Mockito.<Class<?>>when(commandMessage.getPayloadType()).thenReturn(CreateUserSubclassCommand.class); Mockito.<Object>when(commandMessage.getPayload()).thenReturn(createUserSubclassCommand); when(organizationsReadService.getById(ORGANIZATION_ID)).thenReturn(ORGANIZATION); commandValidatingMessageHandlerInterceptor.handle(unitOfWork, interceptorChain); verify(createUserSubclassCommand, times(2)).getEmailAddress(); verify(createUserSubclassCommand, times(4)).getOrganizationId(); }
@Override public Object handle(UnitOfWork<? extends CommandMessage<?>> unitOfWork, InterceptorChain interceptorChain) throws Exception { CommandMessage<?> message = unitOfWork.getMessage(); if (ValidatableCommand.class.isAssignableFrom(message.getPayloadType())) { validate(message); } return interceptorChain.proceed(); }
CommandValidatingMessageHandlerInterceptor implements MessageHandlerInterceptor<CommandMessage<?>> { @Override public Object handle(UnitOfWork<? extends CommandMessage<?>> unitOfWork, InterceptorChain interceptorChain) throws Exception { CommandMessage<?> message = unitOfWork.getMessage(); if (ValidatableCommand.class.isAssignableFrom(message.getPayloadType())) { validate(message); } return interceptorChain.proceed(); } }
CommandValidatingMessageHandlerInterceptor implements MessageHandlerInterceptor<CommandMessage<?>> { @Override public Object handle(UnitOfWork<? extends CommandMessage<?>> unitOfWork, InterceptorChain interceptorChain) throws Exception { CommandMessage<?> message = unitOfWork.getMessage(); if (ValidatableCommand.class.isAssignableFrom(message.getPayloadType())) { validate(message); } return interceptorChain.proceed(); } @Autowired  CommandValidatingMessageHandlerInterceptor(List<Validates> validators, Validator javaBeanValidator); }
CommandValidatingMessageHandlerInterceptor implements MessageHandlerInterceptor<CommandMessage<?>> { @Override public Object handle(UnitOfWork<? extends CommandMessage<?>> unitOfWork, InterceptorChain interceptorChain) throws Exception { CommandMessage<?> message = unitOfWork.getMessage(); if (ValidatableCommand.class.isAssignableFrom(message.getPayloadType())) { validate(message); } return interceptorChain.proceed(); } @Autowired  CommandValidatingMessageHandlerInterceptor(List<Validates> validators, Validator javaBeanValidator); @Override Object handle(UnitOfWork<? extends CommandMessage<?>> unitOfWork, InterceptorChain interceptorChain); }
CommandValidatingMessageHandlerInterceptor implements MessageHandlerInterceptor<CommandMessage<?>> { @Override public Object handle(UnitOfWork<? extends CommandMessage<?>> unitOfWork, InterceptorChain interceptorChain) throws Exception { CommandMessage<?> message = unitOfWork.getMessage(); if (ValidatableCommand.class.isAssignableFrom(message.getPayloadType())) { validate(message); } return interceptorChain.proceed(); } @Autowired  CommandValidatingMessageHandlerInterceptor(List<Validates> validators, Validator javaBeanValidator); @Override Object handle(UnitOfWork<? extends CommandMessage<?>> unitOfWork, InterceptorChain interceptorChain);  }