ProjectDoesNotExistValidator implements ConstraintValidator<ProjectDoesNotExist, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return !globalRepositoryManager.listProjects().contains(value); }  @Override void initialize(ProjectDoesNotExist annotation); @Override boolean isValid(String value, ConstraintValidatorContext context);  }
@Test public void isValid() { when(repoManager.listProjects()).thenReturn(Lists.newArrayList("project")); assertTrue(validator.isValid(null, null)); assertTrue(validator.isValid(StringUtils.EMPTY, null)); assertTrue(validator.isValid("project2", null)); assertFalse(validator.isValid("project", null)); }