### Question:
IndexingService { public void reindexObject(AgentPrincipals agent, PID objectPid) { try (Timer.Context context = timer.time()) { aclService.assertHasAccess("User does not have permission to reindex", objectPid, agent.getPrincipals(), Permission.reindex); indexingMessageSender.sendIndexingOperation(agent.getUsername(), objectPid, IndexingActionType.ADD); } }  void reindexObjectAndChildren(AgentPrincipals agent, PID objectPid, Boolean inplace); void reindexObject(AgentPrincipals agent, PID objectPid); void setAclService(AccessControlService aclService); void setIndexingMessageSender(IndexingMessageSender indexingMessageSender);  }### Answer:
@Test public void reindexObjectTest() { service.reindexObject(agent, objPid); verify(messageSender).sendIndexingOperation(stringCaptor.capture(), pidCaptor.capture(), actionCaptor.capture()); verifyParameters(IndexingActionType.ADD); }
@Test(expected = AccessRestrictionException.class) public void insufficientAccessTest() { doThrow(new AccessRestrictionException()).when(aclService) .assertHasAccess(anyString(), any(PID.class), any(AccessGroupSet.class), eq(reindex)); service.reindexObject(agent, objPid); }