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 e908c81 commit d88a2fd9b09a8c6f6682eb7972c1c4329b2fd275
@@ -56,8 +56,12 @@
* <code>
* AccessApprovalAdminSettings.Builder accessApprovalAdminSettingsBuilder =
* AccessApprovalAdminSettings.newBuilder();
* accessApprovalAdminSettingsBuilder.getApprovalRequestSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* accessApprovalAdminSettingsBuilder
* .getApprovalRequestSettings()
* .setRetrySettings(
* accessApprovalAdminSettingsBuilder.getApprovalRequestSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* AccessApprovalAdminSettings accessApprovalAdminSettings = accessApprovalAdminSettingsBuilder.build();
* </code>
* </pre>
@@ -81,8 +81,12 @@
* <code>
* AccessApprovalStubSettings.Builder accessApprovalAdminSettingsBuilder =
* AccessApprovalStubSettings.newBuilder();
* accessApprovalAdminSettingsBuilder.getApprovalRequestSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* accessApprovalAdminSettingsBuilder
* .getApprovalRequestSettings()
* .setRetrySettings(
* accessApprovalAdminSettingsBuilder.getApprovalRequestSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* AccessApprovalStubSettings accessApprovalAdminSettings = accessApprovalAdminSettingsBuilder.build();
* </code>
* </pre>
@@ -171,6 +171,94 @@ public void getApprovalRequestExceptionTest() throws Exception {
}
}

@Test
@SuppressWarnings("all")
public void approveApprovalRequestTest() {
String name = "name3373707";
String requestedResourceName = "requestedResourceName-1409378037";
ApprovalRequest expectedResponse =
ApprovalRequest.newBuilder()
.setName(name)
.setRequestedResourceName(requestedResourceName)
.build();
mockAccessApproval.addResponse(expectedResponse);

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

ApprovalRequest actualResponse = client.approveApprovalRequest(request);
Assert.assertEquals(expectedResponse, actualResponse);

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

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

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

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

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

@Test
@SuppressWarnings("all")
public void dismissApprovalRequestTest() {
String name = "name3373707";
String requestedResourceName = "requestedResourceName-1409378037";
ApprovalRequest expectedResponse =
ApprovalRequest.newBuilder()
.setName(name)
.setRequestedResourceName(requestedResourceName)
.build();
mockAccessApproval.addResponse(expectedResponse);

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

ApprovalRequest actualResponse = client.dismissApprovalRequest(request);
Assert.assertEquals(expectedResponse, actualResponse);

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

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

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

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

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

@Test
@SuppressWarnings("all")
public void getAccessApprovalSettingsTest() {
@@ -1,13 +1,13 @@
{
"updateTime": "2020-02-07T09:36:49.980960Z",
"updateTime": "2020-02-08T09:37:12.748334Z",
"sources": [
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "e46f761cd6ec15a9e3d5ed4ff321a4bcba8e8585",
"internalRef": "293710856",
"log": "e46f761cd6ec15a9e3d5ed4ff321a4bcba8e8585\nGenerate the Bazel build file for recommendengine public api\n\nPiperOrigin-RevId: 293710856\n\n68477017c4173c98addac0373950c6aa9d7b375f\nMake `language_code` optional for UpdateIntentRequest and BatchUpdateIntentsRequest.\n\nThe comments and proto annotations describe this parameter as optional.\n\nPiperOrigin-RevId: 293703548\n\n16f823f578bca4e845a19b88bb9bc5870ea71ab2\nAdd BUILD.bazel files for managedidentities API\n\nPiperOrigin-RevId: 293698246\n\n2f53fd8178c9a9de4ad10fae8dd17a7ba36133f2\nAdd v1p1beta1 config file\n\nPiperOrigin-RevId: 293696729\n\n052b274138fce2be80f97b6dcb83ab343c7c8812\nAdd source field for user event and add field behavior annotations\n\nPiperOrigin-RevId: 293693115\n\n1e89732b2d69151b1b3418fff3d4cc0434f0dded\ndatacatalog: v1beta1 add three new RPCs to gapic v1beta1 config\n\nPiperOrigin-RevId: 293692823\n\n9c8bd09bbdc7c4160a44f1fbab279b73cd7a2337\nchange the name of AccessApproval service to AccessApprovalAdmin\n\nPiperOrigin-RevId: 293690934\n\n"
"sha": "e7d8a694f4559201e6913f6610069cb08b39274e",
"internalRef": "293903652",
"log": "e7d8a694f4559201e6913f6610069cb08b39274e\nDepend on the latest gapic-generator and resource names plugin.\n\nThis fixes the very old an very annoying bug: https://github.com/googleapis/gapic-generator/pull/3087\n\nPiperOrigin-RevId: 293903652\n\n806b2854a966d55374ee26bb0cef4e30eda17b58\nfix: correct capitalization of Ruby namespaces in SecurityCenter V1p1beta1\n\nPiperOrigin-RevId: 293903613\n\n1b83c92462b14d67a7644e2980f723112472e03a\nPublish annotations and grpc service config for Logging API.\n\nPiperOrigin-RevId: 293893514\n\n"
}
},
{

0 comments on commit d88a2fd

Please sign in to comment.