### Question:
KeyConfigurationValidator implements ConstraintValidator<ValidKeyConfiguration, KeyConfiguration> { @Override public boolean isValid(KeyConfiguration keyConfiguration, ConstraintValidatorContext cvc) { return keyConfiguration==null || !(keyConfiguration.getPasswordFile()!=null && keyConfiguration.getPasswords()!=null); }  @Override boolean isValid(KeyConfiguration keyConfiguration, ConstraintValidatorContext cvc);  }### Answer:
@Test public void bothNotSetIsValid() { final KeyConfiguration configuration = new KeyConfiguration(null, null, null, null, null); assertThat(validator.isValid(configuration, mock(ConstraintValidatorContext.class))).isTrue(); }
@Test public void fileSetIsValid() { final KeyConfiguration configuration = new KeyConfiguration(Paths.get("anything"), null, null, null, null); assertThat(validator.isValid(configuration, mock(ConstraintValidatorContext.class))).isTrue(); }
@Test public void inlineSetIsValid() { final KeyConfiguration configuration = new KeyConfiguration(null, emptyList(), null, null, null); assertThat(validator.isValid(configuration, mock(ConstraintValidatorContext.class))).isTrue(); }
@Test public void bothSetIsInvalid() { final KeyConfiguration configuration = new KeyConfiguration(Paths.get("anything"), emptyList(), null, null, null); assertThat(validator.isValid(configuration, mock(ConstraintValidatorContext.class))).isFalse(); }
@Test public void nullConfigIsValid() { assertThat(validator.isValid(null, mock(ConstraintValidatorContext.class))).isTrue(); }