public static WorkflowInstanceAggregatedInfo computeAggregatedView(
      WorkflowInstance workflowInstance, boolean statusKnown) {
    if (workflowInstance == null) {
      // returning empty object since cannot access state of the current instance run
      return new WorkflowInstanceAggregatedInfo();
    }

    WorkflowInstanceAggregatedInfo instanceAggregated =
        computeAggregatedViewNoStatus(workflowInstance);
    if (statusKnown || workflowInstance.getAggregatedInfo() == null) {
      instanceAggregated.setWorkflowInstanceStatus(workflowInstance.getStatus());
    } else {
      computeAndSetAggregatedInstanceStatus(workflowInstance, instanceAggregated);
    }
    return instanceAggregated;
  }
@Test
  public void testComputeAggregatedViewWithoutRuntimeOverview() {
    WorkflowInstance instance =
        getGenericWorkflowInstance(
            2,
            WorkflowInstance.Status.STOPPED,
            RunPolicy.RESTART_FROM_BEGINNING,
            RestartPolicy.RESTART_FROM_BEGINNING);
    instance.setAggregatedInfo(new WorkflowInstanceAggregatedInfo());
    instance.getAggregatedInfo().setStepAggregatedViews(Collections.emptyMap());
    instance.getAggregatedInfo().setWorkflowInstanceStatus(WorkflowInstance.Status.SUCCEEDED);

    Workflow runtimeWorkflow = mock(Workflow.class);
    instance.setRuntimeWorkflow(runtimeWorkflow);
    Step step1 = mock(Step.class);
    when(step1.getId()).thenReturn("step1");
    Step step2 = mock(Step.class);
    when(step2.getId()).thenReturn("step2");
    Step step3 = mock(Step.class);
    when(step3.getId()).thenReturn("step3");
    when(runtimeWorkflow.getSteps()).thenReturn(Arrays.asList(step1, step2, step3));

    WorkflowInstanceAggregatedInfo aggregated =
        AggregatedViewHelper.computeAggregatedView(instance, true);

    assertEquals(
        StepInstance.Status.NOT_CREATED,
        aggregated.getStepAggregatedViews().get("step1").getStatus());
    assertEquals(
        StepInstance.Status.NOT_CREATED,
        aggregated.getStepAggregatedViews().get("step2").getStatus());
    assertEquals(
        StepInstance.Status.NOT_CREATED,
        aggregated.getStepAggregatedViews().get("step3").getStatus());
    assertEquals(WorkflowInstance.Status.STOPPED, aggregated.getWorkflowInstanceStatus());
  }