@Test public void nonExistentFromFolderTest() { CopyDirectory copyDirectory = new CopyDirectory().relative("nonExistentFolder").setToRelative("src/main/resources"); TOExecutionResult executionResult = copyDirectory.execution(transformedAppFolder, transformationContext); assertEquals(copyDirectory.getToRelative(), "src/main/resources"); assertEquals(executionResult.getType(), TOExecutionResult.Type.ERROR); assertEquals(executionResult.getException().getClass(), TransformationOperationException.class); assertEquals(executionResult.getException().getMessage(), "Directory could not be copied"); assertEquals(executionResult.getException().getCause().getMessage(), "Source '" + new File(transformedAppFolder, "nonExistentFolder").getAbsolutePath() + "' does not exist"); assertEquals(copyDirectory.getDescription(), "Copy directory content from nonExistentFolder to src/main/resources"); assertNull(executionResult.getDetails()); }
@Override protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File filesFrom = getAbsoluteFile(transformedAppFolder, transformationContext); File fileTo = getFileTo(transformedAppFolder, transformationContext); TOExecutionResult result = null; try { FileUtils.copyDirectory(filesFrom, fileTo); String details = String.format("Files from '%s' have been copied to '%s'", getRelativePath(transformedAppFolder, filesFrom), getRelativePath(transformedAppFolder, fileTo)); result = TOExecutionResult.success(this, details); } catch (IOException e) { result = TOExecutionResult.error(this, new TransformationOperationException("Directory could not be copied", e)); } return result; }
CopyDirectory extends AbstractToOperation<CopyDirectory> { @Override protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File filesFrom = getAbsoluteFile(transformedAppFolder, transformationContext); File fileTo = getFileTo(transformedAppFolder, transformationContext); TOExecutionResult result = null; try { FileUtils.copyDirectory(filesFrom, fileTo); String details = String.format("Files from '%s' have been copied to '%s'", getRelativePath(transformedAppFolder, filesFrom), getRelativePath(transformedAppFolder, fileTo)); result = TOExecutionResult.success(this, details); } catch (IOException e) { result = TOExecutionResult.error(this, new TransformationOperationException("Directory could not be copied", e)); } return result; } }
CopyDirectory extends AbstractToOperation<CopyDirectory> { @Override protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File filesFrom = getAbsoluteFile(transformedAppFolder, transformationContext); File fileTo = getFileTo(transformedAppFolder, transformationContext); TOExecutionResult result = null; try { FileUtils.copyDirectory(filesFrom, fileTo); String details = String.format("Files from '%s' have been copied to '%s'", getRelativePath(transformedAppFolder, filesFrom), getRelativePath(transformedAppFolder, fileTo)); result = TOExecutionResult.success(this, details); } catch (IOException e) { result = TOExecutionResult.error(this, new TransformationOperationException("Directory could not be copied", e)); } return result; } CopyDirectory(); }
CopyDirectory extends AbstractToOperation<CopyDirectory> { @Override protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File filesFrom = getAbsoluteFile(transformedAppFolder, transformationContext); File fileTo = getFileTo(transformedAppFolder, transformationContext); TOExecutionResult result = null; try { FileUtils.copyDirectory(filesFrom, fileTo); String details = String.format("Files from '%s' have been copied to '%s'", getRelativePath(transformedAppFolder, filesFrom), getRelativePath(transformedAppFolder, fileTo)); result = TOExecutionResult.success(this, details); } catch (IOException e) { result = TOExecutionResult.error(this, new TransformationOperationException("Directory could not be copied", e)); } return result; } CopyDirectory();  }
CopyDirectory extends AbstractToOperation<CopyDirectory> { @Override protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File filesFrom = getAbsoluteFile(transformedAppFolder, transformationContext); File fileTo = getFileTo(transformedAppFolder, transformationContext); TOExecutionResult result = null; try { FileUtils.copyDirectory(filesFrom, fileTo); String details = String.format("Files from '%s' have been copied to '%s'", getRelativePath(transformedAppFolder, filesFrom), getRelativePath(transformedAppFolder, fileTo)); result = TOExecutionResult.success(this, details); } catch (IOException e) { result = TOExecutionResult.error(this, new TransformationOperationException("Directory could not be copied", e)); } return result; } CopyDirectory();   }