@Test
public void deletingFromArchiveTablesContinuesAsLongAsOldWorkflowsAreFound() {

  doReturn(oldWorkdlowIds, oldWorkdlowIds, oldWorkdlowIds, emptyList).when(dao).getOldWorkflowIds(ARCHIVE, limit, BATCH_SIZE,
      emptySet());
  when(dao.deleteWorkflows(ARCHIVE, oldWorkdlowIds)).thenReturn(oldWorkdlowIds.size());
  MaintenanceResults results = service.cleanupWorkflows(deleteArchiveConfig);
  assertEquals(oldWorkdlowIds.size() * 3, results.deletedArchivedWorkflows);
  assertValidArchiveTablesAreChecked();
  verify(dao, times(4)).getOldWorkflowIds(ARCHIVE, limit, BATCH_SIZE, emptySet());
  verify(dao, times(3)).deleteWorkflows(ARCHIVE, oldWorkdlowIds);
  verifyNoMoreInteractions(dao, tableMetadataChecker);
}