|
16 | 16 | package com.google.cloud.dlp.v2beta1; |
17 | 17 |
|
18 | 18 | import com.google.api.gax.core.NoCredentialsProvider; |
19 | | -import com.google.api.gax.grpc.GrpcApiException; |
| 19 | +import com.google.api.gax.grpc.GrpcStatusCode; |
20 | 20 | import com.google.api.gax.grpc.GrpcTransportProvider; |
21 | 21 | import com.google.api.gax.grpc.testing.MockGrpcService; |
22 | 22 | import com.google.api.gax.grpc.testing.MockServiceHelper; |
| 23 | +import com.google.api.gax.rpc.InvalidArgumentException; |
23 | 24 | import com.google.longrunning.Operation; |
24 | 25 | import com.google.privacy.dlp.v2beta1.ContentItem; |
25 | 26 | import com.google.privacy.dlp.v2beta1.CreateInspectOperationRequest; |
@@ -125,8 +126,8 @@ public void inspectContentExceptionTest() throws Exception { |
125 | 126 |
|
126 | 127 | client.inspectContent(inspectConfig, items); |
127 | 128 | 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 |
130 | 131 | } |
131 | 132 | } |
132 | 133 |
|
@@ -166,8 +167,8 @@ public void redactContentExceptionTest() throws Exception { |
166 | 167 |
|
167 | 168 | client.redactContent(inspectConfig, items, replaceConfigs); |
168 | 169 | 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 |
171 | 172 | } |
172 | 173 | } |
173 | 174 |
|
@@ -217,10 +218,11 @@ public void createInspectOperationExceptionTest() throws Exception { |
217 | 218 | client.createInspectOperationAsync(inspectConfig, storageConfig, outputConfig).get(); |
218 | 219 | Assert.fail("No exception raised"); |
219 | 220 | } 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(); |
222 | 223 | Assert.assertEquals( |
223 | | - Status.INVALID_ARGUMENT.getCode(), apiException.getStatusCode().getCode()); |
| 224 | + Status.INVALID_ARGUMENT.getCode(), |
| 225 | + ((GrpcStatusCode) apiException.getStatusCode()).getCode()); |
224 | 226 | } |
225 | 227 | } |
226 | 228 |
|
@@ -255,8 +257,8 @@ public void listInspectFindingsExceptionTest() throws Exception { |
255 | 257 |
|
256 | 258 | client.listInspectFindings(name); |
257 | 259 | 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 |
260 | 262 | } |
261 | 263 | } |
262 | 264 |
|
@@ -292,8 +294,8 @@ public void listInfoTypesExceptionTest() throws Exception { |
292 | 294 |
|
293 | 295 | client.listInfoTypes(category, languageCode); |
294 | 296 | 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 |
297 | 299 | } |
298 | 300 | } |
299 | 301 |
|
@@ -326,8 +328,8 @@ public void listRootCategoriesExceptionTest() throws Exception { |
326 | 328 |
|
327 | 329 | client.listRootCategories(languageCode); |
328 | 330 | 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 |
331 | 333 | } |
332 | 334 | } |
333 | 335 | } |
0 commit comments