public RunResponse restart(RunRequest runRequest, boolean blocking) {
    if (!runRequest.isFreshRun()
        && runRequest.getCurrentPolicy() != RunPolicy.RESTART_FROM_SPECIFIC) {
      updateRunRequestForRestartFromInlineRoot(runRequest);
    }

    RunResponse runResponse = actionHandler.restartRecursively(runRequest);
    if (runResponse.getStatus() == RunResponse.Status.DELEGATED) {
      return restartDirectly(runResponse, runRequest, blocking);
    }
    return runResponse;
  }
@Test
  public void testRestartNewRun() {
    when(instance.getStatus()).thenReturn(WorkflowInstance.Status.FAILED);
    when(instance.getInitiator()).thenReturn(new ManualInitiator());
    when(actionHandler.restartRecursively(any()))
        .thenReturn(RunResponse.builder().status(RunResponse.Status.WORKFLOW_RUN_CREATED).build());
    RunRequest runRequest =
        RunRequest.builder()
            .requester(user)
            .currentPolicy(RunPolicy.RESTART_FROM_SPECIFIC)
            .restartConfig(
                RestartConfig.builder().addRestartNode("sample-minimal-wf", 1, "job1").build())
            .build();
    RunResponse response = stepActionHandler.restart(runRequest, true);

    ArgumentCaptor<RunRequest> requestCaptor = ArgumentCaptor.forClass(RunRequest.class);
    Mockito.verify(actionHandler, Mockito.times(1)).restartRecursively(requestCaptor.capture());
    RunRequest request = requestCaptor.getValue();
    assertEquals(runRequest, request);
    assertEquals(RunResponse.Status.WORKFLOW_RUN_CREATED, response.getStatus());
  }