FileOrDirectoryTaskOutput extends AbstractTaskOutput implements SingleOrMultipleTaskOutput { public static FileOrDirectoryTaskOutput file(File file) { if (file == null || (file.exists() && !file.isFile())) { throw new IllegalArgumentException("A valid instance is expected (not null or existing file)."); } return new FileOrDirectoryTaskOutput(file); } FileOrDirectoryTaskOutput(File file); @Override File getDestination(); @Override void accept(TaskOutputDispatcher writer); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object other); static FileOrDirectoryTaskOutput file(File file); static FileOrDirectoryTaskOutput directory(File directory);  }
@Test(expected = IllegalArgumentException.class) public void fileFactoryNullFile() { FileOrDirectoryTaskOutput.file(null); }
@Test(expected = IllegalArgumentException.class) public void fileFactoryInvalidFile() { when(file.isFile()).thenReturn(Boolean.FALSE); FileOrDirectoryTaskOutput.file(file); }
@Test public void fileFactoryValidFile_doesntExist() { when(file.isFile()).thenReturn(Boolean.FALSE); when(file.exists()).thenReturn(Boolean.FALSE); FileOrDirectoryTaskOutput instance = FileOrDirectoryTaskOutput.file(file); assertNotNull(instance); }