当前位置: 首页>>代码示例>>Java>>正文


Java JobReference.setProjectId方法代码示例

本文整理汇总了Java中com.google.api.services.bigquery.model.JobReference.setProjectId方法的典型用法代码示例。如果您正苦于以下问题:Java JobReference.setProjectId方法的具体用法?Java JobReference.setProjectId怎么用?Java JobReference.setProjectId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.api.services.bigquery.model.JobReference的用法示例。


在下文中一共展示了JobReference.setProjectId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testStartLoadJobSucceeds

import com.google.api.services.bigquery.model.JobReference; //导入方法依赖的package包/类
/**
 * 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));

  Sleeper sleeper = new FastNanoClockAndSleeper();
  JobServiceImpl.startJob(
      testJob, new ApiErrorExtractor(), bigquery, sleeper,
      BackOffAdapter.toGcpBackOff(FluentBackoff.DEFAULT.backoff()));

  verify(response, times(1)).getStatusCode();
  verify(response, times(1)).getContent();
  verify(response, times(1)).getContentType();
  expectedLogs.verifyInfo(String.format("Started BigQuery job: %s", jobRef));
}
 
开发者ID:apache,项目名称:beam,代码行数:26,代码来源:BigQueryServicesImplTest.java

示例2: testStartLoadJobSucceedsAlreadyExists

import com.google.api.services.bigquery.model.JobReference; //导入方法依赖的package包/类
/**
 * 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);

  when(response.getStatusCode()).thenReturn(409); // 409 means already exists

  Sleeper sleeper = new FastNanoClockAndSleeper();
  JobServiceImpl.startJob(
      testJob, new ApiErrorExtractor(), bigquery, sleeper,
      BackOffAdapter.toGcpBackOff(FluentBackoff.DEFAULT.backoff()));

  verify(response, times(1)).getStatusCode();
  verify(response, times(1)).getContent();
  verify(response, times(1)).getContentType();
  expectedLogs.verifyNotLogged("Started BigQuery job");
}
 
开发者ID:apache,项目名称:beam,代码行数:25,代码来源:BigQueryServicesImplTest.java

示例3: testStartLoadJobRetry

import com.google.api.services.bigquery.model.JobReference; //导入方法依赖的package包/类
/**
 * 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));

  Sleeper sleeper = new FastNanoClockAndSleeper();
  JobServiceImpl.startJob(
      testJob, new ApiErrorExtractor(), bigquery, sleeper,
      BackOffAdapter.toGcpBackOff(FluentBackoff.DEFAULT.backoff()));

  verify(response, times(2)).getStatusCode();
  verify(response, times(2)).getContent();
  verify(response, times(2)).getContentType();
}
 
开发者ID:apache,项目名称:beam,代码行数:28,代码来源:BigQueryServicesImplTest.java

示例4: setUp

import com.google.api.services.bigquery.model.JobReference; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException, GeneralSecurityException {
  // Generate Mocks.  
  MockitoAnnotations.initMocks(this);
  
  // Create Gson to parse Json.
  gson = new Gson();

  // Calls the .run/.call method on the future when the future is first accessed.
  executorService = Executors.newCachedThreadPool();

  // Set input parameters for testing.
  fields = BigQueryUtils.getSchemaFromString(
      "[{'name': 'Name','type': 'STRING'},{'name': 'Number','type': 'INTEGER'}]");
  jobProjectId = "test_job_project";
  outputProjectId = "test_output_project";
  tableId = "test_table";
  datasetId = "test_dataset";
  taskIdentifier = "attempt_201501292132_0016_r_000033_0";

  // Create the key, value pair.
  bigqueryKey = new LongWritable(123);
  jsonValue = new JsonObject();
  jsonValue.addProperty("Name", "test name");
  jsonValue.addProperty("Number", "123");

  // Create the job result.
  jobReference = new JobReference();
  jobReference.setProjectId(jobProjectId);
  jobReference.setJobId(taskIdentifier + "-12345");

  jobStatus = new JobStatus();
  jobStatus.setState("DONE");
  jobStatus.setErrorResult(null);

  jobReturn = new Job();
  jobReturn.setStatus(jobStatus);
  jobReturn.setJobReference(jobReference);

  // Mock BigQuery.
  when(mockFactory.getBigQueryHelper(any(Configuration.class))).thenReturn(mockBigQueryHelper);
  when(mockBigQueryHelper.getRawBigquery()).thenReturn(mockBigQuery);
  when(mockBigQuery.jobs()).thenReturn(mockBigQueryJobs);
  when(mockBigQueryJobs.get(any(String.class), any(String.class)))
      .thenReturn(mockJobsGet);
  when(mockJobsGet.execute()).thenReturn(jobReturn);

  when(mockBigQueryJobs.insert(
      any(String.class), any(Job.class), any(ByteArrayContent.class)))
      .thenReturn(mockInsert);
  when(mockInsert.setProjectId(any(String.class))).thenReturn(mockInsert);

  when(mockClientRequestHelper.getRequestHeaders(any(Insert.class)))
      .thenReturn(mockHeaders);

  // Mock context result
  when(mockContext.getConfiguration()).thenReturn(
      CredentialConfigurationUtil.getTestConfiguration());
}
 
开发者ID:GoogleCloudPlatform,项目名称:bigdata-interop,代码行数:60,代码来源:BigQueryRecordWriterTest.java

示例5: setUp

import com.google.api.services.bigquery.model.JobReference; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
  MockitoAnnotations.initMocks(this);
  Logger.getLogger(GsonBigQueryInputFormat.class).setLevel(Level.DEBUG);

  // Create fake job reference.
  JobReference fakeJobReference = new JobReference();
  fakeJobReference.setProjectId(jobProjectId);
  fakeJobReference.setJobId(jobId);

  // Create the job result.
  jobStatus = new JobStatus();
  jobStatus.setState("DONE");
  jobStatus.setErrorResult(null);

  jobHandle = new Job();
  jobHandle.setStatus(jobStatus);
  jobHandle.setJobReference(fakeJobReference);

  // Mocks for Bigquery jobs.
  when(mockBigquery.jobs()).thenReturn(mockBigqueryJobs);

  // Mock getting Bigquery job.
  when(mockBigqueryJobs.get(any(String.class), any(String.class)))
      .thenReturn(mockBigqueryJobsGet);

  // Mock inserting Bigquery job.
  when(mockBigqueryJobs.insert(any(String.class), any(Job.class)))
      .thenReturn(mockBigqueryJobsInsert);

  // Fake table.
  fakeTableSchema = new TableSchema();
  fakeTable = new Table().setSchema(fakeTableSchema);

  // Mocks for Bigquery tables.
  when(mockBigquery.tables()).thenReturn(mockBigqueryTables);

  // Mocks for getting Bigquery table.
  when(mockBigqueryTables.get(any(String.class), any(String.class), any(String.class)))
      .thenReturn(mockBigqueryTablesGet);

  // Create table reference.
  tableRef = new TableReference();
  tableRef.setProjectId(projectId);
  tableRef.setDatasetId(datasetId);
  tableRef.setTableId(tableId);

  helper = new BigQueryHelper(mockBigquery);
  helper.setErrorExtractor(mockErrorExtractor);
}
 
开发者ID:GoogleCloudPlatform,项目名称:bigdata-interop,代码行数:51,代码来源:BigQueryHelperTest.java


注:本文中的com.google.api.services.bigquery.model.JobReference.setProjectId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。