PomRemoveModule extends AbstractPomOperation<PomRemoveModule> implements ChangeOrRemoveElement<PomRemoveModule> { @Override public PomRemoveModule warnIfNotPresent() { ifNotPresent = IfNotPresent.Warn; return this; } PomRemoveModule();  PomRemoveModule(String moduleName); PomRemoveModule setModuleName(String moduleName); @Override PomRemoveModule failIfNotPresent(); @Override PomRemoveModule warnIfNotPresent(); @Override PomRemoveModule noOpIfNotPresent(); String getModuleName(); @Override String getDescription();  }
@Test public void moduleNotPresentWarnTest() throws IOException, SAXException, ParserConfigurationException { PomRemoveModule pomRemoveModule = new PomRemoveModule("zoo").relative("pom.xml").warnIfNotPresent(); TOExecutionResult executionResult = pomRemoveModule.execution(transformedAppFolder, transformationContext); assertEqualsXml("pom.xml"); assertEquals(executionResult.getType(), TOExecutionResult.Type.WARNING); assertNull(executionResult.getException()); assertNotNull(executionResult.getWarnings()); assertEquals(executionResult.getWarnings().size(), 1); assertEquals(executionResult.getWarnings().get(0).getClass(), TransformationOperationException.class); assertEquals(executionResult.getWarnings().get(0).getMessage(), "Module zoo has not been removed from POM file /pom.xml because it is not present"); }
@Test public void fileDoesNotExistTest() { PomRemoveModule pomRemoveModule = new PomRemoveModule("zoo").relative("non_existent_file.xml").warnIfNotPresent(); TOExecutionResult executionResult = pomRemoveModule.execution(transformedAppFolder, transformationContext); assertEquals(executionResult.getType(), TOExecutionResult.Type.ERROR); assertEquals(executionResult.getException().getClass(), TransformationOperationException.class); assertEquals(executionResult.getException().getMessage(), "POM file could not be modified"); assertEquals(executionResult.getException().getCause().getClass(), FileNotFoundException.class); assertEquals(executionResult.getException().getCause().getMessage(), new File(transformedAppFolder, "non_existent_file.xml").getAbsolutePath() + " (No such file or directory)"); }