@SuppressWarnings("rawtypes")
  public Result waitUntilDone(Config config) {
    return finishOrTimeout(
        config,
        new Supplier[] {() -> false},
        () -> jobIsDone(config.project(), config.region(), config.jobId()));
  }
@Test
  public void testWaitUntilDone() throws IOException {
    // Arrange
    when(client.getJobStatus(any(), any(), any()))
        .thenReturn(JobState.QUEUED)
        .thenReturn(JobState.RUNNING)
        .thenReturn(JobState.CANCELLING)
        .thenReturn(JobState.CANCELLED);

    // Act
    Result result = new PipelineOperator(client).waitUntilDone(DEFAULT_CONFIG);

    // Assert
    verify(client, times(4))
        .getJobStatus(projectCaptor.capture(), regionCaptor.capture(), jobIdCaptor.capture());

    Set<String> allProjects = new HashSet<>(projectCaptor.getAllValues());
    Set<String> allRegions = new HashSet<>(regionCaptor.getAllValues());
    Set<String> allJobIds = new HashSet<>(jobIdCaptor.getAllValues());

    assertThat(allProjects).containsExactly(PROJECT);
    assertThat(allRegions).containsExactly(REGION);
    assertThat(allJobIds).containsExactly(JOB_ID);
    assertThat(result).isEqualTo(Result.LAUNCH_FINISHED);
  }