@Test
  public void testGetVersionDefinitionsForDisabledStack() throws AmbariException {
    Map<String, VersionDefinitionXml> versionDefinitions = metaInfo.getVersionDefinitions();
    Assert.assertNotNull(versionDefinitions);
    // Check presence
    Map.Entry<String, VersionDefinitionXml> vdfEntry = null;
    for (Map.Entry<String, VersionDefinitionXml> entry : versionDefinitions.entrySet()) {
      if (entry.getKey().equals("HDP-2.2.1")) {
        vdfEntry = entry;
      }
    }
    Assert.assertNotNull("Candidate stack and vdf for test case.", vdfEntry);
    StackInfo stackInfo = metaInfo.getStack("HDP", "2.2.1");
    // Strange that this is not immutable but works for this test !
    stackInfo.setActive(false);

    // Hate to use reflection hence changed contract to be package private
    metaInfo.versionDefinitions = null;

    versionDefinitions = metaInfo.getVersionDefinitions();
    vdfEntry = null;
    for (Map.Entry<String, VersionDefinitionXml> entry : versionDefinitions.entrySet()) {
      if (entry.getKey().equals("HDP-2.2.1")) {
        vdfEntry = entry;
      }
    }
    Assert.assertNull("Disabled stack should not be returned by the API", vdfEntry);
  }
Test scenario when service were removed and not mapped alerts need to be disabled

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java