### Question:
AccessRequestService { @PreAuthorize("@gatekeeperRoleService.isApprover()") public List<ActiveAccessRequestWrapper> rejectRequest(String taskId, Long requestId, String approverComments) { updateRequestDetails(requestId, approverComments, REJECTED); handleRequest(gatekeeperRoleService.getUserProfile().getUserId(), taskId, RequestStatus.APPROVAL_REJECTED); return getActiveRequests(); } @Autowired  AccessRequestService(TaskService taskService,
                                AccessRequestRepository accessRequestRepository,
                                GatekeeperRoleService gatekeeperRoleService,
                                RuntimeService runtimeService,
                                HistoryService historyService,
                                AccountInformationService accountInformationService,
                                SsmService ssmService,
                                GatekeeperApprovalProperties gatekeeperApprovalProperties,
                                EntityManager entityManager); AccessRequest storeAccessRequest(AccessRequestWrapper request); boolean isApprovalNeeded(AccessRequest request); List<ActiveAccessRequestWrapper> getActiveRequests(); List<CompletedAccessRequestWrapper> getRequest(Long id); List<CompletedAccessRequestWrapper> getCompletedRequests(); RequestEventDTO getLiveRequestsForUsersInRequest(EventType eventType, AccessRequest request); AccessRequest updateInstanceStatus(AccessRequest accessRequest); @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 testRejected(){ Mockito.when(accessRequestRepository.getAccessRequestById(1L)).thenReturn(nonOwnerRequest); accessRequestService.rejectRequest("taskOne", 1L, "Another Reason"); Map<String,Object> statusMap = new HashMap<>(); statusMap.put("requestStatus", RequestStatus.APPROVAL_REJECTED); verify(accessRequestRepository, times(3)).save(Mockito.any(AccessRequest.class)); verify(taskService,times(1)).setAssignee("taskOne","testUserId"); verify(taskService,times(1)).complete("taskOne",statusMap); }