public void markTerminated(
      StepInstance.Status terminalStatus, MaestroTracingManager tracingManager) {
    Checks.checkTrue(
        terminalStatus.isTerminal(),
        "Cannot terminate step %s to a non-terminal state [%s]",
        getIdentity(),
        terminalStatus);
    if (terminalStatus.isRestartable()) {
      stepRetry.setRetryable(false);
    }
    runtimeState.setEndTime(updateStatus(terminalStatus, tracingManager));
    dbOperation = DbOperation.UPSERT; // last db ops to upsert everything
  }
@Test
  public void testInvalidTerminate() throws Exception {
    StepRuntimeSummary summary =
        loadObject(
            "fixtures/execution/sample-step-runtime-summary-1.json", StepRuntimeSummary.class);
    AssertHelper.assertThrows(
        "Cannot terminate the step",
        IllegalArgumentException.class,
        "Cannot terminate step [foo][2][bar] to a non-terminal state [RUNNING]",
        () -> summary.markTerminated(StepInstance.Status.RUNNING, null));
  }