RequestDAO { @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 void 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);  }
@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<Long>(); group.add(2L); group.add(3L); group.add(4L); List<StageEntity> stages = stageDAO.findByStageIds(requestEntity.getRequestId(), group); 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()); }