@JsonIgnore
  public Map<WorkflowInstance.Status, List<Long>> flatten(
      Predicate<WorkflowInstance.Status> condition) {
    return info.entrySet().stream()
        .filter(e -> condition.test(e.getKey()))
        .collect(
            Collectors.toMap(
                Map.Entry::getKey,
                e -> {
                  List<Long> instanceIds = new ArrayList<>();
                  for (Interval interval : e.getValue()) {
                    for (long id = interval.start; id <= interval.end; ++id) {
                      instanceIds.add(id);
                    }
                  }
                  return instanceIds;
                }));
  }
@Test
  public void testFlatten() throws Exception {
    TestDetails testDetails =
        loadObject("fixtures/instances/sample-foreach-details.json", TestDetails.class);
    Map<WorkflowInstance.Status, List<Long>> flatten = testDetails.test1.flatten(e -> true);
    assertEquals(Collections.singletonList(1L), flatten.get(WorkflowInstance.Status.CREATED));
    assertEquals(Arrays.asList(2L, 4L, 21L), flatten.get(WorkflowInstance.Status.IN_PROGRESS));
    assertEquals(Collections.singletonList(5L), flatten.get(WorkflowInstance.Status.PAUSED));
    assertEquals(Collections.singletonList(7L), flatten.get(WorkflowInstance.Status.TIMED_OUT));
    assertEquals(Collections.singletonList(6L), flatten.get(WorkflowInstance.Status.STOPPED));
    assertEquals(
        Arrays.asList(8L, 9L, 11L, 12L, 13L, 14L, 15L),
        flatten.get(WorkflowInstance.Status.FAILED));
    assertEquals(
        Arrays.asList(10L, 16L, 17L, 18L, 19L, 20L, 22L),
        flatten.get(WorkflowInstance.Status.SUCCEEDED));
  }