Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

Commit

Permalink
docs(regen): update sample code to set total timeout, add API client …
Browse files Browse the repository at this point in the history
…header test
  • Loading branch information
yoshi-automation committed Feb 10, 2020
1 parent 2d98e84 commit a078590
Show file tree
Hide file tree
Showing 10 changed files with 735 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@
* <code>
* DataCatalogSettings.Builder dataCatalogSettingsBuilder =
* DataCatalogSettings.newBuilder();
* dataCatalogSettingsBuilder.createEntryGroupSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* dataCatalogSettingsBuilder
* .createEntryGroupSettings()
* .setRetrySettings(
* dataCatalogSettingsBuilder.createEntryGroupSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* DataCatalogSettings dataCatalogSettings = dataCatalogSettingsBuilder.build();
* </code>
* </pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@
* <code>
* PolicyTagManagerSerializationSettings.Builder policyTagManagerSerializationSettingsBuilder =
* PolicyTagManagerSerializationSettings.newBuilder();
* policyTagManagerSerializationSettingsBuilder.importTaxonomiesSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* policyTagManagerSerializationSettingsBuilder
* .importTaxonomiesSettings()
* .setRetrySettings(
* policyTagManagerSerializationSettingsBuilder.importTaxonomiesSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* PolicyTagManagerSerializationSettings policyTagManagerSerializationSettings = policyTagManagerSerializationSettingsBuilder.build();
* </code>
* </pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@
* <code>
* PolicyTagManagerSettings.Builder policyTagManagerSettingsBuilder =
* PolicyTagManagerSettings.newBuilder();
* policyTagManagerSettingsBuilder.createTaxonomySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* policyTagManagerSettingsBuilder
* .createTaxonomySettings()
* .setRetrySettings(
* policyTagManagerSettingsBuilder.createTaxonomySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* PolicyTagManagerSettings policyTagManagerSettings = policyTagManagerSettingsBuilder.build();
* </code>
* </pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,12 @@
* <code>
* DataCatalogStubSettings.Builder dataCatalogSettingsBuilder =
* DataCatalogStubSettings.newBuilder();
* dataCatalogSettingsBuilder.createEntryGroupSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* dataCatalogSettingsBuilder
* .createEntryGroupSettings()
* .setRetrySettings(
* dataCatalogSettingsBuilder.createEntryGroupSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* DataCatalogStubSettings dataCatalogSettings = dataCatalogSettingsBuilder.build();
* </code>
* </pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@
* <code>
* PolicyTagManagerSerializationStubSettings.Builder policyTagManagerSerializationSettingsBuilder =
* PolicyTagManagerSerializationStubSettings.newBuilder();
* policyTagManagerSerializationSettingsBuilder.importTaxonomiesSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* policyTagManagerSerializationSettingsBuilder
* .importTaxonomiesSettings()
* .setRetrySettings(
* policyTagManagerSerializationSettingsBuilder.importTaxonomiesSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* PolicyTagManagerSerializationStubSettings policyTagManagerSerializationSettings = policyTagManagerSerializationSettingsBuilder.build();
* </code>
* </pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@
* <code>
* PolicyTagManagerStubSettings.Builder policyTagManagerSettingsBuilder =
* PolicyTagManagerStubSettings.newBuilder();
* policyTagManagerSettingsBuilder.createTaxonomySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* policyTagManagerSettingsBuilder
* .createTaxonomySettings()
* .setRetrySettings(
* policyTagManagerSettingsBuilder.createTaxonomySettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* PolicyTagManagerStubSettings policyTagManagerSettings = policyTagManagerSettingsBuilder.build();
* </code>
* </pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,57 @@ public void getEntryExceptionTest() throws Exception {
}
}

@Test
@SuppressWarnings("all")
public void lookupEntryTest() {
String name = "name3373707";
String linkedResource = "linkedResource1544625012";
String userSpecifiedType = "userSpecifiedType-940364963";
String userSpecifiedSystem = "userSpecifiedSystem-1776119406";
String displayName = "displayName1615086568";
String description = "description-1724546052";
Entry expectedResponse =
Entry.newBuilder()
.setName(name)
.setLinkedResource(linkedResource)
.setUserSpecifiedType(userSpecifiedType)
.setUserSpecifiedSystem(userSpecifiedSystem)
.setDisplayName(displayName)
.setDescription(description)
.build();
mockDataCatalog.addResponse(expectedResponse);

LookupEntryRequest request = LookupEntryRequest.newBuilder().build();

Entry actualResponse = client.lookupEntry(request);
Assert.assertEquals(expectedResponse, actualResponse);

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

Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}

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

try {
LookupEntryRequest request = LookupEntryRequest.newBuilder().build();

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

@Test
@SuppressWarnings("all")
public void listEntryGroupsTest() {
Expand Down Expand Up @@ -640,17 +691,15 @@ public void updateEntryGroupTest2() {
mockDataCatalog.addResponse(expectedResponse);

EntryGroup entryGroup = EntryGroup.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();

EntryGroup actualResponse = client.updateEntryGroup(entryGroup, updateMask);
EntryGroup actualResponse = client.updateEntryGroup(entryGroup);
Assert.assertEquals(expectedResponse, actualResponse);

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

Assert.assertEquals(entryGroup, actualRequest.getEntryGroup());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -665,9 +714,8 @@ public void updateEntryGroupExceptionTest2() throws Exception {

try {
EntryGroup entryGroup = EntryGroup.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();

client.updateEntryGroup(entryGroup, updateMask);
client.updateEntryGroup(entryGroup);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
Expand Down
Loading

0 comments on commit a078590

Please sign in to comment.