@Test
public void shouldNotCleanupRunningPodWithoutRunStateIfTerminatedAfterRefresh() {

  final ContainerStatus runningMainContainer = new ContainerStatusBuilder()
      .withName(MAIN_CONTAINER_NAME)
      .withNewState().withNewRunning().endRunning().endState()
      .build();
  final ContainerStatus terminatedMainContainer = new ContainerStatusBuilder()
      .withName(MAIN_CONTAINER_NAME)
      .withNewState()
      .withNewTerminated()
      .withFinishedAt(FIXED_INSTANT.minus(Duration.ofDays(1)).toString())
      .endTerminated()
      .endState()
      .build();
  createdPod.setStatus(new PodStatusBuilder()
      .withContainerStatuses(runningMainContainer, keepaliveContainerStatus)
      .build());
  final Pod refreshedPod = new PodBuilder(createdPod)
      .withStatus(new PodStatusBuilder()
          .withContainerStatuses(terminatedMainContainer, keepaliveContainerStatus)
          .build())
      .build();
  // Return terminated container when refreshing by name
  when(k8sClient.getPod(POD_NAME)).thenReturn(Optional.of(refreshedPod));
  var shouldDelete = kdr.shouldDeletePodWithoutRunState(WORKFLOW_INSTANCE, createdPod);
  // Leave the pod to expire and be deleted by a later poll tick
  assertThat(shouldDelete, is(false));
}