@Test
public void testResolve_Components() throws Exception {

  // resolve should merge the child component collections
  // components 1, 2 and XX are set on the parent
  // components 1, 4 and XX are set on the child
  // component XX is marked for delete on the child and shouldn't be included
  // component 1 should be merged
  // both non-intersecting components 2 and 4 should be included
  ComponentInfo info1 = new ComponentInfo();
  info1.setName("1");
  ComponentInfo info2 = new ComponentInfo();
  info2.setName("2");
  ComponentInfo XX = new ComponentInfo();
  XX.setName("XX");
  ComponentInfo info3 = new ComponentInfo();
  // overlaps with info1
  info3.setName("1");
  info3.setCardinality("ALL");
  info3.setCategory("category");
  ComponentInfo info4 = new ComponentInfo();
  info4.setName("4");
  ComponentInfo info5 = new ComponentInfo();
  // overlaps with componentToBeDeleted
  info5.setName("XX");
  info5.setDeleted(true);
  ServiceInfo info = new ServiceInfo();
  ServiceInfo parentInfo = new ServiceInfo();
  //todo: getComponents() should return a protective copy, but for now there is no set/add method
  List<ComponentInfo> childComponents = info.getComponents();
  childComponents.add(info3);
  childComponents.add(info4);
  childComponents.add(info5);
  List<ComponentInfo> parentComponents = parentInfo.getComponents();
  parentComponents.add(info1);
  parentComponents.add(info2);
  ServiceModule child = createServiceModule(info);
  ServiceModule parent = createServiceModule(parentInfo);
  resolveService(child, parent);
  List<ComponentInfo> components = child.getModuleInfo().getComponents();
  assertEquals(3, components.size());
  Map<String, ComponentInfo> mergedComponents = new HashMap<String, ComponentInfo>();
  for (ComponentInfo component : components) {
    mergedComponents.put(component.getName(), component);
  }
  assertTrue(mergedComponents.containsKey("1"));
  assertTrue(mergedComponents.containsKey("2"));
  assertTrue(mergedComponents.containsKey("4"));
  // ensure that overlapping components were merged.
  //don't test all properties, this is done in ComponentModuleTest
  assertEquals("ALL", mergedComponents.get("1").getCardinality());
  assertEquals("category", mergedComponents.get("1").getCategory());
}