@JsonIgnore
  void resetIterationDetail(
      long iterationId, WorkflowInstance.Status newStatus, WorkflowInstance.Status oldStatus) {
    Checks.checkTrue(
        info.get(oldStatus) != null,
        "Invalid: the restarted iteration [%s]'s status [%s] is missing in the foreach details",
        iterationId,
        oldStatus);
    Interval deleted = null;
    Iterator<Interval> iter = info.get(oldStatus).iterator();
    while (iter.hasNext()) {
      Interval interval = iter.next();
      if (iterationId >= interval.start && iterationId <= interval.end) {
        deleted = interval;
        iter.remove();
        break;
      }
    }
    Checks.checkTrue(
        deleted != null,
        "Invalid: the restarted iteration [%s] is missing in the foreach details",
        iterationId);

    if (deleted.start < iterationId) {
      info.get(oldStatus).add(new Interval(deleted.start, iterationId - 1));
    }
    if (iterationId < deleted.end) {
      info.get(oldStatus).add(new Interval(iterationId + 1, deleted.end));
    }
    if (info.get(oldStatus).isEmpty()) {
      info.remove(oldStatus);
    }
    add(iterationId, newStatus);
  }
@Test
  public void testResetIterationDetail() throws Exception {
    TestDetails testDetails =
        loadObject("fixtures/instances/sample-foreach-details.json", TestDetails.class);
    testDetails.test1.resetIterationDetail(
        8, WorkflowInstance.Status.CREATED, WorkflowInstance.Status.FAILED);
    assertEquals(
        Collections.singletonList(new ForeachDetails.Interval(8L, 8L)),
        testDetails.test1.getPendingInfo().get(WorkflowInstance.Status.CREATED));
    testDetails.test1.resetIterationDetail(
        9, WorkflowInstance.Status.CREATED, WorkflowInstance.Status.FAILED);
    assertEquals(
        Collections.singletonList(new ForeachDetails.Interval(11L, 15L)),
        testDetails.test1.getInfo().get(WorkflowInstance.Status.FAILED));
  }