Here are the examples of the java api class com.google.api.services.bigquery.model.JobConfigurationLoad taken from open source projects.
1. BigQueryServicesImplTest#testStartLoadJobSucceedsAlreadyExists()
View license/** * Tests that {@link BigQueryServicesImpl.JobServiceImpl#startLoadJob} succeeds * with an already exist job. */ @Test public void testStartLoadJobSucceedsAlreadyExists() throws IOException, InterruptedException { Job testJob = new Job(); JobReference jobRef = new JobReference(); jobRef.setJobId("jobId"); jobRef.setProjectId("projectId"); testJob.setJobReference(jobRef); // 409 means already exists when(response.getStatusCode()).thenReturn(409); TableReference ref = new TableReference(); ref.setProjectId("projectId"); JobConfigurationLoad loadConfig = new JobConfigurationLoad(); loadConfig.setDestinationTable(ref); Sleeper sleeper = new FastNanoClockAndSleeper(); BackOff backoff = new AttemptBoundedExponentialBackOff(5, /* attempts */ 1000); JobServiceImpl.startJob(testJob, new ApiErrorExtractor(), bigquery, sleeper, backoff); verify(response, times(1)).getStatusCode(); verify(response, times(1)).getContent(); verify(response, times(1)).getContentType(); }
2. BigQueryServicesImplTest#testStartLoadJobSucceedsAlreadyExists()
View license/** * Tests that {@link BigQueryServicesImpl.JobServiceImpl#startLoadJob} succeeds * with an already exist job. */ @Test public void testStartLoadJobSucceedsAlreadyExists() throws IOException, InterruptedException { Job testJob = new Job(); JobReference jobRef = new JobReference(); jobRef.setJobId("jobId"); jobRef.setProjectId("projectId"); testJob.setJobReference(jobRef); // 409 means already exists when(response.getStatusCode()).thenReturn(409); TableReference ref = new TableReference(); ref.setProjectId("projectId"); JobConfigurationLoad loadConfig = new JobConfigurationLoad(); loadConfig.setDestinationTable(ref); Sleeper sleeper = new FastNanoClockAndSleeper(); BackOff backoff = new AttemptBoundedExponentialBackOff(5, /* attempts */ 1000); JobServiceImpl.startJob(testJob, new ApiErrorExtractor(), bigquery, sleeper, backoff); verify(response, times(1)).getStatusCode(); verify(response, times(1)).getContent(); verify(response, times(1)).getContentType(); }
3. LoadJobConfiguration#toPb()
View license@Override com.google.api.services.bigquery.model.JobConfiguration toPb() { JobConfigurationLoad loadConfigurationPb = new JobConfigurationLoad(); loadConfigurationPb.setDestinationTable(destinationTable.toPb()); if (createDisposition != null) { loadConfigurationPb.setCreateDisposition(createDisposition.toString()); } if (writeDisposition != null) { loadConfigurationPb.setWriteDisposition(writeDisposition.toString()); } if (csvOptions() != null) { CsvOptions csvOptions = csvOptions(); loadConfigurationPb.setFieldDelimiter(csvOptions.fieldDelimiter()).setAllowJaggedRows(csvOptions.allowJaggedRows()).setAllowQuotedNewlines(csvOptions.allowQuotedNewLines()).setEncoding(csvOptions.encoding()).setQuote(csvOptions.quote()); if (csvOptions.skipLeadingRows() != null) { // todo(mziccard) remove checked cast or comment when #1044 is closed loadConfigurationPb.setSkipLeadingRows(Ints.checkedCast(csvOptions.skipLeadingRows())); } } if (schema != null) { loadConfigurationPb.setSchema(schema.toPb()); } if (formatOptions != null) { loadConfigurationPb.setSourceFormat(formatOptions.type()); } loadConfigurationPb.setMaxBadRecords(maxBadRecords); loadConfigurationPb.setIgnoreUnknownValues(ignoreUnknownValues); loadConfigurationPb.setProjectionFields(projectionFields); if (sourceUris != null) { loadConfigurationPb.setSourceUris(ImmutableList.copyOf(sourceUris)); } return new com.google.api.services.bigquery.model.JobConfiguration().setLoad(loadConfigurationPb); }
4. WriteChannelConfiguration#toPb()
View licensecom.google.api.services.bigquery.model.JobConfiguration toPb() { JobConfigurationLoad loadConfigurationPb = new JobConfigurationLoad(); loadConfigurationPb.setDestinationTable(destinationTable.toPb()); if (createDisposition != null) { loadConfigurationPb.setCreateDisposition(createDisposition.toString()); } if (writeDisposition != null) { loadConfigurationPb.setWriteDisposition(writeDisposition.toString()); } if (csvOptions() != null) { CsvOptions csvOptions = csvOptions(); loadConfigurationPb.setFieldDelimiter(csvOptions.fieldDelimiter()).setAllowJaggedRows(csvOptions.allowJaggedRows()).setAllowQuotedNewlines(csvOptions.allowQuotedNewLines()).setEncoding(csvOptions.encoding()).setQuote(csvOptions.quote()); if (csvOptions.skipLeadingRows() != null) { // todo(mziccard) remove checked cast or comment when #1044 is closed loadConfigurationPb.setSkipLeadingRows(Ints.checkedCast(csvOptions.skipLeadingRows())); } } if (schema != null) { loadConfigurationPb.setSchema(schema.toPb()); } if (formatOptions != null) { loadConfigurationPb.setSourceFormat(formatOptions.type()); } loadConfigurationPb.setMaxBadRecords(maxBadRecords); loadConfigurationPb.setIgnoreUnknownValues(ignoreUnknownValues); loadConfigurationPb.setProjectionFields(projectionFields); return new com.google.api.services.bigquery.model.JobConfiguration().setLoad(loadConfigurationPb); }
5. BigQueryServicesImplTest#testStartLoadJobSucceeds()
View license/** * Tests that {@link BigQueryServicesImpl.JobServiceImpl#startLoadJob} succeeds. */ @Test public void testStartLoadJobSucceeds() throws IOException, InterruptedException { Job testJob = new Job(); JobReference jobRef = new JobReference(); jobRef.setJobId("jobId"); jobRef.setProjectId("projectId"); testJob.setJobReference(jobRef); when(response.getContentType()).thenReturn(Json.MEDIA_TYPE); when(response.getStatusCode()).thenReturn(200); when(response.getContent()).thenReturn(toStream(testJob)); TableReference ref = new TableReference(); ref.setProjectId("projectId"); JobConfigurationLoad loadConfig = new JobConfigurationLoad(); loadConfig.setDestinationTable(ref); Sleeper sleeper = new FastNanoClockAndSleeper(); BackOff backoff = new AttemptBoundedExponentialBackOff(5, /* attempts */ 1000); JobServiceImpl.startJob(testJob, new ApiErrorExtractor(), bigquery, sleeper, backoff); verify(response, times(1)).getStatusCode(); verify(response, times(1)).getContent(); verify(response, times(1)).getContentType(); }
6. BigQueryServicesImplTest#testStartLoadJobRetry()
View license/** * Tests that {@link BigQueryServicesImpl.JobServiceImpl#startLoadJob} succeeds with a retry. */ @Test public void testStartLoadJobRetry() throws IOException, InterruptedException { Job testJob = new Job(); JobReference jobRef = new JobReference(); jobRef.setJobId("jobId"); jobRef.setProjectId("projectId"); testJob.setJobReference(jobRef); // First response is 403 rate limited, second response has valid payload. when(response.getContentType()).thenReturn(Json.MEDIA_TYPE); when(response.getStatusCode()).thenReturn(403).thenReturn(200); when(response.getContent()).thenReturn(toStream(errorWithReasonAndStatus("rateLimitExceeded", 403))).thenReturn(toStream(testJob)); TableReference ref = new TableReference(); ref.setProjectId("projectId"); JobConfigurationLoad loadConfig = new JobConfigurationLoad(); loadConfig.setDestinationTable(ref); Sleeper sleeper = new FastNanoClockAndSleeper(); BackOff backoff = new AttemptBoundedExponentialBackOff(5, /* attempts */ 1000); JobServiceImpl.startJob(testJob, new ApiErrorExtractor(), bigquery, sleeper, backoff); verify(response, times(2)).getStatusCode(); verify(response, times(2)).getContent(); verify(response, times(2)).getContentType(); }
7. BigQueryServicesImplTest#testStartLoadJobSucceeds()
View license/** * Tests that {@link BigQueryServicesImpl.JobServiceImpl#startLoadJob} succeeds. */ @Test public void testStartLoadJobSucceeds() throws IOException, InterruptedException { Job testJob = new Job(); JobReference jobRef = new JobReference(); jobRef.setJobId("jobId"); jobRef.setProjectId("projectId"); testJob.setJobReference(jobRef); when(response.getContentType()).thenReturn(Json.MEDIA_TYPE); when(response.getStatusCode()).thenReturn(200); when(response.getContent()).thenReturn(toStream(testJob)); TableReference ref = new TableReference(); ref.setProjectId("projectId"); JobConfigurationLoad loadConfig = new JobConfigurationLoad(); loadConfig.setDestinationTable(ref); Sleeper sleeper = new FastNanoClockAndSleeper(); BackOff backoff = new AttemptBoundedExponentialBackOff(5, /* attempts */ 1000); JobServiceImpl.startJob(testJob, new ApiErrorExtractor(), bigquery, sleeper, backoff); verify(response, times(1)).getStatusCode(); verify(response, times(1)).getContent(); verify(response, times(1)).getContentType(); }
8. BigQueryServicesImplTest#testStartLoadJobRetry()
View license/** * Tests that {@link BigQueryServicesImpl.JobServiceImpl#startLoadJob} succeeds with a retry. */ @Test public void testStartLoadJobRetry() throws IOException, InterruptedException { Job testJob = new Job(); JobReference jobRef = new JobReference(); jobRef.setJobId("jobId"); jobRef.setProjectId("projectId"); testJob.setJobReference(jobRef); // First response is 403 rate limited, second response has valid payload. when(response.getContentType()).thenReturn(Json.MEDIA_TYPE); when(response.getStatusCode()).thenReturn(403).thenReturn(200); when(response.getContent()).thenReturn(toStream(errorWithReasonAndStatus("rateLimitExceeded", 403))).thenReturn(toStream(testJob)); TableReference ref = new TableReference(); ref.setProjectId("projectId"); JobConfigurationLoad loadConfig = new JobConfigurationLoad(); loadConfig.setDestinationTable(ref); Sleeper sleeper = new FastNanoClockAndSleeper(); BackOff backoff = new AttemptBoundedExponentialBackOff(5, /* attempts */ 1000); JobServiceImpl.startJob(testJob, new ApiErrorExtractor(), bigquery, sleeper, backoff); verify(response, times(2)).getStatusCode(); verify(response, times(2)).getContent(); verify(response, times(2)).getContentType(); }