Skip to content

Commit

Permalink
Regenerate dataproc client: Adding beta APIs for workflow templates (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and chingor13 committed Dec 10, 2018
1 parent 885d409 commit a6a2302
Show file tree
Hide file tree
Showing 7 changed files with 541 additions and 162 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
* <pre>
* <code>
* try (WorkflowTemplateServiceClient workflowTemplateServiceClient = WorkflowTemplateServiceClient.create()) {
* String formattedParent = RegionName.format("[PROJECT]", "[REGION]");
* RegionName parent = RegionName.of("[PROJECT]", "[REGION]");
* WorkflowTemplate template = WorkflowTemplate.newBuilder().build();
* WorkflowTemplate response = workflowTemplateServiceClient.createWorkflowTemplate(formattedParent, template);
* WorkflowTemplate response = workflowTemplateServiceClient.createWorkflowTemplate(parent, template);
* }
* </code>
* </pre>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
* <pre>
* <code>
* try (WorkflowTemplateServiceClient workflowTemplateServiceClient = WorkflowTemplateServiceClient.create()) {
* String formattedParent = RegionName.format("[PROJECT]", "[REGION]");
* RegionName parent = RegionName.of("[PROJECT]", "[REGION]");
* WorkflowTemplate template = WorkflowTemplate.newBuilder().build();
* WorkflowTemplate response = workflowTemplateServiceClient.createWorkflowTemplate(formattedParent, template);
* WorkflowTemplate response = workflowTemplateServiceClient.createWorkflowTemplate(parent, template);
* }
* </code>
* </pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,18 @@ public void createWorkflowTemplateTest() {
.build();
mockWorkflowTemplateService.addResponse(expectedResponse);

String formattedParent = RegionName.format("[PROJECT]", "[REGION]");
RegionName parent = RegionName.of("[PROJECT]", "[REGION]");
WorkflowTemplate template = WorkflowTemplate.newBuilder().build();

WorkflowTemplate actualResponse = client.createWorkflowTemplate(formattedParent, template);
WorkflowTemplate actualResponse = client.createWorkflowTemplate(parent, template);
Assert.assertEquals(expectedResponse, actualResponse);

List<GeneratedMessageV3> actualRequests = mockWorkflowTemplateService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateWorkflowTemplateRequest actualRequest =
(CreateWorkflowTemplateRequest) actualRequests.get(0);

Assert.assertEquals(formattedParent, actualRequest.getParent());
Assert.assertEquals(parent, RegionName.parse(actualRequest.getParent()));
Assert.assertEquals(template, actualRequest.getTemplate());
Assert.assertTrue(
channelProvider.isHeaderSent(
Expand All @@ -130,10 +130,10 @@ public void createWorkflowTemplateExceptionTest() throws Exception {
mockWorkflowTemplateService.addException(exception);

try {
String formattedParent = RegionName.format("[PROJECT]", "[REGION]");
RegionName parent = RegionName.of("[PROJECT]", "[REGION]");
WorkflowTemplate template = WorkflowTemplate.newBuilder().build();

client.createWorkflowTemplate(formattedParent, template);
client.createWorkflowTemplate(parent, template);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
Expand All @@ -155,17 +155,17 @@ public void getWorkflowTemplateTest() {
.build();
mockWorkflowTemplateService.addResponse(expectedResponse);

String formattedName =
WorkflowTemplateName.format("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
WorkflowTemplateName name =
WorkflowTemplateName.of("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");

WorkflowTemplate actualResponse = client.getWorkflowTemplate(formattedName);
WorkflowTemplate actualResponse = client.getWorkflowTemplate(name);
Assert.assertEquals(expectedResponse, actualResponse);

List<GeneratedMessageV3> actualRequests = mockWorkflowTemplateService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetWorkflowTemplateRequest actualRequest = (GetWorkflowTemplateRequest) actualRequests.get(0);

Assert.assertEquals(formattedName, actualRequest.getName());
Assert.assertEquals(name, WorkflowTemplateName.parse(actualRequest.getName()));
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -179,10 +179,10 @@ public void getWorkflowTemplateExceptionTest() throws Exception {
mockWorkflowTemplateService.addException(exception);

try {
String formattedName =
WorkflowTemplateName.format("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
WorkflowTemplateName name =
WorkflowTemplateName.of("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");

client.getWorkflowTemplate(formattedName);
client.getWorkflowTemplate(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
Expand All @@ -201,18 +201,18 @@ public void instantiateWorkflowTemplateTest() throws Exception {
.build();
mockWorkflowTemplateService.addResponse(resultOperation);

String formattedName =
WorkflowTemplateName.format("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
WorkflowTemplateName name =
WorkflowTemplateName.of("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");

Empty actualResponse = client.instantiateWorkflowTemplateAsync(formattedName).get();
Empty actualResponse = client.instantiateWorkflowTemplateAsync(name).get();
Assert.assertEquals(expectedResponse, actualResponse);

List<GeneratedMessageV3> actualRequests = mockWorkflowTemplateService.getRequests();
Assert.assertEquals(1, actualRequests.size());
InstantiateWorkflowTemplateRequest actualRequest =
(InstantiateWorkflowTemplateRequest) actualRequests.get(0);

Assert.assertEquals(formattedName, actualRequest.getName());
Assert.assertEquals(name, WorkflowTemplateName.parse(actualRequest.getName()));
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -226,10 +226,10 @@ public void instantiateWorkflowTemplateExceptionTest() throws Exception {
mockWorkflowTemplateService.addException(exception);

try {
String formattedName =
WorkflowTemplateName.format("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
WorkflowTemplateName name =
WorkflowTemplateName.of("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");

client.instantiateWorkflowTemplateAsync(formattedName).get();
client.instantiateWorkflowTemplateAsync(name).get();
Assert.fail("No exception raised");
} catch (ExecutionException e) {
Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
Expand All @@ -250,19 +250,19 @@ public void instantiateWorkflowTemplateTest2() throws Exception {
.build();
mockWorkflowTemplateService.addResponse(resultOperation);

String formattedName =
WorkflowTemplateName.format("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
WorkflowTemplateName name =
WorkflowTemplateName.of("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
Map<String, String> parameters = new HashMap<>();

Empty actualResponse = client.instantiateWorkflowTemplateAsync(formattedName, parameters).get();
Empty actualResponse = client.instantiateWorkflowTemplateAsync(name, parameters).get();
Assert.assertEquals(expectedResponse, actualResponse);

List<GeneratedMessageV3> actualRequests = mockWorkflowTemplateService.getRequests();
Assert.assertEquals(1, actualRequests.size());
InstantiateWorkflowTemplateRequest actualRequest =
(InstantiateWorkflowTemplateRequest) actualRequests.get(0);

Assert.assertEquals(formattedName, actualRequest.getName());
Assert.assertEquals(name, WorkflowTemplateName.parse(actualRequest.getName()));
Assert.assertEquals(parameters, actualRequest.getParametersMap());
Assert.assertTrue(
channelProvider.isHeaderSent(
Expand All @@ -277,11 +277,11 @@ public void instantiateWorkflowTemplateExceptionTest2() throws Exception {
mockWorkflowTemplateService.addException(exception);

try {
String formattedName =
WorkflowTemplateName.format("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
WorkflowTemplateName name =
WorkflowTemplateName.of("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
Map<String, String> parameters = new HashMap<>();

client.instantiateWorkflowTemplateAsync(formattedName, parameters).get();
client.instantiateWorkflowTemplateAsync(name, parameters).get();
Assert.fail("No exception raised");
} catch (ExecutionException e) {
Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
Expand Down Expand Up @@ -402,10 +402,9 @@ public void listWorkflowTemplatesTest() {
.build();
mockWorkflowTemplateService.addResponse(expectedResponse);

String formattedParent = RegionName.format("[PROJECT]", "[REGION]");
RegionName parent = RegionName.of("[PROJECT]", "[REGION]");

ListWorkflowTemplatesPagedResponse pagedListResponse =
client.listWorkflowTemplates(formattedParent);
ListWorkflowTemplatesPagedResponse pagedListResponse = client.listWorkflowTemplates(parent);

List<WorkflowTemplate> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Expand All @@ -416,7 +415,7 @@ public void listWorkflowTemplatesTest() {
ListWorkflowTemplatesRequest actualRequest =
(ListWorkflowTemplatesRequest) actualRequests.get(0);

Assert.assertEquals(formattedParent, actualRequest.getParent());
Assert.assertEquals(parent, RegionName.parse(actualRequest.getParent()));
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -430,9 +429,9 @@ public void listWorkflowTemplatesExceptionTest() throws Exception {
mockWorkflowTemplateService.addException(exception);

try {
String formattedParent = RegionName.format("[PROJECT]", "[REGION]");
RegionName parent = RegionName.of("[PROJECT]", "[REGION]");

client.listWorkflowTemplates(formattedParent);
client.listWorkflowTemplates(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
Expand All @@ -445,17 +444,17 @@ public void deleteWorkflowTemplateTest() {
Empty expectedResponse = Empty.newBuilder().build();
mockWorkflowTemplateService.addResponse(expectedResponse);

String formattedName =
WorkflowTemplateName.format("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
WorkflowTemplateName name =
WorkflowTemplateName.of("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");

client.deleteWorkflowTemplate(formattedName);
client.deleteWorkflowTemplate(name);

List<GeneratedMessageV3> actualRequests = mockWorkflowTemplateService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteWorkflowTemplateRequest actualRequest =
(DeleteWorkflowTemplateRequest) actualRequests.get(0);

Assert.assertEquals(formattedName, actualRequest.getName());
Assert.assertEquals(name, WorkflowTemplateName.parse(actualRequest.getName()));
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -469,10 +468,10 @@ public void deleteWorkflowTemplateExceptionTest() throws Exception {
mockWorkflowTemplateService.addException(exception);

try {
String formattedName =
WorkflowTemplateName.format("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
WorkflowTemplateName name =
WorkflowTemplateName.of("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");

client.deleteWorkflowTemplate(formattedName);
client.deleteWorkflowTemplate(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
Expand Down
Loading

0 comments on commit a6a2302

Please sign in to comment.