@Test public void nonFileTest() { CopyFile copyFile = new CopyFile().relative("blah").setToRelative("src/main/resources"); TOExecutionResult executionResult = copyFile.execution(transformedAppFolder, transformationContext); assertEquals(copyFile.getToRelative(), "src/main/resources"); assertEquals(executionResult.getType(), TOExecutionResult.Type.ERROR); assertEquals(executionResult.getException().getClass(), TransformationOperationException.class); assertEquals(executionResult.getException().getMessage(), "File could not be copied"); assertEquals(executionResult.getException().getCause().getClass(), IOException.class); assertEquals(executionResult.getException().getCause().getMessage(), "/blah (Is a directory)"); assertEquals(copyFile.getDescription(), "Copy file blah to src/main/resources"); assertNull(executionResult.getDetails()); }
@Override protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File fileFrom = getAbsoluteFile(transformedAppFolder, transformationContext); File fileTo = getFileTo(transformedAppFolder, transformationContext); TOExecutionResult result; try { if (fileFrom.isDirectory()) { IOException ex = new IOException(getRelativePath(transformedAppFolder, fileFrom) + " (Is a directory)"); result = TOExecutionResult.error(this, new TransformationOperationException("File could not be copied", ex)); } else { String details = String.format("File '%s' has been copied to '%s'", getRelativePath(), getRelativePath(transformedAppFolder, fileTo)); FileUtils.copyFileToDirectory(fileFrom, fileTo); result = TOExecutionResult.success(this, details); } } catch (IOException e) { result = TOExecutionResult.error(this, new TransformationOperationException("File could not be copied", e)); } return result; }
CopyFile extends AbstractToOperation<CopyFile> { @Override protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File fileFrom = getAbsoluteFile(transformedAppFolder, transformationContext); File fileTo = getFileTo(transformedAppFolder, transformationContext); TOExecutionResult result; try { if (fileFrom.isDirectory()) { IOException ex = new IOException(getRelativePath(transformedAppFolder, fileFrom) + " (Is a directory)"); result = TOExecutionResult.error(this, new TransformationOperationException("File could not be copied", ex)); } else { String details = String.format("File '%s' has been copied to '%s'", getRelativePath(), getRelativePath(transformedAppFolder, fileTo)); FileUtils.copyFileToDirectory(fileFrom, fileTo); result = TOExecutionResult.success(this, details); } } catch (IOException e) { result = TOExecutionResult.error(this, new TransformationOperationException("File could not be copied", e)); } return result; } }
CopyFile extends AbstractToOperation<CopyFile> { @Override protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File fileFrom = getAbsoluteFile(transformedAppFolder, transformationContext); File fileTo = getFileTo(transformedAppFolder, transformationContext); TOExecutionResult result; try { if (fileFrom.isDirectory()) { IOException ex = new IOException(getRelativePath(transformedAppFolder, fileFrom) + " (Is a directory)"); result = TOExecutionResult.error(this, new TransformationOperationException("File could not be copied", ex)); } else { String details = String.format("File '%s' has been copied to '%s'", getRelativePath(), getRelativePath(transformedAppFolder, fileTo)); FileUtils.copyFileToDirectory(fileFrom, fileTo); result = TOExecutionResult.success(this, details); } } catch (IOException e) { result = TOExecutionResult.error(this, new TransformationOperationException("File could not be copied", e)); } return result; } CopyFile(); }
CopyFile extends AbstractToOperation<CopyFile> { @Override protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File fileFrom = getAbsoluteFile(transformedAppFolder, transformationContext); File fileTo = getFileTo(transformedAppFolder, transformationContext); TOExecutionResult result; try { if (fileFrom.isDirectory()) { IOException ex = new IOException(getRelativePath(transformedAppFolder, fileFrom) + " (Is a directory)"); result = TOExecutionResult.error(this, new TransformationOperationException("File could not be copied", ex)); } else { String details = String.format("File '%s' has been copied to '%s'", getRelativePath(), getRelativePath(transformedAppFolder, fileTo)); FileUtils.copyFileToDirectory(fileFrom, fileTo); result = TOExecutionResult.success(this, details); } } catch (IOException e) { result = TOExecutionResult.error(this, new TransformationOperationException("File could not be copied", e)); } return result; } CopyFile();  }
CopyFile extends AbstractToOperation<CopyFile> { @Override protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File fileFrom = getAbsoluteFile(transformedAppFolder, transformationContext); File fileTo = getFileTo(transformedAppFolder, transformationContext); TOExecutionResult result; try { if (fileFrom.isDirectory()) { IOException ex = new IOException(getRelativePath(transformedAppFolder, fileFrom) + " (Is a directory)"); result = TOExecutionResult.error(this, new TransformationOperationException("File could not be copied", ex)); } else { String details = String.format("File '%s' has been copied to '%s'", getRelativePath(), getRelativePath(transformedAppFolder, fileTo)); FileUtils.copyFileToDirectory(fileFrom, fileTo); result = TOExecutionResult.success(this, details); } } catch (IOException e) { result = TOExecutionResult.error(this, new TransformationOperationException("File could not be copied", e)); } return result; } CopyFile();   }