@Override public void dispatch(FileTaskOutput output) { onFile(params, output.getDestination()); }
public FileOutputAdapter(String path) { this.fileOutput = new FileTaskOutput(Paths.get(path).toAbsolutePath().normalize().toFile()); }
@Test(expected = TaskOutputVisitException.class) public void failOnFile() throws TaskOutputVisitException { DefaultMultipleOutputWriter victim = new DefaultMultipleOutputWriter(ExistingOutputPolicy.OVERWRITE, context); new FileTaskOutput(mock(File.class)).accept(victim); }
@Override public void dispatch(FileTaskOutput output) { destination = output.getDestination(); setGraphic(FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.FILE_PDF_ALT, "1.6em")); }
@Test public void testEquals() { File diffFile = mock(File.class); when(diffFile.isFile()).thenReturn(Boolean.TRUE); FileTaskOutput eq1 = new FileTaskOutput(file); FileTaskOutput eq2 = new FileTaskOutput(file); FileTaskOutput eq3 = new FileTaskOutput(file); FileTaskOutput diff = new FileTaskOutput(diffFile); TestUtils.testEqualsAndHashCodes(eq1, eq2, eq3, diff); } }
@Override public void dispatch(FileTaskOutput output) { Path dest = output.getDestination().toPath().getParent(); if (Files.exists(dest)) { bufferLocation = dest; } }
@Test(expected = IllegalArgumentException.class) public void testInvalidFile() { when(file.isFile()).thenReturn(Boolean.FALSE); new FileTaskOutput(file); }
@Override public void dispatch(FileTaskOutput output) { Path dest = output.getDestination().toPath().getParent(); if (Files.exists(dest)) { bufferLocation = dest; } }
/** * Initialize the given params with a {@link FileTaskOutput} * * @param params * @return */ public TaskTestContext pdfOutputTo(SingleOutputTaskParameters params) throws IOException { this.fileOutput = File.createTempFile("SejdaTest", ".pdf"); this.fileOutput.deleteOnExit(); params.setOutput(new FileTaskOutput(fileOutput)); return this; }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof FileTaskOutput)) { return false; } FileTaskOutput output = (FileTaskOutput) other; return new EqualsBuilder().append(file, output.getDestination()).isEquals(); }
@Test(expected = IllegalArgumentException.class) public void testNullFile() { new FileTaskOutput(null); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof FileTaskOutput)) { return false; } FileTaskOutput output = (FileTaskOutput) other; return new EqualsBuilder().append(file, output.getDestination()).isEquals(); }
/** * Initialize the given params with a {@link FileTaskOutput} on a file with the given extension * * @param params * @param extension * @return * @throws IOException */ public TaskTestContext fileOutputTo(SingleOutputTaskParameters params, String extension) throws IOException { this.fileOutput = File.createTempFile("SejdaTest", extension); this.fileOutput.deleteOnExit(); params.setOutput(new FileTaskOutput(fileOutput)); return this; }
@Override public String toString() { return new ToStringBuilder(this).append(getDestination()).toString(); }
@Test public void testValidFile_doesntExist() { when(file.isFile()).thenReturn(Boolean.FALSE); when(file.exists()).thenReturn(Boolean.FALSE); FileTaskOutput instance = new FileTaskOutput(file); assertNotNull(instance); }
@Override public String toString() { return new ToStringBuilder(this).append(getDestination()).toString(); }
@Test public void testValidFile_exists() { FileTaskOutput instance = new FileTaskOutput(file); assertNotNull(instance); }
@Override public int hashCode() { return new HashCodeBuilder().append(getDestination()).toHashCode(); }
@Before public void setUp() throws TaskException { System.setProperty(Sejda.USER_CONFIG_FILE_PROPERTY_NAME, "sejda-test.xml"); parameters.setOutput(new FileTaskOutput(IOUtils.createTemporaryBuffer())); when(context.getTask(Matchers.any(TaskParameters.class))).thenReturn(task); when(context.isValidation()).thenReturn(Boolean.TRUE); }
@Override public int hashCode() { return new HashCodeBuilder().append(getDestination()).toHashCode(); }