@Test
public void archivingContinuesAsLongAsOldWorkflowsAreFound() {

  doReturn(oldWorkdlowIds, oldWorkdlowIds, oldWorkdlowIds, emptyList).when(dao).getOldWorkflowIds(MAIN, limit, BATCH_SIZE,
      emptySet());
  when(dao.archiveWorkflows(oldWorkdlowIds)).thenReturn(oldWorkdlowIds.size());
  MaintenanceResults results = service.cleanupWorkflows(archiveConfig);
  assertEquals(oldWorkdlowIds.size() * 3, results.archivedWorkflows);
  assertValidArchiveTablesAreChecked();
  verify(dao, times(4)).getOldWorkflowIds(MAIN, limit, BATCH_SIZE, emptySet());
  verify(dao, times(3)).archiveWorkflows(oldWorkdlowIds);
  verifyNoMoreInteractions(dao, tableMetadataChecker);
}