Skip to content
Permalink
Browse files
docs(regen): update sample code to set total timeout, add API client …
…header test
  • Loading branch information
yoshi-automation committed Feb 10, 2020
1 parent 4a52acf commit 10922f4c050ea3a54e57c30d5963d95e749228dd
Showing with 361 additions and 34 deletions.
  1. +6 −2 google-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/ApplicationServiceSettings.java
  2. +6 −2 google-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/CompanyServiceSettings.java
  3. +6 −2 google-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/CompletionSettings.java
  4. +6 −2 google-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/EventServiceSettings.java
  5. +6 −2 google-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/JobServiceSettings.java
  6. +6 −2 google-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/ProfileServiceSettings.java
  7. +6 −2 google-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/TenantServiceSettings.java
  8. +6 −2 ...oud-talent/src/main/java/com/google/cloud/talent/v4beta1/stub/ApplicationServiceStubSettings.java
  9. +6 −2 ...e-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/stub/CompanyServiceStubSettings.java
  10. +6 −2 google-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/stub/CompletionStubSettings.java
  11. +6 −2 google-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/stub/EventServiceStubSettings.java
  12. +6 −2 google-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/stub/JobServiceStubSettings.java
  13. +6 −2 ...e-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/stub/ProfileServiceStubSettings.java
  14. +6 −2 ...le-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/stub/TenantServiceStubSettings.java
  15. +65 −0 google-cloud-talent/src/test/java/com/google/cloud/talent/v4beta1/CompletionClientTest.java
  16. +140 −0 google-cloud-talent/src/test/java/com/google/cloud/talent/v4beta1/JobServiceClientTest.java
  17. +66 −0 google-cloud-talent/src/test/java/com/google/cloud/talent/v4beta1/ProfileServiceClientTest.java
  18. +6 −6 synth.metadata
@@ -55,8 +55,12 @@
* <code>
* ApplicationServiceSettings.Builder applicationServiceSettingsBuilder =
* ApplicationServiceSettings.newBuilder();
* applicationServiceSettingsBuilder.createApplicationSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* applicationServiceSettingsBuilder
* .createApplicationSettings()
* .setRetrySettings(
* applicationServiceSettingsBuilder.createApplicationSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* ApplicationServiceSettings applicationServiceSettings = applicationServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -55,8 +55,12 @@
* <code>
* CompanyServiceSettings.Builder companyServiceSettingsBuilder =
* CompanyServiceSettings.newBuilder();
* companyServiceSettingsBuilder.createCompanySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* companyServiceSettingsBuilder
* .createCompanySettings()
* .setRetrySettings(
* companyServiceSettingsBuilder.createCompanySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* CompanyServiceSettings companyServiceSettings = companyServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -51,8 +51,12 @@
* <code>
* CompletionSettings.Builder completionSettingsBuilder =
* CompletionSettings.newBuilder();
* completionSettingsBuilder.completeQuerySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* completionSettingsBuilder
* .completeQuerySettings()
* .setRetrySettings(
* completionSettingsBuilder.completeQuerySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* CompletionSettings completionSettings = completionSettingsBuilder.build();
* </code>
* </pre>
@@ -51,8 +51,12 @@
* <code>
* EventServiceSettings.Builder eventServiceSettingsBuilder =
* EventServiceSettings.newBuilder();
* eventServiceSettingsBuilder.createClientEventSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* eventServiceSettingsBuilder
* .createClientEventSettings()
* .setRetrySettings(
* eventServiceSettingsBuilder.createClientEventSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* EventServiceSettings eventServiceSettings = eventServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -59,8 +59,12 @@
* <code>
* JobServiceSettings.Builder jobServiceSettingsBuilder =
* JobServiceSettings.newBuilder();
* jobServiceSettingsBuilder.createJobSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* jobServiceSettingsBuilder
* .createJobSettings()
* .setRetrySettings(
* jobServiceSettingsBuilder.createJobSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* JobServiceSettings jobServiceSettings = jobServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -56,8 +56,12 @@
* <code>
* ProfileServiceSettings.Builder profileServiceSettingsBuilder =
* ProfileServiceSettings.newBuilder();
* profileServiceSettingsBuilder.createProfileSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* profileServiceSettingsBuilder
* .createProfileSettings()
* .setRetrySettings(
* profileServiceSettingsBuilder.createProfileSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* ProfileServiceSettings profileServiceSettings = profileServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -55,8 +55,12 @@
* <code>
* TenantServiceSettings.Builder tenantServiceSettingsBuilder =
* TenantServiceSettings.newBuilder();
* tenantServiceSettingsBuilder.createTenantSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* tenantServiceSettingsBuilder
* .createTenantSettings()
* .setRetrySettings(
* tenantServiceSettingsBuilder.createTenantSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* TenantServiceSettings tenantServiceSettings = tenantServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -77,8 +77,12 @@
* <code>
* ApplicationServiceStubSettings.Builder applicationServiceSettingsBuilder =
* ApplicationServiceStubSettings.newBuilder();
* applicationServiceSettingsBuilder.createApplicationSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* applicationServiceSettingsBuilder
* .createApplicationSettings()
* .setRetrySettings(
* applicationServiceSettingsBuilder.createApplicationSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* ApplicationServiceStubSettings applicationServiceSettings = applicationServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -77,8 +77,12 @@
* <code>
* CompanyServiceStubSettings.Builder companyServiceSettingsBuilder =
* CompanyServiceStubSettings.newBuilder();
* companyServiceSettingsBuilder.createCompanySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* companyServiceSettingsBuilder
* .createCompanySettings()
* .setRetrySettings(
* companyServiceSettingsBuilder.createCompanySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* CompanyServiceStubSettings companyServiceSettings = companyServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -62,8 +62,12 @@
* <code>
* CompletionStubSettings.Builder completionSettingsBuilder =
* CompletionStubSettings.newBuilder();
* completionSettingsBuilder.completeQuerySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* completionSettingsBuilder
* .completeQuerySettings()
* .setRetrySettings(
* completionSettingsBuilder.completeQuerySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* CompletionStubSettings completionSettings = completionSettingsBuilder.build();
* </code>
* </pre>
@@ -62,8 +62,12 @@
* <code>
* EventServiceStubSettings.Builder eventServiceSettingsBuilder =
* EventServiceStubSettings.newBuilder();
* eventServiceSettingsBuilder.createClientEventSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* eventServiceSettingsBuilder
* .createClientEventSettings()
* .setRetrySettings(
* eventServiceSettingsBuilder.createClientEventSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* EventServiceStubSettings eventServiceSettings = eventServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -91,8 +91,12 @@
* <code>
* JobServiceStubSettings.Builder jobServiceSettingsBuilder =
* JobServiceStubSettings.newBuilder();
* jobServiceSettingsBuilder.createJobSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* jobServiceSettingsBuilder
* .createJobSettings()
* .setRetrySettings(
* jobServiceSettingsBuilder.createJobSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* JobServiceStubSettings jobServiceSettings = jobServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -81,8 +81,12 @@
* <code>
* ProfileServiceStubSettings.Builder profileServiceSettingsBuilder =
* ProfileServiceStubSettings.newBuilder();
* profileServiceSettingsBuilder.createProfileSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* profileServiceSettingsBuilder
* .createProfileSettings()
* .setRetrySettings(
* profileServiceSettingsBuilder.createProfileSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* ProfileServiceStubSettings profileServiceSettings = profileServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -77,8 +77,12 @@
* <code>
* TenantServiceStubSettings.Builder tenantServiceSettingsBuilder =
* TenantServiceStubSettings.newBuilder();
* tenantServiceSettingsBuilder.createTenantSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* tenantServiceSettingsBuilder
* .createTenantSettings()
* .setRetrySettings(
* tenantServiceSettingsBuilder.createTenantSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* TenantServiceStubSettings tenantServiceSettings = tenantServiceSettingsBuilder.build();
* </code>
* </pre>
@@ -16,16 +16,25 @@
package com.google.cloud.talent.v4beta1;

import com.google.api.gax.core.NoCredentialsProvider;
import com.google.api.gax.grpc.GaxGrpcProperties;
import com.google.api.gax.grpc.testing.LocalChannelProvider;
import com.google.api.gax.grpc.testing.MockGrpcService;
import com.google.api.gax.grpc.testing.MockServiceHelper;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.InvalidArgumentException;
import com.google.protobuf.AbstractMessage;
import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

@javax.annotation.Generated("by GAPIC")
public class CompletionClientTest {
@@ -84,4 +93,60 @@ public void setUp() throws IOException {
public void tearDown() throws Exception {
client.close();
}

@Test
@SuppressWarnings("all")
public void completeQueryTest() {
CompleteQueryResponse expectedResponse = CompleteQueryResponse.newBuilder().build();
mockCompletion.addResponse(expectedResponse);

TenantOrProjectName parent = TenantName.of("[PROJECT]", "[TENANT]");
String query = "query107944136";
int pageSize = 883849137;
CompleteQueryRequest request =
CompleteQueryRequest.newBuilder()
.setParent(parent.toString())
.setQuery(query)
.setPageSize(pageSize)
.build();

CompleteQueryResponse actualResponse = client.completeQuery(request);
Assert.assertEquals(expectedResponse, actualResponse);

List<AbstractMessage> actualRequests = mockCompletion.getRequests();
Assert.assertEquals(1, actualRequests.size());
CompleteQueryRequest actualRequest = (CompleteQueryRequest) actualRequests.get(0);

Assert.assertEquals(parent, TenantOrProjectNames.parse(actualRequest.getParent()));
Assert.assertEquals(query, actualRequest.getQuery());
Assert.assertEquals(pageSize, actualRequest.getPageSize());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}

@Test
@SuppressWarnings("all")
public void completeQueryExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockCompletion.addException(exception);

try {
TenantOrProjectName parent = TenantName.of("[PROJECT]", "[TENANT]");
String query = "query107944136";
int pageSize = 883849137;
CompleteQueryRequest request =
CompleteQueryRequest.newBuilder()
.setParent(parent.toString())
.setQuery(query)
.setPageSize(pageSize)
.build();

client.completeQuery(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}
}

0 comments on commit 10922f4

Please sign in to comment.