@SuppressWarnings({"PMD.AvoidInstantiatingObjectsInLoops"})
  @JsonIgnore
  public WorkflowRollupOverview aggregate(WorkflowRollupOverview rollup) {
    if (rollup == null) {
      return this;
    }
    this.totalLeafCount += rollup.totalLeafCount;
    if (rollup.overview == null) {
      return this;
    }

    if (this.overview == null) {
      this.overview = new EnumMap<>(StepInstance.Status.class);
    }
    for (Map.Entry<StepInstance.Status, CountReference> entry : rollup.overview.entrySet()) {
      if (!this.overview.containsKey(entry.getKey())) {
        this.overview.put(entry.getKey(), new CountReference());
      }
      this.overview.get(entry.getKey()).aggregate(entry.getValue());
    }
    return this;
  }
@Test
  public void testAggregate() throws Exception {
    WorkflowRollupOverview overview =
        loadObject(
            "fixtures/instances/sample-workflow-rollup-overview.json",
            WorkflowRollupOverview.class);

    WorkflowRollupOverview.CountReference ref1 = new WorkflowRollupOverview.CountReference();
    ref1.setCnt(1);
    WorkflowRollupOverview.CountReference ref2 = new WorkflowRollupOverview.CountReference();
    ref2.setCnt(1);
    ref2.setRef(
        Collections.singletonMap("maestro_foreach_123", Collections.singletonList("123:job1:1")));
    Map<StepInstance.Status, WorkflowRollupOverview.CountReference> newOverview = new HashMap<>();
    newOverview.put(StepInstance.Status.CREATED, ref1);
    newOverview.put(StepInstance.Status.RUNNING, ref2);

    WorkflowRollupOverview actual = overview.aggregate(WorkflowRollupOverview.of(2, newOverview));

    assertEquals(10081, actual.getTotalLeafCount());
    assertEquals(ref1, actual.getOverview().get(StepInstance.Status.CREATED));
    assertEquals(28, actual.getOverview().get(StepInstance.Status.RUNNING).getCnt());
    assertEquals(
        Collections.singletonList("123:job1:1"),
        actual.getOverview().get(StepInstance.Status.RUNNING).getRef().get("maestro_foreach_123"));
  }