@Test
public void testCalculatedStatus() throws Exception {

  createGraph();
  RequestEntity requestEntity = requestDAO.findByPK(100L);
  // !!! accepted value
  CalculatedStatus calc1 = CalculatedStatus.statusFromStageEntities(
      requestEntity.getStages());
  // !!! aggregated value
  Map<Long, HostRoleCommandStatusSummaryDTO> map = hostRoleCommandDAO.findAggregateCounts(100L);
  CalculatedStatus calc2 = CalculatedStatus.statusFromStageSummary(map,
      map.keySet());
  Assert.assertEquals(HostRoleStatus.IN_PROGRESS, calc1.getStatus());
  Assert.assertEquals(calc1.getStatus(), calc2.getStatus());
  Assert.assertEquals(calc1.getPercent(), calc2.getPercent(), 0.01d);
  // !!! simulate an upgrade group
  Set<Long> group = new HashSet<Long>();
  group.add(2L);
  group.add(3L);
  group.add(4L);
  // !!! accepted
  List<StageEntity> stages = stageDAO.findByStageIds(requestEntity.getRequestId(), group);
  CalculatedStatus calc3 = CalculatedStatus.statusFromStageEntities(stages);
  // !!! aggregated
  CalculatedStatus calc4 = CalculatedStatus.statusFromStageSummary(map, group);
  Assert.assertEquals(100d, calc3.getPercent(), 0.01d);
  Assert.assertEquals(HostRoleStatus.COMPLETED, calc3.getStatus());
  Assert.assertEquals(calc3.getPercent(), calc4.getPercent(), 0.01d);
  Assert.assertEquals(calc3.getStatus(), calc4.getStatus());
}