@Test
  public void testGetServiceInfoFromSingleStack() throws Exception {
    MetainfoDAO metaInfoDao = createNiceMock(MetainfoDAO.class);
    StackDAO stackDao = createNiceMock(StackDAO.class);
    ExtensionDAO extensionDao = createNiceMock(ExtensionDAO.class);
    ExtensionLinkDAO linkDao = createNiceMock(ExtensionLinkDAO.class);
    ActionMetadata actionMetadata = createNiceMock(ActionMetadata.class);
    OsFamily  osFamily = createNiceMock(OsFamily.class);
    StackEntity stackEntity = createNiceMock(StackEntity.class);

    // ensure that service check is added for HDFS
    actionMetadata.addServiceCheckAction("HDFS");

    expect(
        stackDao.find(EasyMock.anyObject(String.class),
            EasyMock.anyObject(String.class))).andReturn(stackEntity).atLeastOnce();

    List<ExtensionLinkEntity> list = Collections.emptyList();
    expect(
        linkDao.findByStack(EasyMock.anyObject(String.class),
            EasyMock.anyObject(String.class))).andReturn(list).atLeastOnce();

    replay(metaInfoDao, stackDao, extensionDao, linkDao, actionMetadata, osFamily);

    String singleStack = ClassLoader.getSystemClassLoader().getResource("single_stack").getPath();
    AmbariManagementHelper helper = new AmbariManagementHelper(stackDao, extensionDao, linkDao);

    StackManager stackManager = new StackManager(new File(singleStack.replace(
        StackManager.PATH_DELIMITER, File.separator)), null, null, osFamily, false, metaInfoDao,
        actionMetadata, stackDao, extensionDao, linkDao, helper);

    Collection<StackInfo> stacks = stackManager.getStacks();
    assertEquals(1, stacks.size());
    assertNotNull(stacks.iterator().next().getService("HDFS"));

    verify(metaInfoDao, stackDao, actionMetadata, osFamily);
  }
This test ensures the service status check is added into the action metadata when
the stack has no parent and is the only stack in the stack family
ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerMiscTest.java