BuildContentHandler { public Build update(final org.guvnor.common.services.project.model.Build from, Build to) { if (from == null) { return null; } else { if (to == null) { to = new Build(); } if (from.getPlugins() != null) { to.setPlugins(new MavenPluginUpdater(to.getPlugins()).update(from.getPlugins())); } return to; } }  Build update(final org.guvnor.common.services.project.model.Build from,
                        Build to);  }
@Test public void testBuildPluginUpdateExisting() throws Exception { org.guvnor.common.services.project.model.Build from = new org.guvnor.common.services.project.model.Build(); from.getPlugins().add(makeGuvnorPlugin("myGroup", "myArtifact", "1.0")); Build to = new Build(); Plugin toPlugin = makeMavenPlugin("myGroup", "myArtifact", "0.11.11.12"); to.getPlugins().add(toPlugin); toPlugin.setGoals("someGoal"); to.setSourceDirectory("someDirectory"); to = new BuildContentHandler().update(from, to); assertEquals(1, to.getPlugins().size()); assertEquals("1.0", to.getPlugins().get(0).getVersion()); assertEquals("someGoal", to.getPlugins().get(0).getGoals()); assertEquals("someDirectory", to.getSourceDirectory()); }
@Test public void testBuildPluginDeletePlugin() throws Exception { org.guvnor.common.services.project.model.Build from = new org.guvnor.common.services.project.model.Build(); from.getPlugins().add(makeGuvnorPlugin("myGroup", "myArtifact", "1.0")); Build to = new Build(); to.getPlugins().add(makeMavenPlugin("myGroup", "myArtifact", "1.0")); to.getPlugins().add(makeMavenPlugin("junit", "junit", "1.44")); to = new BuildContentHandler().update(from, to); assertEquals(1, to.getPlugins().size()); assertEquals("1.0", to.getPlugins().get(0).getVersion()); }