@Override
  public State waitUntilFinish(Duration duration) {
    State state = delegate.waitUntilFinish(duration);
    this.terminalMetrics = delegate.metrics();
    this.terminalState = state;
    this.cancel.run();
    return state;
  }
@Test
  public void givenTerminated_waitUntilFinishIsNoop_reportsTerminalState() {
    PipelineResult delegate = mock(PipelineResult.class);
    when(delegate.waitUntilFinish()).thenReturn(PipelineResult.State.DONE);
    PrismPipelineResult underTest = new PrismPipelineResult(delegate, exec::stop);
    // Terminate Job as setup for additional call.
    underTest.waitUntilFinish();
    assertThat(underTest.waitUntilFinish()).isEqualTo(PipelineResult.State.DONE);
  }