public Stream<WorkflowInstanceStatusChangeEvent> toMaestroEventStream(String clusterName) {
    return changeRecords.stream()
        .map(
            changeRecord ->
                WorkflowInstanceStatusChangeEvent.builder()
                    .workflowId(workflowId)
                    .workflowName(workflowName)
                    .workflowInstanceId(changeRecord.workflowInstanceId)
                    .workflowRunId(changeRecord.workflowRunId)
                    .workflowUuid(changeRecord.workflowUuid)
                    .correlationId(changeRecord.correlationId)
                    .depth(changeRecord.depth)
                    .clusterName(clusterName)
                    .tags(changeRecord.tags)
                    .oldStatus(changeRecord.oldStatus)
                    .newStatus(changeRecord.newStatus)
                    .eventTime(changeRecord.eventTime)
                    .syncTime(syncTime)
                    .sendTime(System.currentTimeMillis())
                    .build());
  }
@Test
  public void testToMaestroEventStream() throws Exception {
    WorkflowInstanceUpdateJobEvent sampleEvent =
        loadObject(
            "fixtures/jobevents/sample-workflow-instance-job-event.json",
            WorkflowInstanceUpdateJobEvent.class);
    List<WorkflowInstanceStatusChangeEvent> res =
        sampleEvent.toMaestroEventStream("test-cluster").collect(Collectors.toList());
    assertEquals(2, res.size());
    assertEquals("sample-dag-test-3", res.get(0).getWorkflowId());
    assertEquals(1L, res.get(0).getWorkflowInstanceId());
    assertEquals(1, res.get(0).getDepth());
    assertEquals("sample-dag-test-3", res.get(1).getWorkflowId());
    assertEquals(2L, res.get(1).getWorkflowInstanceId());
    assertEquals(0, res.get(1).getDepth());
  }