UniqueCleanupPolicyNameValidator extends ConstraintValidatorSupport<UniqueCleanupPolicyName, String> { @Override public boolean isValid(final String value, final ConstraintValidatorContext context) { return !cleanupPolicyStorage.exists(value); } @Inject  UniqueCleanupPolicyNameValidator(final CleanupPolicyStorage cleanupPolicyStorage); @Override boolean isValid(final String value, final ConstraintValidatorContext context);  }
@Test public void isValidByCleanupPolicyName() { when(cleanupPolicyStorage.exists(TEST_NAME)).thenReturn(false); assertThat(underTest.isValid(TEST_NAME, null), is(true)); }
@Test public void isInvalidByCleanupPolicyName() { when(cleanupPolicyStorage.exists(TEST_NAME)).thenReturn(true); assertThat(underTest.isValid(TEST_NAME, null), is(false)); }