@Test
public void testStackServiceExtension() {

  StackInfo stack = stackManager.getStack("OTHER", "1.0");
  assertNotNull(stack);
  assertEquals("OTHER", stack.getName());
  assertEquals("1.0", stack.getVersion());
  Collection<ServiceInfo> services = stack.getServices();
  assertEquals(4, services.size());
  // hdfs service
  assertEquals(6, stack.getService("HDFS").getComponents().size());
  // Extended Sqoop service via explicit service extension
  ServiceInfo sqoopService = stack.getService("SQOOP2");
  assertNotNull(sqoopService);
  assertEquals("Extended SQOOP", sqoopService.getComment());
  assertEquals("Extended Version", sqoopService.getVersion());
  assertNull(sqoopService.getServicePackageFolder());
  Collection<ComponentInfo> components = sqoopService.getComponents();
  assertEquals(1, components.size());
  ComponentInfo component = components.iterator().next();
  assertEquals("SQOOP", component.getName());
  // Get the base sqoop service
  StackInfo baseStack = stackManager.getStack("HDP", "2.1.1");
  ServiceInfo baseSqoopService = baseStack.getService("SQOOP");
  // values from base service
  assertEquals(baseSqoopService.isDeleted(), sqoopService.isDeleted());
  assertEquals(baseSqoopService.getAlertsFile(),sqoopService.getAlertsFile());
  assertEquals(baseSqoopService.getClientComponent(), sqoopService.getClientComponent());
  assertEquals(baseSqoopService.getCommandScript(), sqoopService.getCommandScript());
  assertEquals(baseSqoopService.getConfigDependencies(), sqoopService.getConfigDependencies());
  assertEquals(baseSqoopService.getConfigDir(), sqoopService.getConfigDir());
  assertEquals(baseSqoopService.getConfigDependenciesWithComponents(), sqoopService.getConfigDependenciesWithComponents());
  assertEquals(baseSqoopService.getConfigTypeAttributes(), sqoopService.getConfigTypeAttributes());
  assertEquals(baseSqoopService.getCustomCommands(), sqoopService.getCustomCommands());
  assertEquals(baseSqoopService.getExcludedConfigTypes(), sqoopService.getExcludedConfigTypes());
  assertEquals(baseSqoopService.getProperties(), sqoopService.getProperties());
  assertEquals(baseSqoopService.getMetrics(), sqoopService.getMetrics());
  assertNull(baseSqoopService.getMetricsFile());
  assertNull(sqoopService.getMetricsFile());
  assertEquals(baseSqoopService.getOsSpecifics(), sqoopService.getOsSpecifics());
  assertEquals(baseSqoopService.getRequiredServices(), sqoopService.getRequiredServices());
  assertEquals(baseSqoopService.getSchemaVersion(), sqoopService.getSchemaVersion());
  // extended Storm service via explicit service extension
  ServiceInfo stormService = stack.getService("STORM");
  assertNotNull(stormService);
  assertEquals("STORM", stormService.getName());
  // base storm service
  ServiceInfo baseStormService = baseStack.getService("STORM");
  // overridden value
  assertEquals("Apache Hadoop Stream processing framework (Extended)", stormService.getComment());
  assertEquals("New version", stormService.getVersion());
  String packageDir = StringUtils.join(
      new String[]{"stacks", "OTHER", "1.0", "services", "STORM", "package"}, File.separator);
  assertEquals(packageDir, stormService.getServicePackageFolder());
  // compare components
  List<ComponentInfo> stormServiceComponents = stormService.getComponents();
  List<ComponentInfo> baseStormServiceComponents = baseStormService.getComponents();
  assertEquals(new HashSet<ComponentInfo>(stormServiceComponents), new HashSet<ComponentInfo>(baseStormServiceComponents));
  // values from base service
  assertEquals(baseStormService.isDeleted(), stormService.isDeleted());
  //todo: specify alerts file in stack
  assertEquals(baseStormService.getAlertsFile(),stormService.getAlertsFile());
  assertEquals(baseStormService.getClientComponent(), stormService.getClientComponent());
  assertEquals(baseStormService.getCommandScript(), stormService.getCommandScript());
  assertEquals(baseStormService.getConfigDependencies(), stormService.getConfigDependencies());
  assertEquals(baseStormService.getConfigDir(), stormService.getConfigDir());
  assertEquals(baseStormService.getConfigDependenciesWithComponents(), stormService.getConfigDependenciesWithComponents());
  assertEquals(baseStormService.getConfigTypeAttributes(), stormService.getConfigTypeAttributes());
  assertEquals(baseStormService.getCustomCommands(), stormService.getCustomCommands());
  assertEquals(baseStormService.getExcludedConfigTypes(), stormService.getExcludedConfigTypes());
  assertEquals(baseStormService.getProperties(), stormService.getProperties());
  assertEquals(baseStormService.getMetrics(), stormService.getMetrics());
  assertNotNull(baseStormService.getMetricsFile());
  assertNotNull(stormService.getMetricsFile());
  assertFalse(baseStormService.getMetricsFile().equals(stormService.getMetricsFile()));
  assertEquals(baseStormService.getOsSpecifics(), stormService.getOsSpecifics());
  assertEquals(baseStormService.getRequiredServices(), stormService.getRequiredServices());
  assertEquals(baseStormService.getSchemaVersion(), stormService.getSchemaVersion());
}