From e5f3ca5c70778823fa8ce9a42e8d5e44aa233ba7 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 28 Jun 2022 19:08:15 +0000 Subject: [PATCH] fix: update gapic-generator-java with mock service generation fixes (#979) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 457524730 Source-Link: https://github.com/googleapis/googleapis/commit/917e7f21cb1dc062744c6694437cdd46219f28cb Source-Link: https://github.com/googleapis/googleapis-gen/commit/2497f9a069d3f6b2d6810d5a4e239cda1e7e5a39 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjQ5N2Y5YTA2OWQzZjZiMmQ2ODEwZDVhNGUyMzljZGExZTdlNWEzOSJ9 --- .../v1beta1/DatasetServiceClientTest.java | 2 - .../v1beta1/EndpointServiceClientTest.java | 2 - ...restoreOnlineServingServiceClientTest.java | 2 - .../FeaturestoreServiceClientTest.java | 2 - .../IndexEndpointServiceClientTest.java | 2 - .../v1beta1/IndexServiceClientTest.java | 2 - .../v1beta1/JobServiceClientTest.java | 2 - .../v1beta1/MetadataServiceClientTest.java | 2 - .../v1beta1/MigrationServiceClientTest.java | 2 - .../aiplatform/v1beta1/MockIAMPolicy.java | 59 ++++++++ .../aiplatform/v1beta1/MockIAMPolicyImpl.java | 127 ++++++++++++++++++ .../aiplatform/v1beta1/MockLocations.java | 59 ++++++++ .../aiplatform/v1beta1/MockLocationsImpl.java | 105 +++++++++++++++ .../v1beta1/ModelServiceClientTest.java | 2 - .../v1beta1/PipelineServiceClientTest.java | 2 - .../v1beta1/PredictionServiceClientTest.java | 2 - .../SpecialistPoolServiceClientTest.java | 2 - .../v1beta1/TensorboardServiceClientTest.java | 2 - .../v1beta1/VizierServiceClientTest.java | 2 - 19 files changed, 350 insertions(+), 30 deletions(-) create mode 100644 java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockIAMPolicy.java create mode 100644 java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockIAMPolicyImpl.java create mode 100644 java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockLocations.java create mode 100644 java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockLocationsImpl.java diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/DatasetServiceClientTest.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/DatasetServiceClientTest.java index 7d8ee74e6dfb..f8bafe402dc1 100644 --- a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/DatasetServiceClientTest.java +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/DatasetServiceClientTest.java @@ -34,13 +34,11 @@ 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.AuditConfig; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.MockIAMPolicy; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/EndpointServiceClientTest.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/EndpointServiceClientTest.java index fa71398e996d..b284660074f6 100644 --- a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/EndpointServiceClientTest.java +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/EndpointServiceClientTest.java @@ -31,13 +31,11 @@ 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.AuditConfig; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.MockIAMPolicy; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/FeaturestoreOnlineServingServiceClientTest.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/FeaturestoreOnlineServingServiceClientTest.java index 8123930dc308..e03ad0931223 100644 --- a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/FeaturestoreOnlineServingServiceClientTest.java +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/FeaturestoreOnlineServingServiceClientTest.java @@ -32,13 +32,11 @@ 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.AuditConfig; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.MockIAMPolicy; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/FeaturestoreServiceClientTest.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/FeaturestoreServiceClientTest.java index 13158963dec7..986555ccbb16 100644 --- a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/FeaturestoreServiceClientTest.java +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/FeaturestoreServiceClientTest.java @@ -34,13 +34,11 @@ 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.AuditConfig; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.MockIAMPolicy; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/IndexEndpointServiceClientTest.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/IndexEndpointServiceClientTest.java index 93ee31e90eeb..261ab1694cdc 100644 --- a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/IndexEndpointServiceClientTest.java +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/IndexEndpointServiceClientTest.java @@ -31,13 +31,11 @@ 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.AuditConfig; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.MockIAMPolicy; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/IndexServiceClientTest.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/IndexServiceClientTest.java index 20867a964fe3..c7810750dc83 100644 --- a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/IndexServiceClientTest.java +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/IndexServiceClientTest.java @@ -31,13 +31,11 @@ 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.AuditConfig; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.MockIAMPolicy; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/JobServiceClientTest.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/JobServiceClientTest.java index 3c8437f2d89b..23f08574e58b 100644 --- a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/JobServiceClientTest.java +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/JobServiceClientTest.java @@ -36,13 +36,11 @@ 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.AuditConfig; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.MockIAMPolicy; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MetadataServiceClientTest.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MetadataServiceClientTest.java index 02d5ecfe061a..85160adaba1d 100644 --- a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MetadataServiceClientTest.java +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MetadataServiceClientTest.java @@ -35,13 +35,11 @@ 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.AuditConfig; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.MockIAMPolicy; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MigrationServiceClientTest.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MigrationServiceClientTest.java index 226caf577cc0..0ec1a5fa7b98 100644 --- a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MigrationServiceClientTest.java +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MigrationServiceClientTest.java @@ -31,13 +31,11 @@ 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.AuditConfig; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.MockIAMPolicy; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockIAMPolicy.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockIAMPolicy.java new file mode 100644 index 000000000000..b540e4ca3a41 --- /dev/null +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockIAMPolicy.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.aiplatform.v1beta1; + +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 MockIAMPolicy implements MockGrpcService { + private final MockIAMPolicyImpl serviceImpl; + + public MockIAMPolicy() { + serviceImpl = new MockIAMPolicyImpl(); + } + + @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/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockIAMPolicyImpl.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockIAMPolicyImpl.java new file mode 100644 index 000000000000..fe8bb53d0670 --- /dev/null +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockIAMPolicyImpl.java @@ -0,0 +1,127 @@ +/* + * Copyright 2022 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.aiplatform.v1beta1; + +import com.google.api.core.BetaApi; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.IAMPolicyGrpc.IAMPolicyImplBase; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +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 MockIAMPolicyImpl extends IAMPolicyImplBase { + private List requests; + private Queue responses; + + public MockIAMPolicyImpl() { + 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 testIamPermissions( + TestIamPermissionsRequest request, + StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof TestIamPermissionsResponse) { + requests.add(request); + responseObserver.onNext(((TestIamPermissionsResponse) 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 TestIamPermissions, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + TestIamPermissionsResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void setIamPolicy(SetIamPolicyRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Policy) { + requests.add(request); + responseObserver.onNext(((Policy) 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 SetIamPolicy, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Policy.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getIamPolicy(GetIamPolicyRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Policy) { + requests.add(request); + responseObserver.onNext(((Policy) 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 GetIamPolicy, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Policy.class.getName(), + Exception.class.getName()))); + } + } +} diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockLocations.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockLocations.java new file mode 100644 index 000000000000..219ef13c6107 --- /dev/null +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockLocations.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.aiplatform.v1beta1; + +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/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockLocationsImpl.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockLocationsImpl.java new file mode 100644 index 000000000000..f42a4af46082 --- /dev/null +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MockLocationsImpl.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.aiplatform.v1beta1; + +import com.google.api.core.BetaApi; +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.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.poll(); + 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 == null ? "null" : response.getClass().getName(), + ListLocationsResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getLocation(GetLocationRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + 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 == null ? "null" : response.getClass().getName(), + Location.class.getName(), + Exception.class.getName()))); + } + } +} diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/ModelServiceClientTest.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/ModelServiceClientTest.java index 5da7fe6cda97..e32aa8d33987 100644 --- a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/ModelServiceClientTest.java +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/ModelServiceClientTest.java @@ -34,13 +34,11 @@ 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.AuditConfig; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.MockIAMPolicy; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/PipelineServiceClientTest.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/PipelineServiceClientTest.java index bb8595832d17..bee069daba3a 100644 --- a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/PipelineServiceClientTest.java +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/PipelineServiceClientTest.java @@ -32,13 +32,11 @@ 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.AuditConfig; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.MockIAMPolicy; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/PredictionServiceClientTest.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/PredictionServiceClientTest.java index 3abedd0b7fb2..ccab9208d2c7 100644 --- a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/PredictionServiceClientTest.java +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/PredictionServiceClientTest.java @@ -30,13 +30,11 @@ 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.AuditConfig; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.MockIAMPolicy; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/SpecialistPoolServiceClientTest.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/SpecialistPoolServiceClientTest.java index 9e9494f755ea..d478ca9dafcf 100644 --- a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/SpecialistPoolServiceClientTest.java +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/SpecialistPoolServiceClientTest.java @@ -31,13 +31,11 @@ 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.AuditConfig; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.MockIAMPolicy; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/TensorboardServiceClientTest.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/TensorboardServiceClientTest.java index 51a6c5b629bf..7b5f4023dbcf 100644 --- a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/TensorboardServiceClientTest.java +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/TensorboardServiceClientTest.java @@ -37,13 +37,11 @@ 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.AuditConfig; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.MockIAMPolicy; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; diff --git a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/VizierServiceClientTest.java b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/VizierServiceClientTest.java index a2911543c865..532df1d7b4b6 100644 --- a/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/VizierServiceClientTest.java +++ b/java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/VizierServiceClientTest.java @@ -32,13 +32,11 @@ 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.AuditConfig; import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.MockIAMPolicy; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest;