FileValidator implements ConstraintValidator<IsFile, File> { @Override public boolean isValid(File value, ConstraintValidatorContext context) { if (value != null && value.exists()) { return value.isFile(); } return true; }  @Override void initialize(IsFile 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.isFile()).thenReturn(Boolean.FALSE); assertFalse(victim.isValid(mockFile, null)); }