diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientTestClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientTestClassComposer.java index 7ba0ba35f9..81f8e69541 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientTestClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientTestClassComposer.java @@ -140,11 +140,7 @@ public GapicClass generate(GapicContext context, Service service) { Map messageTypes = context.messages(); String pakkage = service.pakkage(); TypeStore typeStore = new TypeStore(); - addDynamicTypes(service, typeStore); - for (Service mixinService : context.mixinServices()) { - addDynamicTypes(mixinService, typeStore); - } - + addDynamicTypes(context, service, typeStore); String className = ClassNames.getServiceClientTestClassName(service); GapicClass.Kind kind = Kind.MAIN; @@ -466,6 +462,7 @@ private static List createTestMethods( javaMethods.add( createRpcTestMethod( method, + service, matchingService, Collections.emptyList(), 0, @@ -487,6 +484,7 @@ private static List createTestMethods( javaMethods.add( createRpcTestMethod( method, + service, matchingService, method.methodSignatures().get(i), i, @@ -509,9 +507,27 @@ private static List createTestMethods( return javaMethods; } + /** + * Creates a test method for a given RPC, e.g. createAssetTest. + * + * @param method the RPC for which this test method is created. + * @param apiService the host service under test. + * @param rpcService the service that {@code method} belongs to. This is not equal to {@code + * apiService} only when {@code method} is a mixin, in which case {@code rpcService} is the + * mixed-in service. If {@code apiService} and {@code rpcService} are different, they will be + * used only for pagination. Otherwise, {@code rpcService} subsumes {@code apiService}. + * @param methodSignature the method signature of the RPC under test. + * @param variantIndex the nth variant of the RPC under test. This applies when we have + * polymorphism due to the presence of several method signature annotations in the proto. + * @param isRequestArg whether the RPC variant under test take only the request proto message. + * @param classMemberVarExprs the class members in the generated test class. + * @param resourceNames the resource names available for use. + * @param messageTypes the proto message types available for use. + */ private static MethodDefinition createRpcTestMethod( Method method, - Service service, + Service apiService, + Service rpcService, List methodSignature, int variantIndex, boolean isRequestArg, @@ -520,7 +536,7 @@ private static MethodDefinition createRpcTestMethod( Map messageTypes) { if (!method.stream().equals(Method.Stream.NONE)) { return createStreamingRpcTestMethod( - service, method, classMemberVarExprs, resourceNames, messageTypes); + rpcService, method, classMemberVarExprs, resourceNames, messageTypes); } // Construct the expected response. TypeNode methodOutputType = method.hasLro() ? method.lro().responseType() : method.outputType(); @@ -528,6 +544,7 @@ private static MethodDefinition createRpcTestMethod( TypeNode repeatedResponseType = null; VariableExpr responsesElementVarExpr = null; + String mockServiceVarName = getMockServiceVarName(rpcService); if (method.isPaged()) { Message methodOutputMessage = messageTypes.get(method.outputType().reference().simpleName()); Field repeatedPagedResultsField = methodOutputMessage.findAndUnwrapFirstRepeatedField(); @@ -596,6 +613,7 @@ private static MethodDefinition createRpcTestMethod( .setVariableExpr(expectedResponseVarExpr.toBuilder().setIsDecl(true).build()) .setValueExpr(expectedResponseValExpr) .build()); + if (method.hasLro()) { VariableExpr resultOperationVarExpr = VariableExpr.withVariable( @@ -613,14 +631,14 @@ private static MethodDefinition createRpcTestMethod( .build()); methodExprs.add( MethodInvocationExpr.builder() - .setExprReferenceExpr(classMemberVarExprs.get(getMockServiceVarName(service))) + .setExprReferenceExpr(classMemberVarExprs.get(mockServiceVarName)) .setMethodName("addResponse") .setArguments(resultOperationVarExpr) .build()); } else { methodExprs.add( MethodInvocationExpr.builder() - .setExprReferenceExpr(classMemberVarExprs.get(getMockServiceVarName(service))) + .setExprReferenceExpr(classMemberVarExprs.get(mockServiceVarName)) .setMethodName("addResponse") .setArguments(expectedResponseVarExpr) .build()); @@ -675,7 +693,12 @@ private static MethodDefinition createRpcTestMethod( VariableExpr.withVariable( Variable.builder() .setType( - method.isPaged() ? getPagedResponseType(method, service) : methodOutputType) + !method.isPaged() + ? methodOutputType + // If this method is a paginated mixin, use the host service, since + // ServiceClient defines the paged response class and the mixed-in service + // does not have a client. + : getPagedResponseType(method, method.isMixin() ? apiService : rpcService)) .setName(method.isPaged() ? "pagedListResponse" : "actualResponse") .build()); Expr rpcJavaMethodInvocationExpr = @@ -828,7 +851,7 @@ private static MethodDefinition createRpcTestMethod( .setVariableExpr(actualRequestsVarExpr.toBuilder().setIsDecl(true).build()) .setValueExpr( MethodInvocationExpr.builder() - .setExprReferenceExpr(classMemberVarExprs.get(getMockServiceVarName(service))) + .setExprReferenceExpr(classMemberVarExprs.get(mockServiceVarName)) .setMethodName("getRequests") .setReturnType(actualRequestsVarExpr.type()) .build()) @@ -1021,6 +1044,8 @@ private static MethodDefinition createStreamingRpcTestMethod( .setVariableExpr(expectedResponseVarExpr.toBuilder().setIsDecl(true).build()) .setValueExpr(expectedResponseValExpr) .build()); + + String mockServiceVarName = getMockServiceVarName(service); if (method.hasLro()) { VariableExpr resultOperationVarExpr = VariableExpr.withVariable( @@ -1038,14 +1063,14 @@ private static MethodDefinition createStreamingRpcTestMethod( .build()); methodExprs.add( MethodInvocationExpr.builder() - .setExprReferenceExpr(classMemberVarExprs.get(getMockServiceVarName(service))) + .setExprReferenceExpr(classMemberVarExprs.get(mockServiceVarName)) .setMethodName("addResponse") .setArguments(resultOperationVarExpr) .build()); } else { methodExprs.add( MethodInvocationExpr.builder() - .setExprReferenceExpr(classMemberVarExprs.get(getMockServiceVarName(service))) + .setExprReferenceExpr(classMemberVarExprs.get(mockServiceVarName)) .setMethodName("addResponse") .setArguments(expectedResponseVarExpr) .build()); @@ -1251,7 +1276,19 @@ private static MethodDefinition createStreamingRpcTestMethod( .build(); } - // TODO(imraleung): Reorder params. + /** + * Creates a test method to exercise exceptions for a given RPC, e.g. createAssetTest. + * + * @param method the RPC for which this test method is created. + * @param service the service that {@code method} belongs to. + * @param methodSignature the method signature of the RPC under test. + * @param variantIndex the nth variant of the RPC under test. This applies when we have + * polymorphism due to the presence of several method signature annotations in the proto. + * @param classMemberVarExprs the class members in the generated test class. + * @param resourceNames the resource names available for use. + * @param messageTypes the proto message types available for use. + */ + // TODO(miraleung): Reorder params. private static MethodDefinition createRpcExceptionTestMethod( Method method, Service service, @@ -1759,7 +1796,7 @@ private static Map createDefaultMethodNamesToTypes() { return javaMethodNameToReturnType; } - private static void addDynamicTypes(Service service, TypeStore typeStore) { + private static void addDynamicTypes(GapicContext context, Service service, TypeStore typeStore) { typeStore.putAll( service.pakkage(), Arrays.asList( @@ -1775,6 +1812,19 @@ private static void addDynamicTypes(Service service, TypeStore typeStore) { .collect(Collectors.toList()), true, ClassNames.getServiceClientClassName(service)); + for (Service mixinService : context.mixinServices()) { + typeStore.put(mixinService.pakkage(), ClassNames.getMockServiceClassName(mixinService)); + for (Method mixinMethod : mixinService.methods()) { + if (!mixinMethod.isPaged()) { + continue; + } + typeStore.put( + service.pakkage(), + String.format(PAGED_RESPONSE_TYPE_NAME_PATTERN, mixinMethod.name()), + true, + ClassNames.getServiceClientClassName(service)); + } + } } private static TypeNode getOperationCallSettingsType(Method protoMethod) { diff --git a/test/integration/BUILD.bazel b/test/integration/BUILD.bazel index a6c00f0bbd..24d2c9d104 100644 --- a/test/integration/BUILD.bazel +++ b/test/integration/BUILD.bazel @@ -12,7 +12,6 @@ load( "golden_update", "integration_test", ) - load("@rules_proto//proto:defs.bzl", "proto_library") package(default_visibility = ["//visibility:public"]) @@ -204,6 +203,7 @@ proto_library( "@com_google_googleapis//google/api:client_proto", "@com_google_googleapis//google/api:field_behavior_proto", "@com_google_googleapis//google/api:resource_proto", + "@com_google_googleapis//google/cloud/location:location_proto", "@com_google_googleapis//google/iam/v1:iam_policy_proto", "@com_google_googleapis//google/iam/v1:policy_proto", "@com_google_protobuf//:duration_proto", @@ -219,6 +219,7 @@ proto_library_with_info( deps = [ ":kms_proto", "@com_google_googleapis//google/cloud:common_resources_proto", + "@com_google_googleapis//google/cloud/location:location_proto", "@com_google_googleapis//google/iam/v1:iam_policy_proto", "@com_google_googleapis//google/iam/v1:policy_proto", ], @@ -243,10 +244,12 @@ java_gapic_library( service_yaml = "apis/kms/v1/cloudkms_test_mixins_v1.yaml", test_deps = [ ":kms_java_grpc", + "@com_google_googleapis//google/cloud/location:location_java_grpc", "@com_google_googleapis//google/iam/v1:iam_java_grpc", ], deps = [ ":kms_java_proto", + "@com_google_googleapis//google/cloud/location:location_java_proto", "@com_google_googleapis//google/iam/v1:iam_java_proto", ], ) @@ -267,5 +270,7 @@ java_gapic_assembly_gradle_pkg( "@com_google_googleapis//google/cloud/kms/v1:kms_java_grpc", "@com_google_googleapis//google/cloud/kms/v1:kms_java_proto", "@com_google_googleapis//google/cloud/kms/v1:kms_proto", + "@com_google_googleapis//google/cloud/location:location_java_grpc", + "@com_google_googleapis//google/cloud/location:location_java_proto", ], ) diff --git a/test/integration/apis/kms/v1/cloudkms_test_mixins_v1.yaml b/test/integration/apis/kms/v1/cloudkms_test_mixins_v1.yaml index 9acb41abb9..4190b62d0b 100644 --- a/test/integration/apis/kms/v1/cloudkms_test_mixins_v1.yaml +++ b/test/integration/apis/kms/v1/cloudkms_test_mixins_v1.yaml @@ -5,6 +5,7 @@ title: Cloud Key Management Service (KMS) API apis: - name: google.cloud.kms.v1.KeyManagementService +- name: google.cloud.location.Locations - name: google.iam.v1.IAMPolicy types: diff --git a/test/integration/goldens/kms/GrpcKeyManagementServiceStub.java b/test/integration/goldens/kms/GrpcKeyManagementServiceStub.java index 65b4ee5034..d1764393f5 100644 --- a/test/integration/goldens/kms/GrpcKeyManagementServiceStub.java +++ b/test/integration/goldens/kms/GrpcKeyManagementServiceStub.java @@ -20,6 +20,7 @@ import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeysPagedResponse; import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse; import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListKeyRingsPagedResponse; +import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListLocationsPagedResponse; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; @@ -64,6 +65,10 @@ import com.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest; import com.google.cloud.kms.v1.UpdateCryptoKeyRequest; import com.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; import com.google.common.collect.ImmutableMap; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.Policy; @@ -340,6 +345,25 @@ public class GrpcKeyManagementServiceStub extends KeyManagementServiceStub { ProtoUtils.marshaller(TestIamPermissionsResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor + listLocationsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.location.Locations/ListLocations") + .setRequestMarshaller( + ProtoUtils.marshaller(ListLocationsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListLocationsResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor getLocationMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.location.Locations/GetLocation") + .setRequestMarshaller(ProtoUtils.marshaller(GetLocationRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Location.getDefaultInstance())) + .build(); + private final UnaryCallable listKeyRingsCallable; private final UnaryCallable listKeyRingsPagedCallable; @@ -384,6 +408,10 @@ public class GrpcKeyManagementServiceStub extends KeyManagementServiceStub { private final UnaryCallable setIamPolicyCallable; private final UnaryCallable testIamPermissionsCallable; + private final UnaryCallable listLocationsCallable; + private final UnaryCallable + listLocationsPagedCallable; + private final UnaryCallable getLocationCallable; private final BackgroundResource backgroundResources; private final GrpcOperationsStub operationsStub; @@ -784,6 +812,32 @@ public Map extract(TestIamPermissionsRequest request) { } }) .build(); + GrpcCallSettings listLocationsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listLocationsMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(ListLocationsRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings getLocationTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getLocationMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(GetLocationRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + } + }) + .build(); this.listKeyRingsCallable = callableFactory.createUnaryCallable( @@ -897,6 +951,15 @@ public Map extract(TestIamPermissionsRequest request) { testIamPermissionsTransportSettings, settings.testIamPermissionsSettings(), clientContext); + this.listLocationsCallable = + callableFactory.createUnaryCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.listLocationsPagedCallable = + callableFactory.createPagedCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.getLocationCallable = + callableFactory.createUnaryCallable( + getLocationTransportSettings, settings.getLocationSettings(), clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); @@ -1068,6 +1131,22 @@ public UnaryCallable setIamPolicyCallable() { return testIamPermissionsCallable; } + @Override + public UnaryCallable listLocationsCallable() { + return listLocationsCallable; + } + + @Override + public UnaryCallable + listLocationsPagedCallable() { + return listLocationsPagedCallable; + } + + @Override + public UnaryCallable getLocationCallable() { + return getLocationCallable; + } + @Override public final void close() { shutdown(); diff --git a/test/integration/goldens/kms/KeyManagementServiceClient.java b/test/integration/goldens/kms/KeyManagementServiceClient.java index 5144fc1aba..56c5a0c994 100644 --- a/test/integration/goldens/kms/KeyManagementServiceClient.java +++ b/test/integration/goldens/kms/KeyManagementServiceClient.java @@ -29,6 +29,10 @@ import com.google.api.resourcenames.ResourceName; import com.google.cloud.kms.v1.stub.KeyManagementServiceStub; import com.google.cloud.kms.v1.stub.KeyManagementServiceStubSettings; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; import com.google.common.util.concurrent.MoreExecutors; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.Policy; @@ -3268,6 +3272,136 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq return stub.testIamPermissionsCallable(); } + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists information about the supported locations for this service. + * + *

Sample code: + * + *

{@code
+   * try (KeyManagementServiceClient keyManagementServiceClient =
+   *     KeyManagementServiceClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Location element : keyManagementServiceClient.listLocations(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) { + return listLocationsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists information about the supported locations for this service. + * + *

Sample code: + * + *

{@code
+   * try (KeyManagementServiceClient keyManagementServiceClient =
+   *     KeyManagementServiceClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       keyManagementServiceClient.listLocationsPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Location element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + listLocationsPagedCallable() { + return stub.listLocationsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists information about the supported locations for this service. + * + *

Sample code: + * + *

{@code
+   * try (KeyManagementServiceClient keyManagementServiceClient =
+   *     KeyManagementServiceClient.create()) {
+   *   while (true) {
+   *     ListLocationsResponse response =
+   *         keyManagementServiceClient.listLocationsCallable().call(request);
+   *     for (Location element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable listLocationsCallable() { + return stub.listLocationsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a location. + * + *

Sample code: + * + *

{@code
+   * try (KeyManagementServiceClient keyManagementServiceClient =
+   *     KeyManagementServiceClient.create()) {
+   *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
+   *   Location response = keyManagementServiceClient.getLocation(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Location getLocation(GetLocationRequest request) { + return getLocationCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a location. + * + *

Sample code: + * + *

{@code
+   * try (KeyManagementServiceClient keyManagementServiceClient =
+   *     KeyManagementServiceClient.create()) {
+   *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
+   *   ApiFuture future =
+   *       keyManagementServiceClient.getLocationCallable().futureCall(request);
+   *   // Do something.
+   *   Location response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getLocationCallable() { + return stub.getLocationCallable(); + } + @Override public final void close() { stub.close(); @@ -3628,4 +3762,85 @@ protected ListImportJobsFixedSizeCollection createCollection( return new ListImportJobsFixedSizeCollection(pages, collectionSize); } } + + public static class ListLocationsPagedResponse + extends AbstractPagedListResponse< + ListLocationsRequest, + ListLocationsResponse, + Location, + ListLocationsPage, + ListLocationsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListLocationsPagedResponse apply(ListLocationsPage input) { + return new ListLocationsPagedResponse(input); + } + }, + MoreExecutors.directExecutor()); + } + + private ListLocationsPagedResponse(ListLocationsPage page) { + super(page, ListLocationsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListLocationsPage + extends AbstractPage< + ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> { + + private ListLocationsPage( + PageContext context, + ListLocationsResponse response) { + super(context, response); + } + + private static ListLocationsPage createEmptyPage() { + return new ListLocationsPage(null, null); + } + + @Override + protected ListLocationsPage createPage( + PageContext context, + ListLocationsResponse response) { + return new ListLocationsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListLocationsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListLocationsRequest, + ListLocationsResponse, + Location, + ListLocationsPage, + ListLocationsFixedSizeCollection> { + + private ListLocationsFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListLocationsFixedSizeCollection createEmptyCollection() { + return new ListLocationsFixedSizeCollection(null, 0); + } + + @Override + protected ListLocationsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListLocationsFixedSizeCollection(pages, collectionSize); + } + } } diff --git a/test/integration/goldens/kms/KeyManagementServiceClientTest.java b/test/integration/goldens/kms/KeyManagementServiceClientTest.java index 8b68f9af8f..6e15e4ff0e 100644 --- a/test/integration/goldens/kms/KeyManagementServiceClientTest.java +++ b/test/integration/goldens/kms/KeyManagementServiceClientTest.java @@ -20,6 +20,7 @@ import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeysPagedResponse; import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse; import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListKeyRingsPagedResponse; +import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListLocationsPagedResponse; import com.google.api.gax.core.NoCredentialsProvider; import com.google.api.gax.grpc.GaxGrpcProperties; @@ -29,6 +30,11 @@ import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.InvalidArgumentException; import com.google.api.resourcenames.ResourceName; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.cloud.location.MockLocations; import com.google.common.collect.Lists; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; @@ -39,6 +45,7 @@ import com.google.iam.v1.TestIamPermissionsRequest; import com.google.iam.v1.TestIamPermissionsResponse; import com.google.protobuf.AbstractMessage; +import com.google.protobuf.Any; import com.google.protobuf.ByteString; import com.google.protobuf.FieldMask; import com.google.protobuf.Int64Value; @@ -64,16 +71,18 @@ public class KeyManagementServiceClientTest { private static MockServiceHelper mockServiceHelper; private KeyManagementServiceClient client; private static MockIAMPolicy mockIAMPolicy; + private static MockLocations mockLocations; private LocalChannelProvider channelProvider; @BeforeClass public static void startStaticServer() { mockKeyManagementService = new MockKeyManagementService(); mockIAMPolicy = new MockIAMPolicy(); + mockLocations = new MockLocations(); mockServiceHelper = new MockServiceHelper( UUID.randomUUID().toString(), - Arrays.asList(mockKeyManagementService, mockIAMPolicy)); + Arrays.asList(mockKeyManagementService, mockIAMPolicy, mockLocations)); mockServiceHelper.start(); } @@ -2357,4 +2366,105 @@ public void testIamPermissionsExceptionTest() throws Exception { // Expected exception. } } + + @Test + public void listLocationsTest() throws Exception { + Location responsesElement = Location.newBuilder().build(); + ListLocationsResponse expectedResponse = + ListLocationsResponse.newBuilder() + .setNextPageToken("") + .addAllLocations(Arrays.asList(responsesElement)) + .build(); + mockLocations.addResponse(expectedResponse); + + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListLocationsPagedResponse pagedListResponse = client.listLocations(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getLocationsList().get(0), resources.get(0)); + + List actualRequests = mockLocations.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListLocationsRequest actualRequest = ((ListLocationsRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getName(), actualRequest.getName()); + Assert.assertEquals(request.getFilter(), actualRequest.getFilter()); + Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize()); + Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listLocationsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockLocations.addException(exception); + + try { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listLocations(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getLocationTest() throws Exception { + Location expectedResponse = + Location.newBuilder() + .setName("name3373707") + .setLocationId("locationId1541836720") + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setMetadata(Any.newBuilder().build()) + .build(); + mockLocations.addResponse(expectedResponse); + + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + + Location actualResponse = client.getLocation(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockLocations.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetLocationRequest actualRequest = ((GetLocationRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getName(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getLocationExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockLocations.addException(exception); + + try { + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + client.getLocation(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } } diff --git a/test/integration/goldens/kms/KeyManagementServiceSettings.java b/test/integration/goldens/kms/KeyManagementServiceSettings.java index 1f46d029c3..699609b111 100644 --- a/test/integration/goldens/kms/KeyManagementServiceSettings.java +++ b/test/integration/goldens/kms/KeyManagementServiceSettings.java @@ -20,6 +20,7 @@ import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeysPagedResponse; import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse; import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListKeyRingsPagedResponse; +import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListLocationsPagedResponse; import com.google.api.core.ApiFunction; import com.google.api.core.BetaApi; @@ -34,6 +35,10 @@ import com.google.api.gax.rpc.TransportChannelProvider; import com.google.api.gax.rpc.UnaryCallSettings; import com.google.cloud.kms.v1.stub.KeyManagementServiceStubSettings; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; @@ -228,6 +233,17 @@ public UnaryCallSettings setIamPolicySettings() { return ((KeyManagementServiceStubSettings) getStubSettings()).testIamPermissionsSettings(); } + /** Returns the object with the settings used for calls to listLocations. */ + public PagedCallSettings + listLocationsSettings() { + return ((KeyManagementServiceStubSettings) getStubSettings()).listLocationsSettings(); + } + + /** Returns the object with the settings used for calls to getLocation. */ + public UnaryCallSettings getLocationSettings() { + return ((KeyManagementServiceStubSettings) getStubSettings()).getLocationSettings(); + } + public static final KeyManagementServiceSettings create(KeyManagementServiceStubSettings stub) throws IOException { return new KeyManagementServiceSettings.Builder(stub.toBuilder()).build(); @@ -477,6 +493,18 @@ public UnaryCallSettings.Builder setIamPolicySettin return getStubSettingsBuilder().testIamPermissionsSettings(); } + /** Returns the builder for the settings used for calls to listLocations. */ + public PagedCallSettings.Builder< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings() { + return getStubSettingsBuilder().listLocationsSettings(); + } + + /** Returns the builder for the settings used for calls to getLocation. */ + public UnaryCallSettings.Builder getLocationSettings() { + return getStubSettingsBuilder().getLocationSettings(); + } + @Override public KeyManagementServiceSettings build() throws IOException { return new KeyManagementServiceSettings(this); diff --git a/test/integration/goldens/kms/KeyManagementServiceStub.java b/test/integration/goldens/kms/KeyManagementServiceStub.java index de64e0ed7e..19a0dd1749 100644 --- a/test/integration/goldens/kms/KeyManagementServiceStub.java +++ b/test/integration/goldens/kms/KeyManagementServiceStub.java @@ -20,6 +20,7 @@ import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeysPagedResponse; import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse; import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListKeyRingsPagedResponse; +import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListLocationsPagedResponse; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.UnaryCallable; @@ -59,6 +60,10 @@ import com.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest; import com.google.cloud.kms.v1.UpdateCryptoKeyRequest; import com.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; @@ -209,6 +214,19 @@ public UnaryCallable setIamPolicyCallable() { throw new UnsupportedOperationException("Not implemented: testIamPermissionsCallable()"); } + public UnaryCallable + listLocationsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listLocationsPagedCallable()"); + } + + public UnaryCallable listLocationsCallable() { + throw new UnsupportedOperationException("Not implemented: listLocationsCallable()"); + } + + public UnaryCallable getLocationCallable() { + throw new UnsupportedOperationException("Not implemented: getLocationCallable()"); + } + @Override public abstract void close(); } diff --git a/test/integration/goldens/kms/KeyManagementServiceStubSettings.java b/test/integration/goldens/kms/KeyManagementServiceStubSettings.java index 260f7fdd39..c700ebb518 100644 --- a/test/integration/goldens/kms/KeyManagementServiceStubSettings.java +++ b/test/integration/goldens/kms/KeyManagementServiceStubSettings.java @@ -20,6 +20,7 @@ import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeysPagedResponse; import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse; import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListKeyRingsPagedResponse; +import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListLocationsPagedResponse; import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; @@ -79,6 +80,10 @@ import com.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest; import com.google.cloud.kms.v1.UpdateCryptoKeyRequest; import com.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -182,6 +187,10 @@ public class KeyManagementServiceStubSettings private final UnaryCallSettings setIamPolicySettings; private final UnaryCallSettings testIamPermissionsSettings; + private final PagedCallSettings< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings; + private final UnaryCallSettings getLocationSettings; private static final PagedListDescriptor LIST_KEY_RINGS_PAGE_STR_DESC = @@ -334,6 +343,42 @@ public Iterable extractResources(ListImportJobsResponse payload) { } }; + private static final PagedListDescriptor + LIST_LOCATIONS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListLocationsRequest injectToken(ListLocationsRequest payload, String token) { + return ListLocationsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListLocationsRequest injectPageSize(ListLocationsRequest payload, int pageSize) { + return ListLocationsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListLocationsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListLocationsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListLocationsResponse payload) { + return payload.getLocationsList() == null + ? ImmutableList.of() + : payload.getLocationsList(); + } + }; + private static final PagedListResponseFactory< ListKeyRingsRequest, ListKeyRingsResponse, ListKeyRingsPagedResponse> LIST_KEY_RINGS_PAGE_STR_FACT = @@ -409,6 +454,23 @@ public ApiFuture getFuturePagedResponse( } }; + private static final PagedListResponseFactory< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + LIST_LOCATIONS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListLocationsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_LOCATIONS_PAGE_STR_DESC, request, context); + return ListLocationsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + /** Returns the object with the settings used for calls to listKeyRings. */ public PagedCallSettings listKeyRingsSettings() { @@ -557,6 +619,17 @@ public UnaryCallSettings setIamPolicySettings() { return testIamPermissionsSettings; } + /** Returns the object with the settings used for calls to listLocations. */ + public PagedCallSettings + listLocationsSettings() { + return listLocationsSettings; + } + + /** Returns the object with the settings used for calls to getLocation. */ + public UnaryCallSettings getLocationSettings() { + return getLocationSettings; + } + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public KeyManagementServiceStub createStub() throws IOException { if (getTransportChannelProvider() @@ -653,6 +726,8 @@ protected KeyManagementServiceStubSettings(Builder settingsBuilder) throws IOExc getIamPolicySettings = settingsBuilder.getIamPolicySettings().build(); setIamPolicySettings = settingsBuilder.setIamPolicySettings().build(); testIamPermissionsSettings = settingsBuilder.testIamPermissionsSettings().build(); + listLocationsSettings = settingsBuilder.listLocationsSettings().build(); + getLocationSettings = settingsBuilder.getLocationSettings().build(); } /** Builder for KeyManagementServiceStubSettings. */ @@ -708,6 +783,10 @@ public static class Builder private final UnaryCallSettings.Builder setIamPolicySettings; private final UnaryCallSettings.Builder testIamPermissionsSettings; + private final PagedCallSettings.Builder< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings; + private final UnaryCallSettings.Builder getLocationSettings; private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -721,6 +800,7 @@ public static class Builder StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED))); definitions.put( "no_retry_0_codes", ImmutableSet.copyOf(Lists.newArrayList())); + definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -748,6 +828,8 @@ public static class Builder .setTotalTimeout(Duration.ofMillis(60000L)) .build(); definitions.put("no_retry_0_params", settings); + settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); + definitions.put("no_retry_params", settings); RETRY_PARAM_DEFINITIONS = definitions.build(); } @@ -785,6 +867,8 @@ protected Builder(ClientContext clientContext) { getIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); setIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); testIamPermissionsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + listLocationsSettings = PagedCallSettings.newBuilder(LIST_LOCATIONS_PAGE_STR_FACT); + getLocationSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); unaryMethodSettingsBuilders = ImmutableList.>of( @@ -813,7 +897,9 @@ protected Builder(ClientContext clientContext) { restoreCryptoKeyVersionSettings, getIamPolicySettings, setIamPolicySettings, - testIamPermissionsSettings); + testIamPermissionsSettings, + listLocationsSettings, + getLocationSettings); initDefaults(this); } @@ -847,6 +933,8 @@ protected Builder(KeyManagementServiceStubSettings settings) { getIamPolicySettings = settings.getIamPolicySettings.toBuilder(); setIamPolicySettings = settings.setIamPolicySettings.toBuilder(); testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder(); + listLocationsSettings = settings.listLocationsSettings.toBuilder(); + getLocationSettings = settings.getLocationSettings.toBuilder(); unaryMethodSettingsBuilders = ImmutableList.>of( @@ -875,7 +963,9 @@ protected Builder(KeyManagementServiceStubSettings settings) { restoreCryptoKeyVersionSettings, getIamPolicySettings, setIamPolicySettings, - testIamPermissionsSettings); + testIamPermissionsSettings, + listLocationsSettings, + getLocationSettings); } private static Builder createDefault() { @@ -1020,6 +1110,16 @@ private static Builder initDefaults(Builder builder) { .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + builder + .listLocationsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .getLocationSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + return builder; } @@ -1189,6 +1289,18 @@ public UnaryCallSettings.Builder setIamPolicySettin return testIamPermissionsSettings; } + /** Returns the builder for the settings used for calls to listLocations. */ + public PagedCallSettings.Builder< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings() { + return listLocationsSettings; + } + + /** Returns the builder for the settings used for calls to getLocation. */ + public UnaryCallSettings.Builder getLocationSettings() { + return getLocationSettings; + } + @Override public KeyManagementServiceStubSettings build() throws IOException { return new KeyManagementServiceStubSettings(this); diff --git a/test/integration/goldens/kms/MockLocations.java b/test/integration/goldens/kms/MockLocations.java new file mode 100644 index 0000000000..6afa0e0a7d --- /dev/null +++ b/test/integration/goldens/kms/MockLocations.java @@ -0,0 +1,59 @@ +/* + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.location; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockLocations implements MockGrpcService { + private final MockLocationsImpl serviceImpl; + + public MockLocations() { + serviceImpl = new MockLocationsImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(AbstractMessage response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/test/integration/goldens/kms/MockLocationsImpl.java b/test/integration/goldens/kms/MockLocationsImpl.java new file mode 100644 index 0000000000..d2c5e0f8ab --- /dev/null +++ b/test/integration/goldens/kms/MockLocationsImpl.java @@ -0,0 +1,101 @@ +/* + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.location; + +import com.google.api.core.BetaApi; +import com.google.cloud.location.LocationsGrpc.LocationsImplBase; +import com.google.protobuf.AbstractMessage; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockLocationsImpl extends LocationsImplBase { + private List requests; + private Queue responses; + + public MockLocationsImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(AbstractMessage response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void listLocations( + ListLocationsRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof ListLocationsResponse) { + requests.add(request); + responseObserver.onNext(((ListLocationsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListLocations, expected %s or %s", + response.getClass().getName(), + ListLocationsResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getLocation(GetLocationRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Location) { + requests.add(request); + responseObserver.onNext(((Location) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetLocation, expected %s or %s", + response.getClass().getName(), + Location.class.getName(), + Exception.class.getName()))); + } + } +} diff --git a/test/integration/goldens/kms/gapic_metadata.json b/test/integration/goldens/kms/gapic_metadata.json index e34e14ad07..a3c2c93ed7 100644 --- a/test/integration/goldens/kms/gapic_metadata.json +++ b/test/integration/goldens/kms/gapic_metadata.json @@ -52,6 +52,9 @@ "GetKeyRing": { "methods": ["getKeyRing", "getKeyRing", "getKeyRing", "getKeyRingCallable"] }, + "GetLocation": { + "methods": ["getLocation", "getLocationCallable"] + }, "GetPublicKey": { "methods": ["getPublicKey", "getPublicKey", "getPublicKey", "getPublicKeyCallable"] }, @@ -70,6 +73,9 @@ "ListKeyRings": { "methods": ["listKeyRings", "listKeyRings", "listKeyRings", "listKeyRingsPagedCallable", "listKeyRingsCallable"] }, + "ListLocations": { + "methods": ["listLocations", "listLocationsPagedCallable", "listLocationsCallable"] + }, "RestoreCryptoKeyVersion": { "methods": ["restoreCryptoKeyVersion", "restoreCryptoKeyVersion", "restoreCryptoKeyVersion", "restoreCryptoKeyVersionCallable"] },