PomStructureEditor { public void onNewDynamicDependency(final @Observes AddPomDependencyEvent event) { final Path projectPath = event.getProjectPath(); final DependencyType dependencyType = event.getDependencyType(); addDependenciesToPom(projectPath, mapper.getDependencies(dependencyType)); } PomStructureEditor(); void onNewDynamicDependency(final @Observes AddPomDependencyEvent event);  }
@Test public void onNEwDynamicDependencyEventTest() throws Exception { MavenXpp3Reader reader = new MavenXpp3Reader(); Model model = reader.read(new ByteArrayInputStream(Files.readAllBytes(Paths.get(tmp.toAbsolutePath().toString() + fileSeparator + POM)))); assertThat(model.getDependencies()).hasSize(0); editor = new PomStructureEditor(); AddPomDependencyEvent event = new AddPomDependencyEvent(DependencyType.JPA, PathFactory.newPath(tmp.getFileName().toString(), tmp.toUri().toString() + fileSeparator + POM)); editor.onNewDynamicDependency(event); model = reader.read(new ByteArrayInputStream(Files.readAllBytes(Paths.get(tmp.toAbsolutePath().toString() + fileSeparator + POM)))); assertThat(model.getDependencies()).hasSize(1); Dependency dep = model.getDependencies().get(0); assertThat(dep.getGroupId()).containsOnlyOnce("javax.persistence"); assertThat(dep.getArtifactId()).containsOnlyOnce("javax.persistence-api"); assertThat(dep.getVersion()).containsOnlyOnce("2.2"); }