ProjectAssignmentServiceImpl implements ProjectAssignmentService { @Override @Transactional(readOnly = true) public ProjectAssignment getProjectAssignment(Integer assignmentId) throws ObjectNotFoundException { ProjectAssignment assignment = projectAssignmentDAO.findById(assignmentId); if (assignment == null) { throw new ObjectNotFoundException("Assignment not found for id: " + assignmentId); } List<AssignmentAggregateReportElement> aggregates = reportAggregatedDAO.getCumulatedHoursPerAssignmentForAssignments(Arrays.asList(assignmentId)); assignment.setDeletable(ReportUtil.isEmptyAggregateList(aggregates)); return assignment; } @Autowired  ProjectAssignmentServiceImpl(ProjectAssignmentDao projectAssignmentDAO, ProjectAssignmentStatusService projectAssignmentStatusService, ReportAggregatedDao reportAggregatedDAO); @Override @Transactional(readOnly = true) List<ProjectAssignment> getProjectAssignmentsForUser(Integer userId, DateRange dateRange); @Override @Transactional(readOnly = true) List<ProjectAssignment> getProjectAssignmentsForUser(User user); @Override @Transactional(readOnly = true) ProjectAssignment getProjectAssignment(Integer assignmentId); @Override @Transactional(readOnly = true) List<ProjectAssignment> getProjectAssignments(Project project, DateRange range); @Override @Transactional(readOnly = true) List<ProjectAssignment> getProjectAssignmentsAndCheckDeletability(Project project); @Override @Transactional(readOnly = true) List<ProjectAssignmentType> getProjectAssignmentTypes();  }
@Test public void should_find_project_assignment() throws ObjectNotFoundException { ProjectAssignment pa = ProjectAssignmentObjectMother.createProjectAssignment(1); when(projectAssignmentDAO.findById(1)).thenReturn(pa); List<Integer> ids = Lists.newArrayList(); ids.add(1); when(reportAggregatedDAO.getCumulatedHoursPerAssignmentForAssignments(ids)).thenReturn(new ArrayList<AssignmentAggregateReportElement>()); ProjectAssignment assignment = projectAssignmentService.getProjectAssignment(1); assertEquals(pa, assignment); }