### Question:
UserResourceValidator implements Validator { @Override public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "name.empty"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "currency", "currency.empty"); }  @Override boolean supports(Class<?> clazz); @Override void validate(Object target, Errors errors);  }### Answer:
@Test public void nameShouldNotBeEmpty() { final UserResource userResource = new UserResource("", "€"); final BeanPropertyBindingResult errors = createBindingResult(userResource); testSubject.validate(userResource, errors); assertThat(errors.getFieldError("name").getCode()).isEqualTo("name.empty"); }
@Test public void currencyShouldNotBeEmpty() { final UserResource userResource = new UserResource("Foo", ""); final BeanPropertyBindingResult errors = createBindingResult(userResource); testSubject.validate(userResource, errors); assertThat(errors.getFieldError("currency").getCode()).isEqualTo("currency.empty"); }