DirectoryValidator implements ConstraintValidator<Directory, File> { @Override public boolean isValid(File value, ConstraintValidatorContext context) { if (value != null && value.exists()) { return value.isDirectory(); } return true; }  @Override void initialize(Directory constraintAnnotation); @Override boolean isValid(File value, ConstraintValidatorContext context);  }
@Test public void testNull() { assertTrue(victim.isValid(null, null)); }
@Test public void testPositiveExisting() throws IOException { assertTrue(victim.isValid(folder.newFolder(), null)); }
@Test public void testPositiveNonExisting() { assertTrue(victim.isValid(new File("I will be created"), null)); }
@Test public void testNegative() throws IOException { assertFalse(victim.isValid(folder.newFile(), null)); }