@Test
public void shouldPollPodStatusAndEmitEvents() throws Exception {

  // Change the pod status to terminated without notifying the runner through the pod watcher
  final Pod terminatedPod = new PodBuilder(createdPod)
      .withStatus(terminated("Succeeded", 20, null))
      .build();
  when(k8sClient.getPod(POD_NAME)).thenReturn(Optional.of(terminatedPod));
  // Poll for execution status
  var stateData = StateData.newBuilder().executionId(POD_NAME).build();
  var runState = RunState.create(WORKFLOW_INSTANCE, State.SUBMITTED, stateData);
  kdr.poll(runState);
  // Verify that the runner found out that the pod is terminated and emits events
  verify(stateManager, atLeastOnce()).receive(
      Event.started(WORKFLOW_INSTANCE),
      -1);
  verify(stateManager, atLeastOnce()).receive(
      Event.terminate(WORKFLOW_INSTANCE, Optional.of(20)),
      0);
}