### Question:
ProcessEngineClient { public void deleteArchivedProcessInstancesByBunch(final long processId, final int bunchSize, final List<Long> processesAllowedToBeDeletedIds) throws DeletionException, ProcessDefinitionNotFoundException { long numberOfDeletedArchivedProcessInstances = 0; do { try { numberOfDeletedArchivedProcessInstances = getProcessApi().deleteArchivedProcessInstances(processId, 0, bunchSize); } catch (final ProcessInstanceHierarchicalDeletionException e) { final long parentProcessInstanceID = e.getProcessInstanceId(); final long parentProcessID = getProcessApi().getProcessDefinitionIdFromProcessInstanceId(parentProcessInstanceID); if (processesAllowedToBeDeletedIds.contains(parentProcessID)) { deleteProcessInstancesByBunch(parentProcessID, DELETE_PROCESS_BUNCH_SIZE, processesAllowedToBeDeletedIds); } else { LOGGER.log(Level.WARNING, "Process with ID " + processId + " cannot be deleted without also deleting its parent (" + parentProcessID + ")."); } } } while (numberOfDeletedArchivedProcessInstances >= bunchSize); } ProcessEngineClient(final ProcessAPI processAPI); ProcessDeploymentInfo getProcessDeploymentInfo(final long processId); ProcessAPI getProcessApi(); ProcessDefinition deploy(final BusinessArchive businessArchive); void enableProcess(final long processId); void disableProcess(final long processId); ProcessDeploymentInfo updateProcessDeploymentInfo(final long processId, final ProcessDeploymentInfoUpdater processDeploymentInfoUpdater); void deleteDisabledProcesses(final List<Long> processIds); void deleteArchivedProcessInstancesByBunch(final long processId, final int bunchSize, final List<Long> processesAllowedToBeDeletedIds); void deleteProcessInstancesByBunch(final long processId, final int bunchSize, final List<Long> processesAllowedToBeDeletedIds); SearchResult<ProcessDeploymentInfo> searchProcessDefinitions(final SearchOptions searchOptions); SearchResult<ProcessDeploymentInfo> searchUncategorizedProcessDefinitionsSupervisedBy(final long userId, final SearchOptions searchOptions); SearchResult<ProcessDeploymentInfo> searchProcessDefinitionsSupervisedBy(final long userId, final SearchOptions searchOptions); SearchResult<ProcessDeploymentInfo> searchUncategorizedProcessDefinitionsUserCanStart(final long userId, final SearchOptions searchOptions); SearchResult<ProcessDeploymentInfo> searchRecentlyStartedProcessDefinitions(final long userId, final SearchOptions searchOptions); long countResolvedProcesses(); SearchResult<ProcessDeploymentInfo> searchProcessDeploymentInfosWithAssignedOrPendingHumanTasksSupervisedBy(final long supervisorId,
            final SearchOptions searchOptions); SearchResult<ProcessDeploymentInfo> searchProcessDeploymentInfosWithAssignedOrPendingHumanTasks(final SearchOptions searchOptions); SearchResult<ProcessDeploymentInfo> searchProcessDeploymentInfosWithAssignedOrPendingHumanTasksFor(final long userId,
            final SearchOptions searchOptions); SearchResult<ProcessDeploymentInfo> searchProcessDeploymentInfos(final long userId, final SearchOptions searchOptions); List<DataDefinition> getProcessDataDefinitions(final long processId);  }### Answer:
@Test public void deleteArchivedProcessInstancesByBunch_delete_archived_processes_instances_by_bunch() throws Exception { when(processAPI.deleteArchivedProcessInstances(1L, 0, BUNCH_SIZE)) .thenReturn(BUNCH_SIZE.longValue(), BUNCH_SIZE.longValue(), 0L); final List<Long> processList = new ArrayList<Long>(); processList.add(1L); processEngineClient.deleteArchivedProcessInstancesByBunch(1L, 10, processList); verify(processAPI, times(3)).deleteArchivedProcessInstances(1L, 0, 10); }