@Test public void isValid() throws IOException { when(userStore.getRole("role")).thenReturn(role); assertTrue(validator.isValid(null, null)); assertTrue(validator.isValid(StringUtils.EMPTY, null)); assertTrue(validator.isValid("role", null)); assertFalse(validator.isValid("role2", null)); }
@Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } try { return userStore.getRole(value) != null; } catch (IOException e) { throw new ValidationException(e); } }
RoleExistsValidator implements ConstraintValidator<RoleExists, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } try { return userStore.getRole(value) != null; } catch (IOException e) { throw new ValidationException(e); } } }
RoleExistsValidator implements ConstraintValidator<RoleExists, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } try { return userStore.getRole(value) != null; } catch (IOException e) { throw new ValidationException(e); } }  }
RoleExistsValidator implements ConstraintValidator<RoleExists, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } try { return userStore.getRole(value) != null; } catch (IOException e) { throw new ValidationException(e); } }  @Override void initialize(RoleExists annotation); @Override boolean isValid(String value, ConstraintValidatorContext context); }
RoleExistsValidator implements ConstraintValidator<RoleExists, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } try { return userStore.getRole(value) != null; } catch (IOException e) { throw new ValidationException(e); } }  @Override void initialize(RoleExists annotation); @Override boolean isValid(String value, ConstraintValidatorContext context);  }