MavenPluginUpdater { public List<Plugin> update(final List<org.guvnor.common.services.project.model.Plugin> from) { List<Plugin> result = new ArrayList<>(); for (org.guvnor.common.services.project.model.Plugin plugin : from) { if (plugin.getArtifactId() != null && plugin.getGroupId() != null) { result.add(update(plugin, findPlugin(plugin.getGroupId(), plugin.getArtifactId()))); } } return result; } MavenPluginUpdater(List<Plugin> pluginsDeclaredInPOM); List<Plugin> update(final List<org.guvnor.common.services.project.model.Plugin> from);  }
@Test public void testIgnorePluginsThatHaveNoGroupIdOrArtifactId() throws Exception { List<Plugin> to = new ArrayList<Plugin>(); ArrayList<org.guvnor.common.services.project.model.Plugin> from = new ArrayList<org.guvnor.common.services.project.model.Plugin>(); from.add(makeGuvnorPlugin(null, null, null)); from.add(makeGuvnorPlugin(null, null, "1.0")); from.add(makeGuvnorPlugin("myGroup", null, "1.0")); from.add(makeGuvnorPlugin(null, "myArtifact", "1.0")); to = new MavenPluginUpdater(to).update(from); assertTrue(to.isEmpty()); }
@Test public void testChangeVersion() throws Exception { List<Plugin> to = new ArrayList<Plugin>(); to.add(makeMavenPlugin("myPlugin", "myArtifact", "1.0")); ArrayList<org.guvnor.common.services.project.model.Plugin> from = new ArrayList<org.guvnor.common.services.project.model.Plugin>(); from.add(makeGuvnorPlugin("myPlugin", "myArtifact", "2.0")); to = new MavenPluginUpdater(to).update(from); assertEquals(1, to.size()); assertEquals("2.0", to.get(0).getVersion()); }
@Test public void testAddNew() throws Exception { List<Plugin> to = new ArrayList<Plugin>(); to.add(makeMavenPlugin("myPlugin", "myArtifact", "1.0")); ArrayList<org.guvnor.common.services.project.model.Plugin> from = new ArrayList<org.guvnor.common.services.project.model.Plugin>(); from.add(makeGuvnorPlugin("myPlugin", "myArtifact", "1.0")); from.add(makeGuvnorPlugin("junit", "junit", "1.44")); to = new MavenPluginUpdater(to).update(from); assertEquals(2, to.size()); assertEquals("1.0", to.get(0).getVersion()); assertEquals("1.44", to.get(1).getVersion()); }
@Test public void testRemove() throws Exception { List<Plugin> to = new ArrayList<Plugin>(); to.add(makeMavenPlugin("myPlugin", "myArtifact", "1.0")); to.add(makeMavenPlugin("junit", "junit", "1.44")); ArrayList<org.guvnor.common.services.project.model.Plugin> from = new ArrayList<org.guvnor.common.services.project.model.Plugin>(); from.add(makeGuvnorPlugin("myPlugin", "myArtifact", "1.0")); to = new MavenPluginUpdater(to).update(from); assertEquals(1, to.size()); assertEquals("1.0", to.get(0).getVersion()); }