@Test
public void testStackVersionInheritance() {

  StackInfo stack = stackManager.getStack("HDP", "2.1.1");
  assertNotNull(stack);
  assertEquals("HDP", stack.getName());
  assertEquals("2.1.1", stack.getVersion());
  Collection<ServiceInfo> services = stack.getServices();
  ServiceInfo si = stack.getService("SPARK");
  assertNull(si);
  si = stack.getService("SPARK2");
  assertNull(si);
  si = stack.getService("SPARK3");
  assertNotNull(si);
  //should include all stacks in hierarchy
  assertEquals(17, services.size());
  HashSet<String> expectedServices = new HashSet<String>();
  expectedServices.add("GANGLIA");
  expectedServices.add("HBASE");
  expectedServices.add("HCATALOG");
  expectedServices.add("HDFS");
  expectedServices.add("HIVE");
  expectedServices.add("MAPREDUCE2");
  expectedServices.add("OOZIE");
  expectedServices.add("PIG");
  expectedServices.add("SQOOP");
  expectedServices.add("YARN");
  expectedServices.add("ZOOKEEPER");
  expectedServices.add("STORM");
  expectedServices.add("FLUME");
  expectedServices.add("FAKENAGIOS");
  expectedServices.add("TEZ");
  expectedServices.add("AMBARI_METRICS");
  expectedServices.add("SPARK3");
  ServiceInfo pigService = null;
  for (ServiceInfo service : services) {
    if (service.getName().equals("PIG")) {
      pigService = service;
    }
    assertTrue(expectedServices.remove(service.getName()));
  }
  assertTrue(expectedServices.isEmpty());
  // extended values
  assertNotNull(pigService);
  assertEquals("0.12.1.2.1.1", pigService.getVersion());
  assertEquals("Scripting platform for analyzing large datasets (Extended)", pigService.getComment());
  //base value
  ServiceInfo basePigService = stackManager.getStack("HDP", "2.0.5").getService("PIG");
  assertEquals("0.11.1.2.0.5.0", basePigService.getVersion());
  assertEquals(1, basePigService.getComponents().size());
  // new component added in extended version
  assertEquals(2, pigService.getComponents().size());
  // no properties in base service
  assertEquals(0, basePigService.getProperties().size());
  assertEquals(1, pigService.getProperties().size());
  assertEquals("content", pigService.getProperties().get(0).getName());
}