### Question:
ModuleSaver { public KieModule save(final Path repositoryRoot, final POM pom) { try { ioService.startBatch(Paths.convert(repositoryRoot).getFileSystem(), commentedOptionFactory.makeCommentedOption("New module [" + pom.getName() + "]")); KieModule kieModule = createNewModuleCreator(repositoryRoot, pom).create(); newModuleEvent.fire(new NewModuleEvent(kieModule, safeSessionInfo.getId(), safeSessionInfo.getIdentity().getIdentifier())); return kieModule; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } finally { ioService.endBatch(); } } ModuleSaver(); @Inject  ModuleSaver(final @Named("ioStrategy") IOService ioService,
                       final POMService pomService,
                       final KModuleService kModuleService,
                       final Event<NewModuleEvent> newModuleEvent,
                       final Event<NewPackageEvent> newPackageEvent,
                       final KieResourceResolver resourceResolver,
                       final ProjectImportsService projectImportsService,
                       final ModuleRepositoriesService moduleRepositoriesService,
                       final PackageNameWhiteListService packageNameWhiteListService,
                       final CommentedOptionFactory commentedOptionFactory,
                       final SessionInfo sessionInfo); KieModule save(final Path repositoryRoot,
                          final POM pom); NewModuleCreator createNewModuleCreator(final Path repositoryRoot, final POM pom);  }### Answer:
@Test public void testDuplicatedChildInManagedRepositoryPrevention() throws URISyntaxException, IOException { final POM parentPom = mock(POM.class); final POM newPOM = mock(POM.class); final Repository repository = mock(Repository.class); final File test = File.createTempFile("test", Long.toString(System.nanoTime())); final Path repositoryRootPath = paths.convert(fs.getPath(test.toURI())); FileAlreadyExistsException fileExistsException = null; when(repository.getDefaultBranch()).thenReturn(Optional.of(new Branch("master", repositoryRootPath))); when(newPOM.getName()).thenReturn("existingModule"); final org.uberfire.java.nio.file.Path parentPomNioPath = paths.convert(repositoryRootPath).resolve("pom.xml"); final Path parentPomVFSPath = paths.convert(parentPomNioPath); final org.uberfire.java.nio.file.Path moduleNioPath = paths.convert(repositoryRootPath).resolve("existingModule").resolve("pom.xml"); when(pomService.load(parentPomVFSPath)).thenReturn(parentPom); when(ioService.exists(any())).thenReturn(true); try { saver.save(Paths.convert(moduleNioPath), newPOM); } catch (FileAlreadyExistsException e) { fileExistsException = e; } assertNotNull(fileExistsException); verify(pomService, never()).save(eq(parentPomVFSPath), any(POM.class), any(Metadata.class), any(String.class)); }