Skip to content

Commit 099118e

Browse files
authored
Update to GAX 1.7.0 and 0.24.0 (googleapis#2420)
1 parent 8ceb43c commit 099118e

File tree

25 files changed

+214
-202
lines changed

25 files changed

+214
-202
lines changed

google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/BaseGrpcServiceException.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
import com.google.api.client.http.HttpResponseException;
2020
import com.google.api.core.BetaApi;
2121
import com.google.api.core.InternalApi;
22-
import com.google.api.gax.grpc.GrpcApiException;
22+
import com.google.api.gax.grpc.GrpcStatusCode;
23+
import com.google.api.gax.rpc.ApiException;
2324
import com.google.cloud.BaseServiceException;
2425
import com.google.common.base.MoreObjects;
2526
import java.io.IOException;
@@ -66,13 +67,13 @@ private static ExceptionData makeExceptionData(IOException exception, boolean id
6667
}
6768

6869
@BetaApi
69-
public BaseGrpcServiceException(GrpcApiException apiException) {
70+
public BaseGrpcServiceException(ApiException apiException) {
7071
super(ExceptionData.newBuilder()
7172
.setMessage(apiException.getMessage())
7273
.setCause(apiException)
7374
.setRetryable(apiException.isRetryable())
74-
.setCode(apiException.getStatusCode().getCode().value())
75-
.setReason(apiException.getStatusCode().getCode().name())
75+
.setCode(((GrpcStatusCode) apiException.getStatusCode()).getCode().value())
76+
.setReason(((GrpcStatusCode) apiException.getStatusCode()).getCode().name())
7677
.setLocation(null)
7778
.setDebugInfo(null)
7879
.build());

google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/BaseGrpcServiceExceptionTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
import static org.junit.Assert.assertNull;
2626
import static org.junit.Assert.assertTrue;
2727

28-
import com.google.api.gax.grpc.GrpcApiException;
28+
import com.google.api.gax.grpc.GrpcStatusCode;
29+
import com.google.api.gax.rpc.ApiException;
30+
import com.google.api.gax.rpc.InternalException;
2931
import com.google.cloud.BaseServiceException;
3032
import com.google.cloud.RetryHelper;
3133
import io.grpc.Status.Code;
@@ -73,8 +75,8 @@ public void testBaseServiceException() {
7375
assertNull(serviceException.getDebugInfo());
7476

7577
Exception cause = new IllegalArgumentException("bad arg");
76-
GrpcApiException apiException =
77-
new GrpcApiException(MESSAGE, cause, Code.INTERNAL, NOT_RETRYABLE);
78+
InternalException apiException =
79+
new InternalException(MESSAGE, cause, GrpcStatusCode.of(Code.INTERNAL), NOT_RETRYABLE);
7880
serviceException = new BaseGrpcServiceException(apiException);
7981
assertFalse(serviceException.isRetryable());
8082
assertEquals(MESSAGE, serviceException.getMessage());

google-cloud-dlp/src/test/java/com/google/cloud/dlp/v2beta1/DlpServiceClientTest.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
package com.google.cloud.dlp.v2beta1;
1717

1818
import com.google.api.gax.core.NoCredentialsProvider;
19-
import com.google.api.gax.grpc.GrpcApiException;
19+
import com.google.api.gax.grpc.GrpcStatusCode;
2020
import com.google.api.gax.grpc.GrpcTransportProvider;
2121
import com.google.api.gax.grpc.testing.MockGrpcService;
2222
import com.google.api.gax.grpc.testing.MockServiceHelper;
23+
import com.google.api.gax.rpc.InvalidArgumentException;
2324
import com.google.longrunning.Operation;
2425
import com.google.privacy.dlp.v2beta1.ContentItem;
2526
import com.google.privacy.dlp.v2beta1.CreateInspectOperationRequest;
@@ -125,8 +126,8 @@ public void inspectContentExceptionTest() throws Exception {
125126

126127
client.inspectContent(inspectConfig, items);
127128
Assert.fail("No exception raised");
128-
} catch (GrpcApiException e) {
129-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
129+
} catch (InvalidArgumentException e) {
130+
// Expected exception
130131
}
131132
}
132133

@@ -166,8 +167,8 @@ public void redactContentExceptionTest() throws Exception {
166167

167168
client.redactContent(inspectConfig, items, replaceConfigs);
168169
Assert.fail("No exception raised");
169-
} catch (GrpcApiException e) {
170-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
170+
} catch (InvalidArgumentException e) {
171+
// Expected exception
171172
}
172173
}
173174

@@ -217,10 +218,11 @@ public void createInspectOperationExceptionTest() throws Exception {
217218
client.createInspectOperationAsync(inspectConfig, storageConfig, outputConfig).get();
218219
Assert.fail("No exception raised");
219220
} catch (ExecutionException e) {
220-
Assert.assertEquals(GrpcApiException.class, e.getCause().getClass());
221-
GrpcApiException apiException = (GrpcApiException) e.getCause();
221+
Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
222+
InvalidArgumentException apiException = (InvalidArgumentException) e.getCause();
222223
Assert.assertEquals(
223-
Status.INVALID_ARGUMENT.getCode(), apiException.getStatusCode().getCode());
224+
Status.INVALID_ARGUMENT.getCode(),
225+
((GrpcStatusCode) apiException.getStatusCode()).getCode());
224226
}
225227
}
226228

@@ -255,8 +257,8 @@ public void listInspectFindingsExceptionTest() throws Exception {
255257

256258
client.listInspectFindings(name);
257259
Assert.fail("No exception raised");
258-
} catch (GrpcApiException e) {
259-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
260+
} catch (InvalidArgumentException e) {
261+
// Expected exception
260262
}
261263
}
262264

@@ -292,8 +294,8 @@ public void listInfoTypesExceptionTest() throws Exception {
292294

293295
client.listInfoTypes(category, languageCode);
294296
Assert.fail("No exception raised");
295-
} catch (GrpcApiException e) {
296-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
297+
} catch (InvalidArgumentException e) {
298+
// Expected exception
297299
}
298300
}
299301

@@ -326,8 +328,8 @@ public void listRootCategoriesExceptionTest() throws Exception {
326328

327329
client.listRootCategories(languageCode);
328330
Assert.fail("No exception raised");
329-
} catch (GrpcApiException e) {
330-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
331+
} catch (InvalidArgumentException e) {
332+
// Expected exception
331333
}
332334
}
333335
}

google-cloud-errorreporting/src/test/java/com/google/cloud/errorreporting/v1beta1/ErrorGroupServiceClientTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
package com.google.cloud.errorreporting.v1beta1;
1717

1818
import com.google.api.gax.core.NoCredentialsProvider;
19-
import com.google.api.gax.grpc.GrpcApiException;
2019
import com.google.api.gax.grpc.GrpcTransportProvider;
2120
import com.google.api.gax.grpc.testing.MockGrpcService;
2221
import com.google.api.gax.grpc.testing.MockServiceHelper;
22+
import com.google.api.gax.rpc.InvalidArgumentException;
2323
import com.google.devtools.clouderrorreporting.v1beta1.ErrorGroup;
2424
import com.google.devtools.clouderrorreporting.v1beta1.GetGroupRequest;
2525
import com.google.devtools.clouderrorreporting.v1beta1.GroupName;
@@ -114,8 +114,8 @@ public void getGroupExceptionTest() throws Exception {
114114

115115
client.getGroup(groupName);
116116
Assert.fail("No exception raised");
117-
} catch (GrpcApiException e) {
118-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
117+
} catch (InvalidArgumentException e) {
118+
// Expected exception
119119
}
120120
}
121121

@@ -151,8 +151,8 @@ public void updateGroupExceptionTest() throws Exception {
151151

152152
client.updateGroup(group);
153153
Assert.fail("No exception raised");
154-
} catch (GrpcApiException e) {
155-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
154+
} catch (InvalidArgumentException e) {
155+
// Expected exception
156156
}
157157
}
158158
}

google-cloud-errorreporting/src/test/java/com/google/cloud/errorreporting/v1beta1/ErrorStatsServiceClientTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
import static com.google.cloud.errorreporting.v1beta1.PagedResponseWrappers.ListGroupStatsPagedResponse;
2020

2121
import com.google.api.gax.core.NoCredentialsProvider;
22-
import com.google.api.gax.grpc.GrpcApiException;
2322
import com.google.api.gax.grpc.GrpcTransportProvider;
2423
import com.google.api.gax.grpc.testing.MockGrpcService;
2524
import com.google.api.gax.grpc.testing.MockServiceHelper;
25+
import com.google.api.gax.rpc.InvalidArgumentException;
2626
import com.google.common.collect.Lists;
2727
import com.google.devtools.clouderrorreporting.v1beta1.DeleteEventsRequest;
2828
import com.google.devtools.clouderrorreporting.v1beta1.DeleteEventsResponse;
@@ -134,8 +134,8 @@ public void listGroupStatsExceptionTest() throws Exception {
134134

135135
client.listGroupStats(projectName, timeRange);
136136
Assert.fail("No exception raised");
137-
} catch (GrpcApiException e) {
138-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
137+
} catch (InvalidArgumentException e) {
138+
// Expected exception
139139
}
140140
}
141141

@@ -181,8 +181,8 @@ public void listEventsExceptionTest() throws Exception {
181181

182182
client.listEvents(projectName, groupId);
183183
Assert.fail("No exception raised");
184-
} catch (GrpcApiException e) {
185-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
184+
} catch (InvalidArgumentException e) {
185+
// Expected exception
186186
}
187187
}
188188

@@ -215,8 +215,8 @@ public void deleteEventsExceptionTest() throws Exception {
215215

216216
client.deleteEvents(projectName);
217217
Assert.fail("No exception raised");
218-
} catch (GrpcApiException e) {
219-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
218+
} catch (InvalidArgumentException e) {
219+
// Expected exception
220220
}
221221
}
222222
}

google-cloud-errorreporting/src/test/java/com/google/cloud/errorreporting/v1beta1/ReportErrorsServiceClientTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
package com.google.cloud.errorreporting.v1beta1;
1717

1818
import com.google.api.gax.core.NoCredentialsProvider;
19-
import com.google.api.gax.grpc.GrpcApiException;
2019
import com.google.api.gax.grpc.GrpcTransportProvider;
2120
import com.google.api.gax.grpc.testing.MockGrpcService;
2221
import com.google.api.gax.grpc.testing.MockServiceHelper;
22+
import com.google.api.gax.rpc.InvalidArgumentException;
2323
import com.google.devtools.clouderrorreporting.v1beta1.ProjectName;
2424
import com.google.devtools.clouderrorreporting.v1beta1.ReportErrorEventRequest;
2525
import com.google.devtools.clouderrorreporting.v1beta1.ReportErrorEventResponse;
@@ -114,8 +114,8 @@ public void reportErrorEventExceptionTest() throws Exception {
114114

115115
client.reportErrorEvent(projectName, event);
116116
Assert.fail("No exception raised");
117-
} catch (GrpcApiException e) {
118-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
117+
} catch (InvalidArgumentException e) {
118+
// Expected exception
119119
}
120120
}
121121
}

google-cloud-examples/src/test/java/com/google/cloud/examples/pubsub/snippets/ITSubscriptionAdminClientSnippets.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import static org.junit.Assert.assertNotNull;
2121
import static org.junit.Assert.assertTrue;
2222

23-
import com.google.api.gax.grpc.GrpcApiException;
23+
import com.google.api.gax.rpc.ApiException;
2424
import com.google.cloud.Identity;
2525
import com.google.cloud.Role;
2626
import com.google.cloud.pubsub.v1.PagedResponseWrappers.ListSubscriptionsPagedResponse;
@@ -124,7 +124,7 @@ public void listSubscriptionsRetrievesAllAddedSubscriptions() throws Exception {
124124
assertTrue(subFound[0] && subFound[1]);
125125
}
126126

127-
@Test(expected = GrpcApiException.class)
127+
@Test(expected = ApiException.class)
128128
public void deleteSubscriptionThrowsExceptionWhenRetrieved() throws Exception {
129129
String topicName = topics[0];
130130
String subscriptionName = subscriptions[0];

google-cloud-examples/src/test/java/com/google/cloud/examples/pubsub/snippets/ITTopicAdminClientSnippets.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import static org.junit.Assert.assertNotNull;
2121
import static org.junit.Assert.assertTrue;
2222

23-
import com.google.api.gax.grpc.GrpcApiException;
23+
import com.google.api.gax.rpc.ApiException;
2424
import com.google.cloud.Identity;
2525
import com.google.cloud.Role;
2626
import com.google.cloud.pubsub.v1.PagedResponseWrappers.ListTopicSubscriptionsPagedResponse;
@@ -136,7 +136,7 @@ public void listTopicSubscriptionsRetrievesAddedSubscriptions() throws Exception
136136
assertTrue(subFound[0] && subFound[1]);
137137
}
138138

139-
@Test(expected = GrpcApiException.class)
139+
@Test(expected = ApiException.class)
140140
public void deletedTopicIsNotRetrievableAndThrowsException() throws Exception {
141141
String topicName = topics[0];
142142
Topic topicAdded = topicAdminClientSnippets.createTopic(topicName);

google-cloud-language/src/test/java/com/google/cloud/language/v1/LanguageServiceClientTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
package com.google.cloud.language.v1;
1717

1818
import com.google.api.gax.core.NoCredentialsProvider;
19-
import com.google.api.gax.grpc.GrpcApiException;
2019
import com.google.api.gax.grpc.GrpcTransportProvider;
2120
import com.google.api.gax.grpc.testing.MockGrpcService;
2221
import com.google.api.gax.grpc.testing.MockServiceHelper;
22+
import com.google.api.gax.rpc.InvalidArgumentException;
2323
import com.google.cloud.language.v1.AnnotateTextRequest.Features;
2424
import com.google.protobuf.GeneratedMessageV3;
2525
import io.grpc.Status;
@@ -103,8 +103,8 @@ public void analyzeSentimentExceptionTest() throws Exception {
103103

104104
client.analyzeSentiment(document);
105105
Assert.fail("No exception raised");
106-
} catch (GrpcApiException e) {
107-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
106+
} catch (InvalidArgumentException e) {
107+
// Expected exception
108108
}
109109
}
110110

@@ -142,8 +142,8 @@ public void analyzeEntitiesExceptionTest() throws Exception {
142142

143143
client.analyzeEntities(document, encodingType);
144144
Assert.fail("No exception raised");
145-
} catch (GrpcApiException e) {
146-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
145+
} catch (InvalidArgumentException e) {
146+
// Expected exception
147147
}
148148
}
149149

@@ -181,8 +181,8 @@ public void analyzeSyntaxExceptionTest() throws Exception {
181181

182182
client.analyzeSyntax(document, encodingType);
183183
Assert.fail("No exception raised");
184-
} catch (GrpcApiException e) {
185-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
184+
} catch (InvalidArgumentException e) {
185+
// Expected exception
186186
}
187187
}
188188

@@ -223,8 +223,8 @@ public void annotateTextExceptionTest() throws Exception {
223223

224224
client.annotateText(document, features, encodingType);
225225
Assert.fail("No exception raised");
226-
} catch (GrpcApiException e) {
227-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
226+
} catch (InvalidArgumentException e) {
227+
// Expected exception
228228
}
229229
}
230230
}

google-cloud-language/src/test/java/com/google/cloud/language/v1beta2/LanguageServiceClientTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
package com.google.cloud.language.v1beta2;
1717

1818
import com.google.api.gax.core.NoCredentialsProvider;
19-
import com.google.api.gax.grpc.GrpcApiException;
2019
import com.google.api.gax.grpc.GrpcTransportProvider;
2120
import com.google.api.gax.grpc.testing.MockGrpcService;
2221
import com.google.api.gax.grpc.testing.MockServiceHelper;
22+
import com.google.api.gax.rpc.InvalidArgumentException;
2323
import com.google.cloud.language.v1beta2.AnnotateTextRequest.Features;
2424
import com.google.protobuf.GeneratedMessageV3;
2525
import io.grpc.Status;
@@ -103,8 +103,8 @@ public void analyzeSentimentExceptionTest() throws Exception {
103103

104104
client.analyzeSentiment(document);
105105
Assert.fail("No exception raised");
106-
} catch (GrpcApiException e) {
107-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
106+
} catch (InvalidArgumentException e) {
107+
// Expected exception
108108
}
109109
}
110110

@@ -142,8 +142,8 @@ public void analyzeEntitiesExceptionTest() throws Exception {
142142

143143
client.analyzeEntities(document, encodingType);
144144
Assert.fail("No exception raised");
145-
} catch (GrpcApiException e) {
146-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
145+
} catch (InvalidArgumentException e) {
146+
// Expected exception
147147
}
148148
}
149149

@@ -183,8 +183,8 @@ public void analyzeEntitySentimentExceptionTest() throws Exception {
183183

184184
client.analyzeEntitySentiment(document, encodingType);
185185
Assert.fail("No exception raised");
186-
} catch (GrpcApiException e) {
187-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
186+
} catch (InvalidArgumentException e) {
187+
// Expected exception
188188
}
189189
}
190190

@@ -222,8 +222,8 @@ public void analyzeSyntaxExceptionTest() throws Exception {
222222

223223
client.analyzeSyntax(document, encodingType);
224224
Assert.fail("No exception raised");
225-
} catch (GrpcApiException e) {
226-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
225+
} catch (InvalidArgumentException e) {
226+
// Expected exception
227227
}
228228
}
229229

@@ -264,8 +264,8 @@ public void annotateTextExceptionTest() throws Exception {
264264

265265
client.annotateText(document, features, encodingType);
266266
Assert.fail("No exception raised");
267-
} catch (GrpcApiException e) {
268-
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode().getCode());
267+
} catch (InvalidArgumentException e) {
268+
// Expected exception
269269
}
270270
}
271271
}

0 commit comments

Comments
 (0)