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


Java Job.setId方法代码示例

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


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

示例1: buildMockDataflow

import com.google.api.services.dataflow.model.Job; //导入方法依赖的package包/类
private static Dataflow buildMockDataflow(
    ArgumentMatcher<Job> jobMatcher) throws IOException {
  Dataflow mockDataflowClient = mock(Dataflow.class);
  Dataflow.Projects mockProjects = mock(Dataflow.Projects.class);
  Dataflow.Projects.Jobs mockJobs = mock(Dataflow.Projects.Jobs.class);
  Dataflow.Projects.Jobs.Create mockRequest = mock(
      Dataflow.Projects.Jobs.Create.class);

  when(mockDataflowClient.projects()).thenReturn(mockProjects);
  when(mockProjects.jobs()).thenReturn(mockJobs);
  when(mockJobs.create(eq("someProject"), argThat(jobMatcher)))
      .thenReturn(mockRequest);

  Job resultJob = new Job();
  resultJob.setId("newid");
  when(mockRequest.execute()).thenReturn(resultJob);
  return mockDataflowClient;
}
 
开发者ID:apache,项目名称:beam,代码行数:19,代码来源:DataflowPipelineTranslatorTest.java

示例2: testCancelUnterminatedJobThatSucceeds

import com.google.api.services.dataflow.model.Job; //导入方法依赖的package包/类
@Test
public void testCancelUnterminatedJobThatSucceeds() throws IOException {
  Dataflow.Projects.Locations.Jobs.Update update =
      mock(Dataflow.Projects.Locations.Jobs.Update.class);
  when(mockJobs.update(eq(PROJECT_ID), eq(REGION_ID), eq(JOB_ID), any(Job.class)))
      .thenReturn(update);
  when(update.execute()).thenReturn(new Job().setCurrentState("JOB_STATE_CANCELLED"));

  DataflowPipelineJob job =
      new DataflowPipelineJob(DataflowClient.create(options), JOB_ID, options, null);

  assertEquals(State.CANCELLED, job.cancel());
  Job content = new Job();
  content.setProjectId(PROJECT_ID);
  content.setId(JOB_ID);
  content.setRequestedState("JOB_STATE_CANCELLED");
  verify(mockJobs).update(eq(PROJECT_ID), eq(REGION_ID), eq(JOB_ID), eq(content));
  verifyNoMoreInteractions(mockJobs);
}
 
开发者ID:apache,项目名称:beam,代码行数:20,代码来源:DataflowPipelineJobTest.java

示例3: testRunReturnDifferentRequestId

import com.google.api.services.dataflow.model.Job; //导入方法依赖的package包/类
@Test
public void testRunReturnDifferentRequestId() throws IOException {
  DataflowPipelineOptions options = buildPipelineOptions();
  Dataflow mockDataflowClient = options.getDataflowClient();
  Dataflow.Projects.Locations.Jobs.Create mockRequest = mock(
      Dataflow.Projects.Locations.Jobs.Create.class);
  when(mockDataflowClient.projects().locations().jobs()
      .create(eq(PROJECT_ID), eq(REGION_ID), any(Job.class)))
      .thenReturn(mockRequest);
  Job resultJob = new Job();
  resultJob.setId("newid");
  // Return a different request id.
  resultJob.setClientRequestId("different_request_id");
  when(mockRequest.execute()).thenReturn(resultJob);

  Pipeline p = buildDataflowPipeline(options);
  try {
    p.run();
    fail("Expected DataflowJobAlreadyExistsException");
  } catch (DataflowJobAlreadyExistsException expected) {
    assertThat(expected.getMessage(),
        containsString("If you want to submit a second job, try again by setting a "
            + "different name using --jobName."));
    assertEquals(expected.getJob().getJobId(), resultJob.getId());
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:27,代码来源:DataflowRunnerTest.java

示例4: setUp

import com.google.api.services.dataflow.model.Job; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
  dataflow = mock(Dataflow.class);
  projects = mock(Projects.class);
  templates = mock(Templates.class);
  launch = mock(Launch.class);
  when(dataflow.projects()).thenReturn(projects);
  when(projects.templates()).thenReturn(templates);
  when(templates.launch(any(String.class), any(LaunchTemplateParameters.class)))
      .thenReturn(launch);
  when(launch.setGcsPath(any(String.class))).thenReturn(launch);

  response = new FakeResponse();
  Job job = new Job();
  job.setId("12345");
  when(launch.execute()).thenReturn(new LaunchTemplateResponse().setJob(job));

  action = new GenerateInvoicesAction(
      "test-project", "gs://test-project-beam", new YearMonth(2017, 10), dataflow, response);
}
 
开发者ID:google,项目名称:nomulus,代码行数:21,代码来源:GenerateInvoicesActionTest.java

示例5: testCancelTerminatedJob

import com.google.api.services.dataflow.model.Job; //导入方法依赖的package包/类
@Test
public void testCancelTerminatedJob() throws IOException {
  Dataflow.Projects.Locations.Jobs.Get statusRequest = mock(
      Dataflow.Projects.Locations.Jobs.Get.class);

  Job statusResponse = new Job();
  statusResponse.setCurrentState("JOB_STATE_FAILED");
  when(mockJobs.get(PROJECT_ID, REGION_ID, JOB_ID)).thenReturn(statusRequest);
  when(statusRequest.execute()).thenReturn(statusResponse);

  Dataflow.Projects.Locations.Jobs.Update update = mock(
      Dataflow.Projects.Locations.Jobs.Update.class);
  when(mockJobs.update(eq(PROJECT_ID), eq(REGION_ID), eq(JOB_ID), any(Job.class)))
      .thenReturn(update);
  when(update.execute()).thenThrow(new IOException());

  DataflowPipelineJob job =
      new DataflowPipelineJob(DataflowClient.create(options), JOB_ID, options, null);

  assertEquals(State.FAILED, job.cancel());
  Job content = new Job();
  content.setProjectId(PROJECT_ID);
  content.setId(JOB_ID);
  content.setRequestedState("JOB_STATE_CANCELLED");
  verify(mockJobs).update(eq(PROJECT_ID), eq(REGION_ID), eq(JOB_ID), eq(content));
  verify(mockJobs).get(PROJECT_ID, REGION_ID, JOB_ID);
  verifyNoMoreInteractions(mockJobs);
}
 
开发者ID:apache,项目名称:beam,代码行数:29,代码来源:DataflowPipelineJobTest.java

示例6: buildMockDataflow

import com.google.api.services.dataflow.model.Job; //导入方法依赖的package包/类
private Dataflow buildMockDataflow() throws IOException {
  Dataflow mockDataflowClient = mock(Dataflow.class);
  Dataflow.Projects mockProjects = mock(Dataflow.Projects.class);
  Dataflow.Projects.Locations mockLocations = mock(Dataflow.Projects.Locations.class);
  Dataflow.Projects.Locations.Jobs.Create mockRequest =
      mock(Dataflow.Projects.Locations.Jobs.Create.class);
  Dataflow.Projects.Locations.Jobs.List mockList = mock(
      Dataflow.Projects.Locations.Jobs.List.class);

  when(mockDataflowClient.projects()).thenReturn(mockProjects);
  when(mockProjects.locations()).thenReturn(mockLocations);
  when(mockLocations.jobs()).thenReturn(mockJobs);
  when(mockJobs.create(eq(PROJECT_ID), eq(REGION_ID), isA(Job.class))).thenReturn(mockRequest);
  when(mockJobs.list(eq(PROJECT_ID), eq(REGION_ID))).thenReturn(mockList);
  when(mockList.setPageToken(anyString())).thenReturn(mockList);
  when(mockList.execute())
      .thenReturn(
          new ListJobsResponse()
              .setJobs(
                  Arrays.asList(
                      new Job()
                          .setName("oldjobname")
                          .setId("oldJobId")
                          .setCurrentState("JOB_STATE_RUNNING"))));

  Job resultJob = new Job();
  resultJob.setId("newid");
  when(mockRequest.execute()).thenReturn(resultJob);
  return mockDataflowClient;
}
 
开发者ID:apache,项目名称:beam,代码行数:31,代码来源:DataflowRunnerTest.java

示例7: testUpdateAlreadyUpdatedPipeline

import com.google.api.services.dataflow.model.Job; //导入方法依赖的package包/类
@Test
public void testUpdateAlreadyUpdatedPipeline() throws IOException {
  DataflowPipelineOptions options = buildPipelineOptions();
  options.setUpdate(true);
  options.setJobName("oldJobName");
  Dataflow mockDataflowClient = options.getDataflowClient();
  Dataflow.Projects.Locations.Jobs.Create mockRequest = mock(
      Dataflow.Projects.Locations.Jobs.Create.class);
  when(mockDataflowClient.projects().locations().jobs()
      .create(eq(PROJECT_ID), eq(REGION_ID), any(Job.class)))
      .thenReturn(mockRequest);
  final Job resultJob = new Job();
  resultJob.setId("newid");
  // Return a different request id.
  resultJob.setClientRequestId("different_request_id");
  when(mockRequest.execute()).thenReturn(resultJob);

  Pipeline p = buildDataflowPipeline(options);

  thrown.expect(DataflowJobAlreadyUpdatedException.class);
  thrown.expect(new TypeSafeMatcher<DataflowJobAlreadyUpdatedException>() {
    @Override
    public void describeTo(Description description) {
      description.appendText("Expected job ID: " + resultJob.getId());
    }

    @Override
    protected boolean matchesSafely(DataflowJobAlreadyUpdatedException item) {
      return resultJob.getId().equals(item.getJob().getJobId());
    }
  });
  thrown.expectMessage("The job named oldjobname with id: oldJobId has already been updated "
      + "into job id: newid and cannot be updated again.");
  p.run();
}
 
开发者ID:apache,项目名称:beam,代码行数:36,代码来源:DataflowRunnerTest.java


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