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