Skip to content

Commit e5f3ca5

Browse files
fix: update gapic-generator-java with mock service generation fixes (googleapis#979)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 457524730 Source-Link: googleapis/googleapis@917e7f2 Source-Link: https://github.com/googleapis/googleapis-gen/commit/2497f9a069d3f6b2d6810d5a4e239cda1e7e5a39 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjQ5N2Y5YTA2OWQzZjZiMmQ2ODEwZDVhNGUyMzljZGExZTdlNWEzOSJ9
1 parent d4e8fb7 commit e5f3ca5

19 files changed

+350
-30
lines changed

java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/DatasetServiceClientTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@
3434
import com.google.cloud.location.ListLocationsRequest;
3535
import com.google.cloud.location.ListLocationsResponse;
3636
import com.google.cloud.location.Location;
37-
import com.google.cloud.location.MockLocations;
3837
import com.google.common.collect.Lists;
3938
import com.google.iam.v1.AuditConfig;
4039
import com.google.iam.v1.Binding;
4140
import com.google.iam.v1.GetIamPolicyRequest;
4241
import com.google.iam.v1.GetPolicyOptions;
43-
import com.google.iam.v1.MockIAMPolicy;
4442
import com.google.iam.v1.Policy;
4543
import com.google.iam.v1.SetIamPolicyRequest;
4644
import com.google.iam.v1.TestIamPermissionsRequest;

java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/EndpointServiceClientTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@
3131
import com.google.cloud.location.ListLocationsRequest;
3232
import com.google.cloud.location.ListLocationsResponse;
3333
import com.google.cloud.location.Location;
34-
import com.google.cloud.location.MockLocations;
3534
import com.google.common.collect.Lists;
3635
import com.google.iam.v1.AuditConfig;
3736
import com.google.iam.v1.Binding;
3837
import com.google.iam.v1.GetIamPolicyRequest;
3938
import com.google.iam.v1.GetPolicyOptions;
40-
import com.google.iam.v1.MockIAMPolicy;
4139
import com.google.iam.v1.Policy;
4240
import com.google.iam.v1.SetIamPolicyRequest;
4341
import com.google.iam.v1.TestIamPermissionsRequest;

java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/FeaturestoreOnlineServingServiceClientTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,11 @@
3232
import com.google.cloud.location.ListLocationsRequest;
3333
import com.google.cloud.location.ListLocationsResponse;
3434
import com.google.cloud.location.Location;
35-
import com.google.cloud.location.MockLocations;
3635
import com.google.common.collect.Lists;
3736
import com.google.iam.v1.AuditConfig;
3837
import com.google.iam.v1.Binding;
3938
import com.google.iam.v1.GetIamPolicyRequest;
4039
import com.google.iam.v1.GetPolicyOptions;
41-
import com.google.iam.v1.MockIAMPolicy;
4240
import com.google.iam.v1.Policy;
4341
import com.google.iam.v1.SetIamPolicyRequest;
4442
import com.google.iam.v1.TestIamPermissionsRequest;

java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/FeaturestoreServiceClientTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@
3434
import com.google.cloud.location.ListLocationsRequest;
3535
import com.google.cloud.location.ListLocationsResponse;
3636
import com.google.cloud.location.Location;
37-
import com.google.cloud.location.MockLocations;
3837
import com.google.common.collect.Lists;
3938
import com.google.iam.v1.AuditConfig;
4039
import com.google.iam.v1.Binding;
4140
import com.google.iam.v1.GetIamPolicyRequest;
4241
import com.google.iam.v1.GetPolicyOptions;
43-
import com.google.iam.v1.MockIAMPolicy;
4442
import com.google.iam.v1.Policy;
4543
import com.google.iam.v1.SetIamPolicyRequest;
4644
import com.google.iam.v1.TestIamPermissionsRequest;

java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/IndexEndpointServiceClientTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@
3131
import com.google.cloud.location.ListLocationsRequest;
3232
import com.google.cloud.location.ListLocationsResponse;
3333
import com.google.cloud.location.Location;
34-
import com.google.cloud.location.MockLocations;
3534
import com.google.common.collect.Lists;
3635
import com.google.iam.v1.AuditConfig;
3736
import com.google.iam.v1.Binding;
3837
import com.google.iam.v1.GetIamPolicyRequest;
3938
import com.google.iam.v1.GetPolicyOptions;
40-
import com.google.iam.v1.MockIAMPolicy;
4139
import com.google.iam.v1.Policy;
4240
import com.google.iam.v1.SetIamPolicyRequest;
4341
import com.google.iam.v1.TestIamPermissionsRequest;

java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/IndexServiceClientTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@
3131
import com.google.cloud.location.ListLocationsRequest;
3232
import com.google.cloud.location.ListLocationsResponse;
3333
import com.google.cloud.location.Location;
34-
import com.google.cloud.location.MockLocations;
3534
import com.google.common.collect.Lists;
3635
import com.google.iam.v1.AuditConfig;
3736
import com.google.iam.v1.Binding;
3837
import com.google.iam.v1.GetIamPolicyRequest;
3938
import com.google.iam.v1.GetPolicyOptions;
40-
import com.google.iam.v1.MockIAMPolicy;
4139
import com.google.iam.v1.Policy;
4240
import com.google.iam.v1.SetIamPolicyRequest;
4341
import com.google.iam.v1.TestIamPermissionsRequest;

java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/JobServiceClientTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@
3636
import com.google.cloud.location.ListLocationsRequest;
3737
import com.google.cloud.location.ListLocationsResponse;
3838
import com.google.cloud.location.Location;
39-
import com.google.cloud.location.MockLocations;
4039
import com.google.common.collect.Lists;
4140
import com.google.iam.v1.AuditConfig;
4241
import com.google.iam.v1.Binding;
4342
import com.google.iam.v1.GetIamPolicyRequest;
4443
import com.google.iam.v1.GetPolicyOptions;
45-
import com.google.iam.v1.MockIAMPolicy;
4644
import com.google.iam.v1.Policy;
4745
import com.google.iam.v1.SetIamPolicyRequest;
4846
import com.google.iam.v1.TestIamPermissionsRequest;

java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MetadataServiceClientTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@
3535
import com.google.cloud.location.ListLocationsRequest;
3636
import com.google.cloud.location.ListLocationsResponse;
3737
import com.google.cloud.location.Location;
38-
import com.google.cloud.location.MockLocations;
3938
import com.google.common.collect.Lists;
4039
import com.google.iam.v1.AuditConfig;
4140
import com.google.iam.v1.Binding;
4241
import com.google.iam.v1.GetIamPolicyRequest;
4342
import com.google.iam.v1.GetPolicyOptions;
44-
import com.google.iam.v1.MockIAMPolicy;
4543
import com.google.iam.v1.Policy;
4644
import com.google.iam.v1.SetIamPolicyRequest;
4745
import com.google.iam.v1.TestIamPermissionsRequest;

java-aiplatform/google-cloud-aiplatform/src/test/java/com/google/cloud/aiplatform/v1beta1/MigrationServiceClientTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@
3131
import com.google.cloud.location.ListLocationsRequest;
3232
import com.google.cloud.location.ListLocationsResponse;
3333
import com.google.cloud.location.Location;
34-
import com.google.cloud.location.MockLocations;
3534
import com.google.common.collect.Lists;
3635
import com.google.iam.v1.AuditConfig;
3736
import com.google.iam.v1.Binding;
3837
import com.google.iam.v1.GetIamPolicyRequest;
3938
import com.google.iam.v1.GetPolicyOptions;
40-
import com.google.iam.v1.MockIAMPolicy;
4139
import com.google.iam.v1.Policy;
4240
import com.google.iam.v1.SetIamPolicyRequest;
4341
import com.google.iam.v1.TestIamPermissionsRequest;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.aiplatform.v1beta1;
18+
19+
import com.google.api.core.BetaApi;
20+
import com.google.api.gax.grpc.testing.MockGrpcService;
21+
import com.google.protobuf.AbstractMessage;
22+
import io.grpc.ServerServiceDefinition;
23+
import java.util.List;
24+
import javax.annotation.Generated;
25+
26+
@BetaApi
27+
@Generated("by gapic-generator-java")
28+
public class MockIAMPolicy implements MockGrpcService {
29+
private final MockIAMPolicyImpl serviceImpl;
30+
31+
public MockIAMPolicy() {
32+
serviceImpl = new MockIAMPolicyImpl();
33+
}
34+
35+
@Override
36+
public List<AbstractMessage> getRequests() {
37+
return serviceImpl.getRequests();
38+
}
39+
40+
@Override
41+
public void addResponse(AbstractMessage response) {
42+
serviceImpl.addResponse(response);
43+
}
44+
45+
@Override
46+
public void addException(Exception exception) {
47+
serviceImpl.addException(exception);
48+
}
49+
50+
@Override
51+
public ServerServiceDefinition getServiceDefinition() {
52+
return serviceImpl.bindService();
53+
}
54+
55+
@Override
56+
public void reset() {
57+
serviceImpl.reset();
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.aiplatform.v1beta1;
18+
19+
import com.google.api.core.BetaApi;
20+
import com.google.iam.v1.GetIamPolicyRequest;
21+
import com.google.iam.v1.IAMPolicyGrpc.IAMPolicyImplBase;
22+
import com.google.iam.v1.Policy;
23+
import com.google.iam.v1.SetIamPolicyRequest;
24+
import com.google.iam.v1.TestIamPermissionsRequest;
25+
import com.google.iam.v1.TestIamPermissionsResponse;
26+
import com.google.protobuf.AbstractMessage;
27+
import io.grpc.stub.StreamObserver;
28+
import java.util.ArrayList;
29+
import java.util.LinkedList;
30+
import java.util.List;
31+
import java.util.Queue;
32+
import javax.annotation.Generated;
33+
34+
@BetaApi
35+
@Generated("by gapic-generator-java")
36+
public class MockIAMPolicyImpl extends IAMPolicyImplBase {
37+
private List<AbstractMessage> requests;
38+
private Queue<Object> responses;
39+
40+
public MockIAMPolicyImpl() {
41+
requests = new ArrayList<>();
42+
responses = new LinkedList<>();
43+
}
44+
45+
public List<AbstractMessage> getRequests() {
46+
return requests;
47+
}
48+
49+
public void addResponse(AbstractMessage response) {
50+
responses.add(response);
51+
}
52+
53+
public void setResponses(List<AbstractMessage> responses) {
54+
this.responses = new LinkedList<Object>(responses);
55+
}
56+
57+
public void addException(Exception exception) {
58+
responses.add(exception);
59+
}
60+
61+
public void reset() {
62+
requests = new ArrayList<>();
63+
responses = new LinkedList<>();
64+
}
65+
66+
@Override
67+
public void testIamPermissions(
68+
TestIamPermissionsRequest request,
69+
StreamObserver<TestIamPermissionsResponse> responseObserver) {
70+
Object response = responses.poll();
71+
if (response instanceof TestIamPermissionsResponse) {
72+
requests.add(request);
73+
responseObserver.onNext(((TestIamPermissionsResponse) response));
74+
responseObserver.onCompleted();
75+
} else if (response instanceof Exception) {
76+
responseObserver.onError(((Exception) response));
77+
} else {
78+
responseObserver.onError(
79+
new IllegalArgumentException(
80+
String.format(
81+
"Unrecognized response type %s for method TestIamPermissions, expected %s or %s",
82+
response == null ? "null" : response.getClass().getName(),
83+
TestIamPermissionsResponse.class.getName(),
84+
Exception.class.getName())));
85+
}
86+
}
87+
88+
@Override
89+
public void setIamPolicy(SetIamPolicyRequest request, StreamObserver<Policy> responseObserver) {
90+
Object response = responses.poll();
91+
if (response instanceof Policy) {
92+
requests.add(request);
93+
responseObserver.onNext(((Policy) response));
94+
responseObserver.onCompleted();
95+
} else if (response instanceof Exception) {
96+
responseObserver.onError(((Exception) response));
97+
} else {
98+
responseObserver.onError(
99+
new IllegalArgumentException(
100+
String.format(
101+
"Unrecognized response type %s for method SetIamPolicy, expected %s or %s",
102+
response == null ? "null" : response.getClass().getName(),
103+
Policy.class.getName(),
104+
Exception.class.getName())));
105+
}
106+
}
107+
108+
@Override
109+
public void getIamPolicy(GetIamPolicyRequest request, StreamObserver<Policy> responseObserver) {
110+
Object response = responses.poll();
111+
if (response instanceof Policy) {
112+
requests.add(request);
113+
responseObserver.onNext(((Policy) response));
114+
responseObserver.onCompleted();
115+
} else if (response instanceof Exception) {
116+
responseObserver.onError(((Exception) response));
117+
} else {
118+
responseObserver.onError(
119+
new IllegalArgumentException(
120+
String.format(
121+
"Unrecognized response type %s for method GetIamPolicy, expected %s or %s",
122+
response == null ? "null" : response.getClass().getName(),
123+
Policy.class.getName(),
124+
Exception.class.getName())));
125+
}
126+
}
127+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.aiplatform.v1beta1;
18+
19+
import com.google.api.core.BetaApi;
20+
import com.google.api.gax.grpc.testing.MockGrpcService;
21+
import com.google.protobuf.AbstractMessage;
22+
import io.grpc.ServerServiceDefinition;
23+
import java.util.List;
24+
import javax.annotation.Generated;
25+
26+
@BetaApi
27+
@Generated("by gapic-generator-java")
28+
public class MockLocations implements MockGrpcService {
29+
private final MockLocationsImpl serviceImpl;
30+
31+
public MockLocations() {
32+
serviceImpl = new MockLocationsImpl();
33+
}
34+
35+
@Override
36+
public List<AbstractMessage> getRequests() {
37+
return serviceImpl.getRequests();
38+
}
39+
40+
@Override
41+
public void addResponse(AbstractMessage response) {
42+
serviceImpl.addResponse(response);
43+
}
44+
45+
@Override
46+
public void addException(Exception exception) {
47+
serviceImpl.addException(exception);
48+
}
49+
50+
@Override
51+
public ServerServiceDefinition getServiceDefinition() {
52+
return serviceImpl.bindService();
53+
}
54+
55+
@Override
56+
public void reset() {
57+
serviceImpl.reset();
58+
}
59+
}

0 commit comments

Comments
 (0)