CseFormValidator implements Validator { @Override public void validate(final Object object, final Errors errors) { final CSEPaymentForm form = (CSEPaymentForm) object; if (StringUtils.isBlank(form.getCseToken())) { errors.reject(GLOBAL_MISSING_CSE_TOKEN); } }  @Override boolean supports(final Class<?> aClass); @Override void validate(final Object object, final Errors errors);  }
@Test public void shouldNotRejectIfCseIsSet() throws Exception { when(csePaymentFormMock.getCseToken()).thenReturn(CSE_TOKEN); testObj.validate(csePaymentFormMock, errorsMock); verify(errorsMock, never()).reject(CseFormValidator.GLOBAL_MISSING_CSE_TOKEN); }
@Test public void shouldRejectIfCseIsNotSet() throws Exception { when(csePaymentFormMock.getCseToken()).thenReturn(""); testObj.validate(csePaymentFormMock, errorsMock); verify(errorsMock).reject(CseFormValidator.GLOBAL_MISSING_CSE_TOKEN); }