@JsonIgnore
  public StepInstance.Status getTerminalStatus(String wfId, long instanceId) {
    Checks.checkTrue(
        action.isUsingUpstream(),
        "[%s][%s] cannot getTerminalStatus for action [%s], which does not support upstream mode",
        wfId,
        instanceId,
        this);
    if (Objects.equals(workflowId, wfId) && workflowInstanceId == instanceId) {
      return action.getStatus();
    }
    return StepInstance.Status.STOPPED;
  }
@Test
  public void testGetTerminalStatus() {
    StepAction action =
        StepAction.builder()
            .workflowId("sample-dag-test-3")
            .workflowInstanceId(1)
            .stepId("job1")
            .action(Actions.StepInstanceAction.STOP)
            .build();
    assertEquals(StepInstance.Status.STOPPED, action.getTerminalStatus("sample-dag-test-3", 1));
    assertEquals(StepInstance.Status.STOPPED, action.getTerminalStatus("downstream-wf", 2));
    action =
        StepAction.builder()
            .workflowId("sample-dag-test-3")
            .workflowInstanceId(1)
            .stepId("job1")
            .action(Actions.StepInstanceAction.KILL)
            .build();
    assertEquals(
        StepInstance.Status.FATALLY_FAILED, action.getTerminalStatus("sample-dag-test-3", 1));
    assertEquals(StepInstance.Status.STOPPED, action.getTerminalStatus("downstream-wf", 2));
    action =
        StepAction.builder()
            .workflowId("sample-dag-test-3")
            .workflowInstanceId(1)
            .stepId("job1")
            .action(Actions.StepInstanceAction.SKIP)
            .build();
    assertEquals(StepInstance.Status.SKIPPED, action.getTerminalStatus("sample-dag-test-3", 1));
    assertEquals(StepInstance.Status.STOPPED, action.getTerminalStatus("downstream-wf", 2));

    StepAction invalidAction =
        StepAction.builder()
            .workflowId("sample-dag-test-3")
            .workflowInstanceId(1)
            .stepId("job1")
            .action(Actions.StepInstanceAction.PAUSE)
            .build();
    AssertHelper.assertThrows(
        "Cannot call getTerminalStatus for non-termination actions",
        IllegalArgumentException.class,
        "[sample-dag-test-3][1] cannot getTerminalStatus for action",
        () -> invalidAction.getTerminalStatus("sample-dag-test-3", 1));
  }