• 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.compute.v1;
18 
19 import static com.google.cloud.compute.v1.TargetSslProxiesClient.ListPagedResponse;
20 
21 import com.google.api.gax.core.NoCredentialsProvider;
22 import com.google.api.gax.httpjson.GaxHttpJsonProperties;
23 import com.google.api.gax.httpjson.testing.MockHttpService;
24 import com.google.api.gax.rpc.ApiClientHeaderProvider;
25 import com.google.api.gax.rpc.ApiException;
26 import com.google.api.gax.rpc.ApiExceptionFactory;
27 import com.google.api.gax.rpc.InvalidArgumentException;
28 import com.google.api.gax.rpc.StatusCode;
29 import com.google.api.gax.rpc.testing.FakeStatusCode;
30 import com.google.cloud.compute.v1.Operation.Status;
31 import com.google.cloud.compute.v1.stub.HttpJsonTargetSslProxiesStub;
32 import com.google.common.collect.Lists;
33 import java.io.IOException;
34 import java.util.ArrayList;
35 import java.util.Arrays;
36 import java.util.List;
37 import java.util.concurrent.ExecutionException;
38 import javax.annotation.Generated;
39 import org.junit.After;
40 import org.junit.AfterClass;
41 import org.junit.Assert;
42 import org.junit.Before;
43 import org.junit.BeforeClass;
44 import org.junit.Test;
45 
46 @Generated("by gapic-generator-java")
47 public class TargetSslProxiesClientTest {
48   private static MockHttpService mockService;
49   private static TargetSslProxiesClient client;
50 
51   @BeforeClass
startStaticServer()52   public static void startStaticServer() throws IOException {
53     mockService =
54         new MockHttpService(
55             HttpJsonTargetSslProxiesStub.getMethodDescriptors(),
56             TargetSslProxiesSettings.getDefaultEndpoint());
57     TargetSslProxiesSettings settings =
58         TargetSslProxiesSettings.newBuilder()
59             .setTransportChannelProvider(
60                 TargetSslProxiesSettings.defaultHttpJsonTransportProviderBuilder()
61                     .setHttpTransport(mockService)
62                     .build())
63             .setCredentialsProvider(NoCredentialsProvider.create())
64             .build();
65     client = TargetSslProxiesClient.create(settings);
66   }
67 
68   @AfterClass
stopServer()69   public static void stopServer() {
70     client.close();
71   }
72 
73   @Before
setUp()74   public void setUp() {}
75 
76   @After
tearDown()77   public void tearDown() throws Exception {
78     mockService.reset();
79   }
80 
81   @Test
deleteTest()82   public void deleteTest() throws Exception {
83     Operation expectedResponse =
84         Operation.newBuilder()
85             .setClientOperationId("clientOperationId-1230366697")
86             .setCreationTimestamp("creationTimestamp-370203401")
87             .setDescription("description-1724546052")
88             .setEndTime("endTime-1607243192")
89             .setError(Error.newBuilder().build())
90             .setHttpErrorMessage("httpErrorMessage1577303431")
91             .setHttpErrorStatusCode(0)
92             .setId(3355)
93             .setInsertTime("insertTime966165798")
94             .setKind("kind3292052")
95             .setName("name3373707")
96             .setOperationGroupId("operationGroupId1716161683")
97             .setOperationType("operationType91999553")
98             .setProgress(-1001078227)
99             .setRegion("region-934795532")
100             .setSelfLink("selfLink1191800166")
101             .setStartTime("startTime-2129294769")
102             .setStatus(Status.DONE)
103             .setStatusMessage("statusMessage-958704715")
104             .setTargetId(-815576439)
105             .setTargetLink("targetLink486368555")
106             .setUser("user3599307")
107             .addAllWarnings(new ArrayList<Warnings>())
108             .setZone("zone3744684")
109             .build();
110     mockService.addResponse(expectedResponse);
111 
112     String project = "project-6911";
113     String targetSslProxy = "targetSslProxy-5881";
114 
115     Operation actualResponse = client.deleteAsync(project, targetSslProxy).get();
116     Assert.assertEquals(expectedResponse, actualResponse);
117 
118     List<String> actualRequests = mockService.getRequestPaths();
119     Assert.assertEquals(1, actualRequests.size());
120 
121     String apiClientHeaderKey =
122         mockService
123             .getRequestHeaders()
124             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
125             .iterator()
126             .next();
127     Assert.assertTrue(
128         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
129             .matcher(apiClientHeaderKey)
130             .matches());
131   }
132 
133   @Test
deleteExceptionTest()134   public void deleteExceptionTest() throws Exception {
135     ApiException exception =
136         ApiExceptionFactory.createException(
137             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
138     mockService.addException(exception);
139 
140     try {
141       String project = "project-6911";
142       String targetSslProxy = "targetSslProxy-5881";
143       client.deleteAsync(project, targetSslProxy).get();
144       Assert.fail("No exception raised");
145     } catch (ExecutionException e) {
146     }
147   }
148 
149   @Test
getTest()150   public void getTest() throws Exception {
151     TargetSslProxy expectedResponse =
152         TargetSslProxy.newBuilder()
153             .setCertificateMap("certificateMap1494413381")
154             .setCreationTimestamp("creationTimestamp-370203401")
155             .setDescription("description-1724546052")
156             .setId(3355)
157             .setKind("kind3292052")
158             .setName("name3373707")
159             .setProxyHeader("proxyHeader1768394395")
160             .setSelfLink("selfLink1191800166")
161             .setService("service1984153269")
162             .addAllSslCertificates(new ArrayList<String>())
163             .setSslPolicy("sslPolicy618174046")
164             .build();
165     mockService.addResponse(expectedResponse);
166 
167     String project = "project-6911";
168     String targetSslProxy = "targetSslProxy-5881";
169 
170     TargetSslProxy actualResponse = client.get(project, targetSslProxy);
171     Assert.assertEquals(expectedResponse, actualResponse);
172 
173     List<String> actualRequests = mockService.getRequestPaths();
174     Assert.assertEquals(1, actualRequests.size());
175 
176     String apiClientHeaderKey =
177         mockService
178             .getRequestHeaders()
179             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
180             .iterator()
181             .next();
182     Assert.assertTrue(
183         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
184             .matcher(apiClientHeaderKey)
185             .matches());
186   }
187 
188   @Test
getExceptionTest()189   public void getExceptionTest() throws Exception {
190     ApiException exception =
191         ApiExceptionFactory.createException(
192             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
193     mockService.addException(exception);
194 
195     try {
196       String project = "project-6911";
197       String targetSslProxy = "targetSslProxy-5881";
198       client.get(project, targetSslProxy);
199       Assert.fail("No exception raised");
200     } catch (InvalidArgumentException e) {
201       // Expected exception.
202     }
203   }
204 
205   @Test
insertTest()206   public void insertTest() throws Exception {
207     Operation expectedResponse =
208         Operation.newBuilder()
209             .setClientOperationId("clientOperationId-1230366697")
210             .setCreationTimestamp("creationTimestamp-370203401")
211             .setDescription("description-1724546052")
212             .setEndTime("endTime-1607243192")
213             .setError(Error.newBuilder().build())
214             .setHttpErrorMessage("httpErrorMessage1577303431")
215             .setHttpErrorStatusCode(0)
216             .setId(3355)
217             .setInsertTime("insertTime966165798")
218             .setKind("kind3292052")
219             .setName("name3373707")
220             .setOperationGroupId("operationGroupId1716161683")
221             .setOperationType("operationType91999553")
222             .setProgress(-1001078227)
223             .setRegion("region-934795532")
224             .setSelfLink("selfLink1191800166")
225             .setStartTime("startTime-2129294769")
226             .setStatus(Status.DONE)
227             .setStatusMessage("statusMessage-958704715")
228             .setTargetId(-815576439)
229             .setTargetLink("targetLink486368555")
230             .setUser("user3599307")
231             .addAllWarnings(new ArrayList<Warnings>())
232             .setZone("zone3744684")
233             .build();
234     mockService.addResponse(expectedResponse);
235 
236     String project = "project-6911";
237     TargetSslProxy targetSslProxyResource = TargetSslProxy.newBuilder().build();
238 
239     Operation actualResponse = client.insertAsync(project, targetSslProxyResource).get();
240     Assert.assertEquals(expectedResponse, actualResponse);
241 
242     List<String> actualRequests = mockService.getRequestPaths();
243     Assert.assertEquals(1, actualRequests.size());
244 
245     String apiClientHeaderKey =
246         mockService
247             .getRequestHeaders()
248             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
249             .iterator()
250             .next();
251     Assert.assertTrue(
252         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
253             .matcher(apiClientHeaderKey)
254             .matches());
255   }
256 
257   @Test
insertExceptionTest()258   public void insertExceptionTest() throws Exception {
259     ApiException exception =
260         ApiExceptionFactory.createException(
261             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
262     mockService.addException(exception);
263 
264     try {
265       String project = "project-6911";
266       TargetSslProxy targetSslProxyResource = TargetSslProxy.newBuilder().build();
267       client.insertAsync(project, targetSslProxyResource).get();
268       Assert.fail("No exception raised");
269     } catch (ExecutionException e) {
270     }
271   }
272 
273   @Test
listTest()274   public void listTest() throws Exception {
275     TargetSslProxy responsesElement = TargetSslProxy.newBuilder().build();
276     TargetSslProxyList expectedResponse =
277         TargetSslProxyList.newBuilder()
278             .setNextPageToken("")
279             .addAllItems(Arrays.asList(responsesElement))
280             .build();
281     mockService.addResponse(expectedResponse);
282 
283     String project = "project-6911";
284 
285     ListPagedResponse pagedListResponse = client.list(project);
286 
287     List<TargetSslProxy> resources = Lists.newArrayList(pagedListResponse.iterateAll());
288 
289     Assert.assertEquals(1, resources.size());
290     Assert.assertEquals(expectedResponse.getItemsList().get(0), resources.get(0));
291 
292     List<String> actualRequests = mockService.getRequestPaths();
293     Assert.assertEquals(1, actualRequests.size());
294 
295     String apiClientHeaderKey =
296         mockService
297             .getRequestHeaders()
298             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
299             .iterator()
300             .next();
301     Assert.assertTrue(
302         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
303             .matcher(apiClientHeaderKey)
304             .matches());
305   }
306 
307   @Test
listExceptionTest()308   public void listExceptionTest() throws Exception {
309     ApiException exception =
310         ApiExceptionFactory.createException(
311             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
312     mockService.addException(exception);
313 
314     try {
315       String project = "project-6911";
316       client.list(project);
317       Assert.fail("No exception raised");
318     } catch (InvalidArgumentException e) {
319       // Expected exception.
320     }
321   }
322 
323   @Test
setBackendServiceTest()324   public void setBackendServiceTest() throws Exception {
325     Operation expectedResponse =
326         Operation.newBuilder()
327             .setClientOperationId("clientOperationId-1230366697")
328             .setCreationTimestamp("creationTimestamp-370203401")
329             .setDescription("description-1724546052")
330             .setEndTime("endTime-1607243192")
331             .setError(Error.newBuilder().build())
332             .setHttpErrorMessage("httpErrorMessage1577303431")
333             .setHttpErrorStatusCode(0)
334             .setId(3355)
335             .setInsertTime("insertTime966165798")
336             .setKind("kind3292052")
337             .setName("name3373707")
338             .setOperationGroupId("operationGroupId1716161683")
339             .setOperationType("operationType91999553")
340             .setProgress(-1001078227)
341             .setRegion("region-934795532")
342             .setSelfLink("selfLink1191800166")
343             .setStartTime("startTime-2129294769")
344             .setStatus(Status.DONE)
345             .setStatusMessage("statusMessage-958704715")
346             .setTargetId(-815576439)
347             .setTargetLink("targetLink486368555")
348             .setUser("user3599307")
349             .addAllWarnings(new ArrayList<Warnings>())
350             .setZone("zone3744684")
351             .build();
352     mockService.addResponse(expectedResponse);
353 
354     String project = "project-6911";
355     String targetSslProxy = "targetSslProxy-5881";
356     TargetSslProxiesSetBackendServiceRequest targetSslProxiesSetBackendServiceRequestResource =
357         TargetSslProxiesSetBackendServiceRequest.newBuilder().build();
358 
359     Operation actualResponse =
360         client
361             .setBackendServiceAsync(
362                 project, targetSslProxy, targetSslProxiesSetBackendServiceRequestResource)
363             .get();
364     Assert.assertEquals(expectedResponse, actualResponse);
365 
366     List<String> actualRequests = mockService.getRequestPaths();
367     Assert.assertEquals(1, actualRequests.size());
368 
369     String apiClientHeaderKey =
370         mockService
371             .getRequestHeaders()
372             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
373             .iterator()
374             .next();
375     Assert.assertTrue(
376         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
377             .matcher(apiClientHeaderKey)
378             .matches());
379   }
380 
381   @Test
setBackendServiceExceptionTest()382   public void setBackendServiceExceptionTest() throws Exception {
383     ApiException exception =
384         ApiExceptionFactory.createException(
385             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
386     mockService.addException(exception);
387 
388     try {
389       String project = "project-6911";
390       String targetSslProxy = "targetSslProxy-5881";
391       TargetSslProxiesSetBackendServiceRequest targetSslProxiesSetBackendServiceRequestResource =
392           TargetSslProxiesSetBackendServiceRequest.newBuilder().build();
393       client
394           .setBackendServiceAsync(
395               project, targetSslProxy, targetSslProxiesSetBackendServiceRequestResource)
396           .get();
397       Assert.fail("No exception raised");
398     } catch (ExecutionException e) {
399     }
400   }
401 
402   @Test
setCertificateMapTest()403   public void setCertificateMapTest() throws Exception {
404     Operation expectedResponse =
405         Operation.newBuilder()
406             .setClientOperationId("clientOperationId-1230366697")
407             .setCreationTimestamp("creationTimestamp-370203401")
408             .setDescription("description-1724546052")
409             .setEndTime("endTime-1607243192")
410             .setError(Error.newBuilder().build())
411             .setHttpErrorMessage("httpErrorMessage1577303431")
412             .setHttpErrorStatusCode(0)
413             .setId(3355)
414             .setInsertTime("insertTime966165798")
415             .setKind("kind3292052")
416             .setName("name3373707")
417             .setOperationGroupId("operationGroupId1716161683")
418             .setOperationType("operationType91999553")
419             .setProgress(-1001078227)
420             .setRegion("region-934795532")
421             .setSelfLink("selfLink1191800166")
422             .setStartTime("startTime-2129294769")
423             .setStatus(Status.DONE)
424             .setStatusMessage("statusMessage-958704715")
425             .setTargetId(-815576439)
426             .setTargetLink("targetLink486368555")
427             .setUser("user3599307")
428             .addAllWarnings(new ArrayList<Warnings>())
429             .setZone("zone3744684")
430             .build();
431     mockService.addResponse(expectedResponse);
432 
433     String project = "project-6911";
434     String targetSslProxy = "targetSslProxy-5881";
435     TargetSslProxiesSetCertificateMapRequest targetSslProxiesSetCertificateMapRequestResource =
436         TargetSslProxiesSetCertificateMapRequest.newBuilder().build();
437 
438     Operation actualResponse =
439         client
440             .setCertificateMapAsync(
441                 project, targetSslProxy, targetSslProxiesSetCertificateMapRequestResource)
442             .get();
443     Assert.assertEquals(expectedResponse, actualResponse);
444 
445     List<String> actualRequests = mockService.getRequestPaths();
446     Assert.assertEquals(1, actualRequests.size());
447 
448     String apiClientHeaderKey =
449         mockService
450             .getRequestHeaders()
451             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
452             .iterator()
453             .next();
454     Assert.assertTrue(
455         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
456             .matcher(apiClientHeaderKey)
457             .matches());
458   }
459 
460   @Test
setCertificateMapExceptionTest()461   public void setCertificateMapExceptionTest() throws Exception {
462     ApiException exception =
463         ApiExceptionFactory.createException(
464             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
465     mockService.addException(exception);
466 
467     try {
468       String project = "project-6911";
469       String targetSslProxy = "targetSslProxy-5881";
470       TargetSslProxiesSetCertificateMapRequest targetSslProxiesSetCertificateMapRequestResource =
471           TargetSslProxiesSetCertificateMapRequest.newBuilder().build();
472       client
473           .setCertificateMapAsync(
474               project, targetSslProxy, targetSslProxiesSetCertificateMapRequestResource)
475           .get();
476       Assert.fail("No exception raised");
477     } catch (ExecutionException e) {
478     }
479   }
480 
481   @Test
setProxyHeaderTest()482   public void setProxyHeaderTest() throws Exception {
483     Operation expectedResponse =
484         Operation.newBuilder()
485             .setClientOperationId("clientOperationId-1230366697")
486             .setCreationTimestamp("creationTimestamp-370203401")
487             .setDescription("description-1724546052")
488             .setEndTime("endTime-1607243192")
489             .setError(Error.newBuilder().build())
490             .setHttpErrorMessage("httpErrorMessage1577303431")
491             .setHttpErrorStatusCode(0)
492             .setId(3355)
493             .setInsertTime("insertTime966165798")
494             .setKind("kind3292052")
495             .setName("name3373707")
496             .setOperationGroupId("operationGroupId1716161683")
497             .setOperationType("operationType91999553")
498             .setProgress(-1001078227)
499             .setRegion("region-934795532")
500             .setSelfLink("selfLink1191800166")
501             .setStartTime("startTime-2129294769")
502             .setStatus(Status.DONE)
503             .setStatusMessage("statusMessage-958704715")
504             .setTargetId(-815576439)
505             .setTargetLink("targetLink486368555")
506             .setUser("user3599307")
507             .addAllWarnings(new ArrayList<Warnings>())
508             .setZone("zone3744684")
509             .build();
510     mockService.addResponse(expectedResponse);
511 
512     String project = "project-6911";
513     String targetSslProxy = "targetSslProxy-5881";
514     TargetSslProxiesSetProxyHeaderRequest targetSslProxiesSetProxyHeaderRequestResource =
515         TargetSslProxiesSetProxyHeaderRequest.newBuilder().build();
516 
517     Operation actualResponse =
518         client
519             .setProxyHeaderAsync(
520                 project, targetSslProxy, targetSslProxiesSetProxyHeaderRequestResource)
521             .get();
522     Assert.assertEquals(expectedResponse, actualResponse);
523 
524     List<String> actualRequests = mockService.getRequestPaths();
525     Assert.assertEquals(1, actualRequests.size());
526 
527     String apiClientHeaderKey =
528         mockService
529             .getRequestHeaders()
530             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
531             .iterator()
532             .next();
533     Assert.assertTrue(
534         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
535             .matcher(apiClientHeaderKey)
536             .matches());
537   }
538 
539   @Test
setProxyHeaderExceptionTest()540   public void setProxyHeaderExceptionTest() throws Exception {
541     ApiException exception =
542         ApiExceptionFactory.createException(
543             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
544     mockService.addException(exception);
545 
546     try {
547       String project = "project-6911";
548       String targetSslProxy = "targetSslProxy-5881";
549       TargetSslProxiesSetProxyHeaderRequest targetSslProxiesSetProxyHeaderRequestResource =
550           TargetSslProxiesSetProxyHeaderRequest.newBuilder().build();
551       client
552           .setProxyHeaderAsync(
553               project, targetSslProxy, targetSslProxiesSetProxyHeaderRequestResource)
554           .get();
555       Assert.fail("No exception raised");
556     } catch (ExecutionException e) {
557     }
558   }
559 
560   @Test
setSslCertificatesTest()561   public void setSslCertificatesTest() throws Exception {
562     Operation expectedResponse =
563         Operation.newBuilder()
564             .setClientOperationId("clientOperationId-1230366697")
565             .setCreationTimestamp("creationTimestamp-370203401")
566             .setDescription("description-1724546052")
567             .setEndTime("endTime-1607243192")
568             .setError(Error.newBuilder().build())
569             .setHttpErrorMessage("httpErrorMessage1577303431")
570             .setHttpErrorStatusCode(0)
571             .setId(3355)
572             .setInsertTime("insertTime966165798")
573             .setKind("kind3292052")
574             .setName("name3373707")
575             .setOperationGroupId("operationGroupId1716161683")
576             .setOperationType("operationType91999553")
577             .setProgress(-1001078227)
578             .setRegion("region-934795532")
579             .setSelfLink("selfLink1191800166")
580             .setStartTime("startTime-2129294769")
581             .setStatus(Status.DONE)
582             .setStatusMessage("statusMessage-958704715")
583             .setTargetId(-815576439)
584             .setTargetLink("targetLink486368555")
585             .setUser("user3599307")
586             .addAllWarnings(new ArrayList<Warnings>())
587             .setZone("zone3744684")
588             .build();
589     mockService.addResponse(expectedResponse);
590 
591     String project = "project-6911";
592     String targetSslProxy = "targetSslProxy-5881";
593     TargetSslProxiesSetSslCertificatesRequest targetSslProxiesSetSslCertificatesRequestResource =
594         TargetSslProxiesSetSslCertificatesRequest.newBuilder().build();
595 
596     Operation actualResponse =
597         client
598             .setSslCertificatesAsync(
599                 project, targetSslProxy, targetSslProxiesSetSslCertificatesRequestResource)
600             .get();
601     Assert.assertEquals(expectedResponse, actualResponse);
602 
603     List<String> actualRequests = mockService.getRequestPaths();
604     Assert.assertEquals(1, actualRequests.size());
605 
606     String apiClientHeaderKey =
607         mockService
608             .getRequestHeaders()
609             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
610             .iterator()
611             .next();
612     Assert.assertTrue(
613         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
614             .matcher(apiClientHeaderKey)
615             .matches());
616   }
617 
618   @Test
setSslCertificatesExceptionTest()619   public void setSslCertificatesExceptionTest() throws Exception {
620     ApiException exception =
621         ApiExceptionFactory.createException(
622             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
623     mockService.addException(exception);
624 
625     try {
626       String project = "project-6911";
627       String targetSslProxy = "targetSslProxy-5881";
628       TargetSslProxiesSetSslCertificatesRequest targetSslProxiesSetSslCertificatesRequestResource =
629           TargetSslProxiesSetSslCertificatesRequest.newBuilder().build();
630       client
631           .setSslCertificatesAsync(
632               project, targetSslProxy, targetSslProxiesSetSslCertificatesRequestResource)
633           .get();
634       Assert.fail("No exception raised");
635     } catch (ExecutionException e) {
636     }
637   }
638 
639   @Test
setSslPolicyTest()640   public void setSslPolicyTest() throws Exception {
641     Operation expectedResponse =
642         Operation.newBuilder()
643             .setClientOperationId("clientOperationId-1230366697")
644             .setCreationTimestamp("creationTimestamp-370203401")
645             .setDescription("description-1724546052")
646             .setEndTime("endTime-1607243192")
647             .setError(Error.newBuilder().build())
648             .setHttpErrorMessage("httpErrorMessage1577303431")
649             .setHttpErrorStatusCode(0)
650             .setId(3355)
651             .setInsertTime("insertTime966165798")
652             .setKind("kind3292052")
653             .setName("name3373707")
654             .setOperationGroupId("operationGroupId1716161683")
655             .setOperationType("operationType91999553")
656             .setProgress(-1001078227)
657             .setRegion("region-934795532")
658             .setSelfLink("selfLink1191800166")
659             .setStartTime("startTime-2129294769")
660             .setStatus(Status.DONE)
661             .setStatusMessage("statusMessage-958704715")
662             .setTargetId(-815576439)
663             .setTargetLink("targetLink486368555")
664             .setUser("user3599307")
665             .addAllWarnings(new ArrayList<Warnings>())
666             .setZone("zone3744684")
667             .build();
668     mockService.addResponse(expectedResponse);
669 
670     String project = "project-6911";
671     String targetSslProxy = "targetSslProxy-5881";
672     SslPolicyReference sslPolicyReferenceResource = SslPolicyReference.newBuilder().build();
673 
674     Operation actualResponse =
675         client.setSslPolicyAsync(project, targetSslProxy, sslPolicyReferenceResource).get();
676     Assert.assertEquals(expectedResponse, actualResponse);
677 
678     List<String> actualRequests = mockService.getRequestPaths();
679     Assert.assertEquals(1, actualRequests.size());
680 
681     String apiClientHeaderKey =
682         mockService
683             .getRequestHeaders()
684             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
685             .iterator()
686             .next();
687     Assert.assertTrue(
688         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
689             .matcher(apiClientHeaderKey)
690             .matches());
691   }
692 
693   @Test
setSslPolicyExceptionTest()694   public void setSslPolicyExceptionTest() throws Exception {
695     ApiException exception =
696         ApiExceptionFactory.createException(
697             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
698     mockService.addException(exception);
699 
700     try {
701       String project = "project-6911";
702       String targetSslProxy = "targetSslProxy-5881";
703       SslPolicyReference sslPolicyReferenceResource = SslPolicyReference.newBuilder().build();
704       client.setSslPolicyAsync(project, targetSslProxy, sslPolicyReferenceResource).get();
705       Assert.fail("No exception raised");
706     } catch (ExecutionException e) {
707     }
708   }
709 }
710