### Question:
FlowableHistoricDataCleaner implements Cleaner { @Override public void execute(Date expirationTime) { long deletedProcessesCount = 0; long expiredProcessesPages = getExpiredProcessesPageCount(expirationTime); for (int i = 0; i < expiredProcessesPages; i++) { deletedProcessesCount += deleteExpiredProcessesPage(expirationTime); } LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.DELETED_HISTORIC_PROCESSES_0, deletedProcessesCount)); } @Inject  FlowableHistoricDataCleaner(HistoryService historyService);  FlowableHistoricDataCleaner(HistoryService historyService, int pageSize); @Override void execute(Date expirationTime);  }### Answer:
@Test void testExecuteWithMultiplePages() { HistoricProcessInstance process1 = mockHistoricProcessInstanceWithId(OPERATION_ID_1); HistoricProcessInstance process2 = mockHistoricProcessInstanceWithId(OPERATION_ID_2); HistoricProcessInstance process3 = mockHistoricProcessInstanceWithId(OPERATION_ID_3); List<HistoricProcessInstance> page1 = List.of(process1, process2); List<HistoricProcessInstance> page2 = List.of(process3); List<HistoricProcessInstance> page3 = Collections.emptyList(); HistoricProcessInstanceQuery query = mockHistoricProcessInstanceQueryWithPages(List.of(page1, page2, page3)); when(historyService.createHistoricProcessInstanceQuery()).thenReturn(query); cleaner.execute(EXPIRATION_TIME); verify(historyService).deleteHistoricProcessInstance(OPERATION_ID_1); verify(historyService).deleteHistoricProcessInstance(OPERATION_ID_2); verify(historyService).deleteHistoricProcessInstance(OPERATION_ID_3); }
@Test void testExecuteResilience() { HistoricProcessInstance process1 = mockHistoricProcessInstanceWithId(OPERATION_ID_1); HistoricProcessInstance process2 = mockHistoricProcessInstanceWithId(OPERATION_ID_2); List<HistoricProcessInstance> page1 = List.of(process1, process2); List<HistoricProcessInstance> page2 = Collections.emptyList(); HistoricProcessInstanceQuery query = mockHistoricProcessInstanceQueryWithPages(List.of(page1, page2)); when(historyService.createHistoricProcessInstanceQuery()).thenReturn(query); doThrow(new FlowableObjectNotFoundException("Oops! Someone was faster than you!")).when(historyService) .deleteHistoricProcessInstance(OPERATION_ID_1); cleaner.execute(EXPIRATION_TIME); verify(historyService).deleteHistoricProcessInstance(OPERATION_ID_1); verify(historyService).deleteHistoricProcessInstance(OPERATION_ID_2); }