### Question:
AccessRequestService { @PreAuthorize("@gatekeeperRoleService.isApprover()") public List<ActiveAccessRequestWrapper> approveRequest(String taskId, Long requestId, String approverComments ) { updateRequestDetails(requestId, approverComments, APPROVED); handleRequest(gatekeeperRoleService.getUserProfile().getUserId(), taskId, RequestStatus.APPROVAL_GRANTED); return getActiveRequests(); } @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 testApproval(){ Mockito.when(accessRequestRepository.getAccessRequestById(1L)).thenReturn(ownerRequest); accessRequestService.approveRequest("taskOne", 1L, "A reason"); Map<String,Object> statusMap = new HashMap<>(); statusMap.put("requestStatus", RequestStatus.APPROVAL_GRANTED); verify(accessRequestRepository, times(1)).save(Mockito.any(AccessRequest.class)); verify(taskService,times(1)).setAssignee("taskOne","testUserId"); verify(taskService,times(1)).complete("taskOne",statusMap); }