@VisibleForTesting
  void updateRetryDelayTimeToTimeline(StepRuntimeSummary runtimeSummary) {
    StepInstance.Status status = runtimeSummary.getRuntimeState().getStatus();
    if (status == StepInstance.Status.USER_FAILED
        || status == StepInstance.Status.PLATFORM_FAILED
        || status == StepInstance.Status.TIMEOUT_FAILED) {
      int nextRetryDelayInSecs =
          runtimeSummary
              .getStepRetry()
              .getNextRetryDelay(runtimeSummary.getRuntimeState().getStatus());
      String humanReadableRetryTime =
          DurationHelper.humanReadableFormat(Duration.ofSeconds(nextRetryDelayInSecs));
      runtimeSummary.addTimeline(
          TimelineLogEvent.info("Retrying task in [%s]", humanReadableRetryTime));
    }
  }
@Test
  public void testUpdateRetryDelayTimeToTimeline() {
    StepRuntimeState runtimeState = new StepRuntimeState();
    runtimeState.setStatus(StepInstance.Status.USER_FAILED);
    Timeline timeline = new Timeline(new ArrayList<>());
    StepInstance.StepRetry stepRetry = new StepInstance.StepRetry();
    stepRetry.setRetryable(true);
    RetryPolicy.FixedBackoff fixedBackoff =
        RetryPolicy.FixedBackoff.builder()
            .errorRetryBackoffInSecs(100L)
            .platformRetryBackoffInSecs(200L)
            .build();
    stepRetry.setBackoff(fixedBackoff);
    StepRuntimeSummary runtimeSummary =
        StepRuntimeSummary.builder()
            .timeline(timeline)
            .runtimeState(runtimeState)
            .stepRetry(stepRetry)
            .build();

    maestroTask.updateRetryDelayTimeToTimeline(runtimeSummary);
    List<TimelineEvent> timelineEvents = timeline.getTimelineEvents();
    assertThat(timelineEvents)
        .hasSize(1)
        .usingRecursiveFieldByFieldElementComparatorIgnoringFields("timestamp")
        .contains(TimelineLogEvent.info("Retrying task in [1m 40s]"));

    RetryPolicy.ExponentialBackoff exponentialBackoff =
        RetryPolicy.ExponentialBackoff.builder()
            .errorRetryExponent(2)
            .errorRetryLimitInSecs(600L)
            .errorRetryBackoffInSecs(100L)
            .platformRetryBackoffInSecs(200L)
            .build();
    stepRetry.setBackoff(exponentialBackoff);
    stepRetry.setErrorRetries(6);
    timelineEvents.clear();
    maestroTask.updateRetryDelayTimeToTimeline(runtimeSummary);
    assertThat(timelineEvents)
        .hasSize(1)
        .usingRecursiveFieldByFieldElementComparatorIgnoringFields("timestamp")
        .contains(TimelineLogEvent.info("Retrying task in [10m]"));

    timelineEvents.clear();
    runtimeState.setStatus(StepInstance.Status.PAUSED);
    maestroTask.updateRetryDelayTimeToTimeline(runtimeSummary);
    assertThat(timelineEvents).isEmpty();
  }