@Test public void checkPOMSaveInvalidatesPomModelCache() { final ProjectScreenModel model = new ProjectScreenModel(); final Metadata pomMetaData = new Metadata(); final POM pom = new POM(); model.setPOM(pom); model.setPOMMetaData(pomMetaData); KieModule module = mock(KieModule.class); when(moduleService.resolveModule(pathToPom)).thenReturn(module); saver.save(pathToPom, model, DeploymentMode.FORCED, "message"); verify(pomModelCache).invalidateCache(module); }
public void save(final Path pathToPomXML, final ProjectScreenModel model, final DeploymentMode mode, final String comment) { if (DeploymentMode.VALIDATED.equals(mode)) { checkRepositories(pathToPomXML, model); } try { final KieModule module = moduleService.resolveModule(pathToPomXML); pomModelCache.invalidateCache(module); ioService.startBatch(Paths.convert(pathToPomXML).getFileSystem(), commentedOptionFactory.makeCommentedOption(comment)); pomService.save(pathToPomXML, model.getPOM(), model.getPOMMetaData(), comment); kModuleService.save(model.getPathToKModule(), model.getKModule(), model.getKModuleMetaData(), comment); importsService.save(model.getPathToImports(), model.getProjectImports(), model.getProjectImportsMetaData(), comment); repositoriesService.save(model.getPathToRepositories(), model.getRepositories(), comment); whiteListService.save(model.getPathToWhiteList(), model.getWhiteList(), model.getWhiteListMetaData(), comment); } catch (final Exception e) { throw new RuntimeException(e); } finally { ioService.endBatch(); } }
ProjectScreenModelSaver { public void save(final Path pathToPomXML, final ProjectScreenModel model, final DeploymentMode mode, final String comment) { if (DeploymentMode.VALIDATED.equals(mode)) { checkRepositories(pathToPomXML, model); } try { final KieModule module = moduleService.resolveModule(pathToPomXML); pomModelCache.invalidateCache(module); ioService.startBatch(Paths.convert(pathToPomXML).getFileSystem(), commentedOptionFactory.makeCommentedOption(comment)); pomService.save(pathToPomXML, model.getPOM(), model.getPOMMetaData(), comment); kModuleService.save(model.getPathToKModule(), model.getKModule(), model.getKModuleMetaData(), comment); importsService.save(model.getPathToImports(), model.getProjectImports(), model.getProjectImportsMetaData(), comment); repositoriesService.save(model.getPathToRepositories(), model.getRepositories(), comment); whiteListService.save(model.getPathToWhiteList(), model.getWhiteList(), model.getWhiteListMetaData(), comment); } catch (final Exception e) { throw new RuntimeException(e); } finally { ioService.endBatch(); } } }
ProjectScreenModelSaver { public void save(final Path pathToPomXML, final ProjectScreenModel model, final DeploymentMode mode, final String comment) { if (DeploymentMode.VALIDATED.equals(mode)) { checkRepositories(pathToPomXML, model); } try { final KieModule module = moduleService.resolveModule(pathToPomXML); pomModelCache.invalidateCache(module); ioService.startBatch(Paths.convert(pathToPomXML).getFileSystem(), commentedOptionFactory.makeCommentedOption(comment)); pomService.save(pathToPomXML, model.getPOM(), model.getPOMMetaData(), comment); kModuleService.save(model.getPathToKModule(), model.getKModule(), model.getKModuleMetaData(), comment); importsService.save(model.getPathToImports(), model.getProjectImports(), model.getProjectImportsMetaData(), comment); repositoriesService.save(model.getPathToRepositories(), model.getRepositories(), comment); whiteListService.save(model.getPathToWhiteList(), model.getWhiteList(), model.getWhiteListMetaData(), comment); } catch (final Exception e) { throw new RuntimeException(e); } finally { ioService.endBatch(); } } ProjectScreenModelSaver(); @Inject  ProjectScreenModelSaver(final POMService pomService,
                                   final KModuleService kModuleService,
                                   final ProjectImportsService importsService,
                                   final ModuleRepositoriesService repositoriesService,
                                   final PackageNameWhiteListService whiteListService,
                                   final @Named("ioStrategy") IOService ioService,
                                   final KieModuleService moduleService,
                                   final ModuleRepositoryResolver repositoryResolver,
                                   final CommentedOptionFactory commentedOptionFactory,
                                   final LRUPomModelCache pomModelCache); }
ProjectScreenModelSaver { public void save(final Path pathToPomXML, final ProjectScreenModel model, final DeploymentMode mode, final String comment) { if (DeploymentMode.VALIDATED.equals(mode)) { checkRepositories(pathToPomXML, model); } try { final KieModule module = moduleService.resolveModule(pathToPomXML); pomModelCache.invalidateCache(module); ioService.startBatch(Paths.convert(pathToPomXML).getFileSystem(), commentedOptionFactory.makeCommentedOption(comment)); pomService.save(pathToPomXML, model.getPOM(), model.getPOMMetaData(), comment); kModuleService.save(model.getPathToKModule(), model.getKModule(), model.getKModuleMetaData(), comment); importsService.save(model.getPathToImports(), model.getProjectImports(), model.getProjectImportsMetaData(), comment); repositoriesService.save(model.getPathToRepositories(), model.getRepositories(), comment); whiteListService.save(model.getPathToWhiteList(), model.getWhiteList(), model.getWhiteListMetaData(), comment); } catch (final Exception e) { throw new RuntimeException(e); } finally { ioService.endBatch(); } } ProjectScreenModelSaver(); @Inject  ProjectScreenModelSaver(final POMService pomService,
                                   final KModuleService kModuleService,
                                   final ProjectImportsService importsService,
                                   final ModuleRepositoriesService repositoriesService,
                                   final PackageNameWhiteListService whiteListService,
                                   final @Named("ioStrategy") IOService ioService,
                                   final KieModuleService moduleService,
                                   final ModuleRepositoryResolver repositoryResolver,
                                   final CommentedOptionFactory commentedOptionFactory,
                                   final LRUPomModelCache pomModelCache); void save(final Path pathToPomXML,
                     final ProjectScreenModel model,
                     final DeploymentMode mode,
                     final String comment); }
ProjectScreenModelSaver { public void save(final Path pathToPomXML, final ProjectScreenModel model, final DeploymentMode mode, final String comment) { if (DeploymentMode.VALIDATED.equals(mode)) { checkRepositories(pathToPomXML, model); } try { final KieModule module = moduleService.resolveModule(pathToPomXML); pomModelCache.invalidateCache(module); ioService.startBatch(Paths.convert(pathToPomXML).getFileSystem(), commentedOptionFactory.makeCommentedOption(comment)); pomService.save(pathToPomXML, model.getPOM(), model.getPOMMetaData(), comment); kModuleService.save(model.getPathToKModule(), model.getKModule(), model.getKModuleMetaData(), comment); importsService.save(model.getPathToImports(), model.getProjectImports(), model.getProjectImportsMetaData(), comment); repositoriesService.save(model.getPathToRepositories(), model.getRepositories(), comment); whiteListService.save(model.getPathToWhiteList(), model.getWhiteList(), model.getWhiteListMetaData(), comment); } catch (final Exception e) { throw new RuntimeException(e); } finally { ioService.endBatch(); } } ProjectScreenModelSaver(); @Inject  ProjectScreenModelSaver(final POMService pomService,
                                   final KModuleService kModuleService,
                                   final ProjectImportsService importsService,
                                   final ModuleRepositoriesService repositoriesService,
                                   final PackageNameWhiteListService whiteListService,
                                   final @Named("ioStrategy") IOService ioService,
                                   final KieModuleService moduleService,
                                   final ModuleRepositoryResolver repositoryResolver,
                                   final CommentedOptionFactory commentedOptionFactory,
                                   final LRUPomModelCache pomModelCache); void save(final Path pathToPomXML,
                     final ProjectScreenModel model,
                     final DeploymentMode mode,
                     final String comment);  }