### Question:
RequestDAO implements Cleanable { @RequiresSession public RequestEntity findByPK(Long requestId) { return entityManagerProvider.get().find(RequestEntity.class, requestId); }  @RequiresSession RequestEntity findByPK(Long requestId); @RequiresSession List<RequestEntity> findByPks(Collection<Long> requestIds); @RequiresSession List<RequestEntity> findByPks(Collection<Long> requestIds, boolean refreshHint); @RequiresSession List<RequestEntity> findAll(); @RequiresSession List<Long> findAllRequestIds(int limit, boolean ascending); @RequiresSession List<RequestResourceFilterEntity> findAllResourceFilters(); @RequiresSession boolean isAllTasksCompleted(long requestId); @RequiresSession Long getLastStageId(long requestId); @Transactional RequestEntity updateStatus(long requestId, HostRoleStatus status, HostRoleStatus displayStatus); @Transactional void create(RequestEntity requestEntity); @Transactional RequestEntity merge(RequestEntity requestEntity); @Transactional void remove(RequestEntity requestEntity); @Transactional void removeByPK(Long requestId); @RequiresSession List<Long> findAllRequestIds(int limit, boolean sortAscending, Long clusterId); List<StageEntityPK> findRequestAndStageIdsInClusterBeforeDate(Long clusterId, long  beforeDateMillis); @Transactional @Override long cleanup(TimeBasedCleanupPolicy policy);  }### Answer:
@Test public void testCalculatedStatus() throws Exception { createGraph(); RequestEntity requestEntity = requestDAO.findByPK(100L); CalculatedStatus calc1 = CalculatedStatus.statusFromStageEntities( requestEntity.getStages()); 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); Set<Long> group = new HashSet<>(); group.add(2L); group.add(3L); group.add(4L); List<StageEntity> stages = new ArrayList<>(); StageEntityPK primaryKey = new StageEntityPK(); primaryKey.setRequestId(requestEntity.getRequestId()); primaryKey.setStageId(2L); StageEntity stage = stageDAO.findByPK(primaryKey); Assert.assertNotNull(stage); stages.add(stage); primaryKey.setStageId(3L); stage = stageDAO.findByPK(primaryKey); Assert.assertNotNull(stage); stages.add(stage); primaryKey.setStageId(4L); stage = stageDAO.findByPK(primaryKey); Assert.assertNotNull(stage); stages.add(stage); CalculatedStatus calc3 = CalculatedStatus.statusFromStageEntities(stages); 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()); }