PomAddModule extends AbstractPomOperation<PomAddModule> implements AddElement<PomAddModule> { @Override public PomAddModule warnButAddIfPresent() { ifPresent = IfPresent.WarnButAdd; return this; } PomAddModule();  PomAddModule(String moduleName); @Override PomAddModule failIfPresent(); @Override PomAddModule warnNotAddIfPresent(); @Override PomAddModule warnButAddIfPresent(); @Override PomAddModule noOpIfPresent(); @Override PomAddModule overwriteIfPresent(); PomAddModule setModuleName(String moduleName); String getModuleName(); @Override String getDescription(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void moduleAlreadyPresentOverwriteWarnTest() throws IOException, SAXException, ParserConfigurationException, XmlPullParserException { PomAddModule pomAddModule = new PomAddModule("module1").relative("pom.xml").warnButAddIfPresent(); TOExecutionResult executionResult = pomAddModule.execution(transformedAppFolder, transformationContext); 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 module1 was already present in POM file pom.xml"); Model pomModelAfterChange = getTransformedPomModel("pom.xml"); assertEquals(pomModelAfterChange.getModules().size(), 1); assertTrue(pomModelAfterChange.getModules().contains("module1")); }