@Test
public void getOldWorkflowIdsReturnsRequestedNumberOfItemsOrderedById() {

  List<Long> expectedIds = new ArrayList<>();
  expectedIds.add(storePassiveWorkflow(archiveTime2));
  for (int i = 0; i < 9; i++) {
    expectedIds.add(storePassiveWorkflow(archiveTime4));
  }
  long eleventh = storePassiveWorkflow(archiveTime3);
  storeActiveWorkflow(archiveTime1);
  storeActiveWorkflow(prodTime3);
  storePassiveWorkflow(prodTime4);
  List<Long> oldWorkflowIds = maintenanceDao.getOldWorkflowIds(MAIN, archiveTimeLimit, 10, emptySet());
  assertArrayEquals(oldWorkflowIds.toArray(), expectedIds.toArray());
  expectedIds.add(eleventh);
  oldWorkflowIds = maintenanceDao.getOldWorkflowIds(MAIN, archiveTimeLimit, 11, emptySet());
  assertArrayEquals(oldWorkflowIds.toArray(), expectedIds.toArray());
}