@Test public void testStartWorkingReturnsNullWhenUserNotInOwningGroup() throws Exception { participant.setParticipantLdapId(""); oldestNotAssignedRequest.setParticipants(Arrays.asList(participant, owningGroupParticipant)); expect(mockedRequestDao.getOldestRequestInQueueAssignedToUser(queueId, userId)).andReturn(null); expect(mockedRequestDao.getAllUnassignedRequestsInQueue(queueId)).andReturn(Arrays.asList(oldestNotAssignedRequest)); expect(mockedGroupService.isUserMemberOfGroup(userId, owningGroup)).andReturn(false); expect(mockedAuthentication.getName()).andReturn(userId).anyTimes(); replay(mocks); FOIARequest returnedRequest = unit.startWorking(queueId, mockedAuthentication, mockedHttpSession); verify(mocks); assertNull(returnedRequest); }
public FOIARequest startWorking(Long queueId, Authentication auth, HttpSession session) { FOIARequest oldestAssignedRequestInQueueToUser = getRequestDao().getOldestRequestInQueueAssignedToUser(queueId, auth.getName()); List<FOIARequest> unassignedRequestsInQueue = getRequestDao().getAllUnassignedRequestsInQueue(queueId); FOIARequest oldestAssignableRequestForUser = getOldestAssignableRequestForUser(unassignedRequestsInQueue, auth.getName()); if (oldestAssignedRequestInQueueToUser != null && (oldestAssignableRequestForUser == null || oldestAssignedRequestInQueueToUser.getQueueEnterDate().isBefore(oldestAssignableRequestForUser.getQueueEnterDate()))) { return oldestAssignedRequestInQueueToUser; } if (oldestAssignableRequestForUser != null) { return assignRequestToUser(oldestAssignableRequestForUser, auth, session); } log.debug("No unassigned requests in queue with ID [[{}]]", queueId); return null; }
RequestAssignmentService { public FOIARequest startWorking(Long queueId, Authentication auth, HttpSession session) { FOIARequest oldestAssignedRequestInQueueToUser = getRequestDao().getOldestRequestInQueueAssignedToUser(queueId, auth.getName()); List<FOIARequest> unassignedRequestsInQueue = getRequestDao().getAllUnassignedRequestsInQueue(queueId); FOIARequest oldestAssignableRequestForUser = getOldestAssignableRequestForUser(unassignedRequestsInQueue, auth.getName()); if (oldestAssignedRequestInQueueToUser != null && (oldestAssignableRequestForUser == null || oldestAssignedRequestInQueueToUser.getQueueEnterDate().isBefore(oldestAssignableRequestForUser.getQueueEnterDate()))) { return oldestAssignedRequestInQueueToUser; } if (oldestAssignableRequestForUser != null) { return assignRequestToUser(oldestAssignableRequestForUser, auth, session); } log.debug("No unassigned requests in queue with ID [[{}]]", queueId); return null; } }
RequestAssignmentService { public FOIARequest startWorking(Long queueId, Authentication auth, HttpSession session) { FOIARequest oldestAssignedRequestInQueueToUser = getRequestDao().getOldestRequestInQueueAssignedToUser(queueId, auth.getName()); List<FOIARequest> unassignedRequestsInQueue = getRequestDao().getAllUnassignedRequestsInQueue(queueId); FOIARequest oldestAssignableRequestForUser = getOldestAssignableRequestForUser(unassignedRequestsInQueue, auth.getName()); if (oldestAssignedRequestInQueueToUser != null && (oldestAssignableRequestForUser == null || oldestAssignedRequestInQueueToUser.getQueueEnterDate().isBefore(oldestAssignableRequestForUser.getQueueEnterDate()))) { return oldestAssignedRequestInQueueToUser; } if (oldestAssignableRequestForUser != null) { return assignRequestToUser(oldestAssignableRequestForUser, auth, session); } log.debug("No unassigned requests in queue with ID [[{}]]", queueId); return null; }  }
RequestAssignmentService { public FOIARequest startWorking(Long queueId, Authentication auth, HttpSession session) { FOIARequest oldestAssignedRequestInQueueToUser = getRequestDao().getOldestRequestInQueueAssignedToUser(queueId, auth.getName()); List<FOIARequest> unassignedRequestsInQueue = getRequestDao().getAllUnassignedRequestsInQueue(queueId); FOIARequest oldestAssignableRequestForUser = getOldestAssignableRequestForUser(unassignedRequestsInQueue, auth.getName()); if (oldestAssignedRequestInQueueToUser != null && (oldestAssignableRequestForUser == null || oldestAssignedRequestInQueueToUser.getQueueEnterDate().isBefore(oldestAssignableRequestForUser.getQueueEnterDate()))) { return oldestAssignedRequestInQueueToUser; } if (oldestAssignableRequestForUser != null) { return assignRequestToUser(oldestAssignableRequestForUser, auth, session); } log.debug("No unassigned requests in queue with ID [[{}]]", queueId); return null; }  FOIARequest startWorking(Long queueId, Authentication auth, HttpSession session); FOIARequest assignRequestToUser(FOIARequest request, Authentication auth, HttpSession session); FOIARequest assignUserGroupToRequest(FOIARequest request, HttpSession session); FOIARequestDao getRequestDao(); void setRequestDao(FOIARequestDao requestDao); SaveCaseService getSaveCaseService(); void setSaveCaseService(SaveCaseService saveCaseService); GroupService getGroupService(); void setGroupService(GroupService groupService); }
RequestAssignmentService { public FOIARequest startWorking(Long queueId, Authentication auth, HttpSession session) { FOIARequest oldestAssignedRequestInQueueToUser = getRequestDao().getOldestRequestInQueueAssignedToUser(queueId, auth.getName()); List<FOIARequest> unassignedRequestsInQueue = getRequestDao().getAllUnassignedRequestsInQueue(queueId); FOIARequest oldestAssignableRequestForUser = getOldestAssignableRequestForUser(unassignedRequestsInQueue, auth.getName()); if (oldestAssignedRequestInQueueToUser != null && (oldestAssignableRequestForUser == null || oldestAssignedRequestInQueueToUser.getQueueEnterDate().isBefore(oldestAssignableRequestForUser.getQueueEnterDate()))) { return oldestAssignedRequestInQueueToUser; } if (oldestAssignableRequestForUser != null) { return assignRequestToUser(oldestAssignableRequestForUser, auth, session); } log.debug("No unassigned requests in queue with ID [[{}]]", queueId); return null; }  FOIARequest startWorking(Long queueId, Authentication auth, HttpSession session); FOIARequest assignRequestToUser(FOIARequest request, Authentication auth, HttpSession session); FOIARequest assignUserGroupToRequest(FOIARequest request, HttpSession session); FOIARequestDao getRequestDao(); void setRequestDao(FOIARequestDao requestDao); SaveCaseService getSaveCaseService(); void setSaveCaseService(SaveCaseService saveCaseService); GroupService getGroupService(); void setGroupService(GroupService groupService);  }