DependencyUpdater { void updateDependencies(final List<Dependency> dependencies) { removeAllThatDoNotExist(dependencies); addTheOnesThatDoNotExist(dependencies); updateTheRest(dependencies); } DependencyUpdater(final List<org.apache.maven.model.Dependency> dependencies);   }
@Test public void testEmptyDependency() throws Exception { Model model = new Model(); ArrayList<Dependency> dependencies = new ArrayList<Dependency>(); dependencies.add(new Dependency()); assertTrue(model.getDependencies().isEmpty()); new DependencyUpdater(model.getDependencies()).updateDependencies(dependencies); assertEquals(1, model.getDependencies().size()); assertNull(model.getDependencies().get(0).getGroupId()); assertNull(model.getDependencies().get(0).getArtifactId()); assertNull(model.getDependencies().get(0).getVersion()); }
@Test public void testAdd() throws Exception { Model model = new Model(); ArrayList<Dependency> dependencies = new ArrayList<Dependency>(); dependencies.add(makeWorkbenchDependency("group", "artifact-id", "1.0")); assertTrue(model.getDependencies().isEmpty()); new DependencyUpdater(model.getDependencies()).updateDependencies(dependencies); assertEquals(1, model.getDependencies().size()); assertEquals("group", model.getDependencies().get(0).getGroupId()); assertEquals("artifact-id", model.getDependencies().get(0).getArtifactId()); assertEquals("1.0", model.getDependencies().get(0).getVersion()); }
@Test public void testRemove() throws Exception { Model model = new Model(); model.getDependencies().add(makeMavenDependency("group", "artifact-id", "1.0")); assertFalse(model.getDependencies().isEmpty()); new DependencyUpdater(model.getDependencies()).updateDependencies(Collections.EMPTY_LIST); assertTrue(model.getDependencies().isEmpty()); }
@Test public void testUpdate() throws Exception { Model model = new Model(); model.getDependencies().add(makeMavenDependency("group", "artifact-id", "1.0")); ArrayList<Dependency> dependencies = new ArrayList<Dependency>(); dependencies.add(makeWorkbenchDependency("group", "artifact-id", "2.0")); assertFalse(model.getDependencies().isEmpty()); new DependencyUpdater(model.getDependencies()).updateDependencies(dependencies); assertEquals(1, model.getDependencies().size()); assertEquals("group", model.getDependencies().get(0).getGroupId()); assertEquals("artifact-id", model.getDependencies().get(0).getArtifactId()); assertEquals("2.0", model.getDependencies().get(0).getVersion()); }