### Question:
Base64Validator implements ConstraintValidator<ValidBase64, String> { @Override public boolean isValid(String value, ConstraintValidatorContext cvc) { if(Objects.isNull(value)) { return true; } if(value.startsWith(NACL_FAILURE_TOKEN)) { return true; } try { Base64.getDecoder().decode(value); return true; } catch (IllegalArgumentException ex) { return false; } }  @Override boolean isValid(String value, ConstraintValidatorContext cvc);  }### Answer:
@Test public void validBase64() { final String value = Base64.getEncoder().encodeToString("HELLOW".getBytes()); assertThat(validator.isValid(value, constraintValidatorContext)).isTrue(); }
@Test public void invalidBase64() { final String value = UUID.randomUUID().toString(); assertThat(validator.isValid(value, constraintValidatorContext)).isFalse(); }
@Test public void nullValueIsIgnoredAndReturns() { assertThat(validator.isValid(null, constraintValidatorContext)).isTrue(); }
@Test public void naclFailureValueIsIgnoredAndReturns() { assertThat(validator.isValid("NACL_FAILURE: It's broken son!!", constraintValidatorContext)).isTrue(); assertThat(validator.isValid("NACL_FAILURE", constraintValidatorContext)).isTrue(); }