• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.securitycenter.v1;
18 
19 import static com.google.cloud.securitycenter.v1.SecurityCenterClient.GroupAssetsPagedResponse;
20 import static com.google.cloud.securitycenter.v1.SecurityCenterClient.GroupFindingsPagedResponse;
21 import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListAssetsPagedResponse;
22 import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListBigQueryExportsPagedResponse;
23 import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListDescendantSecurityHealthAnalyticsCustomModulesPagedResponse;
24 import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListEffectiveSecurityHealthAnalyticsCustomModulesPagedResponse;
25 import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListFindingsPagedResponse;
26 import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListMuteConfigsPagedResponse;
27 import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListNotificationConfigsPagedResponse;
28 import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListSecurityHealthAnalyticsCustomModulesPagedResponse;
29 import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListSourcesPagedResponse;
30 
31 import com.google.api.gax.core.NoCredentialsProvider;
32 import com.google.api.gax.httpjson.GaxHttpJsonProperties;
33 import com.google.api.gax.httpjson.testing.MockHttpService;
34 import com.google.api.gax.rpc.ApiClientHeaderProvider;
35 import com.google.api.gax.rpc.ApiException;
36 import com.google.api.gax.rpc.ApiExceptionFactory;
37 import com.google.api.gax.rpc.InvalidArgumentException;
38 import com.google.api.gax.rpc.StatusCode;
39 import com.google.api.gax.rpc.testing.FakeStatusCode;
40 import com.google.api.resourcenames.ResourceName;
41 import com.google.cloud.securitycenter.v1.stub.HttpJsonSecurityCenterStub;
42 import com.google.common.collect.Lists;
43 import com.google.iam.v1.AuditConfig;
44 import com.google.iam.v1.Binding;
45 import com.google.iam.v1.Policy;
46 import com.google.iam.v1.TestIamPermissionsResponse;
47 import com.google.longrunning.Operation;
48 import com.google.protobuf.Any;
49 import com.google.protobuf.ByteString;
50 import com.google.protobuf.Duration;
51 import com.google.protobuf.Empty;
52 import com.google.protobuf.FieldMask;
53 import com.google.protobuf.Timestamp;
54 import com.google.protobuf.Value;
55 import java.io.IOException;
56 import java.util.ArrayList;
57 import java.util.Arrays;
58 import java.util.HashMap;
59 import java.util.List;
60 import java.util.concurrent.ExecutionException;
61 import javax.annotation.Generated;
62 import org.junit.After;
63 import org.junit.AfterClass;
64 import org.junit.Assert;
65 import org.junit.Before;
66 import org.junit.BeforeClass;
67 import org.junit.Test;
68 
69 @Generated("by gapic-generator-java")
70 public class SecurityCenterClientHttpJsonTest {
71   private static MockHttpService mockService;
72   private static SecurityCenterClient client;
73 
74   @BeforeClass
startStaticServer()75   public static void startStaticServer() throws IOException {
76     mockService =
77         new MockHttpService(
78             HttpJsonSecurityCenterStub.getMethodDescriptors(),
79             SecurityCenterSettings.getDefaultEndpoint());
80     SecurityCenterSettings settings =
81         SecurityCenterSettings.newHttpJsonBuilder()
82             .setTransportChannelProvider(
83                 SecurityCenterSettings.defaultHttpJsonTransportProviderBuilder()
84                     .setHttpTransport(mockService)
85                     .build())
86             .setCredentialsProvider(NoCredentialsProvider.create())
87             .build();
88     client = SecurityCenterClient.create(settings);
89   }
90 
91   @AfterClass
stopServer()92   public static void stopServer() {
93     client.close();
94   }
95 
96   @Before
setUp()97   public void setUp() {}
98 
99   @After
tearDown()100   public void tearDown() throws Exception {
101     mockService.reset();
102   }
103 
104   @Test
bulkMuteFindingsTest()105   public void bulkMuteFindingsTest() throws Exception {
106     BulkMuteFindingsResponse expectedResponse = BulkMuteFindingsResponse.newBuilder().build();
107     Operation resultOperation =
108         Operation.newBuilder()
109             .setName("bulkMuteFindingsTest")
110             .setDone(true)
111             .setResponse(Any.pack(expectedResponse))
112             .build();
113     mockService.addResponse(resultOperation);
114 
115     ResourceName parent = FolderName.of("[FOLDER]");
116 
117     BulkMuteFindingsResponse actualResponse = client.bulkMuteFindingsAsync(parent).get();
118     Assert.assertEquals(expectedResponse, actualResponse);
119 
120     List<String> actualRequests = mockService.getRequestPaths();
121     Assert.assertEquals(1, actualRequests.size());
122 
123     String apiClientHeaderKey =
124         mockService
125             .getRequestHeaders()
126             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
127             .iterator()
128             .next();
129     Assert.assertTrue(
130         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
131             .matcher(apiClientHeaderKey)
132             .matches());
133   }
134 
135   @Test
bulkMuteFindingsExceptionTest()136   public void bulkMuteFindingsExceptionTest() throws Exception {
137     ApiException exception =
138         ApiExceptionFactory.createException(
139             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
140     mockService.addException(exception);
141 
142     try {
143       ResourceName parent = FolderName.of("[FOLDER]");
144       client.bulkMuteFindingsAsync(parent).get();
145       Assert.fail("No exception raised");
146     } catch (ExecutionException e) {
147     }
148   }
149 
150   @Test
bulkMuteFindingsTest2()151   public void bulkMuteFindingsTest2() throws Exception {
152     BulkMuteFindingsResponse expectedResponse = BulkMuteFindingsResponse.newBuilder().build();
153     Operation resultOperation =
154         Operation.newBuilder()
155             .setName("bulkMuteFindingsTest")
156             .setDone(true)
157             .setResponse(Any.pack(expectedResponse))
158             .build();
159     mockService.addResponse(resultOperation);
160 
161     String parent = "organizations/organization-8287";
162 
163     BulkMuteFindingsResponse actualResponse = client.bulkMuteFindingsAsync(parent).get();
164     Assert.assertEquals(expectedResponse, actualResponse);
165 
166     List<String> actualRequests = mockService.getRequestPaths();
167     Assert.assertEquals(1, actualRequests.size());
168 
169     String apiClientHeaderKey =
170         mockService
171             .getRequestHeaders()
172             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
173             .iterator()
174             .next();
175     Assert.assertTrue(
176         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
177             .matcher(apiClientHeaderKey)
178             .matches());
179   }
180 
181   @Test
bulkMuteFindingsExceptionTest2()182   public void bulkMuteFindingsExceptionTest2() throws Exception {
183     ApiException exception =
184         ApiExceptionFactory.createException(
185             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
186     mockService.addException(exception);
187 
188     try {
189       String parent = "organizations/organization-8287";
190       client.bulkMuteFindingsAsync(parent).get();
191       Assert.fail("No exception raised");
192     } catch (ExecutionException e) {
193     }
194   }
195 
196   @Test
createSecurityHealthAnalyticsCustomModuleTest()197   public void createSecurityHealthAnalyticsCustomModuleTest() throws Exception {
198     SecurityHealthAnalyticsCustomModule expectedResponse =
199         SecurityHealthAnalyticsCustomModule.newBuilder()
200             .setName(
201                 SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
202                         "[ORGANIZATION]", "[CUSTOM_MODULE]")
203                     .toString())
204             .setDisplayName("displayName1714148973")
205             .setUpdateTime(Timestamp.newBuilder().build())
206             .setLastEditor("lastEditor1523898275")
207             .setAncestorModule(
208                 SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
209                         "[ORGANIZATION]", "[CUSTOM_MODULE]")
210                     .toString())
211             .setCustomConfig(CustomConfig.newBuilder().build())
212             .build();
213     mockService.addResponse(expectedResponse);
214 
215     SecurityHealthAnalyticsSettingsName parent =
216         SecurityHealthAnalyticsSettingsName.ofOrganizationName("[ORGANIZATION]");
217     SecurityHealthAnalyticsCustomModule securityHealthAnalyticsCustomModule =
218         SecurityHealthAnalyticsCustomModule.newBuilder().build();
219 
220     SecurityHealthAnalyticsCustomModule actualResponse =
221         client.createSecurityHealthAnalyticsCustomModule(
222             parent, securityHealthAnalyticsCustomModule);
223     Assert.assertEquals(expectedResponse, actualResponse);
224 
225     List<String> actualRequests = mockService.getRequestPaths();
226     Assert.assertEquals(1, actualRequests.size());
227 
228     String apiClientHeaderKey =
229         mockService
230             .getRequestHeaders()
231             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
232             .iterator()
233             .next();
234     Assert.assertTrue(
235         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
236             .matcher(apiClientHeaderKey)
237             .matches());
238   }
239 
240   @Test
createSecurityHealthAnalyticsCustomModuleExceptionTest()241   public void createSecurityHealthAnalyticsCustomModuleExceptionTest() throws Exception {
242     ApiException exception =
243         ApiExceptionFactory.createException(
244             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
245     mockService.addException(exception);
246 
247     try {
248       SecurityHealthAnalyticsSettingsName parent =
249           SecurityHealthAnalyticsSettingsName.ofOrganizationName("[ORGANIZATION]");
250       SecurityHealthAnalyticsCustomModule securityHealthAnalyticsCustomModule =
251           SecurityHealthAnalyticsCustomModule.newBuilder().build();
252       client.createSecurityHealthAnalyticsCustomModule(parent, securityHealthAnalyticsCustomModule);
253       Assert.fail("No exception raised");
254     } catch (InvalidArgumentException e) {
255       // Expected exception.
256     }
257   }
258 
259   @Test
createSecurityHealthAnalyticsCustomModuleTest2()260   public void createSecurityHealthAnalyticsCustomModuleTest2() throws Exception {
261     SecurityHealthAnalyticsCustomModule expectedResponse =
262         SecurityHealthAnalyticsCustomModule.newBuilder()
263             .setName(
264                 SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
265                         "[ORGANIZATION]", "[CUSTOM_MODULE]")
266                     .toString())
267             .setDisplayName("displayName1714148973")
268             .setUpdateTime(Timestamp.newBuilder().build())
269             .setLastEditor("lastEditor1523898275")
270             .setAncestorModule(
271                 SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
272                         "[ORGANIZATION]", "[CUSTOM_MODULE]")
273                     .toString())
274             .setCustomConfig(CustomConfig.newBuilder().build())
275             .build();
276     mockService.addResponse(expectedResponse);
277 
278     String parent = "organizations/organization-7807/securityHealthAnalyticsSettings";
279     SecurityHealthAnalyticsCustomModule securityHealthAnalyticsCustomModule =
280         SecurityHealthAnalyticsCustomModule.newBuilder().build();
281 
282     SecurityHealthAnalyticsCustomModule actualResponse =
283         client.createSecurityHealthAnalyticsCustomModule(
284             parent, securityHealthAnalyticsCustomModule);
285     Assert.assertEquals(expectedResponse, actualResponse);
286 
287     List<String> actualRequests = mockService.getRequestPaths();
288     Assert.assertEquals(1, actualRequests.size());
289 
290     String apiClientHeaderKey =
291         mockService
292             .getRequestHeaders()
293             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
294             .iterator()
295             .next();
296     Assert.assertTrue(
297         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
298             .matcher(apiClientHeaderKey)
299             .matches());
300   }
301 
302   @Test
createSecurityHealthAnalyticsCustomModuleExceptionTest2()303   public void createSecurityHealthAnalyticsCustomModuleExceptionTest2() throws Exception {
304     ApiException exception =
305         ApiExceptionFactory.createException(
306             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
307     mockService.addException(exception);
308 
309     try {
310       String parent = "organizations/organization-7807/securityHealthAnalyticsSettings";
311       SecurityHealthAnalyticsCustomModule securityHealthAnalyticsCustomModule =
312           SecurityHealthAnalyticsCustomModule.newBuilder().build();
313       client.createSecurityHealthAnalyticsCustomModule(parent, securityHealthAnalyticsCustomModule);
314       Assert.fail("No exception raised");
315     } catch (InvalidArgumentException e) {
316       // Expected exception.
317     }
318   }
319 
320   @Test
createSourceTest()321   public void createSourceTest() throws Exception {
322     Source expectedResponse =
323         Source.newBuilder()
324             .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString())
325             .setDisplayName("displayName1714148973")
326             .setDescription("description-1724546052")
327             .setCanonicalName("canonicalName2122381727")
328             .build();
329     mockService.addResponse(expectedResponse);
330 
331     OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
332     Source source = Source.newBuilder().build();
333 
334     Source actualResponse = client.createSource(parent, source);
335     Assert.assertEquals(expectedResponse, actualResponse);
336 
337     List<String> actualRequests = mockService.getRequestPaths();
338     Assert.assertEquals(1, actualRequests.size());
339 
340     String apiClientHeaderKey =
341         mockService
342             .getRequestHeaders()
343             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
344             .iterator()
345             .next();
346     Assert.assertTrue(
347         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
348             .matcher(apiClientHeaderKey)
349             .matches());
350   }
351 
352   @Test
createSourceExceptionTest()353   public void createSourceExceptionTest() throws Exception {
354     ApiException exception =
355         ApiExceptionFactory.createException(
356             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
357     mockService.addException(exception);
358 
359     try {
360       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
361       Source source = Source.newBuilder().build();
362       client.createSource(parent, source);
363       Assert.fail("No exception raised");
364     } catch (InvalidArgumentException e) {
365       // Expected exception.
366     }
367   }
368 
369   @Test
createSourceTest2()370   public void createSourceTest2() throws Exception {
371     Source expectedResponse =
372         Source.newBuilder()
373             .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString())
374             .setDisplayName("displayName1714148973")
375             .setDescription("description-1724546052")
376             .setCanonicalName("canonicalName2122381727")
377             .build();
378     mockService.addResponse(expectedResponse);
379 
380     String parent = "organizations/organization-8287";
381     Source source = Source.newBuilder().build();
382 
383     Source actualResponse = client.createSource(parent, source);
384     Assert.assertEquals(expectedResponse, actualResponse);
385 
386     List<String> actualRequests = mockService.getRequestPaths();
387     Assert.assertEquals(1, actualRequests.size());
388 
389     String apiClientHeaderKey =
390         mockService
391             .getRequestHeaders()
392             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
393             .iterator()
394             .next();
395     Assert.assertTrue(
396         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
397             .matcher(apiClientHeaderKey)
398             .matches());
399   }
400 
401   @Test
createSourceExceptionTest2()402   public void createSourceExceptionTest2() throws Exception {
403     ApiException exception =
404         ApiExceptionFactory.createException(
405             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
406     mockService.addException(exception);
407 
408     try {
409       String parent = "organizations/organization-8287";
410       Source source = Source.newBuilder().build();
411       client.createSource(parent, source);
412       Assert.fail("No exception raised");
413     } catch (InvalidArgumentException e) {
414       // Expected exception.
415     }
416   }
417 
418   @Test
createFindingTest()419   public void createFindingTest() throws Exception {
420     Finding expectedResponse =
421         Finding.newBuilder()
422             .setName(
423                 FindingName.ofOrganizationSourceFindingName(
424                         "[ORGANIZATION]", "[SOURCE]", "[FINDING]")
425                     .toString())
426             .setParent("parent-995424086")
427             .setResourceName("resourceName-384566343")
428             .setCategory("category50511102")
429             .setExternalUri("externalUri-1153085023")
430             .putAllSourceProperties(new HashMap<String, Value>())
431             .setSecurityMarks(SecurityMarks.newBuilder().build())
432             .setEventTime(Timestamp.newBuilder().build())
433             .setCreateTime(Timestamp.newBuilder().build())
434             .setCanonicalName("canonicalName2122381727")
435             .setIndicator(Indicator.newBuilder().build())
436             .setVulnerability(Vulnerability.newBuilder().build())
437             .setMuteUpdateTime(Timestamp.newBuilder().build())
438             .putAllExternalSystems(new HashMap<String, ExternalSystem>())
439             .setMitreAttack(MitreAttack.newBuilder().build())
440             .setAccess(Access.newBuilder().build())
441             .addAllConnections(new ArrayList<Connection>())
442             .setMuteInitiator("muteInitiator1395645462")
443             .addAllProcesses(new ArrayList<Process>())
444             .putAllContacts(new HashMap<String, ContactDetails>())
445             .addAllCompliances(new ArrayList<Compliance>())
446             .setParentDisplayName("parentDisplayName-1523759261")
447             .setDescription("description-1724546052")
448             .setExfiltration(Exfiltration.newBuilder().build())
449             .addAllIamBindings(new ArrayList<IamBinding>())
450             .setNextSteps("nextSteps1206138868")
451             .setModuleName("moduleName-870351081")
452             .addAllContainers(new ArrayList<Container>())
453             .setKubernetes(Kubernetes.newBuilder().build())
454             .setDatabase(Database.newBuilder().build())
455             .addAllFiles(new ArrayList<File>())
456             .setCloudDlpInspection(CloudDlpInspection.newBuilder().build())
457             .setCloudDlpDataProfile(CloudDlpDataProfile.newBuilder().build())
458             .setKernelRootkit(KernelRootkit.newBuilder().build())
459             .build();
460     mockService.addResponse(expectedResponse);
461 
462     SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]");
463     String findingId = "findingId439150212";
464     Finding finding = Finding.newBuilder().build();
465 
466     Finding actualResponse = client.createFinding(parent, findingId, finding);
467     Assert.assertEquals(expectedResponse, actualResponse);
468 
469     List<String> actualRequests = mockService.getRequestPaths();
470     Assert.assertEquals(1, actualRequests.size());
471 
472     String apiClientHeaderKey =
473         mockService
474             .getRequestHeaders()
475             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
476             .iterator()
477             .next();
478     Assert.assertTrue(
479         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
480             .matcher(apiClientHeaderKey)
481             .matches());
482   }
483 
484   @Test
createFindingExceptionTest()485   public void createFindingExceptionTest() throws Exception {
486     ApiException exception =
487         ApiExceptionFactory.createException(
488             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
489     mockService.addException(exception);
490 
491     try {
492       SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]");
493       String findingId = "findingId439150212";
494       Finding finding = Finding.newBuilder().build();
495       client.createFinding(parent, findingId, finding);
496       Assert.fail("No exception raised");
497     } catch (InvalidArgumentException e) {
498       // Expected exception.
499     }
500   }
501 
502   @Test
createFindingTest2()503   public void createFindingTest2() throws Exception {
504     Finding expectedResponse =
505         Finding.newBuilder()
506             .setName(
507                 FindingName.ofOrganizationSourceFindingName(
508                         "[ORGANIZATION]", "[SOURCE]", "[FINDING]")
509                     .toString())
510             .setParent("parent-995424086")
511             .setResourceName("resourceName-384566343")
512             .setCategory("category50511102")
513             .setExternalUri("externalUri-1153085023")
514             .putAllSourceProperties(new HashMap<String, Value>())
515             .setSecurityMarks(SecurityMarks.newBuilder().build())
516             .setEventTime(Timestamp.newBuilder().build())
517             .setCreateTime(Timestamp.newBuilder().build())
518             .setCanonicalName("canonicalName2122381727")
519             .setIndicator(Indicator.newBuilder().build())
520             .setVulnerability(Vulnerability.newBuilder().build())
521             .setMuteUpdateTime(Timestamp.newBuilder().build())
522             .putAllExternalSystems(new HashMap<String, ExternalSystem>())
523             .setMitreAttack(MitreAttack.newBuilder().build())
524             .setAccess(Access.newBuilder().build())
525             .addAllConnections(new ArrayList<Connection>())
526             .setMuteInitiator("muteInitiator1395645462")
527             .addAllProcesses(new ArrayList<Process>())
528             .putAllContacts(new HashMap<String, ContactDetails>())
529             .addAllCompliances(new ArrayList<Compliance>())
530             .setParentDisplayName("parentDisplayName-1523759261")
531             .setDescription("description-1724546052")
532             .setExfiltration(Exfiltration.newBuilder().build())
533             .addAllIamBindings(new ArrayList<IamBinding>())
534             .setNextSteps("nextSteps1206138868")
535             .setModuleName("moduleName-870351081")
536             .addAllContainers(new ArrayList<Container>())
537             .setKubernetes(Kubernetes.newBuilder().build())
538             .setDatabase(Database.newBuilder().build())
539             .addAllFiles(new ArrayList<File>())
540             .setCloudDlpInspection(CloudDlpInspection.newBuilder().build())
541             .setCloudDlpDataProfile(CloudDlpDataProfile.newBuilder().build())
542             .setKernelRootkit(KernelRootkit.newBuilder().build())
543             .build();
544     mockService.addResponse(expectedResponse);
545 
546     String parent = "organizations/organization-8741/sources/source-8741";
547     String findingId = "findingId439150212";
548     Finding finding = Finding.newBuilder().build();
549 
550     Finding actualResponse = client.createFinding(parent, findingId, finding);
551     Assert.assertEquals(expectedResponse, actualResponse);
552 
553     List<String> actualRequests = mockService.getRequestPaths();
554     Assert.assertEquals(1, actualRequests.size());
555 
556     String apiClientHeaderKey =
557         mockService
558             .getRequestHeaders()
559             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
560             .iterator()
561             .next();
562     Assert.assertTrue(
563         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
564             .matcher(apiClientHeaderKey)
565             .matches());
566   }
567 
568   @Test
createFindingExceptionTest2()569   public void createFindingExceptionTest2() throws Exception {
570     ApiException exception =
571         ApiExceptionFactory.createException(
572             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
573     mockService.addException(exception);
574 
575     try {
576       String parent = "organizations/organization-8741/sources/source-8741";
577       String findingId = "findingId439150212";
578       Finding finding = Finding.newBuilder().build();
579       client.createFinding(parent, findingId, finding);
580       Assert.fail("No exception raised");
581     } catch (InvalidArgumentException e) {
582       // Expected exception.
583     }
584   }
585 
586   @Test
createMuteConfigTest()587   public void createMuteConfigTest() throws Exception {
588     MuteConfig expectedResponse =
589         MuteConfig.newBuilder()
590             .setName(
591                 MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]")
592                     .toString())
593             .setDisplayName("displayName1714148973")
594             .setDescription("description-1724546052")
595             .setFilter("filter-1274492040")
596             .setCreateTime(Timestamp.newBuilder().build())
597             .setUpdateTime(Timestamp.newBuilder().build())
598             .setMostRecentEditor("mostRecentEditor-833861941")
599             .build();
600     mockService.addResponse(expectedResponse);
601 
602     FolderName parent = FolderName.of("[FOLDER]");
603     MuteConfig muteConfig = MuteConfig.newBuilder().build();
604 
605     MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig);
606     Assert.assertEquals(expectedResponse, actualResponse);
607 
608     List<String> actualRequests = mockService.getRequestPaths();
609     Assert.assertEquals(1, actualRequests.size());
610 
611     String apiClientHeaderKey =
612         mockService
613             .getRequestHeaders()
614             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
615             .iterator()
616             .next();
617     Assert.assertTrue(
618         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
619             .matcher(apiClientHeaderKey)
620             .matches());
621   }
622 
623   @Test
createMuteConfigExceptionTest()624   public void createMuteConfigExceptionTest() throws Exception {
625     ApiException exception =
626         ApiExceptionFactory.createException(
627             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
628     mockService.addException(exception);
629 
630     try {
631       FolderName parent = FolderName.of("[FOLDER]");
632       MuteConfig muteConfig = MuteConfig.newBuilder().build();
633       client.createMuteConfig(parent, muteConfig);
634       Assert.fail("No exception raised");
635     } catch (InvalidArgumentException e) {
636       // Expected exception.
637     }
638   }
639 
640   @Test
createMuteConfigTest2()641   public void createMuteConfigTest2() throws Exception {
642     MuteConfig expectedResponse =
643         MuteConfig.newBuilder()
644             .setName(
645                 MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]")
646                     .toString())
647             .setDisplayName("displayName1714148973")
648             .setDescription("description-1724546052")
649             .setFilter("filter-1274492040")
650             .setCreateTime(Timestamp.newBuilder().build())
651             .setUpdateTime(Timestamp.newBuilder().build())
652             .setMostRecentEditor("mostRecentEditor-833861941")
653             .build();
654     mockService.addResponse(expectedResponse);
655 
656     OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
657     MuteConfig muteConfig = MuteConfig.newBuilder().build();
658 
659     MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig);
660     Assert.assertEquals(expectedResponse, actualResponse);
661 
662     List<String> actualRequests = mockService.getRequestPaths();
663     Assert.assertEquals(1, actualRequests.size());
664 
665     String apiClientHeaderKey =
666         mockService
667             .getRequestHeaders()
668             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
669             .iterator()
670             .next();
671     Assert.assertTrue(
672         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
673             .matcher(apiClientHeaderKey)
674             .matches());
675   }
676 
677   @Test
createMuteConfigExceptionTest2()678   public void createMuteConfigExceptionTest2() throws Exception {
679     ApiException exception =
680         ApiExceptionFactory.createException(
681             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
682     mockService.addException(exception);
683 
684     try {
685       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
686       MuteConfig muteConfig = MuteConfig.newBuilder().build();
687       client.createMuteConfig(parent, muteConfig);
688       Assert.fail("No exception raised");
689     } catch (InvalidArgumentException e) {
690       // Expected exception.
691     }
692   }
693 
694   @Test
createMuteConfigTest3()695   public void createMuteConfigTest3() throws Exception {
696     MuteConfig expectedResponse =
697         MuteConfig.newBuilder()
698             .setName(
699                 MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]")
700                     .toString())
701             .setDisplayName("displayName1714148973")
702             .setDescription("description-1724546052")
703             .setFilter("filter-1274492040")
704             .setCreateTime(Timestamp.newBuilder().build())
705             .setUpdateTime(Timestamp.newBuilder().build())
706             .setMostRecentEditor("mostRecentEditor-833861941")
707             .build();
708     mockService.addResponse(expectedResponse);
709 
710     ProjectName parent = ProjectName.of("[PROJECT]");
711     MuteConfig muteConfig = MuteConfig.newBuilder().build();
712 
713     MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig);
714     Assert.assertEquals(expectedResponse, actualResponse);
715 
716     List<String> actualRequests = mockService.getRequestPaths();
717     Assert.assertEquals(1, actualRequests.size());
718 
719     String apiClientHeaderKey =
720         mockService
721             .getRequestHeaders()
722             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
723             .iterator()
724             .next();
725     Assert.assertTrue(
726         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
727             .matcher(apiClientHeaderKey)
728             .matches());
729   }
730 
731   @Test
createMuteConfigExceptionTest3()732   public void createMuteConfigExceptionTest3() throws Exception {
733     ApiException exception =
734         ApiExceptionFactory.createException(
735             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
736     mockService.addException(exception);
737 
738     try {
739       ProjectName parent = ProjectName.of("[PROJECT]");
740       MuteConfig muteConfig = MuteConfig.newBuilder().build();
741       client.createMuteConfig(parent, muteConfig);
742       Assert.fail("No exception raised");
743     } catch (InvalidArgumentException e) {
744       // Expected exception.
745     }
746   }
747 
748   @Test
createMuteConfigTest4()749   public void createMuteConfigTest4() throws Exception {
750     MuteConfig expectedResponse =
751         MuteConfig.newBuilder()
752             .setName(
753                 MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]")
754                     .toString())
755             .setDisplayName("displayName1714148973")
756             .setDescription("description-1724546052")
757             .setFilter("filter-1274492040")
758             .setCreateTime(Timestamp.newBuilder().build())
759             .setUpdateTime(Timestamp.newBuilder().build())
760             .setMostRecentEditor("mostRecentEditor-833861941")
761             .build();
762     mockService.addResponse(expectedResponse);
763 
764     String parent = "organizations/organization-8287";
765     MuteConfig muteConfig = MuteConfig.newBuilder().build();
766 
767     MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig);
768     Assert.assertEquals(expectedResponse, actualResponse);
769 
770     List<String> actualRequests = mockService.getRequestPaths();
771     Assert.assertEquals(1, actualRequests.size());
772 
773     String apiClientHeaderKey =
774         mockService
775             .getRequestHeaders()
776             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
777             .iterator()
778             .next();
779     Assert.assertTrue(
780         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
781             .matcher(apiClientHeaderKey)
782             .matches());
783   }
784 
785   @Test
createMuteConfigExceptionTest4()786   public void createMuteConfigExceptionTest4() throws Exception {
787     ApiException exception =
788         ApiExceptionFactory.createException(
789             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
790     mockService.addException(exception);
791 
792     try {
793       String parent = "organizations/organization-8287";
794       MuteConfig muteConfig = MuteConfig.newBuilder().build();
795       client.createMuteConfig(parent, muteConfig);
796       Assert.fail("No exception raised");
797     } catch (InvalidArgumentException e) {
798       // Expected exception.
799     }
800   }
801 
802   @Test
createMuteConfigTest5()803   public void createMuteConfigTest5() throws Exception {
804     MuteConfig expectedResponse =
805         MuteConfig.newBuilder()
806             .setName(
807                 MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]")
808                     .toString())
809             .setDisplayName("displayName1714148973")
810             .setDescription("description-1724546052")
811             .setFilter("filter-1274492040")
812             .setCreateTime(Timestamp.newBuilder().build())
813             .setUpdateTime(Timestamp.newBuilder().build())
814             .setMostRecentEditor("mostRecentEditor-833861941")
815             .build();
816     mockService.addResponse(expectedResponse);
817 
818     FolderName parent = FolderName.of("[FOLDER]");
819     MuteConfig muteConfig = MuteConfig.newBuilder().build();
820     String muteConfigId = "muteConfigId1689669942";
821 
822     MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig, muteConfigId);
823     Assert.assertEquals(expectedResponse, actualResponse);
824 
825     List<String> actualRequests = mockService.getRequestPaths();
826     Assert.assertEquals(1, actualRequests.size());
827 
828     String apiClientHeaderKey =
829         mockService
830             .getRequestHeaders()
831             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
832             .iterator()
833             .next();
834     Assert.assertTrue(
835         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
836             .matcher(apiClientHeaderKey)
837             .matches());
838   }
839 
840   @Test
createMuteConfigExceptionTest5()841   public void createMuteConfigExceptionTest5() throws Exception {
842     ApiException exception =
843         ApiExceptionFactory.createException(
844             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
845     mockService.addException(exception);
846 
847     try {
848       FolderName parent = FolderName.of("[FOLDER]");
849       MuteConfig muteConfig = MuteConfig.newBuilder().build();
850       String muteConfigId = "muteConfigId1689669942";
851       client.createMuteConfig(parent, muteConfig, muteConfigId);
852       Assert.fail("No exception raised");
853     } catch (InvalidArgumentException e) {
854       // Expected exception.
855     }
856   }
857 
858   @Test
createMuteConfigTest6()859   public void createMuteConfigTest6() throws Exception {
860     MuteConfig expectedResponse =
861         MuteConfig.newBuilder()
862             .setName(
863                 MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]")
864                     .toString())
865             .setDisplayName("displayName1714148973")
866             .setDescription("description-1724546052")
867             .setFilter("filter-1274492040")
868             .setCreateTime(Timestamp.newBuilder().build())
869             .setUpdateTime(Timestamp.newBuilder().build())
870             .setMostRecentEditor("mostRecentEditor-833861941")
871             .build();
872     mockService.addResponse(expectedResponse);
873 
874     OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
875     MuteConfig muteConfig = MuteConfig.newBuilder().build();
876     String muteConfigId = "muteConfigId1689669942";
877 
878     MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig, muteConfigId);
879     Assert.assertEquals(expectedResponse, actualResponse);
880 
881     List<String> actualRequests = mockService.getRequestPaths();
882     Assert.assertEquals(1, actualRequests.size());
883 
884     String apiClientHeaderKey =
885         mockService
886             .getRequestHeaders()
887             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
888             .iterator()
889             .next();
890     Assert.assertTrue(
891         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
892             .matcher(apiClientHeaderKey)
893             .matches());
894   }
895 
896   @Test
createMuteConfigExceptionTest6()897   public void createMuteConfigExceptionTest6() throws Exception {
898     ApiException exception =
899         ApiExceptionFactory.createException(
900             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
901     mockService.addException(exception);
902 
903     try {
904       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
905       MuteConfig muteConfig = MuteConfig.newBuilder().build();
906       String muteConfigId = "muteConfigId1689669942";
907       client.createMuteConfig(parent, muteConfig, muteConfigId);
908       Assert.fail("No exception raised");
909     } catch (InvalidArgumentException e) {
910       // Expected exception.
911     }
912   }
913 
914   @Test
createMuteConfigTest7()915   public void createMuteConfigTest7() throws Exception {
916     MuteConfig expectedResponse =
917         MuteConfig.newBuilder()
918             .setName(
919                 MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]")
920                     .toString())
921             .setDisplayName("displayName1714148973")
922             .setDescription("description-1724546052")
923             .setFilter("filter-1274492040")
924             .setCreateTime(Timestamp.newBuilder().build())
925             .setUpdateTime(Timestamp.newBuilder().build())
926             .setMostRecentEditor("mostRecentEditor-833861941")
927             .build();
928     mockService.addResponse(expectedResponse);
929 
930     ProjectName parent = ProjectName.of("[PROJECT]");
931     MuteConfig muteConfig = MuteConfig.newBuilder().build();
932     String muteConfigId = "muteConfigId1689669942";
933 
934     MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig, muteConfigId);
935     Assert.assertEquals(expectedResponse, actualResponse);
936 
937     List<String> actualRequests = mockService.getRequestPaths();
938     Assert.assertEquals(1, actualRequests.size());
939 
940     String apiClientHeaderKey =
941         mockService
942             .getRequestHeaders()
943             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
944             .iterator()
945             .next();
946     Assert.assertTrue(
947         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
948             .matcher(apiClientHeaderKey)
949             .matches());
950   }
951 
952   @Test
createMuteConfigExceptionTest7()953   public void createMuteConfigExceptionTest7() throws Exception {
954     ApiException exception =
955         ApiExceptionFactory.createException(
956             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
957     mockService.addException(exception);
958 
959     try {
960       ProjectName parent = ProjectName.of("[PROJECT]");
961       MuteConfig muteConfig = MuteConfig.newBuilder().build();
962       String muteConfigId = "muteConfigId1689669942";
963       client.createMuteConfig(parent, muteConfig, muteConfigId);
964       Assert.fail("No exception raised");
965     } catch (InvalidArgumentException e) {
966       // Expected exception.
967     }
968   }
969 
970   @Test
createMuteConfigTest8()971   public void createMuteConfigTest8() throws Exception {
972     MuteConfig expectedResponse =
973         MuteConfig.newBuilder()
974             .setName(
975                 MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]")
976                     .toString())
977             .setDisplayName("displayName1714148973")
978             .setDescription("description-1724546052")
979             .setFilter("filter-1274492040")
980             .setCreateTime(Timestamp.newBuilder().build())
981             .setUpdateTime(Timestamp.newBuilder().build())
982             .setMostRecentEditor("mostRecentEditor-833861941")
983             .build();
984     mockService.addResponse(expectedResponse);
985 
986     String parent = "organizations/organization-8287";
987     MuteConfig muteConfig = MuteConfig.newBuilder().build();
988     String muteConfigId = "muteConfigId1689669942";
989 
990     MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig, muteConfigId);
991     Assert.assertEquals(expectedResponse, actualResponse);
992 
993     List<String> actualRequests = mockService.getRequestPaths();
994     Assert.assertEquals(1, actualRequests.size());
995 
996     String apiClientHeaderKey =
997         mockService
998             .getRequestHeaders()
999             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1000             .iterator()
1001             .next();
1002     Assert.assertTrue(
1003         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1004             .matcher(apiClientHeaderKey)
1005             .matches());
1006   }
1007 
1008   @Test
createMuteConfigExceptionTest8()1009   public void createMuteConfigExceptionTest8() throws Exception {
1010     ApiException exception =
1011         ApiExceptionFactory.createException(
1012             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1013     mockService.addException(exception);
1014 
1015     try {
1016       String parent = "organizations/organization-8287";
1017       MuteConfig muteConfig = MuteConfig.newBuilder().build();
1018       String muteConfigId = "muteConfigId1689669942";
1019       client.createMuteConfig(parent, muteConfig, muteConfigId);
1020       Assert.fail("No exception raised");
1021     } catch (InvalidArgumentException e) {
1022       // Expected exception.
1023     }
1024   }
1025 
1026   @Test
createNotificationConfigTest()1027   public void createNotificationConfigTest() throws Exception {
1028     NotificationConfig expectedResponse =
1029         NotificationConfig.newBuilder()
1030             .setName(
1031                 NotificationConfigName.ofOrganizationNotificationConfigName(
1032                         "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
1033                     .toString())
1034             .setDescription("description-1724546052")
1035             .setPubsubTopic("pubsubTopic255880396")
1036             .setServiceAccount("serviceAccount1079137720")
1037             .build();
1038     mockService.addResponse(expectedResponse);
1039 
1040     FolderName parent = FolderName.of("[FOLDER]");
1041     NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1042 
1043     NotificationConfig actualResponse = client.createNotificationConfig(parent, notificationConfig);
1044     Assert.assertEquals(expectedResponse, actualResponse);
1045 
1046     List<String> actualRequests = mockService.getRequestPaths();
1047     Assert.assertEquals(1, actualRequests.size());
1048 
1049     String apiClientHeaderKey =
1050         mockService
1051             .getRequestHeaders()
1052             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1053             .iterator()
1054             .next();
1055     Assert.assertTrue(
1056         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1057             .matcher(apiClientHeaderKey)
1058             .matches());
1059   }
1060 
1061   @Test
createNotificationConfigExceptionTest()1062   public void createNotificationConfigExceptionTest() throws Exception {
1063     ApiException exception =
1064         ApiExceptionFactory.createException(
1065             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1066     mockService.addException(exception);
1067 
1068     try {
1069       FolderName parent = FolderName.of("[FOLDER]");
1070       NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1071       client.createNotificationConfig(parent, notificationConfig);
1072       Assert.fail("No exception raised");
1073     } catch (InvalidArgumentException e) {
1074       // Expected exception.
1075     }
1076   }
1077 
1078   @Test
createNotificationConfigTest2()1079   public void createNotificationConfigTest2() throws Exception {
1080     NotificationConfig expectedResponse =
1081         NotificationConfig.newBuilder()
1082             .setName(
1083                 NotificationConfigName.ofOrganizationNotificationConfigName(
1084                         "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
1085                     .toString())
1086             .setDescription("description-1724546052")
1087             .setPubsubTopic("pubsubTopic255880396")
1088             .setServiceAccount("serviceAccount1079137720")
1089             .build();
1090     mockService.addResponse(expectedResponse);
1091 
1092     OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
1093     NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1094 
1095     NotificationConfig actualResponse = client.createNotificationConfig(parent, notificationConfig);
1096     Assert.assertEquals(expectedResponse, actualResponse);
1097 
1098     List<String> actualRequests = mockService.getRequestPaths();
1099     Assert.assertEquals(1, actualRequests.size());
1100 
1101     String apiClientHeaderKey =
1102         mockService
1103             .getRequestHeaders()
1104             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1105             .iterator()
1106             .next();
1107     Assert.assertTrue(
1108         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1109             .matcher(apiClientHeaderKey)
1110             .matches());
1111   }
1112 
1113   @Test
createNotificationConfigExceptionTest2()1114   public void createNotificationConfigExceptionTest2() throws Exception {
1115     ApiException exception =
1116         ApiExceptionFactory.createException(
1117             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1118     mockService.addException(exception);
1119 
1120     try {
1121       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
1122       NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1123       client.createNotificationConfig(parent, notificationConfig);
1124       Assert.fail("No exception raised");
1125     } catch (InvalidArgumentException e) {
1126       // Expected exception.
1127     }
1128   }
1129 
1130   @Test
createNotificationConfigTest3()1131   public void createNotificationConfigTest3() throws Exception {
1132     NotificationConfig expectedResponse =
1133         NotificationConfig.newBuilder()
1134             .setName(
1135                 NotificationConfigName.ofOrganizationNotificationConfigName(
1136                         "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
1137                     .toString())
1138             .setDescription("description-1724546052")
1139             .setPubsubTopic("pubsubTopic255880396")
1140             .setServiceAccount("serviceAccount1079137720")
1141             .build();
1142     mockService.addResponse(expectedResponse);
1143 
1144     ProjectName parent = ProjectName.of("[PROJECT]");
1145     NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1146 
1147     NotificationConfig actualResponse = client.createNotificationConfig(parent, notificationConfig);
1148     Assert.assertEquals(expectedResponse, actualResponse);
1149 
1150     List<String> actualRequests = mockService.getRequestPaths();
1151     Assert.assertEquals(1, actualRequests.size());
1152 
1153     String apiClientHeaderKey =
1154         mockService
1155             .getRequestHeaders()
1156             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1157             .iterator()
1158             .next();
1159     Assert.assertTrue(
1160         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1161             .matcher(apiClientHeaderKey)
1162             .matches());
1163   }
1164 
1165   @Test
createNotificationConfigExceptionTest3()1166   public void createNotificationConfigExceptionTest3() throws Exception {
1167     ApiException exception =
1168         ApiExceptionFactory.createException(
1169             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1170     mockService.addException(exception);
1171 
1172     try {
1173       ProjectName parent = ProjectName.of("[PROJECT]");
1174       NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1175       client.createNotificationConfig(parent, notificationConfig);
1176       Assert.fail("No exception raised");
1177     } catch (InvalidArgumentException e) {
1178       // Expected exception.
1179     }
1180   }
1181 
1182   @Test
createNotificationConfigTest4()1183   public void createNotificationConfigTest4() throws Exception {
1184     NotificationConfig expectedResponse =
1185         NotificationConfig.newBuilder()
1186             .setName(
1187                 NotificationConfigName.ofOrganizationNotificationConfigName(
1188                         "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
1189                     .toString())
1190             .setDescription("description-1724546052")
1191             .setPubsubTopic("pubsubTopic255880396")
1192             .setServiceAccount("serviceAccount1079137720")
1193             .build();
1194     mockService.addResponse(expectedResponse);
1195 
1196     String parent = "organizations/organization-8287";
1197     NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1198 
1199     NotificationConfig actualResponse = client.createNotificationConfig(parent, notificationConfig);
1200     Assert.assertEquals(expectedResponse, actualResponse);
1201 
1202     List<String> actualRequests = mockService.getRequestPaths();
1203     Assert.assertEquals(1, actualRequests.size());
1204 
1205     String apiClientHeaderKey =
1206         mockService
1207             .getRequestHeaders()
1208             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1209             .iterator()
1210             .next();
1211     Assert.assertTrue(
1212         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1213             .matcher(apiClientHeaderKey)
1214             .matches());
1215   }
1216 
1217   @Test
createNotificationConfigExceptionTest4()1218   public void createNotificationConfigExceptionTest4() throws Exception {
1219     ApiException exception =
1220         ApiExceptionFactory.createException(
1221             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1222     mockService.addException(exception);
1223 
1224     try {
1225       String parent = "organizations/organization-8287";
1226       NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1227       client.createNotificationConfig(parent, notificationConfig);
1228       Assert.fail("No exception raised");
1229     } catch (InvalidArgumentException e) {
1230       // Expected exception.
1231     }
1232   }
1233 
1234   @Test
createNotificationConfigTest5()1235   public void createNotificationConfigTest5() throws Exception {
1236     NotificationConfig expectedResponse =
1237         NotificationConfig.newBuilder()
1238             .setName(
1239                 NotificationConfigName.ofOrganizationNotificationConfigName(
1240                         "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
1241                     .toString())
1242             .setDescription("description-1724546052")
1243             .setPubsubTopic("pubsubTopic255880396")
1244             .setServiceAccount("serviceAccount1079137720")
1245             .build();
1246     mockService.addResponse(expectedResponse);
1247 
1248     FolderName parent = FolderName.of("[FOLDER]");
1249     String configId = "configId-580140035";
1250     NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1251 
1252     NotificationConfig actualResponse =
1253         client.createNotificationConfig(parent, configId, notificationConfig);
1254     Assert.assertEquals(expectedResponse, actualResponse);
1255 
1256     List<String> actualRequests = mockService.getRequestPaths();
1257     Assert.assertEquals(1, actualRequests.size());
1258 
1259     String apiClientHeaderKey =
1260         mockService
1261             .getRequestHeaders()
1262             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1263             .iterator()
1264             .next();
1265     Assert.assertTrue(
1266         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1267             .matcher(apiClientHeaderKey)
1268             .matches());
1269   }
1270 
1271   @Test
createNotificationConfigExceptionTest5()1272   public void createNotificationConfigExceptionTest5() throws Exception {
1273     ApiException exception =
1274         ApiExceptionFactory.createException(
1275             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1276     mockService.addException(exception);
1277 
1278     try {
1279       FolderName parent = FolderName.of("[FOLDER]");
1280       String configId = "configId-580140035";
1281       NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1282       client.createNotificationConfig(parent, configId, notificationConfig);
1283       Assert.fail("No exception raised");
1284     } catch (InvalidArgumentException e) {
1285       // Expected exception.
1286     }
1287   }
1288 
1289   @Test
createNotificationConfigTest6()1290   public void createNotificationConfigTest6() throws Exception {
1291     NotificationConfig expectedResponse =
1292         NotificationConfig.newBuilder()
1293             .setName(
1294                 NotificationConfigName.ofOrganizationNotificationConfigName(
1295                         "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
1296                     .toString())
1297             .setDescription("description-1724546052")
1298             .setPubsubTopic("pubsubTopic255880396")
1299             .setServiceAccount("serviceAccount1079137720")
1300             .build();
1301     mockService.addResponse(expectedResponse);
1302 
1303     OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
1304     String configId = "configId-580140035";
1305     NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1306 
1307     NotificationConfig actualResponse =
1308         client.createNotificationConfig(parent, configId, notificationConfig);
1309     Assert.assertEquals(expectedResponse, actualResponse);
1310 
1311     List<String> actualRequests = mockService.getRequestPaths();
1312     Assert.assertEquals(1, actualRequests.size());
1313 
1314     String apiClientHeaderKey =
1315         mockService
1316             .getRequestHeaders()
1317             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1318             .iterator()
1319             .next();
1320     Assert.assertTrue(
1321         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1322             .matcher(apiClientHeaderKey)
1323             .matches());
1324   }
1325 
1326   @Test
createNotificationConfigExceptionTest6()1327   public void createNotificationConfigExceptionTest6() throws Exception {
1328     ApiException exception =
1329         ApiExceptionFactory.createException(
1330             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1331     mockService.addException(exception);
1332 
1333     try {
1334       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
1335       String configId = "configId-580140035";
1336       NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1337       client.createNotificationConfig(parent, configId, notificationConfig);
1338       Assert.fail("No exception raised");
1339     } catch (InvalidArgumentException e) {
1340       // Expected exception.
1341     }
1342   }
1343 
1344   @Test
createNotificationConfigTest7()1345   public void createNotificationConfigTest7() throws Exception {
1346     NotificationConfig expectedResponse =
1347         NotificationConfig.newBuilder()
1348             .setName(
1349                 NotificationConfigName.ofOrganizationNotificationConfigName(
1350                         "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
1351                     .toString())
1352             .setDescription("description-1724546052")
1353             .setPubsubTopic("pubsubTopic255880396")
1354             .setServiceAccount("serviceAccount1079137720")
1355             .build();
1356     mockService.addResponse(expectedResponse);
1357 
1358     ProjectName parent = ProjectName.of("[PROJECT]");
1359     String configId = "configId-580140035";
1360     NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1361 
1362     NotificationConfig actualResponse =
1363         client.createNotificationConfig(parent, configId, notificationConfig);
1364     Assert.assertEquals(expectedResponse, actualResponse);
1365 
1366     List<String> actualRequests = mockService.getRequestPaths();
1367     Assert.assertEquals(1, actualRequests.size());
1368 
1369     String apiClientHeaderKey =
1370         mockService
1371             .getRequestHeaders()
1372             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1373             .iterator()
1374             .next();
1375     Assert.assertTrue(
1376         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1377             .matcher(apiClientHeaderKey)
1378             .matches());
1379   }
1380 
1381   @Test
createNotificationConfigExceptionTest7()1382   public void createNotificationConfigExceptionTest7() throws Exception {
1383     ApiException exception =
1384         ApiExceptionFactory.createException(
1385             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1386     mockService.addException(exception);
1387 
1388     try {
1389       ProjectName parent = ProjectName.of("[PROJECT]");
1390       String configId = "configId-580140035";
1391       NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1392       client.createNotificationConfig(parent, configId, notificationConfig);
1393       Assert.fail("No exception raised");
1394     } catch (InvalidArgumentException e) {
1395       // Expected exception.
1396     }
1397   }
1398 
1399   @Test
createNotificationConfigTest8()1400   public void createNotificationConfigTest8() throws Exception {
1401     NotificationConfig expectedResponse =
1402         NotificationConfig.newBuilder()
1403             .setName(
1404                 NotificationConfigName.ofOrganizationNotificationConfigName(
1405                         "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
1406                     .toString())
1407             .setDescription("description-1724546052")
1408             .setPubsubTopic("pubsubTopic255880396")
1409             .setServiceAccount("serviceAccount1079137720")
1410             .build();
1411     mockService.addResponse(expectedResponse);
1412 
1413     String parent = "organizations/organization-8287";
1414     String configId = "configId-580140035";
1415     NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1416 
1417     NotificationConfig actualResponse =
1418         client.createNotificationConfig(parent, configId, notificationConfig);
1419     Assert.assertEquals(expectedResponse, actualResponse);
1420 
1421     List<String> actualRequests = mockService.getRequestPaths();
1422     Assert.assertEquals(1, actualRequests.size());
1423 
1424     String apiClientHeaderKey =
1425         mockService
1426             .getRequestHeaders()
1427             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1428             .iterator()
1429             .next();
1430     Assert.assertTrue(
1431         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1432             .matcher(apiClientHeaderKey)
1433             .matches());
1434   }
1435 
1436   @Test
createNotificationConfigExceptionTest8()1437   public void createNotificationConfigExceptionTest8() throws Exception {
1438     ApiException exception =
1439         ApiExceptionFactory.createException(
1440             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1441     mockService.addException(exception);
1442 
1443     try {
1444       String parent = "organizations/organization-8287";
1445       String configId = "configId-580140035";
1446       NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
1447       client.createNotificationConfig(parent, configId, notificationConfig);
1448       Assert.fail("No exception raised");
1449     } catch (InvalidArgumentException e) {
1450       // Expected exception.
1451     }
1452   }
1453 
1454   @Test
deleteMuteConfigTest()1455   public void deleteMuteConfigTest() throws Exception {
1456     Empty expectedResponse = Empty.newBuilder().build();
1457     mockService.addResponse(expectedResponse);
1458 
1459     MuteConfigName name =
1460         MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]");
1461 
1462     client.deleteMuteConfig(name);
1463 
1464     List<String> actualRequests = mockService.getRequestPaths();
1465     Assert.assertEquals(1, actualRequests.size());
1466 
1467     String apiClientHeaderKey =
1468         mockService
1469             .getRequestHeaders()
1470             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1471             .iterator()
1472             .next();
1473     Assert.assertTrue(
1474         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1475             .matcher(apiClientHeaderKey)
1476             .matches());
1477   }
1478 
1479   @Test
deleteMuteConfigExceptionTest()1480   public void deleteMuteConfigExceptionTest() throws Exception {
1481     ApiException exception =
1482         ApiExceptionFactory.createException(
1483             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1484     mockService.addException(exception);
1485 
1486     try {
1487       MuteConfigName name =
1488           MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]");
1489       client.deleteMuteConfig(name);
1490       Assert.fail("No exception raised");
1491     } catch (InvalidArgumentException e) {
1492       // Expected exception.
1493     }
1494   }
1495 
1496   @Test
deleteMuteConfigTest2()1497   public void deleteMuteConfigTest2() throws Exception {
1498     Empty expectedResponse = Empty.newBuilder().build();
1499     mockService.addResponse(expectedResponse);
1500 
1501     String name = "organizations/organization-3180/muteConfigs/muteConfig-3180";
1502 
1503     client.deleteMuteConfig(name);
1504 
1505     List<String> actualRequests = mockService.getRequestPaths();
1506     Assert.assertEquals(1, actualRequests.size());
1507 
1508     String apiClientHeaderKey =
1509         mockService
1510             .getRequestHeaders()
1511             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1512             .iterator()
1513             .next();
1514     Assert.assertTrue(
1515         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1516             .matcher(apiClientHeaderKey)
1517             .matches());
1518   }
1519 
1520   @Test
deleteMuteConfigExceptionTest2()1521   public void deleteMuteConfigExceptionTest2() throws Exception {
1522     ApiException exception =
1523         ApiExceptionFactory.createException(
1524             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1525     mockService.addException(exception);
1526 
1527     try {
1528       String name = "organizations/organization-3180/muteConfigs/muteConfig-3180";
1529       client.deleteMuteConfig(name);
1530       Assert.fail("No exception raised");
1531     } catch (InvalidArgumentException e) {
1532       // Expected exception.
1533     }
1534   }
1535 
1536   @Test
deleteNotificationConfigTest()1537   public void deleteNotificationConfigTest() throws Exception {
1538     Empty expectedResponse = Empty.newBuilder().build();
1539     mockService.addResponse(expectedResponse);
1540 
1541     NotificationConfigName name =
1542         NotificationConfigName.ofOrganizationNotificationConfigName(
1543             "[ORGANIZATION]", "[NOTIFICATION_CONFIG]");
1544 
1545     client.deleteNotificationConfig(name);
1546 
1547     List<String> actualRequests = mockService.getRequestPaths();
1548     Assert.assertEquals(1, actualRequests.size());
1549 
1550     String apiClientHeaderKey =
1551         mockService
1552             .getRequestHeaders()
1553             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1554             .iterator()
1555             .next();
1556     Assert.assertTrue(
1557         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1558             .matcher(apiClientHeaderKey)
1559             .matches());
1560   }
1561 
1562   @Test
deleteNotificationConfigExceptionTest()1563   public void deleteNotificationConfigExceptionTest() throws Exception {
1564     ApiException exception =
1565         ApiExceptionFactory.createException(
1566             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1567     mockService.addException(exception);
1568 
1569     try {
1570       NotificationConfigName name =
1571           NotificationConfigName.ofOrganizationNotificationConfigName(
1572               "[ORGANIZATION]", "[NOTIFICATION_CONFIG]");
1573       client.deleteNotificationConfig(name);
1574       Assert.fail("No exception raised");
1575     } catch (InvalidArgumentException e) {
1576       // Expected exception.
1577     }
1578   }
1579 
1580   @Test
deleteNotificationConfigTest2()1581   public void deleteNotificationConfigTest2() throws Exception {
1582     Empty expectedResponse = Empty.newBuilder().build();
1583     mockService.addResponse(expectedResponse);
1584 
1585     String name = "organizations/organization-7374/notificationConfigs/notificationConfig-7374";
1586 
1587     client.deleteNotificationConfig(name);
1588 
1589     List<String> actualRequests = mockService.getRequestPaths();
1590     Assert.assertEquals(1, actualRequests.size());
1591 
1592     String apiClientHeaderKey =
1593         mockService
1594             .getRequestHeaders()
1595             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1596             .iterator()
1597             .next();
1598     Assert.assertTrue(
1599         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1600             .matcher(apiClientHeaderKey)
1601             .matches());
1602   }
1603 
1604   @Test
deleteNotificationConfigExceptionTest2()1605   public void deleteNotificationConfigExceptionTest2() throws Exception {
1606     ApiException exception =
1607         ApiExceptionFactory.createException(
1608             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1609     mockService.addException(exception);
1610 
1611     try {
1612       String name = "organizations/organization-7374/notificationConfigs/notificationConfig-7374";
1613       client.deleteNotificationConfig(name);
1614       Assert.fail("No exception raised");
1615     } catch (InvalidArgumentException e) {
1616       // Expected exception.
1617     }
1618   }
1619 
1620   @Test
deleteSecurityHealthAnalyticsCustomModuleTest()1621   public void deleteSecurityHealthAnalyticsCustomModuleTest() throws Exception {
1622     Empty expectedResponse = Empty.newBuilder().build();
1623     mockService.addResponse(expectedResponse);
1624 
1625     SecurityHealthAnalyticsCustomModuleName name =
1626         SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
1627             "[ORGANIZATION]", "[CUSTOM_MODULE]");
1628 
1629     client.deleteSecurityHealthAnalyticsCustomModule(name);
1630 
1631     List<String> actualRequests = mockService.getRequestPaths();
1632     Assert.assertEquals(1, actualRequests.size());
1633 
1634     String apiClientHeaderKey =
1635         mockService
1636             .getRequestHeaders()
1637             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1638             .iterator()
1639             .next();
1640     Assert.assertTrue(
1641         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1642             .matcher(apiClientHeaderKey)
1643             .matches());
1644   }
1645 
1646   @Test
deleteSecurityHealthAnalyticsCustomModuleExceptionTest()1647   public void deleteSecurityHealthAnalyticsCustomModuleExceptionTest() throws Exception {
1648     ApiException exception =
1649         ApiExceptionFactory.createException(
1650             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1651     mockService.addException(exception);
1652 
1653     try {
1654       SecurityHealthAnalyticsCustomModuleName name =
1655           SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
1656               "[ORGANIZATION]", "[CUSTOM_MODULE]");
1657       client.deleteSecurityHealthAnalyticsCustomModule(name);
1658       Assert.fail("No exception raised");
1659     } catch (InvalidArgumentException e) {
1660       // Expected exception.
1661     }
1662   }
1663 
1664   @Test
deleteSecurityHealthAnalyticsCustomModuleTest2()1665   public void deleteSecurityHealthAnalyticsCustomModuleTest2() throws Exception {
1666     Empty expectedResponse = Empty.newBuilder().build();
1667     mockService.addResponse(expectedResponse);
1668 
1669     String name =
1670         "organizations/organization-3280/securityHealthAnalyticsSettings/customModules/customModule-3280";
1671 
1672     client.deleteSecurityHealthAnalyticsCustomModule(name);
1673 
1674     List<String> actualRequests = mockService.getRequestPaths();
1675     Assert.assertEquals(1, actualRequests.size());
1676 
1677     String apiClientHeaderKey =
1678         mockService
1679             .getRequestHeaders()
1680             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1681             .iterator()
1682             .next();
1683     Assert.assertTrue(
1684         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1685             .matcher(apiClientHeaderKey)
1686             .matches());
1687   }
1688 
1689   @Test
deleteSecurityHealthAnalyticsCustomModuleExceptionTest2()1690   public void deleteSecurityHealthAnalyticsCustomModuleExceptionTest2() throws Exception {
1691     ApiException exception =
1692         ApiExceptionFactory.createException(
1693             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1694     mockService.addException(exception);
1695 
1696     try {
1697       String name =
1698           "organizations/organization-3280/securityHealthAnalyticsSettings/customModules/customModule-3280";
1699       client.deleteSecurityHealthAnalyticsCustomModule(name);
1700       Assert.fail("No exception raised");
1701     } catch (InvalidArgumentException e) {
1702       // Expected exception.
1703     }
1704   }
1705 
1706   @Test
getBigQueryExportTest()1707   public void getBigQueryExportTest() throws Exception {
1708     BigQueryExport expectedResponse =
1709         BigQueryExport.newBuilder()
1710             .setName(
1711                 BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]")
1712                     .toString())
1713             .setDescription("description-1724546052")
1714             .setFilter("filter-1274492040")
1715             .setDataset("dataset1443214456")
1716             .setCreateTime(Timestamp.newBuilder().build())
1717             .setUpdateTime(Timestamp.newBuilder().build())
1718             .setMostRecentEditor("mostRecentEditor-833861941")
1719             .setPrincipal("principal-1812041682")
1720             .build();
1721     mockService.addResponse(expectedResponse);
1722 
1723     BigQueryExportName name =
1724         BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]");
1725 
1726     BigQueryExport actualResponse = client.getBigQueryExport(name);
1727     Assert.assertEquals(expectedResponse, actualResponse);
1728 
1729     List<String> actualRequests = mockService.getRequestPaths();
1730     Assert.assertEquals(1, actualRequests.size());
1731 
1732     String apiClientHeaderKey =
1733         mockService
1734             .getRequestHeaders()
1735             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1736             .iterator()
1737             .next();
1738     Assert.assertTrue(
1739         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1740             .matcher(apiClientHeaderKey)
1741             .matches());
1742   }
1743 
1744   @Test
getBigQueryExportExceptionTest()1745   public void getBigQueryExportExceptionTest() throws Exception {
1746     ApiException exception =
1747         ApiExceptionFactory.createException(
1748             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1749     mockService.addException(exception);
1750 
1751     try {
1752       BigQueryExportName name =
1753           BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]");
1754       client.getBigQueryExport(name);
1755       Assert.fail("No exception raised");
1756     } catch (InvalidArgumentException e) {
1757       // Expected exception.
1758     }
1759   }
1760 
1761   @Test
getBigQueryExportTest2()1762   public void getBigQueryExportTest2() throws Exception {
1763     BigQueryExport expectedResponse =
1764         BigQueryExport.newBuilder()
1765             .setName(
1766                 BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]")
1767                     .toString())
1768             .setDescription("description-1724546052")
1769             .setFilter("filter-1274492040")
1770             .setDataset("dataset1443214456")
1771             .setCreateTime(Timestamp.newBuilder().build())
1772             .setUpdateTime(Timestamp.newBuilder().build())
1773             .setMostRecentEditor("mostRecentEditor-833861941")
1774             .setPrincipal("principal-1812041682")
1775             .build();
1776     mockService.addResponse(expectedResponse);
1777 
1778     String name = "organizations/organization-3683/bigQueryExports/bigQueryExport-3683";
1779 
1780     BigQueryExport actualResponse = client.getBigQueryExport(name);
1781     Assert.assertEquals(expectedResponse, actualResponse);
1782 
1783     List<String> actualRequests = mockService.getRequestPaths();
1784     Assert.assertEquals(1, actualRequests.size());
1785 
1786     String apiClientHeaderKey =
1787         mockService
1788             .getRequestHeaders()
1789             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1790             .iterator()
1791             .next();
1792     Assert.assertTrue(
1793         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1794             .matcher(apiClientHeaderKey)
1795             .matches());
1796   }
1797 
1798   @Test
getBigQueryExportExceptionTest2()1799   public void getBigQueryExportExceptionTest2() throws Exception {
1800     ApiException exception =
1801         ApiExceptionFactory.createException(
1802             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1803     mockService.addException(exception);
1804 
1805     try {
1806       String name = "organizations/organization-3683/bigQueryExports/bigQueryExport-3683";
1807       client.getBigQueryExport(name);
1808       Assert.fail("No exception raised");
1809     } catch (InvalidArgumentException e) {
1810       // Expected exception.
1811     }
1812   }
1813 
1814   @Test
getIamPolicyTest()1815   public void getIamPolicyTest() throws Exception {
1816     Policy expectedResponse =
1817         Policy.newBuilder()
1818             .setVersion(351608024)
1819             .addAllBindings(new ArrayList<Binding>())
1820             .addAllAuditConfigs(new ArrayList<AuditConfig>())
1821             .setEtag(ByteString.EMPTY)
1822             .build();
1823     mockService.addResponse(expectedResponse);
1824 
1825     ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]");
1826 
1827     Policy actualResponse = client.getIamPolicy(resource);
1828     Assert.assertEquals(expectedResponse, actualResponse);
1829 
1830     List<String> actualRequests = mockService.getRequestPaths();
1831     Assert.assertEquals(1, actualRequests.size());
1832 
1833     String apiClientHeaderKey =
1834         mockService
1835             .getRequestHeaders()
1836             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1837             .iterator()
1838             .next();
1839     Assert.assertTrue(
1840         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1841             .matcher(apiClientHeaderKey)
1842             .matches());
1843   }
1844 
1845   @Test
getIamPolicyExceptionTest()1846   public void getIamPolicyExceptionTest() throws Exception {
1847     ApiException exception =
1848         ApiExceptionFactory.createException(
1849             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1850     mockService.addException(exception);
1851 
1852     try {
1853       ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]");
1854       client.getIamPolicy(resource);
1855       Assert.fail("No exception raised");
1856     } catch (InvalidArgumentException e) {
1857       // Expected exception.
1858     }
1859   }
1860 
1861   @Test
getIamPolicyTest2()1862   public void getIamPolicyTest2() throws Exception {
1863     Policy expectedResponse =
1864         Policy.newBuilder()
1865             .setVersion(351608024)
1866             .addAllBindings(new ArrayList<Binding>())
1867             .addAllAuditConfigs(new ArrayList<AuditConfig>())
1868             .setEtag(ByteString.EMPTY)
1869             .build();
1870     mockService.addResponse(expectedResponse);
1871 
1872     String resource = "organizations/organization-3393/sources/source-3393";
1873 
1874     Policy actualResponse = client.getIamPolicy(resource);
1875     Assert.assertEquals(expectedResponse, actualResponse);
1876 
1877     List<String> actualRequests = mockService.getRequestPaths();
1878     Assert.assertEquals(1, actualRequests.size());
1879 
1880     String apiClientHeaderKey =
1881         mockService
1882             .getRequestHeaders()
1883             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1884             .iterator()
1885             .next();
1886     Assert.assertTrue(
1887         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1888             .matcher(apiClientHeaderKey)
1889             .matches());
1890   }
1891 
1892   @Test
getIamPolicyExceptionTest2()1893   public void getIamPolicyExceptionTest2() throws Exception {
1894     ApiException exception =
1895         ApiExceptionFactory.createException(
1896             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1897     mockService.addException(exception);
1898 
1899     try {
1900       String resource = "organizations/organization-3393/sources/source-3393";
1901       client.getIamPolicy(resource);
1902       Assert.fail("No exception raised");
1903     } catch (InvalidArgumentException e) {
1904       // Expected exception.
1905     }
1906   }
1907 
1908   @Test
getMuteConfigTest()1909   public void getMuteConfigTest() throws Exception {
1910     MuteConfig expectedResponse =
1911         MuteConfig.newBuilder()
1912             .setName(
1913                 MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]")
1914                     .toString())
1915             .setDisplayName("displayName1714148973")
1916             .setDescription("description-1724546052")
1917             .setFilter("filter-1274492040")
1918             .setCreateTime(Timestamp.newBuilder().build())
1919             .setUpdateTime(Timestamp.newBuilder().build())
1920             .setMostRecentEditor("mostRecentEditor-833861941")
1921             .build();
1922     mockService.addResponse(expectedResponse);
1923 
1924     MuteConfigName name =
1925         MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]");
1926 
1927     MuteConfig actualResponse = client.getMuteConfig(name);
1928     Assert.assertEquals(expectedResponse, actualResponse);
1929 
1930     List<String> actualRequests = mockService.getRequestPaths();
1931     Assert.assertEquals(1, actualRequests.size());
1932 
1933     String apiClientHeaderKey =
1934         mockService
1935             .getRequestHeaders()
1936             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1937             .iterator()
1938             .next();
1939     Assert.assertTrue(
1940         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1941             .matcher(apiClientHeaderKey)
1942             .matches());
1943   }
1944 
1945   @Test
getMuteConfigExceptionTest()1946   public void getMuteConfigExceptionTest() throws Exception {
1947     ApiException exception =
1948         ApiExceptionFactory.createException(
1949             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1950     mockService.addException(exception);
1951 
1952     try {
1953       MuteConfigName name =
1954           MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]");
1955       client.getMuteConfig(name);
1956       Assert.fail("No exception raised");
1957     } catch (InvalidArgumentException e) {
1958       // Expected exception.
1959     }
1960   }
1961 
1962   @Test
getMuteConfigTest2()1963   public void getMuteConfigTest2() throws Exception {
1964     MuteConfig expectedResponse =
1965         MuteConfig.newBuilder()
1966             .setName(
1967                 MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]")
1968                     .toString())
1969             .setDisplayName("displayName1714148973")
1970             .setDescription("description-1724546052")
1971             .setFilter("filter-1274492040")
1972             .setCreateTime(Timestamp.newBuilder().build())
1973             .setUpdateTime(Timestamp.newBuilder().build())
1974             .setMostRecentEditor("mostRecentEditor-833861941")
1975             .build();
1976     mockService.addResponse(expectedResponse);
1977 
1978     String name = "organizations/organization-3180/muteConfigs/muteConfig-3180";
1979 
1980     MuteConfig actualResponse = client.getMuteConfig(name);
1981     Assert.assertEquals(expectedResponse, actualResponse);
1982 
1983     List<String> actualRequests = mockService.getRequestPaths();
1984     Assert.assertEquals(1, actualRequests.size());
1985 
1986     String apiClientHeaderKey =
1987         mockService
1988             .getRequestHeaders()
1989             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1990             .iterator()
1991             .next();
1992     Assert.assertTrue(
1993         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1994             .matcher(apiClientHeaderKey)
1995             .matches());
1996   }
1997 
1998   @Test
getMuteConfigExceptionTest2()1999   public void getMuteConfigExceptionTest2() throws Exception {
2000     ApiException exception =
2001         ApiExceptionFactory.createException(
2002             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2003     mockService.addException(exception);
2004 
2005     try {
2006       String name = "organizations/organization-3180/muteConfigs/muteConfig-3180";
2007       client.getMuteConfig(name);
2008       Assert.fail("No exception raised");
2009     } catch (InvalidArgumentException e) {
2010       // Expected exception.
2011     }
2012   }
2013 
2014   @Test
getNotificationConfigTest()2015   public void getNotificationConfigTest() throws Exception {
2016     NotificationConfig expectedResponse =
2017         NotificationConfig.newBuilder()
2018             .setName(
2019                 NotificationConfigName.ofOrganizationNotificationConfigName(
2020                         "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
2021                     .toString())
2022             .setDescription("description-1724546052")
2023             .setPubsubTopic("pubsubTopic255880396")
2024             .setServiceAccount("serviceAccount1079137720")
2025             .build();
2026     mockService.addResponse(expectedResponse);
2027 
2028     NotificationConfigName name =
2029         NotificationConfigName.ofOrganizationNotificationConfigName(
2030             "[ORGANIZATION]", "[NOTIFICATION_CONFIG]");
2031 
2032     NotificationConfig actualResponse = client.getNotificationConfig(name);
2033     Assert.assertEquals(expectedResponse, actualResponse);
2034 
2035     List<String> actualRequests = mockService.getRequestPaths();
2036     Assert.assertEquals(1, actualRequests.size());
2037 
2038     String apiClientHeaderKey =
2039         mockService
2040             .getRequestHeaders()
2041             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2042             .iterator()
2043             .next();
2044     Assert.assertTrue(
2045         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2046             .matcher(apiClientHeaderKey)
2047             .matches());
2048   }
2049 
2050   @Test
getNotificationConfigExceptionTest()2051   public void getNotificationConfigExceptionTest() throws Exception {
2052     ApiException exception =
2053         ApiExceptionFactory.createException(
2054             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2055     mockService.addException(exception);
2056 
2057     try {
2058       NotificationConfigName name =
2059           NotificationConfigName.ofOrganizationNotificationConfigName(
2060               "[ORGANIZATION]", "[NOTIFICATION_CONFIG]");
2061       client.getNotificationConfig(name);
2062       Assert.fail("No exception raised");
2063     } catch (InvalidArgumentException e) {
2064       // Expected exception.
2065     }
2066   }
2067 
2068   @Test
getNotificationConfigTest2()2069   public void getNotificationConfigTest2() throws Exception {
2070     NotificationConfig expectedResponse =
2071         NotificationConfig.newBuilder()
2072             .setName(
2073                 NotificationConfigName.ofOrganizationNotificationConfigName(
2074                         "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
2075                     .toString())
2076             .setDescription("description-1724546052")
2077             .setPubsubTopic("pubsubTopic255880396")
2078             .setServiceAccount("serviceAccount1079137720")
2079             .build();
2080     mockService.addResponse(expectedResponse);
2081 
2082     String name = "organizations/organization-7374/notificationConfigs/notificationConfig-7374";
2083 
2084     NotificationConfig actualResponse = client.getNotificationConfig(name);
2085     Assert.assertEquals(expectedResponse, actualResponse);
2086 
2087     List<String> actualRequests = mockService.getRequestPaths();
2088     Assert.assertEquals(1, actualRequests.size());
2089 
2090     String apiClientHeaderKey =
2091         mockService
2092             .getRequestHeaders()
2093             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2094             .iterator()
2095             .next();
2096     Assert.assertTrue(
2097         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2098             .matcher(apiClientHeaderKey)
2099             .matches());
2100   }
2101 
2102   @Test
getNotificationConfigExceptionTest2()2103   public void getNotificationConfigExceptionTest2() throws Exception {
2104     ApiException exception =
2105         ApiExceptionFactory.createException(
2106             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2107     mockService.addException(exception);
2108 
2109     try {
2110       String name = "organizations/organization-7374/notificationConfigs/notificationConfig-7374";
2111       client.getNotificationConfig(name);
2112       Assert.fail("No exception raised");
2113     } catch (InvalidArgumentException e) {
2114       // Expected exception.
2115     }
2116   }
2117 
2118   @Test
getOrganizationSettingsTest()2119   public void getOrganizationSettingsTest() throws Exception {
2120     OrganizationSettings expectedResponse =
2121         OrganizationSettings.newBuilder()
2122             .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString())
2123             .setEnableAssetDiscovery(true)
2124             .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build())
2125             .build();
2126     mockService.addResponse(expectedResponse);
2127 
2128     OrganizationSettingsName name = OrganizationSettingsName.of("[ORGANIZATION]");
2129 
2130     OrganizationSettings actualResponse = client.getOrganizationSettings(name);
2131     Assert.assertEquals(expectedResponse, actualResponse);
2132 
2133     List<String> actualRequests = mockService.getRequestPaths();
2134     Assert.assertEquals(1, actualRequests.size());
2135 
2136     String apiClientHeaderKey =
2137         mockService
2138             .getRequestHeaders()
2139             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2140             .iterator()
2141             .next();
2142     Assert.assertTrue(
2143         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2144             .matcher(apiClientHeaderKey)
2145             .matches());
2146   }
2147 
2148   @Test
getOrganizationSettingsExceptionTest()2149   public void getOrganizationSettingsExceptionTest() throws Exception {
2150     ApiException exception =
2151         ApiExceptionFactory.createException(
2152             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2153     mockService.addException(exception);
2154 
2155     try {
2156       OrganizationSettingsName name = OrganizationSettingsName.of("[ORGANIZATION]");
2157       client.getOrganizationSettings(name);
2158       Assert.fail("No exception raised");
2159     } catch (InvalidArgumentException e) {
2160       // Expected exception.
2161     }
2162   }
2163 
2164   @Test
getOrganizationSettingsTest2()2165   public void getOrganizationSettingsTest2() throws Exception {
2166     OrganizationSettings expectedResponse =
2167         OrganizationSettings.newBuilder()
2168             .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString())
2169             .setEnableAssetDiscovery(true)
2170             .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build())
2171             .build();
2172     mockService.addResponse(expectedResponse);
2173 
2174     String name = "organizations/organization-9995/organizationSettings";
2175 
2176     OrganizationSettings actualResponse = client.getOrganizationSettings(name);
2177     Assert.assertEquals(expectedResponse, actualResponse);
2178 
2179     List<String> actualRequests = mockService.getRequestPaths();
2180     Assert.assertEquals(1, actualRequests.size());
2181 
2182     String apiClientHeaderKey =
2183         mockService
2184             .getRequestHeaders()
2185             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2186             .iterator()
2187             .next();
2188     Assert.assertTrue(
2189         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2190             .matcher(apiClientHeaderKey)
2191             .matches());
2192   }
2193 
2194   @Test
getOrganizationSettingsExceptionTest2()2195   public void getOrganizationSettingsExceptionTest2() throws Exception {
2196     ApiException exception =
2197         ApiExceptionFactory.createException(
2198             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2199     mockService.addException(exception);
2200 
2201     try {
2202       String name = "organizations/organization-9995/organizationSettings";
2203       client.getOrganizationSettings(name);
2204       Assert.fail("No exception raised");
2205     } catch (InvalidArgumentException e) {
2206       // Expected exception.
2207     }
2208   }
2209 
2210   @Test
getEffectiveSecurityHealthAnalyticsCustomModuleTest()2211   public void getEffectiveSecurityHealthAnalyticsCustomModuleTest() throws Exception {
2212     EffectiveSecurityHealthAnalyticsCustomModule expectedResponse =
2213         EffectiveSecurityHealthAnalyticsCustomModule.newBuilder()
2214             .setName(
2215                 EffectiveSecurityHealthAnalyticsCustomModuleName
2216                     .ofOrganizationEffectiveCustomModuleName(
2217                         "[ORGANIZATION]", "[EFFECTIVE_CUSTOM_MODULE]")
2218                     .toString())
2219             .setCustomConfig(CustomConfig.newBuilder().build())
2220             .setDisplayName("displayName1714148973")
2221             .build();
2222     mockService.addResponse(expectedResponse);
2223 
2224     EffectiveSecurityHealthAnalyticsCustomModuleName name =
2225         EffectiveSecurityHealthAnalyticsCustomModuleName.ofOrganizationEffectiveCustomModuleName(
2226             "[ORGANIZATION]", "[EFFECTIVE_CUSTOM_MODULE]");
2227 
2228     EffectiveSecurityHealthAnalyticsCustomModule actualResponse =
2229         client.getEffectiveSecurityHealthAnalyticsCustomModule(name);
2230     Assert.assertEquals(expectedResponse, actualResponse);
2231 
2232     List<String> actualRequests = mockService.getRequestPaths();
2233     Assert.assertEquals(1, actualRequests.size());
2234 
2235     String apiClientHeaderKey =
2236         mockService
2237             .getRequestHeaders()
2238             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2239             .iterator()
2240             .next();
2241     Assert.assertTrue(
2242         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2243             .matcher(apiClientHeaderKey)
2244             .matches());
2245   }
2246 
2247   @Test
getEffectiveSecurityHealthAnalyticsCustomModuleExceptionTest()2248   public void getEffectiveSecurityHealthAnalyticsCustomModuleExceptionTest() throws Exception {
2249     ApiException exception =
2250         ApiExceptionFactory.createException(
2251             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2252     mockService.addException(exception);
2253 
2254     try {
2255       EffectiveSecurityHealthAnalyticsCustomModuleName name =
2256           EffectiveSecurityHealthAnalyticsCustomModuleName.ofOrganizationEffectiveCustomModuleName(
2257               "[ORGANIZATION]", "[EFFECTIVE_CUSTOM_MODULE]");
2258       client.getEffectiveSecurityHealthAnalyticsCustomModule(name);
2259       Assert.fail("No exception raised");
2260     } catch (InvalidArgumentException e) {
2261       // Expected exception.
2262     }
2263   }
2264 
2265   @Test
getEffectiveSecurityHealthAnalyticsCustomModuleTest2()2266   public void getEffectiveSecurityHealthAnalyticsCustomModuleTest2() throws Exception {
2267     EffectiveSecurityHealthAnalyticsCustomModule expectedResponse =
2268         EffectiveSecurityHealthAnalyticsCustomModule.newBuilder()
2269             .setName(
2270                 EffectiveSecurityHealthAnalyticsCustomModuleName
2271                     .ofOrganizationEffectiveCustomModuleName(
2272                         "[ORGANIZATION]", "[EFFECTIVE_CUSTOM_MODULE]")
2273                     .toString())
2274             .setCustomConfig(CustomConfig.newBuilder().build())
2275             .setDisplayName("displayName1714148973")
2276             .build();
2277     mockService.addResponse(expectedResponse);
2278 
2279     String name =
2280         "organizations/organization-9493/securityHealthAnalyticsSettings/effectiveCustomModules/effectiveCustomModule-9493";
2281 
2282     EffectiveSecurityHealthAnalyticsCustomModule actualResponse =
2283         client.getEffectiveSecurityHealthAnalyticsCustomModule(name);
2284     Assert.assertEquals(expectedResponse, actualResponse);
2285 
2286     List<String> actualRequests = mockService.getRequestPaths();
2287     Assert.assertEquals(1, actualRequests.size());
2288 
2289     String apiClientHeaderKey =
2290         mockService
2291             .getRequestHeaders()
2292             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2293             .iterator()
2294             .next();
2295     Assert.assertTrue(
2296         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2297             .matcher(apiClientHeaderKey)
2298             .matches());
2299   }
2300 
2301   @Test
getEffectiveSecurityHealthAnalyticsCustomModuleExceptionTest2()2302   public void getEffectiveSecurityHealthAnalyticsCustomModuleExceptionTest2() throws Exception {
2303     ApiException exception =
2304         ApiExceptionFactory.createException(
2305             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2306     mockService.addException(exception);
2307 
2308     try {
2309       String name =
2310           "organizations/organization-9493/securityHealthAnalyticsSettings/effectiveCustomModules/effectiveCustomModule-9493";
2311       client.getEffectiveSecurityHealthAnalyticsCustomModule(name);
2312       Assert.fail("No exception raised");
2313     } catch (InvalidArgumentException e) {
2314       // Expected exception.
2315     }
2316   }
2317 
2318   @Test
getSecurityHealthAnalyticsCustomModuleTest()2319   public void getSecurityHealthAnalyticsCustomModuleTest() throws Exception {
2320     SecurityHealthAnalyticsCustomModule expectedResponse =
2321         SecurityHealthAnalyticsCustomModule.newBuilder()
2322             .setName(
2323                 SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
2324                         "[ORGANIZATION]", "[CUSTOM_MODULE]")
2325                     .toString())
2326             .setDisplayName("displayName1714148973")
2327             .setUpdateTime(Timestamp.newBuilder().build())
2328             .setLastEditor("lastEditor1523898275")
2329             .setAncestorModule(
2330                 SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
2331                         "[ORGANIZATION]", "[CUSTOM_MODULE]")
2332                     .toString())
2333             .setCustomConfig(CustomConfig.newBuilder().build())
2334             .build();
2335     mockService.addResponse(expectedResponse);
2336 
2337     SecurityHealthAnalyticsCustomModuleName name =
2338         SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
2339             "[ORGANIZATION]", "[CUSTOM_MODULE]");
2340 
2341     SecurityHealthAnalyticsCustomModule actualResponse =
2342         client.getSecurityHealthAnalyticsCustomModule(name);
2343     Assert.assertEquals(expectedResponse, actualResponse);
2344 
2345     List<String> actualRequests = mockService.getRequestPaths();
2346     Assert.assertEquals(1, actualRequests.size());
2347 
2348     String apiClientHeaderKey =
2349         mockService
2350             .getRequestHeaders()
2351             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2352             .iterator()
2353             .next();
2354     Assert.assertTrue(
2355         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2356             .matcher(apiClientHeaderKey)
2357             .matches());
2358   }
2359 
2360   @Test
getSecurityHealthAnalyticsCustomModuleExceptionTest()2361   public void getSecurityHealthAnalyticsCustomModuleExceptionTest() throws Exception {
2362     ApiException exception =
2363         ApiExceptionFactory.createException(
2364             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2365     mockService.addException(exception);
2366 
2367     try {
2368       SecurityHealthAnalyticsCustomModuleName name =
2369           SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
2370               "[ORGANIZATION]", "[CUSTOM_MODULE]");
2371       client.getSecurityHealthAnalyticsCustomModule(name);
2372       Assert.fail("No exception raised");
2373     } catch (InvalidArgumentException e) {
2374       // Expected exception.
2375     }
2376   }
2377 
2378   @Test
getSecurityHealthAnalyticsCustomModuleTest2()2379   public void getSecurityHealthAnalyticsCustomModuleTest2() throws Exception {
2380     SecurityHealthAnalyticsCustomModule expectedResponse =
2381         SecurityHealthAnalyticsCustomModule.newBuilder()
2382             .setName(
2383                 SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
2384                         "[ORGANIZATION]", "[CUSTOM_MODULE]")
2385                     .toString())
2386             .setDisplayName("displayName1714148973")
2387             .setUpdateTime(Timestamp.newBuilder().build())
2388             .setLastEditor("lastEditor1523898275")
2389             .setAncestorModule(
2390                 SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
2391                         "[ORGANIZATION]", "[CUSTOM_MODULE]")
2392                     .toString())
2393             .setCustomConfig(CustomConfig.newBuilder().build())
2394             .build();
2395     mockService.addResponse(expectedResponse);
2396 
2397     String name =
2398         "organizations/organization-3280/securityHealthAnalyticsSettings/customModules/customModule-3280";
2399 
2400     SecurityHealthAnalyticsCustomModule actualResponse =
2401         client.getSecurityHealthAnalyticsCustomModule(name);
2402     Assert.assertEquals(expectedResponse, actualResponse);
2403 
2404     List<String> actualRequests = mockService.getRequestPaths();
2405     Assert.assertEquals(1, actualRequests.size());
2406 
2407     String apiClientHeaderKey =
2408         mockService
2409             .getRequestHeaders()
2410             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2411             .iterator()
2412             .next();
2413     Assert.assertTrue(
2414         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2415             .matcher(apiClientHeaderKey)
2416             .matches());
2417   }
2418 
2419   @Test
getSecurityHealthAnalyticsCustomModuleExceptionTest2()2420   public void getSecurityHealthAnalyticsCustomModuleExceptionTest2() throws Exception {
2421     ApiException exception =
2422         ApiExceptionFactory.createException(
2423             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2424     mockService.addException(exception);
2425 
2426     try {
2427       String name =
2428           "organizations/organization-3280/securityHealthAnalyticsSettings/customModules/customModule-3280";
2429       client.getSecurityHealthAnalyticsCustomModule(name);
2430       Assert.fail("No exception raised");
2431     } catch (InvalidArgumentException e) {
2432       // Expected exception.
2433     }
2434   }
2435 
2436   @Test
getSourceTest()2437   public void getSourceTest() throws Exception {
2438     Source expectedResponse =
2439         Source.newBuilder()
2440             .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString())
2441             .setDisplayName("displayName1714148973")
2442             .setDescription("description-1724546052")
2443             .setCanonicalName("canonicalName2122381727")
2444             .build();
2445     mockService.addResponse(expectedResponse);
2446 
2447     SourceName name = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]");
2448 
2449     Source actualResponse = client.getSource(name);
2450     Assert.assertEquals(expectedResponse, actualResponse);
2451 
2452     List<String> actualRequests = mockService.getRequestPaths();
2453     Assert.assertEquals(1, actualRequests.size());
2454 
2455     String apiClientHeaderKey =
2456         mockService
2457             .getRequestHeaders()
2458             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2459             .iterator()
2460             .next();
2461     Assert.assertTrue(
2462         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2463             .matcher(apiClientHeaderKey)
2464             .matches());
2465   }
2466 
2467   @Test
getSourceExceptionTest()2468   public void getSourceExceptionTest() throws Exception {
2469     ApiException exception =
2470         ApiExceptionFactory.createException(
2471             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2472     mockService.addException(exception);
2473 
2474     try {
2475       SourceName name = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]");
2476       client.getSource(name);
2477       Assert.fail("No exception raised");
2478     } catch (InvalidArgumentException e) {
2479       // Expected exception.
2480     }
2481   }
2482 
2483   @Test
getSourceTest2()2484   public void getSourceTest2() throws Exception {
2485     Source expectedResponse =
2486         Source.newBuilder()
2487             .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString())
2488             .setDisplayName("displayName1714148973")
2489             .setDescription("description-1724546052")
2490             .setCanonicalName("canonicalName2122381727")
2491             .build();
2492     mockService.addResponse(expectedResponse);
2493 
2494     String name = "organizations/organization-7292/sources/source-7292";
2495 
2496     Source actualResponse = client.getSource(name);
2497     Assert.assertEquals(expectedResponse, actualResponse);
2498 
2499     List<String> actualRequests = mockService.getRequestPaths();
2500     Assert.assertEquals(1, actualRequests.size());
2501 
2502     String apiClientHeaderKey =
2503         mockService
2504             .getRequestHeaders()
2505             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2506             .iterator()
2507             .next();
2508     Assert.assertTrue(
2509         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2510             .matcher(apiClientHeaderKey)
2511             .matches());
2512   }
2513 
2514   @Test
getSourceExceptionTest2()2515   public void getSourceExceptionTest2() throws Exception {
2516     ApiException exception =
2517         ApiExceptionFactory.createException(
2518             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2519     mockService.addException(exception);
2520 
2521     try {
2522       String name = "organizations/organization-7292/sources/source-7292";
2523       client.getSource(name);
2524       Assert.fail("No exception raised");
2525     } catch (InvalidArgumentException e) {
2526       // Expected exception.
2527     }
2528   }
2529 
2530   @Test
groupAssetsTest()2531   public void groupAssetsTest() throws Exception {
2532     GroupResult responsesElement = GroupResult.newBuilder().build();
2533     GroupAssetsResponse expectedResponse =
2534         GroupAssetsResponse.newBuilder()
2535             .setNextPageToken("")
2536             .addAllGroupByResults(Arrays.asList(responsesElement))
2537             .build();
2538     mockService.addResponse(expectedResponse);
2539 
2540     GroupAssetsRequest request =
2541         GroupAssetsRequest.newBuilder()
2542             .setParent(OrganizationName.of("[ORGANIZATION]").toString())
2543             .setFilter("filter-1274492040")
2544             .setGroupBy("groupBy293428022")
2545             .setCompareDuration(Duration.newBuilder().build())
2546             .setReadTime(Timestamp.newBuilder().build())
2547             .setPageToken("pageToken873572522")
2548             .setPageSize(883849137)
2549             .build();
2550 
2551     GroupAssetsPagedResponse pagedListResponse = client.groupAssets(request);
2552 
2553     List<GroupResult> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2554 
2555     Assert.assertEquals(1, resources.size());
2556     Assert.assertEquals(expectedResponse.getGroupByResultsList().get(0), resources.get(0));
2557 
2558     List<String> actualRequests = mockService.getRequestPaths();
2559     Assert.assertEquals(1, actualRequests.size());
2560 
2561     String apiClientHeaderKey =
2562         mockService
2563             .getRequestHeaders()
2564             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2565             .iterator()
2566             .next();
2567     Assert.assertTrue(
2568         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2569             .matcher(apiClientHeaderKey)
2570             .matches());
2571   }
2572 
2573   @Test
groupAssetsExceptionTest()2574   public void groupAssetsExceptionTest() throws Exception {
2575     ApiException exception =
2576         ApiExceptionFactory.createException(
2577             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2578     mockService.addException(exception);
2579 
2580     try {
2581       GroupAssetsRequest request =
2582           GroupAssetsRequest.newBuilder()
2583               .setParent(OrganizationName.of("[ORGANIZATION]").toString())
2584               .setFilter("filter-1274492040")
2585               .setGroupBy("groupBy293428022")
2586               .setCompareDuration(Duration.newBuilder().build())
2587               .setReadTime(Timestamp.newBuilder().build())
2588               .setPageToken("pageToken873572522")
2589               .setPageSize(883849137)
2590               .build();
2591       client.groupAssets(request);
2592       Assert.fail("No exception raised");
2593     } catch (InvalidArgumentException e) {
2594       // Expected exception.
2595     }
2596   }
2597 
2598   @Test
groupFindingsTest()2599   public void groupFindingsTest() throws Exception {
2600     GroupResult responsesElement = GroupResult.newBuilder().build();
2601     GroupFindingsResponse expectedResponse =
2602         GroupFindingsResponse.newBuilder()
2603             .setNextPageToken("")
2604             .addAllGroupByResults(Arrays.asList(responsesElement))
2605             .build();
2606     mockService.addResponse(expectedResponse);
2607 
2608     SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]");
2609     String groupBy = "groupBy293428022";
2610 
2611     GroupFindingsPagedResponse pagedListResponse = client.groupFindings(parent, groupBy);
2612 
2613     List<GroupResult> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2614 
2615     Assert.assertEquals(1, resources.size());
2616     Assert.assertEquals(expectedResponse.getGroupByResultsList().get(0), resources.get(0));
2617 
2618     List<String> actualRequests = mockService.getRequestPaths();
2619     Assert.assertEquals(1, actualRequests.size());
2620 
2621     String apiClientHeaderKey =
2622         mockService
2623             .getRequestHeaders()
2624             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2625             .iterator()
2626             .next();
2627     Assert.assertTrue(
2628         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2629             .matcher(apiClientHeaderKey)
2630             .matches());
2631   }
2632 
2633   @Test
groupFindingsExceptionTest()2634   public void groupFindingsExceptionTest() throws Exception {
2635     ApiException exception =
2636         ApiExceptionFactory.createException(
2637             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2638     mockService.addException(exception);
2639 
2640     try {
2641       SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]");
2642       String groupBy = "groupBy293428022";
2643       client.groupFindings(parent, groupBy);
2644       Assert.fail("No exception raised");
2645     } catch (InvalidArgumentException e) {
2646       // Expected exception.
2647     }
2648   }
2649 
2650   @Test
groupFindingsTest2()2651   public void groupFindingsTest2() throws Exception {
2652     GroupResult responsesElement = GroupResult.newBuilder().build();
2653     GroupFindingsResponse expectedResponse =
2654         GroupFindingsResponse.newBuilder()
2655             .setNextPageToken("")
2656             .addAllGroupByResults(Arrays.asList(responsesElement))
2657             .build();
2658     mockService.addResponse(expectedResponse);
2659 
2660     String parent = "organizations/organization-8741/sources/source-8741";
2661     String groupBy = "groupBy293428022";
2662 
2663     GroupFindingsPagedResponse pagedListResponse = client.groupFindings(parent, groupBy);
2664 
2665     List<GroupResult> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2666 
2667     Assert.assertEquals(1, resources.size());
2668     Assert.assertEquals(expectedResponse.getGroupByResultsList().get(0), resources.get(0));
2669 
2670     List<String> actualRequests = mockService.getRequestPaths();
2671     Assert.assertEquals(1, actualRequests.size());
2672 
2673     String apiClientHeaderKey =
2674         mockService
2675             .getRequestHeaders()
2676             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2677             .iterator()
2678             .next();
2679     Assert.assertTrue(
2680         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2681             .matcher(apiClientHeaderKey)
2682             .matches());
2683   }
2684 
2685   @Test
groupFindingsExceptionTest2()2686   public void groupFindingsExceptionTest2() throws Exception {
2687     ApiException exception =
2688         ApiExceptionFactory.createException(
2689             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2690     mockService.addException(exception);
2691 
2692     try {
2693       String parent = "organizations/organization-8741/sources/source-8741";
2694       String groupBy = "groupBy293428022";
2695       client.groupFindings(parent, groupBy);
2696       Assert.fail("No exception raised");
2697     } catch (InvalidArgumentException e) {
2698       // Expected exception.
2699     }
2700   }
2701 
2702   @Test
listAssetsTest()2703   public void listAssetsTest() throws Exception {
2704     ListAssetsResponse.ListAssetsResult responsesElement =
2705         ListAssetsResponse.ListAssetsResult.newBuilder().build();
2706     ListAssetsResponse expectedResponse =
2707         ListAssetsResponse.newBuilder()
2708             .setNextPageToken("")
2709             .addAllListAssetsResults(Arrays.asList(responsesElement))
2710             .build();
2711     mockService.addResponse(expectedResponse);
2712 
2713     ListAssetsRequest request =
2714         ListAssetsRequest.newBuilder()
2715             .setParent(OrganizationName.of("[ORGANIZATION]").toString())
2716             .setFilter("filter-1274492040")
2717             .setOrderBy("orderBy-1207110587")
2718             .setReadTime(Timestamp.newBuilder().build())
2719             .setCompareDuration(Duration.newBuilder().build())
2720             .setFieldMask(FieldMask.newBuilder().build())
2721             .setPageToken("pageToken873572522")
2722             .setPageSize(883849137)
2723             .build();
2724 
2725     ListAssetsPagedResponse pagedListResponse = client.listAssets(request);
2726 
2727     List<ListAssetsResponse.ListAssetsResult> resources =
2728         Lists.newArrayList(pagedListResponse.iterateAll());
2729 
2730     Assert.assertEquals(1, resources.size());
2731     Assert.assertEquals(expectedResponse.getListAssetsResultsList().get(0), resources.get(0));
2732 
2733     List<String> actualRequests = mockService.getRequestPaths();
2734     Assert.assertEquals(1, actualRequests.size());
2735 
2736     String apiClientHeaderKey =
2737         mockService
2738             .getRequestHeaders()
2739             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2740             .iterator()
2741             .next();
2742     Assert.assertTrue(
2743         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2744             .matcher(apiClientHeaderKey)
2745             .matches());
2746   }
2747 
2748   @Test
listAssetsExceptionTest()2749   public void listAssetsExceptionTest() throws Exception {
2750     ApiException exception =
2751         ApiExceptionFactory.createException(
2752             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2753     mockService.addException(exception);
2754 
2755     try {
2756       ListAssetsRequest request =
2757           ListAssetsRequest.newBuilder()
2758               .setParent(OrganizationName.of("[ORGANIZATION]").toString())
2759               .setFilter("filter-1274492040")
2760               .setOrderBy("orderBy-1207110587")
2761               .setReadTime(Timestamp.newBuilder().build())
2762               .setCompareDuration(Duration.newBuilder().build())
2763               .setFieldMask(FieldMask.newBuilder().build())
2764               .setPageToken("pageToken873572522")
2765               .setPageSize(883849137)
2766               .build();
2767       client.listAssets(request);
2768       Assert.fail("No exception raised");
2769     } catch (InvalidArgumentException e) {
2770       // Expected exception.
2771     }
2772   }
2773 
2774   @Test
listDescendantSecurityHealthAnalyticsCustomModulesTest()2775   public void listDescendantSecurityHealthAnalyticsCustomModulesTest() throws Exception {
2776     SecurityHealthAnalyticsCustomModule responsesElement =
2777         SecurityHealthAnalyticsCustomModule.newBuilder().build();
2778     ListDescendantSecurityHealthAnalyticsCustomModulesResponse expectedResponse =
2779         ListDescendantSecurityHealthAnalyticsCustomModulesResponse.newBuilder()
2780             .setNextPageToken("")
2781             .addAllSecurityHealthAnalyticsCustomModules(Arrays.asList(responsesElement))
2782             .build();
2783     mockService.addResponse(expectedResponse);
2784 
2785     SecurityHealthAnalyticsSettingsName parent =
2786         SecurityHealthAnalyticsSettingsName.ofOrganizationName("[ORGANIZATION]");
2787 
2788     ListDescendantSecurityHealthAnalyticsCustomModulesPagedResponse pagedListResponse =
2789         client.listDescendantSecurityHealthAnalyticsCustomModules(parent);
2790 
2791     List<SecurityHealthAnalyticsCustomModule> resources =
2792         Lists.newArrayList(pagedListResponse.iterateAll());
2793 
2794     Assert.assertEquals(1, resources.size());
2795     Assert.assertEquals(
2796         expectedResponse.getSecurityHealthAnalyticsCustomModulesList().get(0), resources.get(0));
2797 
2798     List<String> actualRequests = mockService.getRequestPaths();
2799     Assert.assertEquals(1, actualRequests.size());
2800 
2801     String apiClientHeaderKey =
2802         mockService
2803             .getRequestHeaders()
2804             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2805             .iterator()
2806             .next();
2807     Assert.assertTrue(
2808         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2809             .matcher(apiClientHeaderKey)
2810             .matches());
2811   }
2812 
2813   @Test
listDescendantSecurityHealthAnalyticsCustomModulesExceptionTest()2814   public void listDescendantSecurityHealthAnalyticsCustomModulesExceptionTest() throws Exception {
2815     ApiException exception =
2816         ApiExceptionFactory.createException(
2817             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2818     mockService.addException(exception);
2819 
2820     try {
2821       SecurityHealthAnalyticsSettingsName parent =
2822           SecurityHealthAnalyticsSettingsName.ofOrganizationName("[ORGANIZATION]");
2823       client.listDescendantSecurityHealthAnalyticsCustomModules(parent);
2824       Assert.fail("No exception raised");
2825     } catch (InvalidArgumentException e) {
2826       // Expected exception.
2827     }
2828   }
2829 
2830   @Test
listDescendantSecurityHealthAnalyticsCustomModulesTest2()2831   public void listDescendantSecurityHealthAnalyticsCustomModulesTest2() throws Exception {
2832     SecurityHealthAnalyticsCustomModule responsesElement =
2833         SecurityHealthAnalyticsCustomModule.newBuilder().build();
2834     ListDescendantSecurityHealthAnalyticsCustomModulesResponse expectedResponse =
2835         ListDescendantSecurityHealthAnalyticsCustomModulesResponse.newBuilder()
2836             .setNextPageToken("")
2837             .addAllSecurityHealthAnalyticsCustomModules(Arrays.asList(responsesElement))
2838             .build();
2839     mockService.addResponse(expectedResponse);
2840 
2841     String parent = "organizations/organization-7807/securityHealthAnalyticsSettings";
2842 
2843     ListDescendantSecurityHealthAnalyticsCustomModulesPagedResponse pagedListResponse =
2844         client.listDescendantSecurityHealthAnalyticsCustomModules(parent);
2845 
2846     List<SecurityHealthAnalyticsCustomModule> resources =
2847         Lists.newArrayList(pagedListResponse.iterateAll());
2848 
2849     Assert.assertEquals(1, resources.size());
2850     Assert.assertEquals(
2851         expectedResponse.getSecurityHealthAnalyticsCustomModulesList().get(0), resources.get(0));
2852 
2853     List<String> actualRequests = mockService.getRequestPaths();
2854     Assert.assertEquals(1, actualRequests.size());
2855 
2856     String apiClientHeaderKey =
2857         mockService
2858             .getRequestHeaders()
2859             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2860             .iterator()
2861             .next();
2862     Assert.assertTrue(
2863         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2864             .matcher(apiClientHeaderKey)
2865             .matches());
2866   }
2867 
2868   @Test
listDescendantSecurityHealthAnalyticsCustomModulesExceptionTest2()2869   public void listDescendantSecurityHealthAnalyticsCustomModulesExceptionTest2() throws Exception {
2870     ApiException exception =
2871         ApiExceptionFactory.createException(
2872             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2873     mockService.addException(exception);
2874 
2875     try {
2876       String parent = "organizations/organization-7807/securityHealthAnalyticsSettings";
2877       client.listDescendantSecurityHealthAnalyticsCustomModules(parent);
2878       Assert.fail("No exception raised");
2879     } catch (InvalidArgumentException e) {
2880       // Expected exception.
2881     }
2882   }
2883 
2884   @Test
listFindingsTest()2885   public void listFindingsTest() throws Exception {
2886     ListFindingsResponse.ListFindingsResult responsesElement =
2887         ListFindingsResponse.ListFindingsResult.newBuilder().build();
2888     ListFindingsResponse expectedResponse =
2889         ListFindingsResponse.newBuilder()
2890             .setNextPageToken("")
2891             .addAllListFindingsResults(Arrays.asList(responsesElement))
2892             .build();
2893     mockService.addResponse(expectedResponse);
2894 
2895     ListFindingsRequest request =
2896         ListFindingsRequest.newBuilder()
2897             .setParent(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString())
2898             .setFilter("filter-1274492040")
2899             .setOrderBy("orderBy-1207110587")
2900             .setReadTime(Timestamp.newBuilder().build())
2901             .setCompareDuration(Duration.newBuilder().build())
2902             .setFieldMask(FieldMask.newBuilder().build())
2903             .setPageToken("pageToken873572522")
2904             .setPageSize(883849137)
2905             .build();
2906 
2907     ListFindingsPagedResponse pagedListResponse = client.listFindings(request);
2908 
2909     List<ListFindingsResponse.ListFindingsResult> resources =
2910         Lists.newArrayList(pagedListResponse.iterateAll());
2911 
2912     Assert.assertEquals(1, resources.size());
2913     Assert.assertEquals(expectedResponse.getListFindingsResultsList().get(0), resources.get(0));
2914 
2915     List<String> actualRequests = mockService.getRequestPaths();
2916     Assert.assertEquals(1, actualRequests.size());
2917 
2918     String apiClientHeaderKey =
2919         mockService
2920             .getRequestHeaders()
2921             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2922             .iterator()
2923             .next();
2924     Assert.assertTrue(
2925         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2926             .matcher(apiClientHeaderKey)
2927             .matches());
2928   }
2929 
2930   @Test
listFindingsExceptionTest()2931   public void listFindingsExceptionTest() throws Exception {
2932     ApiException exception =
2933         ApiExceptionFactory.createException(
2934             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2935     mockService.addException(exception);
2936 
2937     try {
2938       ListFindingsRequest request =
2939           ListFindingsRequest.newBuilder()
2940               .setParent(
2941                   SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString())
2942               .setFilter("filter-1274492040")
2943               .setOrderBy("orderBy-1207110587")
2944               .setReadTime(Timestamp.newBuilder().build())
2945               .setCompareDuration(Duration.newBuilder().build())
2946               .setFieldMask(FieldMask.newBuilder().build())
2947               .setPageToken("pageToken873572522")
2948               .setPageSize(883849137)
2949               .build();
2950       client.listFindings(request);
2951       Assert.fail("No exception raised");
2952     } catch (InvalidArgumentException e) {
2953       // Expected exception.
2954     }
2955   }
2956 
2957   @Test
listMuteConfigsTest()2958   public void listMuteConfigsTest() throws Exception {
2959     MuteConfig responsesElement = MuteConfig.newBuilder().build();
2960     ListMuteConfigsResponse expectedResponse =
2961         ListMuteConfigsResponse.newBuilder()
2962             .setNextPageToken("")
2963             .addAllMuteConfigs(Arrays.asList(responsesElement))
2964             .build();
2965     mockService.addResponse(expectedResponse);
2966 
2967     FolderName parent = FolderName.of("[FOLDER]");
2968 
2969     ListMuteConfigsPagedResponse pagedListResponse = client.listMuteConfigs(parent);
2970 
2971     List<MuteConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2972 
2973     Assert.assertEquals(1, resources.size());
2974     Assert.assertEquals(expectedResponse.getMuteConfigsList().get(0), resources.get(0));
2975 
2976     List<String> actualRequests = mockService.getRequestPaths();
2977     Assert.assertEquals(1, actualRequests.size());
2978 
2979     String apiClientHeaderKey =
2980         mockService
2981             .getRequestHeaders()
2982             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2983             .iterator()
2984             .next();
2985     Assert.assertTrue(
2986         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2987             .matcher(apiClientHeaderKey)
2988             .matches());
2989   }
2990 
2991   @Test
listMuteConfigsExceptionTest()2992   public void listMuteConfigsExceptionTest() throws Exception {
2993     ApiException exception =
2994         ApiExceptionFactory.createException(
2995             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2996     mockService.addException(exception);
2997 
2998     try {
2999       FolderName parent = FolderName.of("[FOLDER]");
3000       client.listMuteConfigs(parent);
3001       Assert.fail("No exception raised");
3002     } catch (InvalidArgumentException e) {
3003       // Expected exception.
3004     }
3005   }
3006 
3007   @Test
listMuteConfigsTest2()3008   public void listMuteConfigsTest2() throws Exception {
3009     MuteConfig responsesElement = MuteConfig.newBuilder().build();
3010     ListMuteConfigsResponse expectedResponse =
3011         ListMuteConfigsResponse.newBuilder()
3012             .setNextPageToken("")
3013             .addAllMuteConfigs(Arrays.asList(responsesElement))
3014             .build();
3015     mockService.addResponse(expectedResponse);
3016 
3017     OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
3018 
3019     ListMuteConfigsPagedResponse pagedListResponse = client.listMuteConfigs(parent);
3020 
3021     List<MuteConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3022 
3023     Assert.assertEquals(1, resources.size());
3024     Assert.assertEquals(expectedResponse.getMuteConfigsList().get(0), resources.get(0));
3025 
3026     List<String> actualRequests = mockService.getRequestPaths();
3027     Assert.assertEquals(1, actualRequests.size());
3028 
3029     String apiClientHeaderKey =
3030         mockService
3031             .getRequestHeaders()
3032             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3033             .iterator()
3034             .next();
3035     Assert.assertTrue(
3036         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3037             .matcher(apiClientHeaderKey)
3038             .matches());
3039   }
3040 
3041   @Test
listMuteConfigsExceptionTest2()3042   public void listMuteConfigsExceptionTest2() throws Exception {
3043     ApiException exception =
3044         ApiExceptionFactory.createException(
3045             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3046     mockService.addException(exception);
3047 
3048     try {
3049       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
3050       client.listMuteConfigs(parent);
3051       Assert.fail("No exception raised");
3052     } catch (InvalidArgumentException e) {
3053       // Expected exception.
3054     }
3055   }
3056 
3057   @Test
listMuteConfigsTest3()3058   public void listMuteConfigsTest3() throws Exception {
3059     MuteConfig responsesElement = MuteConfig.newBuilder().build();
3060     ListMuteConfigsResponse expectedResponse =
3061         ListMuteConfigsResponse.newBuilder()
3062             .setNextPageToken("")
3063             .addAllMuteConfigs(Arrays.asList(responsesElement))
3064             .build();
3065     mockService.addResponse(expectedResponse);
3066 
3067     ProjectName parent = ProjectName.of("[PROJECT]");
3068 
3069     ListMuteConfigsPagedResponse pagedListResponse = client.listMuteConfigs(parent);
3070 
3071     List<MuteConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3072 
3073     Assert.assertEquals(1, resources.size());
3074     Assert.assertEquals(expectedResponse.getMuteConfigsList().get(0), resources.get(0));
3075 
3076     List<String> actualRequests = mockService.getRequestPaths();
3077     Assert.assertEquals(1, actualRequests.size());
3078 
3079     String apiClientHeaderKey =
3080         mockService
3081             .getRequestHeaders()
3082             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3083             .iterator()
3084             .next();
3085     Assert.assertTrue(
3086         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3087             .matcher(apiClientHeaderKey)
3088             .matches());
3089   }
3090 
3091   @Test
listMuteConfigsExceptionTest3()3092   public void listMuteConfigsExceptionTest3() throws Exception {
3093     ApiException exception =
3094         ApiExceptionFactory.createException(
3095             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3096     mockService.addException(exception);
3097 
3098     try {
3099       ProjectName parent = ProjectName.of("[PROJECT]");
3100       client.listMuteConfigs(parent);
3101       Assert.fail("No exception raised");
3102     } catch (InvalidArgumentException e) {
3103       // Expected exception.
3104     }
3105   }
3106 
3107   @Test
listMuteConfigsTest4()3108   public void listMuteConfigsTest4() throws Exception {
3109     MuteConfig responsesElement = MuteConfig.newBuilder().build();
3110     ListMuteConfigsResponse expectedResponse =
3111         ListMuteConfigsResponse.newBuilder()
3112             .setNextPageToken("")
3113             .addAllMuteConfigs(Arrays.asList(responsesElement))
3114             .build();
3115     mockService.addResponse(expectedResponse);
3116 
3117     String parent = "organizations/organization-8287";
3118 
3119     ListMuteConfigsPagedResponse pagedListResponse = client.listMuteConfigs(parent);
3120 
3121     List<MuteConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3122 
3123     Assert.assertEquals(1, resources.size());
3124     Assert.assertEquals(expectedResponse.getMuteConfigsList().get(0), resources.get(0));
3125 
3126     List<String> actualRequests = mockService.getRequestPaths();
3127     Assert.assertEquals(1, actualRequests.size());
3128 
3129     String apiClientHeaderKey =
3130         mockService
3131             .getRequestHeaders()
3132             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3133             .iterator()
3134             .next();
3135     Assert.assertTrue(
3136         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3137             .matcher(apiClientHeaderKey)
3138             .matches());
3139   }
3140 
3141   @Test
listMuteConfigsExceptionTest4()3142   public void listMuteConfigsExceptionTest4() throws Exception {
3143     ApiException exception =
3144         ApiExceptionFactory.createException(
3145             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3146     mockService.addException(exception);
3147 
3148     try {
3149       String parent = "organizations/organization-8287";
3150       client.listMuteConfigs(parent);
3151       Assert.fail("No exception raised");
3152     } catch (InvalidArgumentException e) {
3153       // Expected exception.
3154     }
3155   }
3156 
3157   @Test
listNotificationConfigsTest()3158   public void listNotificationConfigsTest() throws Exception {
3159     NotificationConfig responsesElement = NotificationConfig.newBuilder().build();
3160     ListNotificationConfigsResponse expectedResponse =
3161         ListNotificationConfigsResponse.newBuilder()
3162             .setNextPageToken("")
3163             .addAllNotificationConfigs(Arrays.asList(responsesElement))
3164             .build();
3165     mockService.addResponse(expectedResponse);
3166 
3167     FolderName parent = FolderName.of("[FOLDER]");
3168 
3169     ListNotificationConfigsPagedResponse pagedListResponse = client.listNotificationConfigs(parent);
3170 
3171     List<NotificationConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3172 
3173     Assert.assertEquals(1, resources.size());
3174     Assert.assertEquals(expectedResponse.getNotificationConfigsList().get(0), resources.get(0));
3175 
3176     List<String> actualRequests = mockService.getRequestPaths();
3177     Assert.assertEquals(1, actualRequests.size());
3178 
3179     String apiClientHeaderKey =
3180         mockService
3181             .getRequestHeaders()
3182             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3183             .iterator()
3184             .next();
3185     Assert.assertTrue(
3186         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3187             .matcher(apiClientHeaderKey)
3188             .matches());
3189   }
3190 
3191   @Test
listNotificationConfigsExceptionTest()3192   public void listNotificationConfigsExceptionTest() throws Exception {
3193     ApiException exception =
3194         ApiExceptionFactory.createException(
3195             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3196     mockService.addException(exception);
3197 
3198     try {
3199       FolderName parent = FolderName.of("[FOLDER]");
3200       client.listNotificationConfigs(parent);
3201       Assert.fail("No exception raised");
3202     } catch (InvalidArgumentException e) {
3203       // Expected exception.
3204     }
3205   }
3206 
3207   @Test
listNotificationConfigsTest2()3208   public void listNotificationConfigsTest2() throws Exception {
3209     NotificationConfig responsesElement = NotificationConfig.newBuilder().build();
3210     ListNotificationConfigsResponse expectedResponse =
3211         ListNotificationConfigsResponse.newBuilder()
3212             .setNextPageToken("")
3213             .addAllNotificationConfigs(Arrays.asList(responsesElement))
3214             .build();
3215     mockService.addResponse(expectedResponse);
3216 
3217     OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
3218 
3219     ListNotificationConfigsPagedResponse pagedListResponse = client.listNotificationConfigs(parent);
3220 
3221     List<NotificationConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3222 
3223     Assert.assertEquals(1, resources.size());
3224     Assert.assertEquals(expectedResponse.getNotificationConfigsList().get(0), resources.get(0));
3225 
3226     List<String> actualRequests = mockService.getRequestPaths();
3227     Assert.assertEquals(1, actualRequests.size());
3228 
3229     String apiClientHeaderKey =
3230         mockService
3231             .getRequestHeaders()
3232             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3233             .iterator()
3234             .next();
3235     Assert.assertTrue(
3236         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3237             .matcher(apiClientHeaderKey)
3238             .matches());
3239   }
3240 
3241   @Test
listNotificationConfigsExceptionTest2()3242   public void listNotificationConfigsExceptionTest2() throws Exception {
3243     ApiException exception =
3244         ApiExceptionFactory.createException(
3245             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3246     mockService.addException(exception);
3247 
3248     try {
3249       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
3250       client.listNotificationConfigs(parent);
3251       Assert.fail("No exception raised");
3252     } catch (InvalidArgumentException e) {
3253       // Expected exception.
3254     }
3255   }
3256 
3257   @Test
listNotificationConfigsTest3()3258   public void listNotificationConfigsTest3() throws Exception {
3259     NotificationConfig responsesElement = NotificationConfig.newBuilder().build();
3260     ListNotificationConfigsResponse expectedResponse =
3261         ListNotificationConfigsResponse.newBuilder()
3262             .setNextPageToken("")
3263             .addAllNotificationConfigs(Arrays.asList(responsesElement))
3264             .build();
3265     mockService.addResponse(expectedResponse);
3266 
3267     ProjectName parent = ProjectName.of("[PROJECT]");
3268 
3269     ListNotificationConfigsPagedResponse pagedListResponse = client.listNotificationConfigs(parent);
3270 
3271     List<NotificationConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3272 
3273     Assert.assertEquals(1, resources.size());
3274     Assert.assertEquals(expectedResponse.getNotificationConfigsList().get(0), resources.get(0));
3275 
3276     List<String> actualRequests = mockService.getRequestPaths();
3277     Assert.assertEquals(1, actualRequests.size());
3278 
3279     String apiClientHeaderKey =
3280         mockService
3281             .getRequestHeaders()
3282             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3283             .iterator()
3284             .next();
3285     Assert.assertTrue(
3286         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3287             .matcher(apiClientHeaderKey)
3288             .matches());
3289   }
3290 
3291   @Test
listNotificationConfigsExceptionTest3()3292   public void listNotificationConfigsExceptionTest3() throws Exception {
3293     ApiException exception =
3294         ApiExceptionFactory.createException(
3295             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3296     mockService.addException(exception);
3297 
3298     try {
3299       ProjectName parent = ProjectName.of("[PROJECT]");
3300       client.listNotificationConfigs(parent);
3301       Assert.fail("No exception raised");
3302     } catch (InvalidArgumentException e) {
3303       // Expected exception.
3304     }
3305   }
3306 
3307   @Test
listNotificationConfigsTest4()3308   public void listNotificationConfigsTest4() throws Exception {
3309     NotificationConfig responsesElement = NotificationConfig.newBuilder().build();
3310     ListNotificationConfigsResponse expectedResponse =
3311         ListNotificationConfigsResponse.newBuilder()
3312             .setNextPageToken("")
3313             .addAllNotificationConfigs(Arrays.asList(responsesElement))
3314             .build();
3315     mockService.addResponse(expectedResponse);
3316 
3317     String parent = "organizations/organization-8287";
3318 
3319     ListNotificationConfigsPagedResponse pagedListResponse = client.listNotificationConfigs(parent);
3320 
3321     List<NotificationConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3322 
3323     Assert.assertEquals(1, resources.size());
3324     Assert.assertEquals(expectedResponse.getNotificationConfigsList().get(0), resources.get(0));
3325 
3326     List<String> actualRequests = mockService.getRequestPaths();
3327     Assert.assertEquals(1, actualRequests.size());
3328 
3329     String apiClientHeaderKey =
3330         mockService
3331             .getRequestHeaders()
3332             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3333             .iterator()
3334             .next();
3335     Assert.assertTrue(
3336         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3337             .matcher(apiClientHeaderKey)
3338             .matches());
3339   }
3340 
3341   @Test
listNotificationConfigsExceptionTest4()3342   public void listNotificationConfigsExceptionTest4() throws Exception {
3343     ApiException exception =
3344         ApiExceptionFactory.createException(
3345             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3346     mockService.addException(exception);
3347 
3348     try {
3349       String parent = "organizations/organization-8287";
3350       client.listNotificationConfigs(parent);
3351       Assert.fail("No exception raised");
3352     } catch (InvalidArgumentException e) {
3353       // Expected exception.
3354     }
3355   }
3356 
3357   @Test
listEffectiveSecurityHealthAnalyticsCustomModulesTest()3358   public void listEffectiveSecurityHealthAnalyticsCustomModulesTest() throws Exception {
3359     EffectiveSecurityHealthAnalyticsCustomModule responsesElement =
3360         EffectiveSecurityHealthAnalyticsCustomModule.newBuilder().build();
3361     ListEffectiveSecurityHealthAnalyticsCustomModulesResponse expectedResponse =
3362         ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.newBuilder()
3363             .setNextPageToken("")
3364             .addAllEffectiveSecurityHealthAnalyticsCustomModules(Arrays.asList(responsesElement))
3365             .build();
3366     mockService.addResponse(expectedResponse);
3367 
3368     SecurityHealthAnalyticsSettingsName parent =
3369         SecurityHealthAnalyticsSettingsName.ofOrganizationName("[ORGANIZATION]");
3370 
3371     ListEffectiveSecurityHealthAnalyticsCustomModulesPagedResponse pagedListResponse =
3372         client.listEffectiveSecurityHealthAnalyticsCustomModules(parent);
3373 
3374     List<EffectiveSecurityHealthAnalyticsCustomModule> resources =
3375         Lists.newArrayList(pagedListResponse.iterateAll());
3376 
3377     Assert.assertEquals(1, resources.size());
3378     Assert.assertEquals(
3379         expectedResponse.getEffectiveSecurityHealthAnalyticsCustomModulesList().get(0),
3380         resources.get(0));
3381 
3382     List<String> actualRequests = mockService.getRequestPaths();
3383     Assert.assertEquals(1, actualRequests.size());
3384 
3385     String apiClientHeaderKey =
3386         mockService
3387             .getRequestHeaders()
3388             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3389             .iterator()
3390             .next();
3391     Assert.assertTrue(
3392         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3393             .matcher(apiClientHeaderKey)
3394             .matches());
3395   }
3396 
3397   @Test
listEffectiveSecurityHealthAnalyticsCustomModulesExceptionTest()3398   public void listEffectiveSecurityHealthAnalyticsCustomModulesExceptionTest() throws Exception {
3399     ApiException exception =
3400         ApiExceptionFactory.createException(
3401             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3402     mockService.addException(exception);
3403 
3404     try {
3405       SecurityHealthAnalyticsSettingsName parent =
3406           SecurityHealthAnalyticsSettingsName.ofOrganizationName("[ORGANIZATION]");
3407       client.listEffectiveSecurityHealthAnalyticsCustomModules(parent);
3408       Assert.fail("No exception raised");
3409     } catch (InvalidArgumentException e) {
3410       // Expected exception.
3411     }
3412   }
3413 
3414   @Test
listEffectiveSecurityHealthAnalyticsCustomModulesTest2()3415   public void listEffectiveSecurityHealthAnalyticsCustomModulesTest2() throws Exception {
3416     EffectiveSecurityHealthAnalyticsCustomModule responsesElement =
3417         EffectiveSecurityHealthAnalyticsCustomModule.newBuilder().build();
3418     ListEffectiveSecurityHealthAnalyticsCustomModulesResponse expectedResponse =
3419         ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.newBuilder()
3420             .setNextPageToken("")
3421             .addAllEffectiveSecurityHealthAnalyticsCustomModules(Arrays.asList(responsesElement))
3422             .build();
3423     mockService.addResponse(expectedResponse);
3424 
3425     String parent = "organizations/organization-7807/securityHealthAnalyticsSettings";
3426 
3427     ListEffectiveSecurityHealthAnalyticsCustomModulesPagedResponse pagedListResponse =
3428         client.listEffectiveSecurityHealthAnalyticsCustomModules(parent);
3429 
3430     List<EffectiveSecurityHealthAnalyticsCustomModule> resources =
3431         Lists.newArrayList(pagedListResponse.iterateAll());
3432 
3433     Assert.assertEquals(1, resources.size());
3434     Assert.assertEquals(
3435         expectedResponse.getEffectiveSecurityHealthAnalyticsCustomModulesList().get(0),
3436         resources.get(0));
3437 
3438     List<String> actualRequests = mockService.getRequestPaths();
3439     Assert.assertEquals(1, actualRequests.size());
3440 
3441     String apiClientHeaderKey =
3442         mockService
3443             .getRequestHeaders()
3444             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3445             .iterator()
3446             .next();
3447     Assert.assertTrue(
3448         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3449             .matcher(apiClientHeaderKey)
3450             .matches());
3451   }
3452 
3453   @Test
listEffectiveSecurityHealthAnalyticsCustomModulesExceptionTest2()3454   public void listEffectiveSecurityHealthAnalyticsCustomModulesExceptionTest2() throws Exception {
3455     ApiException exception =
3456         ApiExceptionFactory.createException(
3457             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3458     mockService.addException(exception);
3459 
3460     try {
3461       String parent = "organizations/organization-7807/securityHealthAnalyticsSettings";
3462       client.listEffectiveSecurityHealthAnalyticsCustomModules(parent);
3463       Assert.fail("No exception raised");
3464     } catch (InvalidArgumentException e) {
3465       // Expected exception.
3466     }
3467   }
3468 
3469   @Test
listSecurityHealthAnalyticsCustomModulesTest()3470   public void listSecurityHealthAnalyticsCustomModulesTest() throws Exception {
3471     SecurityHealthAnalyticsCustomModule responsesElement =
3472         SecurityHealthAnalyticsCustomModule.newBuilder().build();
3473     ListSecurityHealthAnalyticsCustomModulesResponse expectedResponse =
3474         ListSecurityHealthAnalyticsCustomModulesResponse.newBuilder()
3475             .setNextPageToken("")
3476             .addAllSecurityHealthAnalyticsCustomModules(Arrays.asList(responsesElement))
3477             .build();
3478     mockService.addResponse(expectedResponse);
3479 
3480     SecurityHealthAnalyticsSettingsName parent =
3481         SecurityHealthAnalyticsSettingsName.ofOrganizationName("[ORGANIZATION]");
3482 
3483     ListSecurityHealthAnalyticsCustomModulesPagedResponse pagedListResponse =
3484         client.listSecurityHealthAnalyticsCustomModules(parent);
3485 
3486     List<SecurityHealthAnalyticsCustomModule> resources =
3487         Lists.newArrayList(pagedListResponse.iterateAll());
3488 
3489     Assert.assertEquals(1, resources.size());
3490     Assert.assertEquals(
3491         expectedResponse.getSecurityHealthAnalyticsCustomModulesList().get(0), resources.get(0));
3492 
3493     List<String> actualRequests = mockService.getRequestPaths();
3494     Assert.assertEquals(1, actualRequests.size());
3495 
3496     String apiClientHeaderKey =
3497         mockService
3498             .getRequestHeaders()
3499             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3500             .iterator()
3501             .next();
3502     Assert.assertTrue(
3503         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3504             .matcher(apiClientHeaderKey)
3505             .matches());
3506   }
3507 
3508   @Test
listSecurityHealthAnalyticsCustomModulesExceptionTest()3509   public void listSecurityHealthAnalyticsCustomModulesExceptionTest() throws Exception {
3510     ApiException exception =
3511         ApiExceptionFactory.createException(
3512             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3513     mockService.addException(exception);
3514 
3515     try {
3516       SecurityHealthAnalyticsSettingsName parent =
3517           SecurityHealthAnalyticsSettingsName.ofOrganizationName("[ORGANIZATION]");
3518       client.listSecurityHealthAnalyticsCustomModules(parent);
3519       Assert.fail("No exception raised");
3520     } catch (InvalidArgumentException e) {
3521       // Expected exception.
3522     }
3523   }
3524 
3525   @Test
listSecurityHealthAnalyticsCustomModulesTest2()3526   public void listSecurityHealthAnalyticsCustomModulesTest2() throws Exception {
3527     SecurityHealthAnalyticsCustomModule responsesElement =
3528         SecurityHealthAnalyticsCustomModule.newBuilder().build();
3529     ListSecurityHealthAnalyticsCustomModulesResponse expectedResponse =
3530         ListSecurityHealthAnalyticsCustomModulesResponse.newBuilder()
3531             .setNextPageToken("")
3532             .addAllSecurityHealthAnalyticsCustomModules(Arrays.asList(responsesElement))
3533             .build();
3534     mockService.addResponse(expectedResponse);
3535 
3536     String parent = "organizations/organization-7807/securityHealthAnalyticsSettings";
3537 
3538     ListSecurityHealthAnalyticsCustomModulesPagedResponse pagedListResponse =
3539         client.listSecurityHealthAnalyticsCustomModules(parent);
3540 
3541     List<SecurityHealthAnalyticsCustomModule> resources =
3542         Lists.newArrayList(pagedListResponse.iterateAll());
3543 
3544     Assert.assertEquals(1, resources.size());
3545     Assert.assertEquals(
3546         expectedResponse.getSecurityHealthAnalyticsCustomModulesList().get(0), resources.get(0));
3547 
3548     List<String> actualRequests = mockService.getRequestPaths();
3549     Assert.assertEquals(1, actualRequests.size());
3550 
3551     String apiClientHeaderKey =
3552         mockService
3553             .getRequestHeaders()
3554             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3555             .iterator()
3556             .next();
3557     Assert.assertTrue(
3558         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3559             .matcher(apiClientHeaderKey)
3560             .matches());
3561   }
3562 
3563   @Test
listSecurityHealthAnalyticsCustomModulesExceptionTest2()3564   public void listSecurityHealthAnalyticsCustomModulesExceptionTest2() throws Exception {
3565     ApiException exception =
3566         ApiExceptionFactory.createException(
3567             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3568     mockService.addException(exception);
3569 
3570     try {
3571       String parent = "organizations/organization-7807/securityHealthAnalyticsSettings";
3572       client.listSecurityHealthAnalyticsCustomModules(parent);
3573       Assert.fail("No exception raised");
3574     } catch (InvalidArgumentException e) {
3575       // Expected exception.
3576     }
3577   }
3578 
3579   @Test
listSourcesTest()3580   public void listSourcesTest() throws Exception {
3581     Source responsesElement = Source.newBuilder().build();
3582     ListSourcesResponse expectedResponse =
3583         ListSourcesResponse.newBuilder()
3584             .setNextPageToken("")
3585             .addAllSources(Arrays.asList(responsesElement))
3586             .build();
3587     mockService.addResponse(expectedResponse);
3588 
3589     FolderName parent = FolderName.of("[FOLDER]");
3590 
3591     ListSourcesPagedResponse pagedListResponse = client.listSources(parent);
3592 
3593     List<Source> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3594 
3595     Assert.assertEquals(1, resources.size());
3596     Assert.assertEquals(expectedResponse.getSourcesList().get(0), resources.get(0));
3597 
3598     List<String> actualRequests = mockService.getRequestPaths();
3599     Assert.assertEquals(1, actualRequests.size());
3600 
3601     String apiClientHeaderKey =
3602         mockService
3603             .getRequestHeaders()
3604             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3605             .iterator()
3606             .next();
3607     Assert.assertTrue(
3608         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3609             .matcher(apiClientHeaderKey)
3610             .matches());
3611   }
3612 
3613   @Test
listSourcesExceptionTest()3614   public void listSourcesExceptionTest() throws Exception {
3615     ApiException exception =
3616         ApiExceptionFactory.createException(
3617             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3618     mockService.addException(exception);
3619 
3620     try {
3621       FolderName parent = FolderName.of("[FOLDER]");
3622       client.listSources(parent);
3623       Assert.fail("No exception raised");
3624     } catch (InvalidArgumentException e) {
3625       // Expected exception.
3626     }
3627   }
3628 
3629   @Test
listSourcesTest2()3630   public void listSourcesTest2() throws Exception {
3631     Source responsesElement = Source.newBuilder().build();
3632     ListSourcesResponse expectedResponse =
3633         ListSourcesResponse.newBuilder()
3634             .setNextPageToken("")
3635             .addAllSources(Arrays.asList(responsesElement))
3636             .build();
3637     mockService.addResponse(expectedResponse);
3638 
3639     OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
3640 
3641     ListSourcesPagedResponse pagedListResponse = client.listSources(parent);
3642 
3643     List<Source> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3644 
3645     Assert.assertEquals(1, resources.size());
3646     Assert.assertEquals(expectedResponse.getSourcesList().get(0), resources.get(0));
3647 
3648     List<String> actualRequests = mockService.getRequestPaths();
3649     Assert.assertEquals(1, actualRequests.size());
3650 
3651     String apiClientHeaderKey =
3652         mockService
3653             .getRequestHeaders()
3654             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3655             .iterator()
3656             .next();
3657     Assert.assertTrue(
3658         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3659             .matcher(apiClientHeaderKey)
3660             .matches());
3661   }
3662 
3663   @Test
listSourcesExceptionTest2()3664   public void listSourcesExceptionTest2() throws Exception {
3665     ApiException exception =
3666         ApiExceptionFactory.createException(
3667             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3668     mockService.addException(exception);
3669 
3670     try {
3671       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
3672       client.listSources(parent);
3673       Assert.fail("No exception raised");
3674     } catch (InvalidArgumentException e) {
3675       // Expected exception.
3676     }
3677   }
3678 
3679   @Test
listSourcesTest3()3680   public void listSourcesTest3() throws Exception {
3681     Source responsesElement = Source.newBuilder().build();
3682     ListSourcesResponse expectedResponse =
3683         ListSourcesResponse.newBuilder()
3684             .setNextPageToken("")
3685             .addAllSources(Arrays.asList(responsesElement))
3686             .build();
3687     mockService.addResponse(expectedResponse);
3688 
3689     ProjectName parent = ProjectName.of("[PROJECT]");
3690 
3691     ListSourcesPagedResponse pagedListResponse = client.listSources(parent);
3692 
3693     List<Source> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3694 
3695     Assert.assertEquals(1, resources.size());
3696     Assert.assertEquals(expectedResponse.getSourcesList().get(0), resources.get(0));
3697 
3698     List<String> actualRequests = mockService.getRequestPaths();
3699     Assert.assertEquals(1, actualRequests.size());
3700 
3701     String apiClientHeaderKey =
3702         mockService
3703             .getRequestHeaders()
3704             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3705             .iterator()
3706             .next();
3707     Assert.assertTrue(
3708         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3709             .matcher(apiClientHeaderKey)
3710             .matches());
3711   }
3712 
3713   @Test
listSourcesExceptionTest3()3714   public void listSourcesExceptionTest3() throws Exception {
3715     ApiException exception =
3716         ApiExceptionFactory.createException(
3717             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3718     mockService.addException(exception);
3719 
3720     try {
3721       ProjectName parent = ProjectName.of("[PROJECT]");
3722       client.listSources(parent);
3723       Assert.fail("No exception raised");
3724     } catch (InvalidArgumentException e) {
3725       // Expected exception.
3726     }
3727   }
3728 
3729   @Test
listSourcesTest4()3730   public void listSourcesTest4() throws Exception {
3731     Source responsesElement = Source.newBuilder().build();
3732     ListSourcesResponse expectedResponse =
3733         ListSourcesResponse.newBuilder()
3734             .setNextPageToken("")
3735             .addAllSources(Arrays.asList(responsesElement))
3736             .build();
3737     mockService.addResponse(expectedResponse);
3738 
3739     String parent = "organizations/organization-8287";
3740 
3741     ListSourcesPagedResponse pagedListResponse = client.listSources(parent);
3742 
3743     List<Source> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3744 
3745     Assert.assertEquals(1, resources.size());
3746     Assert.assertEquals(expectedResponse.getSourcesList().get(0), resources.get(0));
3747 
3748     List<String> actualRequests = mockService.getRequestPaths();
3749     Assert.assertEquals(1, actualRequests.size());
3750 
3751     String apiClientHeaderKey =
3752         mockService
3753             .getRequestHeaders()
3754             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3755             .iterator()
3756             .next();
3757     Assert.assertTrue(
3758         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3759             .matcher(apiClientHeaderKey)
3760             .matches());
3761   }
3762 
3763   @Test
listSourcesExceptionTest4()3764   public void listSourcesExceptionTest4() throws Exception {
3765     ApiException exception =
3766         ApiExceptionFactory.createException(
3767             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3768     mockService.addException(exception);
3769 
3770     try {
3771       String parent = "organizations/organization-8287";
3772       client.listSources(parent);
3773       Assert.fail("No exception raised");
3774     } catch (InvalidArgumentException e) {
3775       // Expected exception.
3776     }
3777   }
3778 
3779   @Test
runAssetDiscoveryTest()3780   public void runAssetDiscoveryTest() throws Exception {
3781     RunAssetDiscoveryResponse expectedResponse =
3782         RunAssetDiscoveryResponse.newBuilder().setDuration(Duration.newBuilder().build()).build();
3783     Operation resultOperation =
3784         Operation.newBuilder()
3785             .setName("runAssetDiscoveryTest")
3786             .setDone(true)
3787             .setResponse(Any.pack(expectedResponse))
3788             .build();
3789     mockService.addResponse(resultOperation);
3790 
3791     OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
3792 
3793     RunAssetDiscoveryResponse actualResponse = client.runAssetDiscoveryAsync(parent).get();
3794     Assert.assertEquals(expectedResponse, actualResponse);
3795 
3796     List<String> actualRequests = mockService.getRequestPaths();
3797     Assert.assertEquals(1, actualRequests.size());
3798 
3799     String apiClientHeaderKey =
3800         mockService
3801             .getRequestHeaders()
3802             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3803             .iterator()
3804             .next();
3805     Assert.assertTrue(
3806         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3807             .matcher(apiClientHeaderKey)
3808             .matches());
3809   }
3810 
3811   @Test
runAssetDiscoveryExceptionTest()3812   public void runAssetDiscoveryExceptionTest() throws Exception {
3813     ApiException exception =
3814         ApiExceptionFactory.createException(
3815             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3816     mockService.addException(exception);
3817 
3818     try {
3819       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
3820       client.runAssetDiscoveryAsync(parent).get();
3821       Assert.fail("No exception raised");
3822     } catch (ExecutionException e) {
3823     }
3824   }
3825 
3826   @Test
runAssetDiscoveryTest2()3827   public void runAssetDiscoveryTest2() throws Exception {
3828     RunAssetDiscoveryResponse expectedResponse =
3829         RunAssetDiscoveryResponse.newBuilder().setDuration(Duration.newBuilder().build()).build();
3830     Operation resultOperation =
3831         Operation.newBuilder()
3832             .setName("runAssetDiscoveryTest")
3833             .setDone(true)
3834             .setResponse(Any.pack(expectedResponse))
3835             .build();
3836     mockService.addResponse(resultOperation);
3837 
3838     String parent = "organizations/organization-8287";
3839 
3840     RunAssetDiscoveryResponse actualResponse = client.runAssetDiscoveryAsync(parent).get();
3841     Assert.assertEquals(expectedResponse, actualResponse);
3842 
3843     List<String> actualRequests = mockService.getRequestPaths();
3844     Assert.assertEquals(1, actualRequests.size());
3845 
3846     String apiClientHeaderKey =
3847         mockService
3848             .getRequestHeaders()
3849             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3850             .iterator()
3851             .next();
3852     Assert.assertTrue(
3853         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3854             .matcher(apiClientHeaderKey)
3855             .matches());
3856   }
3857 
3858   @Test
runAssetDiscoveryExceptionTest2()3859   public void runAssetDiscoveryExceptionTest2() throws Exception {
3860     ApiException exception =
3861         ApiExceptionFactory.createException(
3862             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3863     mockService.addException(exception);
3864 
3865     try {
3866       String parent = "organizations/organization-8287";
3867       client.runAssetDiscoveryAsync(parent).get();
3868       Assert.fail("No exception raised");
3869     } catch (ExecutionException e) {
3870     }
3871   }
3872 
3873   @Test
setFindingStateTest()3874   public void setFindingStateTest() throws Exception {
3875     Finding expectedResponse =
3876         Finding.newBuilder()
3877             .setName(
3878                 FindingName.ofOrganizationSourceFindingName(
3879                         "[ORGANIZATION]", "[SOURCE]", "[FINDING]")
3880                     .toString())
3881             .setParent("parent-995424086")
3882             .setResourceName("resourceName-384566343")
3883             .setCategory("category50511102")
3884             .setExternalUri("externalUri-1153085023")
3885             .putAllSourceProperties(new HashMap<String, Value>())
3886             .setSecurityMarks(SecurityMarks.newBuilder().build())
3887             .setEventTime(Timestamp.newBuilder().build())
3888             .setCreateTime(Timestamp.newBuilder().build())
3889             .setCanonicalName("canonicalName2122381727")
3890             .setIndicator(Indicator.newBuilder().build())
3891             .setVulnerability(Vulnerability.newBuilder().build())
3892             .setMuteUpdateTime(Timestamp.newBuilder().build())
3893             .putAllExternalSystems(new HashMap<String, ExternalSystem>())
3894             .setMitreAttack(MitreAttack.newBuilder().build())
3895             .setAccess(Access.newBuilder().build())
3896             .addAllConnections(new ArrayList<Connection>())
3897             .setMuteInitiator("muteInitiator1395645462")
3898             .addAllProcesses(new ArrayList<Process>())
3899             .putAllContacts(new HashMap<String, ContactDetails>())
3900             .addAllCompliances(new ArrayList<Compliance>())
3901             .setParentDisplayName("parentDisplayName-1523759261")
3902             .setDescription("description-1724546052")
3903             .setExfiltration(Exfiltration.newBuilder().build())
3904             .addAllIamBindings(new ArrayList<IamBinding>())
3905             .setNextSteps("nextSteps1206138868")
3906             .setModuleName("moduleName-870351081")
3907             .addAllContainers(new ArrayList<Container>())
3908             .setKubernetes(Kubernetes.newBuilder().build())
3909             .setDatabase(Database.newBuilder().build())
3910             .addAllFiles(new ArrayList<File>())
3911             .setCloudDlpInspection(CloudDlpInspection.newBuilder().build())
3912             .setCloudDlpDataProfile(CloudDlpDataProfile.newBuilder().build())
3913             .setKernelRootkit(KernelRootkit.newBuilder().build())
3914             .build();
3915     mockService.addResponse(expectedResponse);
3916 
3917     FindingName name =
3918         FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]");
3919     Finding.State state = Finding.State.forNumber(0);
3920     Timestamp startTime = Timestamp.newBuilder().build();
3921 
3922     Finding actualResponse = client.setFindingState(name, state, startTime);
3923     Assert.assertEquals(expectedResponse, actualResponse);
3924 
3925     List<String> actualRequests = mockService.getRequestPaths();
3926     Assert.assertEquals(1, actualRequests.size());
3927 
3928     String apiClientHeaderKey =
3929         mockService
3930             .getRequestHeaders()
3931             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3932             .iterator()
3933             .next();
3934     Assert.assertTrue(
3935         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3936             .matcher(apiClientHeaderKey)
3937             .matches());
3938   }
3939 
3940   @Test
setFindingStateExceptionTest()3941   public void setFindingStateExceptionTest() throws Exception {
3942     ApiException exception =
3943         ApiExceptionFactory.createException(
3944             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3945     mockService.addException(exception);
3946 
3947     try {
3948       FindingName name =
3949           FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]");
3950       Finding.State state = Finding.State.forNumber(0);
3951       Timestamp startTime = Timestamp.newBuilder().build();
3952       client.setFindingState(name, state, startTime);
3953       Assert.fail("No exception raised");
3954     } catch (InvalidArgumentException e) {
3955       // Expected exception.
3956     }
3957   }
3958 
3959   @Test
setFindingStateTest2()3960   public void setFindingStateTest2() throws Exception {
3961     Finding expectedResponse =
3962         Finding.newBuilder()
3963             .setName(
3964                 FindingName.ofOrganizationSourceFindingName(
3965                         "[ORGANIZATION]", "[SOURCE]", "[FINDING]")
3966                     .toString())
3967             .setParent("parent-995424086")
3968             .setResourceName("resourceName-384566343")
3969             .setCategory("category50511102")
3970             .setExternalUri("externalUri-1153085023")
3971             .putAllSourceProperties(new HashMap<String, Value>())
3972             .setSecurityMarks(SecurityMarks.newBuilder().build())
3973             .setEventTime(Timestamp.newBuilder().build())
3974             .setCreateTime(Timestamp.newBuilder().build())
3975             .setCanonicalName("canonicalName2122381727")
3976             .setIndicator(Indicator.newBuilder().build())
3977             .setVulnerability(Vulnerability.newBuilder().build())
3978             .setMuteUpdateTime(Timestamp.newBuilder().build())
3979             .putAllExternalSystems(new HashMap<String, ExternalSystem>())
3980             .setMitreAttack(MitreAttack.newBuilder().build())
3981             .setAccess(Access.newBuilder().build())
3982             .addAllConnections(new ArrayList<Connection>())
3983             .setMuteInitiator("muteInitiator1395645462")
3984             .addAllProcesses(new ArrayList<Process>())
3985             .putAllContacts(new HashMap<String, ContactDetails>())
3986             .addAllCompliances(new ArrayList<Compliance>())
3987             .setParentDisplayName("parentDisplayName-1523759261")
3988             .setDescription("description-1724546052")
3989             .setExfiltration(Exfiltration.newBuilder().build())
3990             .addAllIamBindings(new ArrayList<IamBinding>())
3991             .setNextSteps("nextSteps1206138868")
3992             .setModuleName("moduleName-870351081")
3993             .addAllContainers(new ArrayList<Container>())
3994             .setKubernetes(Kubernetes.newBuilder().build())
3995             .setDatabase(Database.newBuilder().build())
3996             .addAllFiles(new ArrayList<File>())
3997             .setCloudDlpInspection(CloudDlpInspection.newBuilder().build())
3998             .setCloudDlpDataProfile(CloudDlpDataProfile.newBuilder().build())
3999             .setKernelRootkit(KernelRootkit.newBuilder().build())
4000             .build();
4001     mockService.addResponse(expectedResponse);
4002 
4003     String name = "organizations/organization-9392/sources/source-9392/findings/finding-9392";
4004     Finding.State state = Finding.State.forNumber(0);
4005     Timestamp startTime = Timestamp.newBuilder().build();
4006 
4007     Finding actualResponse = client.setFindingState(name, state, startTime);
4008     Assert.assertEquals(expectedResponse, actualResponse);
4009 
4010     List<String> actualRequests = mockService.getRequestPaths();
4011     Assert.assertEquals(1, actualRequests.size());
4012 
4013     String apiClientHeaderKey =
4014         mockService
4015             .getRequestHeaders()
4016             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4017             .iterator()
4018             .next();
4019     Assert.assertTrue(
4020         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4021             .matcher(apiClientHeaderKey)
4022             .matches());
4023   }
4024 
4025   @Test
setFindingStateExceptionTest2()4026   public void setFindingStateExceptionTest2() throws Exception {
4027     ApiException exception =
4028         ApiExceptionFactory.createException(
4029             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4030     mockService.addException(exception);
4031 
4032     try {
4033       String name = "organizations/organization-9392/sources/source-9392/findings/finding-9392";
4034       Finding.State state = Finding.State.forNumber(0);
4035       Timestamp startTime = Timestamp.newBuilder().build();
4036       client.setFindingState(name, state, startTime);
4037       Assert.fail("No exception raised");
4038     } catch (InvalidArgumentException e) {
4039       // Expected exception.
4040     }
4041   }
4042 
4043   @Test
setMuteTest()4044   public void setMuteTest() throws Exception {
4045     Finding expectedResponse =
4046         Finding.newBuilder()
4047             .setName(
4048                 FindingName.ofOrganizationSourceFindingName(
4049                         "[ORGANIZATION]", "[SOURCE]", "[FINDING]")
4050                     .toString())
4051             .setParent("parent-995424086")
4052             .setResourceName("resourceName-384566343")
4053             .setCategory("category50511102")
4054             .setExternalUri("externalUri-1153085023")
4055             .putAllSourceProperties(new HashMap<String, Value>())
4056             .setSecurityMarks(SecurityMarks.newBuilder().build())
4057             .setEventTime(Timestamp.newBuilder().build())
4058             .setCreateTime(Timestamp.newBuilder().build())
4059             .setCanonicalName("canonicalName2122381727")
4060             .setIndicator(Indicator.newBuilder().build())
4061             .setVulnerability(Vulnerability.newBuilder().build())
4062             .setMuteUpdateTime(Timestamp.newBuilder().build())
4063             .putAllExternalSystems(new HashMap<String, ExternalSystem>())
4064             .setMitreAttack(MitreAttack.newBuilder().build())
4065             .setAccess(Access.newBuilder().build())
4066             .addAllConnections(new ArrayList<Connection>())
4067             .setMuteInitiator("muteInitiator1395645462")
4068             .addAllProcesses(new ArrayList<Process>())
4069             .putAllContacts(new HashMap<String, ContactDetails>())
4070             .addAllCompliances(new ArrayList<Compliance>())
4071             .setParentDisplayName("parentDisplayName-1523759261")
4072             .setDescription("description-1724546052")
4073             .setExfiltration(Exfiltration.newBuilder().build())
4074             .addAllIamBindings(new ArrayList<IamBinding>())
4075             .setNextSteps("nextSteps1206138868")
4076             .setModuleName("moduleName-870351081")
4077             .addAllContainers(new ArrayList<Container>())
4078             .setKubernetes(Kubernetes.newBuilder().build())
4079             .setDatabase(Database.newBuilder().build())
4080             .addAllFiles(new ArrayList<File>())
4081             .setCloudDlpInspection(CloudDlpInspection.newBuilder().build())
4082             .setCloudDlpDataProfile(CloudDlpDataProfile.newBuilder().build())
4083             .setKernelRootkit(KernelRootkit.newBuilder().build())
4084             .build();
4085     mockService.addResponse(expectedResponse);
4086 
4087     FindingName name =
4088         FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]");
4089     Finding.Mute mute = Finding.Mute.forNumber(0);
4090 
4091     Finding actualResponse = client.setMute(name, mute);
4092     Assert.assertEquals(expectedResponse, actualResponse);
4093 
4094     List<String> actualRequests = mockService.getRequestPaths();
4095     Assert.assertEquals(1, actualRequests.size());
4096 
4097     String apiClientHeaderKey =
4098         mockService
4099             .getRequestHeaders()
4100             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4101             .iterator()
4102             .next();
4103     Assert.assertTrue(
4104         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4105             .matcher(apiClientHeaderKey)
4106             .matches());
4107   }
4108 
4109   @Test
setMuteExceptionTest()4110   public void setMuteExceptionTest() throws Exception {
4111     ApiException exception =
4112         ApiExceptionFactory.createException(
4113             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4114     mockService.addException(exception);
4115 
4116     try {
4117       FindingName name =
4118           FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]");
4119       Finding.Mute mute = Finding.Mute.forNumber(0);
4120       client.setMute(name, mute);
4121       Assert.fail("No exception raised");
4122     } catch (InvalidArgumentException e) {
4123       // Expected exception.
4124     }
4125   }
4126 
4127   @Test
setMuteTest2()4128   public void setMuteTest2() throws Exception {
4129     Finding expectedResponse =
4130         Finding.newBuilder()
4131             .setName(
4132                 FindingName.ofOrganizationSourceFindingName(
4133                         "[ORGANIZATION]", "[SOURCE]", "[FINDING]")
4134                     .toString())
4135             .setParent("parent-995424086")
4136             .setResourceName("resourceName-384566343")
4137             .setCategory("category50511102")
4138             .setExternalUri("externalUri-1153085023")
4139             .putAllSourceProperties(new HashMap<String, Value>())
4140             .setSecurityMarks(SecurityMarks.newBuilder().build())
4141             .setEventTime(Timestamp.newBuilder().build())
4142             .setCreateTime(Timestamp.newBuilder().build())
4143             .setCanonicalName("canonicalName2122381727")
4144             .setIndicator(Indicator.newBuilder().build())
4145             .setVulnerability(Vulnerability.newBuilder().build())
4146             .setMuteUpdateTime(Timestamp.newBuilder().build())
4147             .putAllExternalSystems(new HashMap<String, ExternalSystem>())
4148             .setMitreAttack(MitreAttack.newBuilder().build())
4149             .setAccess(Access.newBuilder().build())
4150             .addAllConnections(new ArrayList<Connection>())
4151             .setMuteInitiator("muteInitiator1395645462")
4152             .addAllProcesses(new ArrayList<Process>())
4153             .putAllContacts(new HashMap<String, ContactDetails>())
4154             .addAllCompliances(new ArrayList<Compliance>())
4155             .setParentDisplayName("parentDisplayName-1523759261")
4156             .setDescription("description-1724546052")
4157             .setExfiltration(Exfiltration.newBuilder().build())
4158             .addAllIamBindings(new ArrayList<IamBinding>())
4159             .setNextSteps("nextSteps1206138868")
4160             .setModuleName("moduleName-870351081")
4161             .addAllContainers(new ArrayList<Container>())
4162             .setKubernetes(Kubernetes.newBuilder().build())
4163             .setDatabase(Database.newBuilder().build())
4164             .addAllFiles(new ArrayList<File>())
4165             .setCloudDlpInspection(CloudDlpInspection.newBuilder().build())
4166             .setCloudDlpDataProfile(CloudDlpDataProfile.newBuilder().build())
4167             .setKernelRootkit(KernelRootkit.newBuilder().build())
4168             .build();
4169     mockService.addResponse(expectedResponse);
4170 
4171     String name = "organizations/organization-9392/sources/source-9392/findings/finding-9392";
4172     Finding.Mute mute = Finding.Mute.forNumber(0);
4173 
4174     Finding actualResponse = client.setMute(name, mute);
4175     Assert.assertEquals(expectedResponse, actualResponse);
4176 
4177     List<String> actualRequests = mockService.getRequestPaths();
4178     Assert.assertEquals(1, actualRequests.size());
4179 
4180     String apiClientHeaderKey =
4181         mockService
4182             .getRequestHeaders()
4183             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4184             .iterator()
4185             .next();
4186     Assert.assertTrue(
4187         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4188             .matcher(apiClientHeaderKey)
4189             .matches());
4190   }
4191 
4192   @Test
setMuteExceptionTest2()4193   public void setMuteExceptionTest2() throws Exception {
4194     ApiException exception =
4195         ApiExceptionFactory.createException(
4196             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4197     mockService.addException(exception);
4198 
4199     try {
4200       String name = "organizations/organization-9392/sources/source-9392/findings/finding-9392";
4201       Finding.Mute mute = Finding.Mute.forNumber(0);
4202       client.setMute(name, mute);
4203       Assert.fail("No exception raised");
4204     } catch (InvalidArgumentException e) {
4205       // Expected exception.
4206     }
4207   }
4208 
4209   @Test
setIamPolicyTest()4210   public void setIamPolicyTest() throws Exception {
4211     Policy expectedResponse =
4212         Policy.newBuilder()
4213             .setVersion(351608024)
4214             .addAllBindings(new ArrayList<Binding>())
4215             .addAllAuditConfigs(new ArrayList<AuditConfig>())
4216             .setEtag(ByteString.EMPTY)
4217             .build();
4218     mockService.addResponse(expectedResponse);
4219 
4220     ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]");
4221     Policy policy = Policy.newBuilder().build();
4222 
4223     Policy actualResponse = client.setIamPolicy(resource, policy);
4224     Assert.assertEquals(expectedResponse, actualResponse);
4225 
4226     List<String> actualRequests = mockService.getRequestPaths();
4227     Assert.assertEquals(1, actualRequests.size());
4228 
4229     String apiClientHeaderKey =
4230         mockService
4231             .getRequestHeaders()
4232             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4233             .iterator()
4234             .next();
4235     Assert.assertTrue(
4236         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4237             .matcher(apiClientHeaderKey)
4238             .matches());
4239   }
4240 
4241   @Test
setIamPolicyExceptionTest()4242   public void setIamPolicyExceptionTest() throws Exception {
4243     ApiException exception =
4244         ApiExceptionFactory.createException(
4245             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4246     mockService.addException(exception);
4247 
4248     try {
4249       ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]");
4250       Policy policy = Policy.newBuilder().build();
4251       client.setIamPolicy(resource, policy);
4252       Assert.fail("No exception raised");
4253     } catch (InvalidArgumentException e) {
4254       // Expected exception.
4255     }
4256   }
4257 
4258   @Test
setIamPolicyTest2()4259   public void setIamPolicyTest2() throws Exception {
4260     Policy expectedResponse =
4261         Policy.newBuilder()
4262             .setVersion(351608024)
4263             .addAllBindings(new ArrayList<Binding>())
4264             .addAllAuditConfigs(new ArrayList<AuditConfig>())
4265             .setEtag(ByteString.EMPTY)
4266             .build();
4267     mockService.addResponse(expectedResponse);
4268 
4269     String resource = "organizations/organization-3393/sources/source-3393";
4270     Policy policy = Policy.newBuilder().build();
4271 
4272     Policy actualResponse = client.setIamPolicy(resource, policy);
4273     Assert.assertEquals(expectedResponse, actualResponse);
4274 
4275     List<String> actualRequests = mockService.getRequestPaths();
4276     Assert.assertEquals(1, actualRequests.size());
4277 
4278     String apiClientHeaderKey =
4279         mockService
4280             .getRequestHeaders()
4281             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4282             .iterator()
4283             .next();
4284     Assert.assertTrue(
4285         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4286             .matcher(apiClientHeaderKey)
4287             .matches());
4288   }
4289 
4290   @Test
setIamPolicyExceptionTest2()4291   public void setIamPolicyExceptionTest2() throws Exception {
4292     ApiException exception =
4293         ApiExceptionFactory.createException(
4294             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4295     mockService.addException(exception);
4296 
4297     try {
4298       String resource = "organizations/organization-3393/sources/source-3393";
4299       Policy policy = Policy.newBuilder().build();
4300       client.setIamPolicy(resource, policy);
4301       Assert.fail("No exception raised");
4302     } catch (InvalidArgumentException e) {
4303       // Expected exception.
4304     }
4305   }
4306 
4307   @Test
testIamPermissionsTest()4308   public void testIamPermissionsTest() throws Exception {
4309     TestIamPermissionsResponse expectedResponse =
4310         TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList<String>()).build();
4311     mockService.addResponse(expectedResponse);
4312 
4313     ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]");
4314     List<String> permissions = new ArrayList<>();
4315 
4316     TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions);
4317     Assert.assertEquals(expectedResponse, actualResponse);
4318 
4319     List<String> actualRequests = mockService.getRequestPaths();
4320     Assert.assertEquals(1, actualRequests.size());
4321 
4322     String apiClientHeaderKey =
4323         mockService
4324             .getRequestHeaders()
4325             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4326             .iterator()
4327             .next();
4328     Assert.assertTrue(
4329         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4330             .matcher(apiClientHeaderKey)
4331             .matches());
4332   }
4333 
4334   @Test
testIamPermissionsExceptionTest()4335   public void testIamPermissionsExceptionTest() throws Exception {
4336     ApiException exception =
4337         ApiExceptionFactory.createException(
4338             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4339     mockService.addException(exception);
4340 
4341     try {
4342       ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]");
4343       List<String> permissions = new ArrayList<>();
4344       client.testIamPermissions(resource, permissions);
4345       Assert.fail("No exception raised");
4346     } catch (InvalidArgumentException e) {
4347       // Expected exception.
4348     }
4349   }
4350 
4351   @Test
testIamPermissionsTest2()4352   public void testIamPermissionsTest2() throws Exception {
4353     TestIamPermissionsResponse expectedResponse =
4354         TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList<String>()).build();
4355     mockService.addResponse(expectedResponse);
4356 
4357     String resource = "organizations/organization-3393/sources/source-3393";
4358     List<String> permissions = new ArrayList<>();
4359 
4360     TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions);
4361     Assert.assertEquals(expectedResponse, actualResponse);
4362 
4363     List<String> actualRequests = mockService.getRequestPaths();
4364     Assert.assertEquals(1, actualRequests.size());
4365 
4366     String apiClientHeaderKey =
4367         mockService
4368             .getRequestHeaders()
4369             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4370             .iterator()
4371             .next();
4372     Assert.assertTrue(
4373         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4374             .matcher(apiClientHeaderKey)
4375             .matches());
4376   }
4377 
4378   @Test
testIamPermissionsExceptionTest2()4379   public void testIamPermissionsExceptionTest2() throws Exception {
4380     ApiException exception =
4381         ApiExceptionFactory.createException(
4382             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4383     mockService.addException(exception);
4384 
4385     try {
4386       String resource = "organizations/organization-3393/sources/source-3393";
4387       List<String> permissions = new ArrayList<>();
4388       client.testIamPermissions(resource, permissions);
4389       Assert.fail("No exception raised");
4390     } catch (InvalidArgumentException e) {
4391       // Expected exception.
4392     }
4393   }
4394 
4395   @Test
updateExternalSystemTest()4396   public void updateExternalSystemTest() throws Exception {
4397     ExternalSystem expectedResponse =
4398         ExternalSystem.newBuilder()
4399             .setName("name3373707")
4400             .addAllAssignees(new ArrayList<String>())
4401             .setExternalUid("externalUid-1153085307")
4402             .setStatus("status-892481550")
4403             .setExternalSystemUpdateTime(Timestamp.newBuilder().build())
4404             .build();
4405     mockService.addResponse(expectedResponse);
4406 
4407     ExternalSystem externalSystem =
4408         ExternalSystem.newBuilder()
4409             .setName(
4410                 "organizations/organization-5115/sources/source-5115/findings/finding-5115/externalSystems/externalSystem-5115")
4411             .addAllAssignees(new ArrayList<String>())
4412             .setExternalUid("externalUid-1153085307")
4413             .setStatus("status-892481550")
4414             .setExternalSystemUpdateTime(Timestamp.newBuilder().build())
4415             .build();
4416     FieldMask updateMask = FieldMask.newBuilder().build();
4417 
4418     ExternalSystem actualResponse = client.updateExternalSystem(externalSystem, updateMask);
4419     Assert.assertEquals(expectedResponse, actualResponse);
4420 
4421     List<String> actualRequests = mockService.getRequestPaths();
4422     Assert.assertEquals(1, actualRequests.size());
4423 
4424     String apiClientHeaderKey =
4425         mockService
4426             .getRequestHeaders()
4427             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4428             .iterator()
4429             .next();
4430     Assert.assertTrue(
4431         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4432             .matcher(apiClientHeaderKey)
4433             .matches());
4434   }
4435 
4436   @Test
updateExternalSystemExceptionTest()4437   public void updateExternalSystemExceptionTest() throws Exception {
4438     ApiException exception =
4439         ApiExceptionFactory.createException(
4440             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4441     mockService.addException(exception);
4442 
4443     try {
4444       ExternalSystem externalSystem =
4445           ExternalSystem.newBuilder()
4446               .setName(
4447                   "organizations/organization-5115/sources/source-5115/findings/finding-5115/externalSystems/externalSystem-5115")
4448               .addAllAssignees(new ArrayList<String>())
4449               .setExternalUid("externalUid-1153085307")
4450               .setStatus("status-892481550")
4451               .setExternalSystemUpdateTime(Timestamp.newBuilder().build())
4452               .build();
4453       FieldMask updateMask = FieldMask.newBuilder().build();
4454       client.updateExternalSystem(externalSystem, updateMask);
4455       Assert.fail("No exception raised");
4456     } catch (InvalidArgumentException e) {
4457       // Expected exception.
4458     }
4459   }
4460 
4461   @Test
updateFindingTest()4462   public void updateFindingTest() throws Exception {
4463     Finding expectedResponse =
4464         Finding.newBuilder()
4465             .setName(
4466                 FindingName.ofOrganizationSourceFindingName(
4467                         "[ORGANIZATION]", "[SOURCE]", "[FINDING]")
4468                     .toString())
4469             .setParent("parent-995424086")
4470             .setResourceName("resourceName-384566343")
4471             .setCategory("category50511102")
4472             .setExternalUri("externalUri-1153085023")
4473             .putAllSourceProperties(new HashMap<String, Value>())
4474             .setSecurityMarks(SecurityMarks.newBuilder().build())
4475             .setEventTime(Timestamp.newBuilder().build())
4476             .setCreateTime(Timestamp.newBuilder().build())
4477             .setCanonicalName("canonicalName2122381727")
4478             .setIndicator(Indicator.newBuilder().build())
4479             .setVulnerability(Vulnerability.newBuilder().build())
4480             .setMuteUpdateTime(Timestamp.newBuilder().build())
4481             .putAllExternalSystems(new HashMap<String, ExternalSystem>())
4482             .setMitreAttack(MitreAttack.newBuilder().build())
4483             .setAccess(Access.newBuilder().build())
4484             .addAllConnections(new ArrayList<Connection>())
4485             .setMuteInitiator("muteInitiator1395645462")
4486             .addAllProcesses(new ArrayList<Process>())
4487             .putAllContacts(new HashMap<String, ContactDetails>())
4488             .addAllCompliances(new ArrayList<Compliance>())
4489             .setParentDisplayName("parentDisplayName-1523759261")
4490             .setDescription("description-1724546052")
4491             .setExfiltration(Exfiltration.newBuilder().build())
4492             .addAllIamBindings(new ArrayList<IamBinding>())
4493             .setNextSteps("nextSteps1206138868")
4494             .setModuleName("moduleName-870351081")
4495             .addAllContainers(new ArrayList<Container>())
4496             .setKubernetes(Kubernetes.newBuilder().build())
4497             .setDatabase(Database.newBuilder().build())
4498             .addAllFiles(new ArrayList<File>())
4499             .setCloudDlpInspection(CloudDlpInspection.newBuilder().build())
4500             .setCloudDlpDataProfile(CloudDlpDataProfile.newBuilder().build())
4501             .setKernelRootkit(KernelRootkit.newBuilder().build())
4502             .build();
4503     mockService.addResponse(expectedResponse);
4504 
4505     Finding finding =
4506         Finding.newBuilder()
4507             .setName(
4508                 FindingName.ofOrganizationSourceFindingName(
4509                         "[ORGANIZATION]", "[SOURCE]", "[FINDING]")
4510                     .toString())
4511             .setParent("parent-995424086")
4512             .setResourceName("resourceName-384566343")
4513             .setCategory("category50511102")
4514             .setExternalUri("externalUri-1153085023")
4515             .putAllSourceProperties(new HashMap<String, Value>())
4516             .setSecurityMarks(SecurityMarks.newBuilder().build())
4517             .setEventTime(Timestamp.newBuilder().build())
4518             .setCreateTime(Timestamp.newBuilder().build())
4519             .setCanonicalName("canonicalName2122381727")
4520             .setIndicator(Indicator.newBuilder().build())
4521             .setVulnerability(Vulnerability.newBuilder().build())
4522             .setMuteUpdateTime(Timestamp.newBuilder().build())
4523             .putAllExternalSystems(new HashMap<String, ExternalSystem>())
4524             .setMitreAttack(MitreAttack.newBuilder().build())
4525             .setAccess(Access.newBuilder().build())
4526             .addAllConnections(new ArrayList<Connection>())
4527             .setMuteInitiator("muteInitiator1395645462")
4528             .addAllProcesses(new ArrayList<Process>())
4529             .putAllContacts(new HashMap<String, ContactDetails>())
4530             .addAllCompliances(new ArrayList<Compliance>())
4531             .setParentDisplayName("parentDisplayName-1523759261")
4532             .setDescription("description-1724546052")
4533             .setExfiltration(Exfiltration.newBuilder().build())
4534             .addAllIamBindings(new ArrayList<IamBinding>())
4535             .setNextSteps("nextSteps1206138868")
4536             .setModuleName("moduleName-870351081")
4537             .addAllContainers(new ArrayList<Container>())
4538             .setKubernetes(Kubernetes.newBuilder().build())
4539             .setDatabase(Database.newBuilder().build())
4540             .addAllFiles(new ArrayList<File>())
4541             .setCloudDlpInspection(CloudDlpInspection.newBuilder().build())
4542             .setCloudDlpDataProfile(CloudDlpDataProfile.newBuilder().build())
4543             .setKernelRootkit(KernelRootkit.newBuilder().build())
4544             .build();
4545 
4546     Finding actualResponse = client.updateFinding(finding);
4547     Assert.assertEquals(expectedResponse, actualResponse);
4548 
4549     List<String> actualRequests = mockService.getRequestPaths();
4550     Assert.assertEquals(1, actualRequests.size());
4551 
4552     String apiClientHeaderKey =
4553         mockService
4554             .getRequestHeaders()
4555             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4556             .iterator()
4557             .next();
4558     Assert.assertTrue(
4559         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4560             .matcher(apiClientHeaderKey)
4561             .matches());
4562   }
4563 
4564   @Test
updateFindingExceptionTest()4565   public void updateFindingExceptionTest() throws Exception {
4566     ApiException exception =
4567         ApiExceptionFactory.createException(
4568             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4569     mockService.addException(exception);
4570 
4571     try {
4572       Finding finding =
4573           Finding.newBuilder()
4574               .setName(
4575                   FindingName.ofOrganizationSourceFindingName(
4576                           "[ORGANIZATION]", "[SOURCE]", "[FINDING]")
4577                       .toString())
4578               .setParent("parent-995424086")
4579               .setResourceName("resourceName-384566343")
4580               .setCategory("category50511102")
4581               .setExternalUri("externalUri-1153085023")
4582               .putAllSourceProperties(new HashMap<String, Value>())
4583               .setSecurityMarks(SecurityMarks.newBuilder().build())
4584               .setEventTime(Timestamp.newBuilder().build())
4585               .setCreateTime(Timestamp.newBuilder().build())
4586               .setCanonicalName("canonicalName2122381727")
4587               .setIndicator(Indicator.newBuilder().build())
4588               .setVulnerability(Vulnerability.newBuilder().build())
4589               .setMuteUpdateTime(Timestamp.newBuilder().build())
4590               .putAllExternalSystems(new HashMap<String, ExternalSystem>())
4591               .setMitreAttack(MitreAttack.newBuilder().build())
4592               .setAccess(Access.newBuilder().build())
4593               .addAllConnections(new ArrayList<Connection>())
4594               .setMuteInitiator("muteInitiator1395645462")
4595               .addAllProcesses(new ArrayList<Process>())
4596               .putAllContacts(new HashMap<String, ContactDetails>())
4597               .addAllCompliances(new ArrayList<Compliance>())
4598               .setParentDisplayName("parentDisplayName-1523759261")
4599               .setDescription("description-1724546052")
4600               .setExfiltration(Exfiltration.newBuilder().build())
4601               .addAllIamBindings(new ArrayList<IamBinding>())
4602               .setNextSteps("nextSteps1206138868")
4603               .setModuleName("moduleName-870351081")
4604               .addAllContainers(new ArrayList<Container>())
4605               .setKubernetes(Kubernetes.newBuilder().build())
4606               .setDatabase(Database.newBuilder().build())
4607               .addAllFiles(new ArrayList<File>())
4608               .setCloudDlpInspection(CloudDlpInspection.newBuilder().build())
4609               .setCloudDlpDataProfile(CloudDlpDataProfile.newBuilder().build())
4610               .setKernelRootkit(KernelRootkit.newBuilder().build())
4611               .build();
4612       client.updateFinding(finding);
4613       Assert.fail("No exception raised");
4614     } catch (InvalidArgumentException e) {
4615       // Expected exception.
4616     }
4617   }
4618 
4619   @Test
updateMuteConfigTest()4620   public void updateMuteConfigTest() throws Exception {
4621     MuteConfig expectedResponse =
4622         MuteConfig.newBuilder()
4623             .setName(
4624                 MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]")
4625                     .toString())
4626             .setDisplayName("displayName1714148973")
4627             .setDescription("description-1724546052")
4628             .setFilter("filter-1274492040")
4629             .setCreateTime(Timestamp.newBuilder().build())
4630             .setUpdateTime(Timestamp.newBuilder().build())
4631             .setMostRecentEditor("mostRecentEditor-833861941")
4632             .build();
4633     mockService.addResponse(expectedResponse);
4634 
4635     MuteConfig muteConfig =
4636         MuteConfig.newBuilder()
4637             .setName(
4638                 MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]")
4639                     .toString())
4640             .setDisplayName("displayName1714148973")
4641             .setDescription("description-1724546052")
4642             .setFilter("filter-1274492040")
4643             .setCreateTime(Timestamp.newBuilder().build())
4644             .setUpdateTime(Timestamp.newBuilder().build())
4645             .setMostRecentEditor("mostRecentEditor-833861941")
4646             .build();
4647     FieldMask updateMask = FieldMask.newBuilder().build();
4648 
4649     MuteConfig actualResponse = client.updateMuteConfig(muteConfig, updateMask);
4650     Assert.assertEquals(expectedResponse, actualResponse);
4651 
4652     List<String> actualRequests = mockService.getRequestPaths();
4653     Assert.assertEquals(1, actualRequests.size());
4654 
4655     String apiClientHeaderKey =
4656         mockService
4657             .getRequestHeaders()
4658             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4659             .iterator()
4660             .next();
4661     Assert.assertTrue(
4662         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4663             .matcher(apiClientHeaderKey)
4664             .matches());
4665   }
4666 
4667   @Test
updateMuteConfigExceptionTest()4668   public void updateMuteConfigExceptionTest() throws Exception {
4669     ApiException exception =
4670         ApiExceptionFactory.createException(
4671             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4672     mockService.addException(exception);
4673 
4674     try {
4675       MuteConfig muteConfig =
4676           MuteConfig.newBuilder()
4677               .setName(
4678                   MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]")
4679                       .toString())
4680               .setDisplayName("displayName1714148973")
4681               .setDescription("description-1724546052")
4682               .setFilter("filter-1274492040")
4683               .setCreateTime(Timestamp.newBuilder().build())
4684               .setUpdateTime(Timestamp.newBuilder().build())
4685               .setMostRecentEditor("mostRecentEditor-833861941")
4686               .build();
4687       FieldMask updateMask = FieldMask.newBuilder().build();
4688       client.updateMuteConfig(muteConfig, updateMask);
4689       Assert.fail("No exception raised");
4690     } catch (InvalidArgumentException e) {
4691       // Expected exception.
4692     }
4693   }
4694 
4695   @Test
updateNotificationConfigTest()4696   public void updateNotificationConfigTest() throws Exception {
4697     NotificationConfig expectedResponse =
4698         NotificationConfig.newBuilder()
4699             .setName(
4700                 NotificationConfigName.ofOrganizationNotificationConfigName(
4701                         "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
4702                     .toString())
4703             .setDescription("description-1724546052")
4704             .setPubsubTopic("pubsubTopic255880396")
4705             .setServiceAccount("serviceAccount1079137720")
4706             .build();
4707     mockService.addResponse(expectedResponse);
4708 
4709     NotificationConfig notificationConfig =
4710         NotificationConfig.newBuilder()
4711             .setName(
4712                 NotificationConfigName.ofOrganizationNotificationConfigName(
4713                         "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
4714                     .toString())
4715             .setDescription("description-1724546052")
4716             .setPubsubTopic("pubsubTopic255880396")
4717             .setServiceAccount("serviceAccount1079137720")
4718             .build();
4719 
4720     NotificationConfig actualResponse = client.updateNotificationConfig(notificationConfig);
4721     Assert.assertEquals(expectedResponse, actualResponse);
4722 
4723     List<String> actualRequests = mockService.getRequestPaths();
4724     Assert.assertEquals(1, actualRequests.size());
4725 
4726     String apiClientHeaderKey =
4727         mockService
4728             .getRequestHeaders()
4729             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4730             .iterator()
4731             .next();
4732     Assert.assertTrue(
4733         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4734             .matcher(apiClientHeaderKey)
4735             .matches());
4736   }
4737 
4738   @Test
updateNotificationConfigExceptionTest()4739   public void updateNotificationConfigExceptionTest() throws Exception {
4740     ApiException exception =
4741         ApiExceptionFactory.createException(
4742             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4743     mockService.addException(exception);
4744 
4745     try {
4746       NotificationConfig notificationConfig =
4747           NotificationConfig.newBuilder()
4748               .setName(
4749                   NotificationConfigName.ofOrganizationNotificationConfigName(
4750                           "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
4751                       .toString())
4752               .setDescription("description-1724546052")
4753               .setPubsubTopic("pubsubTopic255880396")
4754               .setServiceAccount("serviceAccount1079137720")
4755               .build();
4756       client.updateNotificationConfig(notificationConfig);
4757       Assert.fail("No exception raised");
4758     } catch (InvalidArgumentException e) {
4759       // Expected exception.
4760     }
4761   }
4762 
4763   @Test
updateNotificationConfigTest2()4764   public void updateNotificationConfigTest2() throws Exception {
4765     NotificationConfig expectedResponse =
4766         NotificationConfig.newBuilder()
4767             .setName(
4768                 NotificationConfigName.ofOrganizationNotificationConfigName(
4769                         "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
4770                     .toString())
4771             .setDescription("description-1724546052")
4772             .setPubsubTopic("pubsubTopic255880396")
4773             .setServiceAccount("serviceAccount1079137720")
4774             .build();
4775     mockService.addResponse(expectedResponse);
4776 
4777     NotificationConfig notificationConfig =
4778         NotificationConfig.newBuilder()
4779             .setName(
4780                 NotificationConfigName.ofOrganizationNotificationConfigName(
4781                         "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
4782                     .toString())
4783             .setDescription("description-1724546052")
4784             .setPubsubTopic("pubsubTopic255880396")
4785             .setServiceAccount("serviceAccount1079137720")
4786             .build();
4787     FieldMask updateMask = FieldMask.newBuilder().build();
4788 
4789     NotificationConfig actualResponse =
4790         client.updateNotificationConfig(notificationConfig, updateMask);
4791     Assert.assertEquals(expectedResponse, actualResponse);
4792 
4793     List<String> actualRequests = mockService.getRequestPaths();
4794     Assert.assertEquals(1, actualRequests.size());
4795 
4796     String apiClientHeaderKey =
4797         mockService
4798             .getRequestHeaders()
4799             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4800             .iterator()
4801             .next();
4802     Assert.assertTrue(
4803         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4804             .matcher(apiClientHeaderKey)
4805             .matches());
4806   }
4807 
4808   @Test
updateNotificationConfigExceptionTest2()4809   public void updateNotificationConfigExceptionTest2() throws Exception {
4810     ApiException exception =
4811         ApiExceptionFactory.createException(
4812             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4813     mockService.addException(exception);
4814 
4815     try {
4816       NotificationConfig notificationConfig =
4817           NotificationConfig.newBuilder()
4818               .setName(
4819                   NotificationConfigName.ofOrganizationNotificationConfigName(
4820                           "[ORGANIZATION]", "[NOTIFICATION_CONFIG]")
4821                       .toString())
4822               .setDescription("description-1724546052")
4823               .setPubsubTopic("pubsubTopic255880396")
4824               .setServiceAccount("serviceAccount1079137720")
4825               .build();
4826       FieldMask updateMask = FieldMask.newBuilder().build();
4827       client.updateNotificationConfig(notificationConfig, updateMask);
4828       Assert.fail("No exception raised");
4829     } catch (InvalidArgumentException e) {
4830       // Expected exception.
4831     }
4832   }
4833 
4834   @Test
updateOrganizationSettingsTest()4835   public void updateOrganizationSettingsTest() throws Exception {
4836     OrganizationSettings expectedResponse =
4837         OrganizationSettings.newBuilder()
4838             .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString())
4839             .setEnableAssetDiscovery(true)
4840             .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build())
4841             .build();
4842     mockService.addResponse(expectedResponse);
4843 
4844     OrganizationSettings organizationSettings =
4845         OrganizationSettings.newBuilder()
4846             .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString())
4847             .setEnableAssetDiscovery(true)
4848             .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build())
4849             .build();
4850 
4851     OrganizationSettings actualResponse = client.updateOrganizationSettings(organizationSettings);
4852     Assert.assertEquals(expectedResponse, actualResponse);
4853 
4854     List<String> actualRequests = mockService.getRequestPaths();
4855     Assert.assertEquals(1, actualRequests.size());
4856 
4857     String apiClientHeaderKey =
4858         mockService
4859             .getRequestHeaders()
4860             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4861             .iterator()
4862             .next();
4863     Assert.assertTrue(
4864         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4865             .matcher(apiClientHeaderKey)
4866             .matches());
4867   }
4868 
4869   @Test
updateOrganizationSettingsExceptionTest()4870   public void updateOrganizationSettingsExceptionTest() throws Exception {
4871     ApiException exception =
4872         ApiExceptionFactory.createException(
4873             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4874     mockService.addException(exception);
4875 
4876     try {
4877       OrganizationSettings organizationSettings =
4878           OrganizationSettings.newBuilder()
4879               .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString())
4880               .setEnableAssetDiscovery(true)
4881               .setAssetDiscoveryConfig(
4882                   OrganizationSettings.AssetDiscoveryConfig.newBuilder().build())
4883               .build();
4884       client.updateOrganizationSettings(organizationSettings);
4885       Assert.fail("No exception raised");
4886     } catch (InvalidArgumentException e) {
4887       // Expected exception.
4888     }
4889   }
4890 
4891   @Test
updateSecurityHealthAnalyticsCustomModuleTest()4892   public void updateSecurityHealthAnalyticsCustomModuleTest() throws Exception {
4893     SecurityHealthAnalyticsCustomModule expectedResponse =
4894         SecurityHealthAnalyticsCustomModule.newBuilder()
4895             .setName(
4896                 SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
4897                         "[ORGANIZATION]", "[CUSTOM_MODULE]")
4898                     .toString())
4899             .setDisplayName("displayName1714148973")
4900             .setUpdateTime(Timestamp.newBuilder().build())
4901             .setLastEditor("lastEditor1523898275")
4902             .setAncestorModule(
4903                 SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
4904                         "[ORGANIZATION]", "[CUSTOM_MODULE]")
4905                     .toString())
4906             .setCustomConfig(CustomConfig.newBuilder().build())
4907             .build();
4908     mockService.addResponse(expectedResponse);
4909 
4910     SecurityHealthAnalyticsCustomModule securityHealthAnalyticsCustomModule =
4911         SecurityHealthAnalyticsCustomModule.newBuilder()
4912             .setName(
4913                 SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
4914                         "[ORGANIZATION]", "[CUSTOM_MODULE]")
4915                     .toString())
4916             .setDisplayName("displayName1714148973")
4917             .setUpdateTime(Timestamp.newBuilder().build())
4918             .setLastEditor("lastEditor1523898275")
4919             .setAncestorModule(
4920                 SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
4921                         "[ORGANIZATION]", "[CUSTOM_MODULE]")
4922                     .toString())
4923             .setCustomConfig(CustomConfig.newBuilder().build())
4924             .build();
4925     FieldMask updateMask = FieldMask.newBuilder().build();
4926 
4927     SecurityHealthAnalyticsCustomModule actualResponse =
4928         client.updateSecurityHealthAnalyticsCustomModule(
4929             securityHealthAnalyticsCustomModule, updateMask);
4930     Assert.assertEquals(expectedResponse, actualResponse);
4931 
4932     List<String> actualRequests = mockService.getRequestPaths();
4933     Assert.assertEquals(1, actualRequests.size());
4934 
4935     String apiClientHeaderKey =
4936         mockService
4937             .getRequestHeaders()
4938             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4939             .iterator()
4940             .next();
4941     Assert.assertTrue(
4942         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4943             .matcher(apiClientHeaderKey)
4944             .matches());
4945   }
4946 
4947   @Test
updateSecurityHealthAnalyticsCustomModuleExceptionTest()4948   public void updateSecurityHealthAnalyticsCustomModuleExceptionTest() throws Exception {
4949     ApiException exception =
4950         ApiExceptionFactory.createException(
4951             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4952     mockService.addException(exception);
4953 
4954     try {
4955       SecurityHealthAnalyticsCustomModule securityHealthAnalyticsCustomModule =
4956           SecurityHealthAnalyticsCustomModule.newBuilder()
4957               .setName(
4958                   SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
4959                           "[ORGANIZATION]", "[CUSTOM_MODULE]")
4960                       .toString())
4961               .setDisplayName("displayName1714148973")
4962               .setUpdateTime(Timestamp.newBuilder().build())
4963               .setLastEditor("lastEditor1523898275")
4964               .setAncestorModule(
4965                   SecurityHealthAnalyticsCustomModuleName.ofOrganizationCustomModuleName(
4966                           "[ORGANIZATION]", "[CUSTOM_MODULE]")
4967                       .toString())
4968               .setCustomConfig(CustomConfig.newBuilder().build())
4969               .build();
4970       FieldMask updateMask = FieldMask.newBuilder().build();
4971       client.updateSecurityHealthAnalyticsCustomModule(
4972           securityHealthAnalyticsCustomModule, updateMask);
4973       Assert.fail("No exception raised");
4974     } catch (InvalidArgumentException e) {
4975       // Expected exception.
4976     }
4977   }
4978 
4979   @Test
updateSourceTest()4980   public void updateSourceTest() throws Exception {
4981     Source expectedResponse =
4982         Source.newBuilder()
4983             .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString())
4984             .setDisplayName("displayName1714148973")
4985             .setDescription("description-1724546052")
4986             .setCanonicalName("canonicalName2122381727")
4987             .build();
4988     mockService.addResponse(expectedResponse);
4989 
4990     Source source =
4991         Source.newBuilder()
4992             .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString())
4993             .setDisplayName("displayName1714148973")
4994             .setDescription("description-1724546052")
4995             .setCanonicalName("canonicalName2122381727")
4996             .build();
4997 
4998     Source actualResponse = client.updateSource(source);
4999     Assert.assertEquals(expectedResponse, actualResponse);
5000 
5001     List<String> actualRequests = mockService.getRequestPaths();
5002     Assert.assertEquals(1, actualRequests.size());
5003 
5004     String apiClientHeaderKey =
5005         mockService
5006             .getRequestHeaders()
5007             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
5008             .iterator()
5009             .next();
5010     Assert.assertTrue(
5011         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
5012             .matcher(apiClientHeaderKey)
5013             .matches());
5014   }
5015 
5016   @Test
updateSourceExceptionTest()5017   public void updateSourceExceptionTest() throws Exception {
5018     ApiException exception =
5019         ApiExceptionFactory.createException(
5020             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
5021     mockService.addException(exception);
5022 
5023     try {
5024       Source source =
5025           Source.newBuilder()
5026               .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString())
5027               .setDisplayName("displayName1714148973")
5028               .setDescription("description-1724546052")
5029               .setCanonicalName("canonicalName2122381727")
5030               .build();
5031       client.updateSource(source);
5032       Assert.fail("No exception raised");
5033     } catch (InvalidArgumentException e) {
5034       // Expected exception.
5035     }
5036   }
5037 
5038   @Test
updateSecurityMarksTest()5039   public void updateSecurityMarksTest() throws Exception {
5040     SecurityMarks expectedResponse =
5041         SecurityMarks.newBuilder()
5042             .setName("name3373707")
5043             .putAllMarks(new HashMap<String, String>())
5044             .setCanonicalName("canonicalName2122381727")
5045             .build();
5046     mockService.addResponse(expectedResponse);
5047 
5048     SecurityMarks securityMarks =
5049         SecurityMarks.newBuilder()
5050             .setName("organizations/organization-5924/assets/asset-5924/securityMarks")
5051             .putAllMarks(new HashMap<String, String>())
5052             .setCanonicalName("canonicalName2122381727")
5053             .build();
5054 
5055     SecurityMarks actualResponse = client.updateSecurityMarks(securityMarks);
5056     Assert.assertEquals(expectedResponse, actualResponse);
5057 
5058     List<String> actualRequests = mockService.getRequestPaths();
5059     Assert.assertEquals(1, actualRequests.size());
5060 
5061     String apiClientHeaderKey =
5062         mockService
5063             .getRequestHeaders()
5064             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
5065             .iterator()
5066             .next();
5067     Assert.assertTrue(
5068         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
5069             .matcher(apiClientHeaderKey)
5070             .matches());
5071   }
5072 
5073   @Test
updateSecurityMarksExceptionTest()5074   public void updateSecurityMarksExceptionTest() throws Exception {
5075     ApiException exception =
5076         ApiExceptionFactory.createException(
5077             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
5078     mockService.addException(exception);
5079 
5080     try {
5081       SecurityMarks securityMarks =
5082           SecurityMarks.newBuilder()
5083               .setName("organizations/organization-5924/assets/asset-5924/securityMarks")
5084               .putAllMarks(new HashMap<String, String>())
5085               .setCanonicalName("canonicalName2122381727")
5086               .build();
5087       client.updateSecurityMarks(securityMarks);
5088       Assert.fail("No exception raised");
5089     } catch (InvalidArgumentException e) {
5090       // Expected exception.
5091     }
5092   }
5093 
5094   @Test
createBigQueryExportTest()5095   public void createBigQueryExportTest() throws Exception {
5096     BigQueryExport expectedResponse =
5097         BigQueryExport.newBuilder()
5098             .setName(
5099                 BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]")
5100                     .toString())
5101             .setDescription("description-1724546052")
5102             .setFilter("filter-1274492040")
5103             .setDataset("dataset1443214456")
5104             .setCreateTime(Timestamp.newBuilder().build())
5105             .setUpdateTime(Timestamp.newBuilder().build())
5106             .setMostRecentEditor("mostRecentEditor-833861941")
5107             .setPrincipal("principal-1812041682")
5108             .build();
5109     mockService.addResponse(expectedResponse);
5110 
5111     FolderName parent = FolderName.of("[FOLDER]");
5112     BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build();
5113     String bigQueryExportId = "bigQueryExportId1024198583";
5114 
5115     BigQueryExport actualResponse =
5116         client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId);
5117     Assert.assertEquals(expectedResponse, actualResponse);
5118 
5119     List<String> actualRequests = mockService.getRequestPaths();
5120     Assert.assertEquals(1, actualRequests.size());
5121 
5122     String apiClientHeaderKey =
5123         mockService
5124             .getRequestHeaders()
5125             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
5126             .iterator()
5127             .next();
5128     Assert.assertTrue(
5129         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
5130             .matcher(apiClientHeaderKey)
5131             .matches());
5132   }
5133 
5134   @Test
createBigQueryExportExceptionTest()5135   public void createBigQueryExportExceptionTest() throws Exception {
5136     ApiException exception =
5137         ApiExceptionFactory.createException(
5138             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
5139     mockService.addException(exception);
5140 
5141     try {
5142       FolderName parent = FolderName.of("[FOLDER]");
5143       BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build();
5144       String bigQueryExportId = "bigQueryExportId1024198583";
5145       client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId);
5146       Assert.fail("No exception raised");
5147     } catch (InvalidArgumentException e) {
5148       // Expected exception.
5149     }
5150   }
5151 
5152   @Test
createBigQueryExportTest2()5153   public void createBigQueryExportTest2() throws Exception {
5154     BigQueryExport expectedResponse =
5155         BigQueryExport.newBuilder()
5156             .setName(
5157                 BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]")
5158                     .toString())
5159             .setDescription("description-1724546052")
5160             .setFilter("filter-1274492040")
5161             .setDataset("dataset1443214456")
5162             .setCreateTime(Timestamp.newBuilder().build())
5163             .setUpdateTime(Timestamp.newBuilder().build())
5164             .setMostRecentEditor("mostRecentEditor-833861941")
5165             .setPrincipal("principal-1812041682")
5166             .build();
5167     mockService.addResponse(expectedResponse);
5168 
5169     OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
5170     BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build();
5171     String bigQueryExportId = "bigQueryExportId1024198583";
5172 
5173     BigQueryExport actualResponse =
5174         client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId);
5175     Assert.assertEquals(expectedResponse, actualResponse);
5176 
5177     List<String> actualRequests = mockService.getRequestPaths();
5178     Assert.assertEquals(1, actualRequests.size());
5179 
5180     String apiClientHeaderKey =
5181         mockService
5182             .getRequestHeaders()
5183             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
5184             .iterator()
5185             .next();
5186     Assert.assertTrue(
5187         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
5188             .matcher(apiClientHeaderKey)
5189             .matches());
5190   }
5191 
5192   @Test
createBigQueryExportExceptionTest2()5193   public void createBigQueryExportExceptionTest2() throws Exception {
5194     ApiException exception =
5195         ApiExceptionFactory.createException(
5196             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
5197     mockService.addException(exception);
5198 
5199     try {
5200       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
5201       BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build();
5202       String bigQueryExportId = "bigQueryExportId1024198583";
5203       client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId);
5204       Assert.fail("No exception raised");
5205     } catch (InvalidArgumentException e) {
5206       // Expected exception.
5207     }
5208   }
5209 
5210   @Test
createBigQueryExportTest3()5211   public void createBigQueryExportTest3() throws Exception {
5212     BigQueryExport expectedResponse =
5213         BigQueryExport.newBuilder()
5214             .setName(
5215                 BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]")
5216                     .toString())
5217             .setDescription("description-1724546052")
5218             .setFilter("filter-1274492040")
5219             .setDataset("dataset1443214456")
5220             .setCreateTime(Timestamp.newBuilder().build())
5221             .setUpdateTime(Timestamp.newBuilder().build())
5222             .setMostRecentEditor("mostRecentEditor-833861941")
5223             .setPrincipal("principal-1812041682")
5224             .build();
5225     mockService.addResponse(expectedResponse);
5226 
5227     ProjectName parent = ProjectName.of("[PROJECT]");
5228     BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build();
5229     String bigQueryExportId = "bigQueryExportId1024198583";
5230 
5231     BigQueryExport actualResponse =
5232         client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId);
5233     Assert.assertEquals(expectedResponse, actualResponse);
5234 
5235     List<String> actualRequests = mockService.getRequestPaths();
5236     Assert.assertEquals(1, actualRequests.size());
5237 
5238     String apiClientHeaderKey =
5239         mockService
5240             .getRequestHeaders()
5241             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
5242             .iterator()
5243             .next();
5244     Assert.assertTrue(
5245         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
5246             .matcher(apiClientHeaderKey)
5247             .matches());
5248   }
5249 
5250   @Test
createBigQueryExportExceptionTest3()5251   public void createBigQueryExportExceptionTest3() throws Exception {
5252     ApiException exception =
5253         ApiExceptionFactory.createException(
5254             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
5255     mockService.addException(exception);
5256 
5257     try {
5258       ProjectName parent = ProjectName.of("[PROJECT]");
5259       BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build();
5260       String bigQueryExportId = "bigQueryExportId1024198583";
5261       client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId);
5262       Assert.fail("No exception raised");
5263     } catch (InvalidArgumentException e) {
5264       // Expected exception.
5265     }
5266   }
5267 
5268   @Test
createBigQueryExportTest4()5269   public void createBigQueryExportTest4() throws Exception {
5270     BigQueryExport expectedResponse =
5271         BigQueryExport.newBuilder()
5272             .setName(
5273                 BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]")
5274                     .toString())
5275             .setDescription("description-1724546052")
5276             .setFilter("filter-1274492040")
5277             .setDataset("dataset1443214456")
5278             .setCreateTime(Timestamp.newBuilder().build())
5279             .setUpdateTime(Timestamp.newBuilder().build())
5280             .setMostRecentEditor("mostRecentEditor-833861941")
5281             .setPrincipal("principal-1812041682")
5282             .build();
5283     mockService.addResponse(expectedResponse);
5284 
5285     String parent = "organizations/organization-8287";
5286     BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build();
5287     String bigQueryExportId = "bigQueryExportId1024198583";
5288 
5289     BigQueryExport actualResponse =
5290         client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId);
5291     Assert.assertEquals(expectedResponse, actualResponse);
5292 
5293     List<String> actualRequests = mockService.getRequestPaths();
5294     Assert.assertEquals(1, actualRequests.size());
5295 
5296     String apiClientHeaderKey =
5297         mockService
5298             .getRequestHeaders()
5299             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
5300             .iterator()
5301             .next();
5302     Assert.assertTrue(
5303         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
5304             .matcher(apiClientHeaderKey)
5305             .matches());
5306   }
5307 
5308   @Test
createBigQueryExportExceptionTest4()5309   public void createBigQueryExportExceptionTest4() throws Exception {
5310     ApiException exception =
5311         ApiExceptionFactory.createException(
5312             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
5313     mockService.addException(exception);
5314 
5315     try {
5316       String parent = "organizations/organization-8287";
5317       BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build();
5318       String bigQueryExportId = "bigQueryExportId1024198583";
5319       client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId);
5320       Assert.fail("No exception raised");
5321     } catch (InvalidArgumentException e) {
5322       // Expected exception.
5323     }
5324   }
5325 
5326   @Test
deleteBigQueryExportTest()5327   public void deleteBigQueryExportTest() throws Exception {
5328     Empty expectedResponse = Empty.newBuilder().build();
5329     mockService.addResponse(expectedResponse);
5330 
5331     BigQueryExportName name =
5332         BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]");
5333 
5334     client.deleteBigQueryExport(name);
5335 
5336     List<String> actualRequests = mockService.getRequestPaths();
5337     Assert.assertEquals(1, actualRequests.size());
5338 
5339     String apiClientHeaderKey =
5340         mockService
5341             .getRequestHeaders()
5342             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
5343             .iterator()
5344             .next();
5345     Assert.assertTrue(
5346         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
5347             .matcher(apiClientHeaderKey)
5348             .matches());
5349   }
5350 
5351   @Test
deleteBigQueryExportExceptionTest()5352   public void deleteBigQueryExportExceptionTest() throws Exception {
5353     ApiException exception =
5354         ApiExceptionFactory.createException(
5355             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
5356     mockService.addException(exception);
5357 
5358     try {
5359       BigQueryExportName name =
5360           BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]");
5361       client.deleteBigQueryExport(name);
5362       Assert.fail("No exception raised");
5363     } catch (InvalidArgumentException e) {
5364       // Expected exception.
5365     }
5366   }
5367 
5368   @Test
deleteBigQueryExportTest2()5369   public void deleteBigQueryExportTest2() throws Exception {
5370     Empty expectedResponse = Empty.newBuilder().build();
5371     mockService.addResponse(expectedResponse);
5372 
5373     String name = "organizations/organization-3683/bigQueryExports/bigQueryExport-3683";
5374 
5375     client.deleteBigQueryExport(name);
5376 
5377     List<String> actualRequests = mockService.getRequestPaths();
5378     Assert.assertEquals(1, actualRequests.size());
5379 
5380     String apiClientHeaderKey =
5381         mockService
5382             .getRequestHeaders()
5383             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
5384             .iterator()
5385             .next();
5386     Assert.assertTrue(
5387         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
5388             .matcher(apiClientHeaderKey)
5389             .matches());
5390   }
5391 
5392   @Test
deleteBigQueryExportExceptionTest2()5393   public void deleteBigQueryExportExceptionTest2() throws Exception {
5394     ApiException exception =
5395         ApiExceptionFactory.createException(
5396             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
5397     mockService.addException(exception);
5398 
5399     try {
5400       String name = "organizations/organization-3683/bigQueryExports/bigQueryExport-3683";
5401       client.deleteBigQueryExport(name);
5402       Assert.fail("No exception raised");
5403     } catch (InvalidArgumentException e) {
5404       // Expected exception.
5405     }
5406   }
5407 
5408   @Test
updateBigQueryExportTest()5409   public void updateBigQueryExportTest() throws Exception {
5410     BigQueryExport expectedResponse =
5411         BigQueryExport.newBuilder()
5412             .setName(
5413                 BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]")
5414                     .toString())
5415             .setDescription("description-1724546052")
5416             .setFilter("filter-1274492040")
5417             .setDataset("dataset1443214456")
5418             .setCreateTime(Timestamp.newBuilder().build())
5419             .setUpdateTime(Timestamp.newBuilder().build())
5420             .setMostRecentEditor("mostRecentEditor-833861941")
5421             .setPrincipal("principal-1812041682")
5422             .build();
5423     mockService.addResponse(expectedResponse);
5424 
5425     BigQueryExport bigQueryExport =
5426         BigQueryExport.newBuilder()
5427             .setName(
5428                 BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]")
5429                     .toString())
5430             .setDescription("description-1724546052")
5431             .setFilter("filter-1274492040")
5432             .setDataset("dataset1443214456")
5433             .setCreateTime(Timestamp.newBuilder().build())
5434             .setUpdateTime(Timestamp.newBuilder().build())
5435             .setMostRecentEditor("mostRecentEditor-833861941")
5436             .setPrincipal("principal-1812041682")
5437             .build();
5438     FieldMask updateMask = FieldMask.newBuilder().build();
5439 
5440     BigQueryExport actualResponse = client.updateBigQueryExport(bigQueryExport, updateMask);
5441     Assert.assertEquals(expectedResponse, actualResponse);
5442 
5443     List<String> actualRequests = mockService.getRequestPaths();
5444     Assert.assertEquals(1, actualRequests.size());
5445 
5446     String apiClientHeaderKey =
5447         mockService
5448             .getRequestHeaders()
5449             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
5450             .iterator()
5451             .next();
5452     Assert.assertTrue(
5453         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
5454             .matcher(apiClientHeaderKey)
5455             .matches());
5456   }
5457 
5458   @Test
updateBigQueryExportExceptionTest()5459   public void updateBigQueryExportExceptionTest() throws Exception {
5460     ApiException exception =
5461         ApiExceptionFactory.createException(
5462             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
5463     mockService.addException(exception);
5464 
5465     try {
5466       BigQueryExport bigQueryExport =
5467           BigQueryExport.newBuilder()
5468               .setName(
5469                   BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]")
5470                       .toString())
5471               .setDescription("description-1724546052")
5472               .setFilter("filter-1274492040")
5473               .setDataset("dataset1443214456")
5474               .setCreateTime(Timestamp.newBuilder().build())
5475               .setUpdateTime(Timestamp.newBuilder().build())
5476               .setMostRecentEditor("mostRecentEditor-833861941")
5477               .setPrincipal("principal-1812041682")
5478               .build();
5479       FieldMask updateMask = FieldMask.newBuilder().build();
5480       client.updateBigQueryExport(bigQueryExport, updateMask);
5481       Assert.fail("No exception raised");
5482     } catch (InvalidArgumentException e) {
5483       // Expected exception.
5484     }
5485   }
5486 
5487   @Test
listBigQueryExportsTest()5488   public void listBigQueryExportsTest() throws Exception {
5489     BigQueryExport responsesElement = BigQueryExport.newBuilder().build();
5490     ListBigQueryExportsResponse expectedResponse =
5491         ListBigQueryExportsResponse.newBuilder()
5492             .setNextPageToken("")
5493             .addAllBigQueryExports(Arrays.asList(responsesElement))
5494             .build();
5495     mockService.addResponse(expectedResponse);
5496 
5497     FolderName parent = FolderName.of("[FOLDER]");
5498 
5499     ListBigQueryExportsPagedResponse pagedListResponse = client.listBigQueryExports(parent);
5500 
5501     List<BigQueryExport> resources = Lists.newArrayList(pagedListResponse.iterateAll());
5502 
5503     Assert.assertEquals(1, resources.size());
5504     Assert.assertEquals(expectedResponse.getBigQueryExportsList().get(0), resources.get(0));
5505 
5506     List<String> actualRequests = mockService.getRequestPaths();
5507     Assert.assertEquals(1, actualRequests.size());
5508 
5509     String apiClientHeaderKey =
5510         mockService
5511             .getRequestHeaders()
5512             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
5513             .iterator()
5514             .next();
5515     Assert.assertTrue(
5516         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
5517             .matcher(apiClientHeaderKey)
5518             .matches());
5519   }
5520 
5521   @Test
listBigQueryExportsExceptionTest()5522   public void listBigQueryExportsExceptionTest() throws Exception {
5523     ApiException exception =
5524         ApiExceptionFactory.createException(
5525             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
5526     mockService.addException(exception);
5527 
5528     try {
5529       FolderName parent = FolderName.of("[FOLDER]");
5530       client.listBigQueryExports(parent);
5531       Assert.fail("No exception raised");
5532     } catch (InvalidArgumentException e) {
5533       // Expected exception.
5534     }
5535   }
5536 
5537   @Test
listBigQueryExportsTest2()5538   public void listBigQueryExportsTest2() throws Exception {
5539     BigQueryExport responsesElement = BigQueryExport.newBuilder().build();
5540     ListBigQueryExportsResponse expectedResponse =
5541         ListBigQueryExportsResponse.newBuilder()
5542             .setNextPageToken("")
5543             .addAllBigQueryExports(Arrays.asList(responsesElement))
5544             .build();
5545     mockService.addResponse(expectedResponse);
5546 
5547     OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
5548 
5549     ListBigQueryExportsPagedResponse pagedListResponse = client.listBigQueryExports(parent);
5550 
5551     List<BigQueryExport> resources = Lists.newArrayList(pagedListResponse.iterateAll());
5552 
5553     Assert.assertEquals(1, resources.size());
5554     Assert.assertEquals(expectedResponse.getBigQueryExportsList().get(0), resources.get(0));
5555 
5556     List<String> actualRequests = mockService.getRequestPaths();
5557     Assert.assertEquals(1, actualRequests.size());
5558 
5559     String apiClientHeaderKey =
5560         mockService
5561             .getRequestHeaders()
5562             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
5563             .iterator()
5564             .next();
5565     Assert.assertTrue(
5566         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
5567             .matcher(apiClientHeaderKey)
5568             .matches());
5569   }
5570 
5571   @Test
listBigQueryExportsExceptionTest2()5572   public void listBigQueryExportsExceptionTest2() throws Exception {
5573     ApiException exception =
5574         ApiExceptionFactory.createException(
5575             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
5576     mockService.addException(exception);
5577 
5578     try {
5579       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
5580       client.listBigQueryExports(parent);
5581       Assert.fail("No exception raised");
5582     } catch (InvalidArgumentException e) {
5583       // Expected exception.
5584     }
5585   }
5586 
5587   @Test
listBigQueryExportsTest3()5588   public void listBigQueryExportsTest3() throws Exception {
5589     BigQueryExport responsesElement = BigQueryExport.newBuilder().build();
5590     ListBigQueryExportsResponse expectedResponse =
5591         ListBigQueryExportsResponse.newBuilder()
5592             .setNextPageToken("")
5593             .addAllBigQueryExports(Arrays.asList(responsesElement))
5594             .build();
5595     mockService.addResponse(expectedResponse);
5596 
5597     ProjectName parent = ProjectName.of("[PROJECT]");
5598 
5599     ListBigQueryExportsPagedResponse pagedListResponse = client.listBigQueryExports(parent);
5600 
5601     List<BigQueryExport> resources = Lists.newArrayList(pagedListResponse.iterateAll());
5602 
5603     Assert.assertEquals(1, resources.size());
5604     Assert.assertEquals(expectedResponse.getBigQueryExportsList().get(0), resources.get(0));
5605 
5606     List<String> actualRequests = mockService.getRequestPaths();
5607     Assert.assertEquals(1, actualRequests.size());
5608 
5609     String apiClientHeaderKey =
5610         mockService
5611             .getRequestHeaders()
5612             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
5613             .iterator()
5614             .next();
5615     Assert.assertTrue(
5616         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
5617             .matcher(apiClientHeaderKey)
5618             .matches());
5619   }
5620 
5621   @Test
listBigQueryExportsExceptionTest3()5622   public void listBigQueryExportsExceptionTest3() throws Exception {
5623     ApiException exception =
5624         ApiExceptionFactory.createException(
5625             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
5626     mockService.addException(exception);
5627 
5628     try {
5629       ProjectName parent = ProjectName.of("[PROJECT]");
5630       client.listBigQueryExports(parent);
5631       Assert.fail("No exception raised");
5632     } catch (InvalidArgumentException e) {
5633       // Expected exception.
5634     }
5635   }
5636 
5637   @Test
listBigQueryExportsTest4()5638   public void listBigQueryExportsTest4() throws Exception {
5639     BigQueryExport responsesElement = BigQueryExport.newBuilder().build();
5640     ListBigQueryExportsResponse expectedResponse =
5641         ListBigQueryExportsResponse.newBuilder()
5642             .setNextPageToken("")
5643             .addAllBigQueryExports(Arrays.asList(responsesElement))
5644             .build();
5645     mockService.addResponse(expectedResponse);
5646 
5647     String parent = "organizations/organization-8287";
5648 
5649     ListBigQueryExportsPagedResponse pagedListResponse = client.listBigQueryExports(parent);
5650 
5651     List<BigQueryExport> resources = Lists.newArrayList(pagedListResponse.iterateAll());
5652 
5653     Assert.assertEquals(1, resources.size());
5654     Assert.assertEquals(expectedResponse.getBigQueryExportsList().get(0), resources.get(0));
5655 
5656     List<String> actualRequests = mockService.getRequestPaths();
5657     Assert.assertEquals(1, actualRequests.size());
5658 
5659     String apiClientHeaderKey =
5660         mockService
5661             .getRequestHeaders()
5662             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
5663             .iterator()
5664             .next();
5665     Assert.assertTrue(
5666         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
5667             .matcher(apiClientHeaderKey)
5668             .matches());
5669   }
5670 
5671   @Test
listBigQueryExportsExceptionTest4()5672   public void listBigQueryExportsExceptionTest4() throws Exception {
5673     ApiException exception =
5674         ApiExceptionFactory.createException(
5675             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
5676     mockService.addException(exception);
5677 
5678     try {
5679       String parent = "organizations/organization-8287";
5680       client.listBigQueryExports(parent);
5681       Assert.fail("No exception raised");
5682     } catch (InvalidArgumentException e) {
5683       // Expected exception.
5684     }
5685   }
5686 }
5687