@Test public void successAddTest() throws IOException { AddLine addLine = new AddLine("zoo=zoov").relative("/src/main/resources/application.properties"); TOExecutionResult executionResult = addLine.execution(transformedAppFolder, transformationContext); Assert.assertEquals(executionResult.getType(), TOExecutionResult.Type.SUCCESS); assertChangedFile("/src/main/resources/application.properties"); assertLineCount("/src/main/resources/application.properties", 1); Properties properties = getProperties("/src/main/resources/application.properties"); Assert.assertEquals(properties.size(), 4); Assert.assertEquals(properties.getProperty("bar"), "barv"); Assert.assertEquals(properties.getProperty("foo"), "foov"); Assert.assertEquals(properties.getProperty("foofoo"), "foofoov"); Assert.assertEquals(properties.getProperty("zoo"), "zoov"); }
@Override protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File fileToBeModified = getAbsoluteFile(transformedAppFolder, transformationContext); if (!fileToBeModified.exists()) { FileNotFoundException ex = new FileNotFoundException("File to be modified has not been found"); return TOExecutionResult.error(this, ex); } TOExecutionResult result = null; try { FileUtils.fileAppend(fileToBeModified.getAbsolutePath(), EolHelper.findEolDefaultToOs(fileToBeModified)); FileUtils.fileAppend(fileToBeModified.getAbsolutePath(), newLine); String details = "A new line has been added to file " + getRelativePath(transformedAppFolder, fileToBeModified); result = TOExecutionResult.success(this, details); } catch (IOException e) { result = TOExecutionResult.error(this, e); } return result; }
AddLine extends TransformationOperation<AddLine> { @Override protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File fileToBeModified = getAbsoluteFile(transformedAppFolder, transformationContext); if (!fileToBeModified.exists()) { FileNotFoundException ex = new FileNotFoundException("File to be modified has not been found"); return TOExecutionResult.error(this, ex); } TOExecutionResult result = null; try { FileUtils.fileAppend(fileToBeModified.getAbsolutePath(), EolHelper.findEolDefaultToOs(fileToBeModified)); FileUtils.fileAppend(fileToBeModified.getAbsolutePath(), newLine); String details = "A new line has been added to file " + getRelativePath(transformedAppFolder, fileToBeModified); result = TOExecutionResult.success(this, details); } catch (IOException e) { result = TOExecutionResult.error(this, e); } return result; } }
AddLine extends TransformationOperation<AddLine> { @Override protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File fileToBeModified = getAbsoluteFile(transformedAppFolder, transformationContext); if (!fileToBeModified.exists()) { FileNotFoundException ex = new FileNotFoundException("File to be modified has not been found"); return TOExecutionResult.error(this, ex); } TOExecutionResult result = null; try { FileUtils.fileAppend(fileToBeModified.getAbsolutePath(), EolHelper.findEolDefaultToOs(fileToBeModified)); FileUtils.fileAppend(fileToBeModified.getAbsolutePath(), newLine); String details = "A new line has been added to file " + getRelativePath(transformedAppFolder, fileToBeModified); result = TOExecutionResult.success(this, details); } catch (IOException e) { result = TOExecutionResult.error(this, e); } return result; } AddLine();  AddLine(String newLine); }
AddLine extends TransformationOperation<AddLine> { @Override protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File fileToBeModified = getAbsoluteFile(transformedAppFolder, transformationContext); if (!fileToBeModified.exists()) { FileNotFoundException ex = new FileNotFoundException("File to be modified has not been found"); return TOExecutionResult.error(this, ex); } TOExecutionResult result = null; try { FileUtils.fileAppend(fileToBeModified.getAbsolutePath(), EolHelper.findEolDefaultToOs(fileToBeModified)); FileUtils.fileAppend(fileToBeModified.getAbsolutePath(), newLine); String details = "A new line has been added to file " + getRelativePath(transformedAppFolder, fileToBeModified); result = TOExecutionResult.success(this, details); } catch (IOException e) { result = TOExecutionResult.error(this, e); } return result; } AddLine();  AddLine(String newLine); AddLine setNewLine(String newLine); String getNewLine(); @Override String getDescription(); }
AddLine extends TransformationOperation<AddLine> { @Override protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File fileToBeModified = getAbsoluteFile(transformedAppFolder, transformationContext); if (!fileToBeModified.exists()) { FileNotFoundException ex = new FileNotFoundException("File to be modified has not been found"); return TOExecutionResult.error(this, ex); } TOExecutionResult result = null; try { FileUtils.fileAppend(fileToBeModified.getAbsolutePath(), EolHelper.findEolDefaultToOs(fileToBeModified)); FileUtils.fileAppend(fileToBeModified.getAbsolutePath(), newLine); String details = "A new line has been added to file " + getRelativePath(transformedAppFolder, fileToBeModified); result = TOExecutionResult.success(this, details); } catch (IOException e) { result = TOExecutionResult.error(this, e); } return result; } AddLine();  AddLine(String newLine); AddLine setNewLine(String newLine); String getNewLine(); @Override String getDescription();  }