public RunResponse restartDirectly(
      RunResponse restartStepInfo, RunRequest runRequest, boolean blocking) {
    WorkflowInstance instance = restartStepInfo.getInstance();
    String stepId = restartStepInfo.getStepId();
    validateStepId(instance, stepId, Actions.StepInstanceAction.RESTART);
    StepInstance stepInstance =
        getStepInstanceAndValidate(instance, stepId, runRequest.getRestartConfig());
    // prepare payload and then add to db
    StepAction stepAction = StepAction.createRestart(stepInstance, runRequest);
    saveAction(stepInstance, stepAction);
    if (blocking) {
      return waitResponseWithTimeout(stepInstance, stepAction);
    } else {
      return RunResponse.from(stepInstance, stepAction.toTimelineEvent());
    }
  }
@Test
  public void testRestartDirectly() {
    stepInstance.getRuntimeState().setStatus(StepInstance.Status.FATALLY_FAILED);
    stepInstance.getStepRetry().setRetryable(false);
    ((TypedStep) stepInstance.getDefinition()).setFailureMode(FailureMode.FAIL_AFTER_RUNNING);
    stepInstanceDao.insertOrUpsertStepInstance(stepInstance, true);
    RunResponse restartStepInfo = RunResponse.builder().instance(instance).stepId("job1").build();
    RunRequest runRequest =
        RunRequest.builder()
            .requester(user)
            .currentPolicy(RunPolicy.RESTART_FROM_SPECIFIC)
            .stepRunParams(
                Collections.singletonMap(
                    "job1",
                    Collections.singletonMap(
                        "foo", ParamDefinition.buildParamDefinition("foo", "bar"))))
            .build();
    RunResponse response = actionDao.restartDirectly(restartStepInfo, runRequest, false);
    Assert.assertEquals("sample-dag-test-3", response.getWorkflowId());
    Assert.assertEquals(1, response.getWorkflowInstanceId());
    Assert.assertEquals(1, response.getWorkflowRunId());
    Assert.assertEquals("job1", response.getStepId());
    Assert.assertEquals(2L, response.getStepAttemptId().longValue());
    Assert.assertEquals(
        "User [tester] take action [RESTART] on the step",
        response.getTimelineEvent().getMessage());
  }