public static Map<String, Task> getUserDefinedRealTaskMap(Workflow workflow) {
    return workflow.getTasks().stream()
        .filter(TaskHelper::isUserDefinedRealTask)
        .collect(
            Collectors.toMap(
                Task::getReferenceTaskName,
                Function.identity(),
                // it includes retried tasks so pick the last one
                (task1, task2) -> task2));
  }
@Test
  public void testGetUserDefinedRealTaskMap() {
    when(workflow.getTasks()).thenReturn(Collections.singletonList(task));
    when(task.getTaskType()).thenReturn(Constants.MAESTRO_TASK_NAME);
    when(task.getReferenceTaskName()).thenReturn("test-job");
    Assert.assertEquals(
        Collections.singletonMap("test-job", task), TaskHelper.getUserDefinedRealTaskMap(workflow));
    when(task.getSeq()).thenReturn(-1);
    Assert.assertEquals(Collections.emptyMap(), TaskHelper.getUserDefinedRealTaskMap(workflow));
  }