### Question:
AccessRequestService { public List<CompletedAccessRequestWrapper> getLiveRequests() { List<AccessRequest> liveRequests = accessRequestRepository.getLiveAccessRequests(); Map<String, Map<String, Object>> liveRequestExpirationData = accessRequestRepository.getLiveAccessRequestExpirations() .stream() .collect(Collectors.toMap(item -> item.get("id").toString(), item -> item)); return liveRequests.stream().map( item -> new CompletedAccessRequestWrapper(item) .setUpdated((Date)liveRequestExpirationData.get(String.valueOf(item.getId())).get("granted_on")) .setExpirationDate((Date)liveRequestExpirationData.get(String.valueOf(item.getId())).get("expire_time")) ).collect(Collectors.toList()); } @Autowired  AccessRequestService(TaskService taskService,
                                AccessRequestRepository accessRequestRepository,
                                GatekeeperRoleService gatekeeperRoleService,
                                RuntimeService runtimeService,
                                HistoryService historyService,
                                GatekeeperApprovalProperties gatekeeperApprovalProperties,
                                AccountInformationService accountInformationService,
                                GatekeeperOverrideProperties overridePolicy,
                                DatabaseConnectionService databaseConnectionService,
                                EntityManager entityManager); AccessRequestCreationResponse storeAccessRequest(AccessRequestWrapper request); boolean isApprovalNeeded(AccessRequest request); List<ActiveAccessRequestWrapper> getActiveRequests(); List<CompletedAccessRequestWrapper> getRequest(Long id); List<CompletedAccessRequestWrapper> getCompletedRequests(); List<CompletedAccessRequestWrapper> getLiveRequests(); List<AccessRequest> getLiveRequestsForUserOnDatabase(String userId, String accountName, String database, UserRole role); @PreAuthorize("@gatekeeperRoleService.isApprover()") List<ActiveAccessRequestWrapper> approveRequest(String taskId, Long requestId, String approverComments ); @PreAuthorize("@gatekeeperRoleService.isApprover()") List<ActiveAccessRequestWrapper> rejectRequest(String taskId, Long requestId, String approverComments); List<ActiveAccessRequestWrapper> cancelRequest(String taskId, Long requestId);  }### Answer:
@Test public void testGetLiveRequests(){ Date ownerGranted = Date.from(LocalDateTime.now().toInstant(ZoneOffset.UTC)); Date ownerExpires = Date.from(LocalDateTime.now().plusDays(2).toInstant(ZoneOffset.UTC)); Date nonOwnerGranted = Date.from(LocalDateTime.now().minusDays(1).toInstant(ZoneOffset.UTC)); Date nonOwnerExpires = Date.from(LocalDateTime.now().plusDays(10).toInstant(ZoneOffset.UTC)); Map<String, Object> ownerRequestExpirations = new HashMap<>(); ownerRequestExpirations.put("id", 1L); ownerRequestExpirations.put("granted_on", ownerGranted); ownerRequestExpirations.put("expire_time", ownerExpires); Map<String, Object> nonOwnerRequestExpirations = new HashMap<>(); nonOwnerRequestExpirations.put("id", 2L); nonOwnerRequestExpirations.put("granted_on", nonOwnerGranted); nonOwnerRequestExpirations.put("expire_time", nonOwnerExpires); Mockito.when(accessRequestRepository.getLiveAccessRequests()).thenReturn(Arrays.asList(ownerRequest, nonOwnerRequest)); Mockito.when(accessRequestRepository.getLiveAccessRequestExpirations()).thenReturn(Arrays.asList(ownerRequestExpirations, nonOwnerRequestExpirations)); List<CompletedAccessRequestWrapper> requests = accessRequestService.getLiveRequests(); CompletedAccessRequestWrapper ownerResult = requests.get(0); CompletedAccessRequestWrapper nonOwnerResult = requests.get(1); Assert.assertEquals(ownerRequest.getId(), ownerResult.getId()); Assert.assertEquals(ownerGranted, ownerResult.getUpdated()); Assert.assertEquals(ownerExpires, ownerResult.getExpirationDate()); Assert.assertEquals(nonOwnerResult.getId(), nonOwnerResult.getId()); Assert.assertEquals(ownerGranted, ownerResult.getUpdated()); Assert.assertEquals(ownerExpires, ownerResult.getExpirationDate()); }