@VisibleForTesting
  void initializeForeachArtifactRollup(
      ForeachStepOverview foreachOverview,
      ForeachStepOverview prevForeachOverview,
      String foreachWorkflowId) {
    Set<Long> iterationsToRunInNewRun =
        foreachOverview.getIterationsToRunFromDetails(prevForeachOverview);
    WorkflowRollupOverview aggregatedRollupsPrevRun =
        getAggregatedRollupFromIterations(foreachWorkflowId, iterationsToRunInNewRun);

    foreachOverview.initiateStepRollup(prevForeachOverview.getRollup(), aggregatedRollupsPrevRun);
  }
@Test
  public void testGetAggregatedRollupFromIterationsNotManyUneven() {
    ArgumentCaptor<List<Long>> captor = ArgumentCaptor.forClass(List.class);

    Set<Long> iterations = LongStream.rangeClosed(1, 3).boxed().collect(Collectors.toSet());
    doReturn(Collections.singletonList(new WorkflowRollupOverview()))
        .when(workflowInstanceDao)
        .getBatchForeachLatestRunRollupForIterations(anyString(), any());
    ForeachStepOverview stepOverview = mock(ForeachStepOverview.class);
    ForeachStepOverview prevStepOverview = new ForeachStepOverview();
    doReturn(iterations).when(stepOverview).getIterationsToRunFromDetails(any());
    foreachStepRuntime.initializeForeachArtifactRollup(
        stepOverview, prevStepOverview, "myworkflowid");
    Mockito.verify(workflowInstanceDao, times(1))
        .getBatchForeachLatestRunRollupForIterations(eq("myworkflowid"), captor.capture());
    List<List<Long>> values = captor.getAllValues();
    assertEquals(1, values.get(0).get(0).longValue());
    assertEquals(2, values.get(0).get(1).longValue());
    assertEquals(3, values.get(0).get(2).longValue());
    assertEquals(3, values.get(0).size());
  }