static JobStatus fromPb(com.google.api.services.bigquery.model.JobStatus statusPb) { List<BigQueryError> allErrors = null; if (statusPb.getErrors() != null) { allErrors = Lists.transform(statusPb.getErrors(), BigQueryError.FROM_PB_FUNCTION); } BigQueryError error = statusPb.getErrorResult() != null ? BigQueryError.fromPb(statusPb.getErrorResult()) : null; return new JobStatus(State.valueOf(statusPb.getState()), error, allErrors); } }
@Test public void testWaitForWithCheckingPeriod_Null() throws InterruptedException { initializeExpectedJob(2); BigQuery.JobOption[] expectedOptions = {BigQuery.JobOption.fields(BigQuery.JobField.STATUS)}; expect(bigquery.getOptions()).andReturn(mockOptions); expect(mockOptions.getClock()).andReturn(CurrentMillisClock.getDefaultClock()); Job runningJob = expectedJob.toBuilder().setStatus(new JobStatus(JobStatus.State.RUNNING)).build(); expect(bigquery.getJob(JOB_INFO.getJobId(), expectedOptions)).andReturn(runningJob); expect(bigquery.getJob(JOB_INFO.getJobId(), expectedOptions)).andReturn(null); replay(bigquery, mockOptions); initializeJob(); assertNull(job.waitFor(TEST_RETRY_OPTIONS)); verify(bigquery, mockOptions); }
static JobStatus fromPb(com.google.api.services.bigquery.model.JobStatus statusPb) { List<BigQueryError> allErrors = null; if (statusPb.getErrors() != null) { allErrors = Lists.transform(statusPb.getErrors(), BigQueryError.FROM_PB_FUNCTION); } BigQueryError error = statusPb.getErrorResult() != null ? BigQueryError.fromPb(statusPb.getErrorResult()) : null; return new JobStatus(State.valueOf(statusPb.getState()), error, allErrors); } }
static JobStatus fromPb(com.google.api.services.bigquery.model.JobStatus statusPb) { List<BigQueryError> allErrors = null; if (statusPb.getErrors() != null) { allErrors = Lists.transform(statusPb.getErrors(), BigQueryError.FROM_PB_FUNCTION); } BigQueryError error = statusPb.getErrorResult() != null ? BigQueryError.fromPb(statusPb.getErrorResult()) : null; return new JobStatus(State.valueOf(statusPb.getState()), error, allErrors); } }