@Test
  public void testGetDisplayStatus() throws Exception {
    // clear the HRC call so that it has the correct summary fields to represent
    // 1 skipped and 1 completed task
    EasyMock.reset(hrcDao);
    expect(hrcDao.findAggregateCounts(EasyMock.anyObject(Long.class))).andReturn(
        new HashMap<Long, HostRoleCommandStatusSummaryDTO>() {
          {
            put(0L, new HostRoleCommandStatusSummaryDTO(0, 1000L, 2500L, 0, 0, 1, 0, 0, 0, 0, 0, 0,
                0, 0, 1));
          }
        }).anyTimes();

    replay(hrcDao);

    StageResourceProvider provider = new StageResourceProvider(managementController);

    Request request = createNiceMock(Request.class);
    Predicate predicate = createNiceMock(Predicate.class);

    // make the stage skippable so it resolves to COMPLETED even though it has a
    // skipped failure
    List<StageEntity> entities = getStageEntities(HostRoleStatus.SKIPPED_FAILED);
    entities.get(0).setSkippable(true);

    expect(dao.findAll(request, predicate)).andReturn(entities);

    expect(clusters.getClusterById(anyLong())).andReturn(cluster).anyTimes();
    expect(cluster.getClusterName()).andReturn("c1").anyTimes();

    replay(dao, clusters, cluster, request, predicate);

    Set<Resource> resources = provider.getResources(request, predicate);

    Assert.assertEquals(1, resources.size());

    Resource resource = resources.iterator().next();

    // verify the two statuses
    Assert.assertEquals(HostRoleStatus.COMPLETED, resource.getPropertyValue(StageResourceProvider.STAGE_STATUS));
    Assert.assertEquals(HostRoleStatus.SKIPPED_FAILED, resource.getPropertyValue(StageResourceProvider.STAGE_DISPLAY_STATUS));

    verify(dao, clusters, cluster);
  }
Tests getting the display status of a stage which can differ from the final
status.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java