ExistingFileValidator implements ConstraintValidator<ExistingFile, File> { @Override public boolean isValid(File value, ConstraintValidatorContext context) { if (value != null) { return value.exists(); } return true; }  @Override void initialize(ExistingFile constraintAnnotation); @Override boolean isValid(File value, ConstraintValidatorContext context);  }
@Test public void testNull() { assertTrue(victim.isValid(null, null)); }
@Test public void testPositive() { assertTrue(victim.isValid(mockFile, null)); }
@Test public void testNegative() { when(mockFile.exists()).thenReturn(Boolean.FALSE); assertFalse(victim.isValid(mockFile, null)); }