• 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.analytics.admin.v1beta;
18 
19 import static com.google.analytics.admin.v1beta.AnalyticsAdminServiceClient.ListAccountSummariesPagedResponse;
20 import static com.google.analytics.admin.v1beta.AnalyticsAdminServiceClient.ListAccountsPagedResponse;
21 import static com.google.analytics.admin.v1beta.AnalyticsAdminServiceClient.ListConversionEventsPagedResponse;
22 import static com.google.analytics.admin.v1beta.AnalyticsAdminServiceClient.ListCustomDimensionsPagedResponse;
23 import static com.google.analytics.admin.v1beta.AnalyticsAdminServiceClient.ListCustomMetricsPagedResponse;
24 import static com.google.analytics.admin.v1beta.AnalyticsAdminServiceClient.ListDataStreamsPagedResponse;
25 import static com.google.analytics.admin.v1beta.AnalyticsAdminServiceClient.ListFirebaseLinksPagedResponse;
26 import static com.google.analytics.admin.v1beta.AnalyticsAdminServiceClient.ListGoogleAdsLinksPagedResponse;
27 import static com.google.analytics.admin.v1beta.AnalyticsAdminServiceClient.ListMeasurementProtocolSecretsPagedResponse;
28 import static com.google.analytics.admin.v1beta.AnalyticsAdminServiceClient.ListPropertiesPagedResponse;
29 import static com.google.analytics.admin.v1beta.AnalyticsAdminServiceClient.SearchChangeHistoryEventsPagedResponse;
30 
31 import com.google.analytics.admin.v1beta.stub.HttpJsonAnalyticsAdminServiceStub;
32 import com.google.api.gax.core.NoCredentialsProvider;
33 import com.google.api.gax.httpjson.GaxHttpJsonProperties;
34 import com.google.api.gax.httpjson.testing.MockHttpService;
35 import com.google.api.gax.rpc.ApiClientHeaderProvider;
36 import com.google.api.gax.rpc.ApiException;
37 import com.google.api.gax.rpc.ApiExceptionFactory;
38 import com.google.api.gax.rpc.InvalidArgumentException;
39 import com.google.api.gax.rpc.StatusCode;
40 import com.google.api.gax.rpc.testing.FakeStatusCode;
41 import com.google.common.collect.Lists;
42 import com.google.protobuf.BoolValue;
43 import com.google.protobuf.Empty;
44 import com.google.protobuf.FieldMask;
45 import com.google.protobuf.Timestamp;
46 import java.io.IOException;
47 import java.util.ArrayList;
48 import java.util.Arrays;
49 import java.util.List;
50 import javax.annotation.Generated;
51 import org.junit.After;
52 import org.junit.AfterClass;
53 import org.junit.Assert;
54 import org.junit.Before;
55 import org.junit.BeforeClass;
56 import org.junit.Test;
57 
58 @Generated("by gapic-generator-java")
59 public class AnalyticsAdminServiceClientHttpJsonTest {
60   private static MockHttpService mockService;
61   private static AnalyticsAdminServiceClient client;
62 
63   @BeforeClass
startStaticServer()64   public static void startStaticServer() throws IOException {
65     mockService =
66         new MockHttpService(
67             HttpJsonAnalyticsAdminServiceStub.getMethodDescriptors(),
68             AnalyticsAdminServiceSettings.getDefaultEndpoint());
69     AnalyticsAdminServiceSettings settings =
70         AnalyticsAdminServiceSettings.newHttpJsonBuilder()
71             .setTransportChannelProvider(
72                 AnalyticsAdminServiceSettings.defaultHttpJsonTransportProviderBuilder()
73                     .setHttpTransport(mockService)
74                     .build())
75             .setCredentialsProvider(NoCredentialsProvider.create())
76             .build();
77     client = AnalyticsAdminServiceClient.create(settings);
78   }
79 
80   @AfterClass
stopServer()81   public static void stopServer() {
82     client.close();
83   }
84 
85   @Before
setUp()86   public void setUp() {}
87 
88   @After
tearDown()89   public void tearDown() throws Exception {
90     mockService.reset();
91   }
92 
93   @Test
getAccountTest()94   public void getAccountTest() throws Exception {
95     Account expectedResponse =
96         Account.newBuilder()
97             .setName(AccountName.of("[ACCOUNT]").toString())
98             .setCreateTime(Timestamp.newBuilder().build())
99             .setUpdateTime(Timestamp.newBuilder().build())
100             .setDisplayName("displayName1714148973")
101             .setRegionCode("regionCode-1991004415")
102             .setDeleted(true)
103             .build();
104     mockService.addResponse(expectedResponse);
105 
106     AccountName name = AccountName.of("[ACCOUNT]");
107 
108     Account actualResponse = client.getAccount(name);
109     Assert.assertEquals(expectedResponse, actualResponse);
110 
111     List<String> actualRequests = mockService.getRequestPaths();
112     Assert.assertEquals(1, actualRequests.size());
113 
114     String apiClientHeaderKey =
115         mockService
116             .getRequestHeaders()
117             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
118             .iterator()
119             .next();
120     Assert.assertTrue(
121         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
122             .matcher(apiClientHeaderKey)
123             .matches());
124   }
125 
126   @Test
getAccountExceptionTest()127   public void getAccountExceptionTest() throws Exception {
128     ApiException exception =
129         ApiExceptionFactory.createException(
130             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
131     mockService.addException(exception);
132 
133     try {
134       AccountName name = AccountName.of("[ACCOUNT]");
135       client.getAccount(name);
136       Assert.fail("No exception raised");
137     } catch (InvalidArgumentException e) {
138       // Expected exception.
139     }
140   }
141 
142   @Test
getAccountTest2()143   public void getAccountTest2() throws Exception {
144     Account expectedResponse =
145         Account.newBuilder()
146             .setName(AccountName.of("[ACCOUNT]").toString())
147             .setCreateTime(Timestamp.newBuilder().build())
148             .setUpdateTime(Timestamp.newBuilder().build())
149             .setDisplayName("displayName1714148973")
150             .setRegionCode("regionCode-1991004415")
151             .setDeleted(true)
152             .build();
153     mockService.addResponse(expectedResponse);
154 
155     String name = "accounts/account-3500";
156 
157     Account actualResponse = client.getAccount(name);
158     Assert.assertEquals(expectedResponse, actualResponse);
159 
160     List<String> actualRequests = mockService.getRequestPaths();
161     Assert.assertEquals(1, actualRequests.size());
162 
163     String apiClientHeaderKey =
164         mockService
165             .getRequestHeaders()
166             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
167             .iterator()
168             .next();
169     Assert.assertTrue(
170         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
171             .matcher(apiClientHeaderKey)
172             .matches());
173   }
174 
175   @Test
getAccountExceptionTest2()176   public void getAccountExceptionTest2() throws Exception {
177     ApiException exception =
178         ApiExceptionFactory.createException(
179             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
180     mockService.addException(exception);
181 
182     try {
183       String name = "accounts/account-3500";
184       client.getAccount(name);
185       Assert.fail("No exception raised");
186     } catch (InvalidArgumentException e) {
187       // Expected exception.
188     }
189   }
190 
191   @Test
listAccountsTest()192   public void listAccountsTest() throws Exception {
193     Account responsesElement = Account.newBuilder().build();
194     ListAccountsResponse expectedResponse =
195         ListAccountsResponse.newBuilder()
196             .setNextPageToken("")
197             .addAllAccounts(Arrays.asList(responsesElement))
198             .build();
199     mockService.addResponse(expectedResponse);
200 
201     ListAccountsRequest request =
202         ListAccountsRequest.newBuilder()
203             .setPageSize(883849137)
204             .setPageToken("pageToken873572522")
205             .setShowDeleted(true)
206             .build();
207 
208     ListAccountsPagedResponse pagedListResponse = client.listAccounts(request);
209 
210     List<Account> resources = Lists.newArrayList(pagedListResponse.iterateAll());
211 
212     Assert.assertEquals(1, resources.size());
213     Assert.assertEquals(expectedResponse.getAccountsList().get(0), resources.get(0));
214 
215     List<String> actualRequests = mockService.getRequestPaths();
216     Assert.assertEquals(1, actualRequests.size());
217 
218     String apiClientHeaderKey =
219         mockService
220             .getRequestHeaders()
221             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
222             .iterator()
223             .next();
224     Assert.assertTrue(
225         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
226             .matcher(apiClientHeaderKey)
227             .matches());
228   }
229 
230   @Test
listAccountsExceptionTest()231   public void listAccountsExceptionTest() throws Exception {
232     ApiException exception =
233         ApiExceptionFactory.createException(
234             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
235     mockService.addException(exception);
236 
237     try {
238       ListAccountsRequest request =
239           ListAccountsRequest.newBuilder()
240               .setPageSize(883849137)
241               .setPageToken("pageToken873572522")
242               .setShowDeleted(true)
243               .build();
244       client.listAccounts(request);
245       Assert.fail("No exception raised");
246     } catch (InvalidArgumentException e) {
247       // Expected exception.
248     }
249   }
250 
251   @Test
deleteAccountTest()252   public void deleteAccountTest() throws Exception {
253     Empty expectedResponse = Empty.newBuilder().build();
254     mockService.addResponse(expectedResponse);
255 
256     AccountName name = AccountName.of("[ACCOUNT]");
257 
258     client.deleteAccount(name);
259 
260     List<String> actualRequests = mockService.getRequestPaths();
261     Assert.assertEquals(1, actualRequests.size());
262 
263     String apiClientHeaderKey =
264         mockService
265             .getRequestHeaders()
266             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
267             .iterator()
268             .next();
269     Assert.assertTrue(
270         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
271             .matcher(apiClientHeaderKey)
272             .matches());
273   }
274 
275   @Test
deleteAccountExceptionTest()276   public void deleteAccountExceptionTest() throws Exception {
277     ApiException exception =
278         ApiExceptionFactory.createException(
279             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
280     mockService.addException(exception);
281 
282     try {
283       AccountName name = AccountName.of("[ACCOUNT]");
284       client.deleteAccount(name);
285       Assert.fail("No exception raised");
286     } catch (InvalidArgumentException e) {
287       // Expected exception.
288     }
289   }
290 
291   @Test
deleteAccountTest2()292   public void deleteAccountTest2() throws Exception {
293     Empty expectedResponse = Empty.newBuilder().build();
294     mockService.addResponse(expectedResponse);
295 
296     String name = "accounts/account-3500";
297 
298     client.deleteAccount(name);
299 
300     List<String> actualRequests = mockService.getRequestPaths();
301     Assert.assertEquals(1, actualRequests.size());
302 
303     String apiClientHeaderKey =
304         mockService
305             .getRequestHeaders()
306             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
307             .iterator()
308             .next();
309     Assert.assertTrue(
310         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
311             .matcher(apiClientHeaderKey)
312             .matches());
313   }
314 
315   @Test
deleteAccountExceptionTest2()316   public void deleteAccountExceptionTest2() throws Exception {
317     ApiException exception =
318         ApiExceptionFactory.createException(
319             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
320     mockService.addException(exception);
321 
322     try {
323       String name = "accounts/account-3500";
324       client.deleteAccount(name);
325       Assert.fail("No exception raised");
326     } catch (InvalidArgumentException e) {
327       // Expected exception.
328     }
329   }
330 
331   @Test
updateAccountTest()332   public void updateAccountTest() throws Exception {
333     Account expectedResponse =
334         Account.newBuilder()
335             .setName(AccountName.of("[ACCOUNT]").toString())
336             .setCreateTime(Timestamp.newBuilder().build())
337             .setUpdateTime(Timestamp.newBuilder().build())
338             .setDisplayName("displayName1714148973")
339             .setRegionCode("regionCode-1991004415")
340             .setDeleted(true)
341             .build();
342     mockService.addResponse(expectedResponse);
343 
344     Account account =
345         Account.newBuilder()
346             .setName(AccountName.of("[ACCOUNT]").toString())
347             .setCreateTime(Timestamp.newBuilder().build())
348             .setUpdateTime(Timestamp.newBuilder().build())
349             .setDisplayName("displayName1714148973")
350             .setRegionCode("regionCode-1991004415")
351             .setDeleted(true)
352             .build();
353     FieldMask updateMask = FieldMask.newBuilder().build();
354 
355     Account actualResponse = client.updateAccount(account, updateMask);
356     Assert.assertEquals(expectedResponse, actualResponse);
357 
358     List<String> actualRequests = mockService.getRequestPaths();
359     Assert.assertEquals(1, actualRequests.size());
360 
361     String apiClientHeaderKey =
362         mockService
363             .getRequestHeaders()
364             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
365             .iterator()
366             .next();
367     Assert.assertTrue(
368         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
369             .matcher(apiClientHeaderKey)
370             .matches());
371   }
372 
373   @Test
updateAccountExceptionTest()374   public void updateAccountExceptionTest() throws Exception {
375     ApiException exception =
376         ApiExceptionFactory.createException(
377             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
378     mockService.addException(exception);
379 
380     try {
381       Account account =
382           Account.newBuilder()
383               .setName(AccountName.of("[ACCOUNT]").toString())
384               .setCreateTime(Timestamp.newBuilder().build())
385               .setUpdateTime(Timestamp.newBuilder().build())
386               .setDisplayName("displayName1714148973")
387               .setRegionCode("regionCode-1991004415")
388               .setDeleted(true)
389               .build();
390       FieldMask updateMask = FieldMask.newBuilder().build();
391       client.updateAccount(account, updateMask);
392       Assert.fail("No exception raised");
393     } catch (InvalidArgumentException e) {
394       // Expected exception.
395     }
396   }
397 
398   @Test
provisionAccountTicketTest()399   public void provisionAccountTicketTest() throws Exception {
400     ProvisionAccountTicketResponse expectedResponse =
401         ProvisionAccountTicketResponse.newBuilder()
402             .setAccountTicketId("accountTicketId-1576709484")
403             .build();
404     mockService.addResponse(expectedResponse);
405 
406     ProvisionAccountTicketRequest request =
407         ProvisionAccountTicketRequest.newBuilder()
408             .setAccount(Account.newBuilder().build())
409             .setRedirectUri("redirectUri1970337776")
410             .build();
411 
412     ProvisionAccountTicketResponse actualResponse = client.provisionAccountTicket(request);
413     Assert.assertEquals(expectedResponse, actualResponse);
414 
415     List<String> actualRequests = mockService.getRequestPaths();
416     Assert.assertEquals(1, actualRequests.size());
417 
418     String apiClientHeaderKey =
419         mockService
420             .getRequestHeaders()
421             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
422             .iterator()
423             .next();
424     Assert.assertTrue(
425         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
426             .matcher(apiClientHeaderKey)
427             .matches());
428   }
429 
430   @Test
provisionAccountTicketExceptionTest()431   public void provisionAccountTicketExceptionTest() throws Exception {
432     ApiException exception =
433         ApiExceptionFactory.createException(
434             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
435     mockService.addException(exception);
436 
437     try {
438       ProvisionAccountTicketRequest request =
439           ProvisionAccountTicketRequest.newBuilder()
440               .setAccount(Account.newBuilder().build())
441               .setRedirectUri("redirectUri1970337776")
442               .build();
443       client.provisionAccountTicket(request);
444       Assert.fail("No exception raised");
445     } catch (InvalidArgumentException e) {
446       // Expected exception.
447     }
448   }
449 
450   @Test
listAccountSummariesTest()451   public void listAccountSummariesTest() throws Exception {
452     AccountSummary responsesElement = AccountSummary.newBuilder().build();
453     ListAccountSummariesResponse expectedResponse =
454         ListAccountSummariesResponse.newBuilder()
455             .setNextPageToken("")
456             .addAllAccountSummaries(Arrays.asList(responsesElement))
457             .build();
458     mockService.addResponse(expectedResponse);
459 
460     ListAccountSummariesRequest request =
461         ListAccountSummariesRequest.newBuilder()
462             .setPageSize(883849137)
463             .setPageToken("pageToken873572522")
464             .build();
465 
466     ListAccountSummariesPagedResponse pagedListResponse = client.listAccountSummaries(request);
467 
468     List<AccountSummary> resources = Lists.newArrayList(pagedListResponse.iterateAll());
469 
470     Assert.assertEquals(1, resources.size());
471     Assert.assertEquals(expectedResponse.getAccountSummariesList().get(0), resources.get(0));
472 
473     List<String> actualRequests = mockService.getRequestPaths();
474     Assert.assertEquals(1, actualRequests.size());
475 
476     String apiClientHeaderKey =
477         mockService
478             .getRequestHeaders()
479             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
480             .iterator()
481             .next();
482     Assert.assertTrue(
483         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
484             .matcher(apiClientHeaderKey)
485             .matches());
486   }
487 
488   @Test
listAccountSummariesExceptionTest()489   public void listAccountSummariesExceptionTest() throws Exception {
490     ApiException exception =
491         ApiExceptionFactory.createException(
492             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
493     mockService.addException(exception);
494 
495     try {
496       ListAccountSummariesRequest request =
497           ListAccountSummariesRequest.newBuilder()
498               .setPageSize(883849137)
499               .setPageToken("pageToken873572522")
500               .build();
501       client.listAccountSummaries(request);
502       Assert.fail("No exception raised");
503     } catch (InvalidArgumentException e) {
504       // Expected exception.
505     }
506   }
507 
508   @Test
getPropertyTest()509   public void getPropertyTest() throws Exception {
510     Property expectedResponse =
511         Property.newBuilder()
512             .setName(PropertyName.of("[PROPERTY]").toString())
513             .setPropertyType(PropertyType.forNumber(0))
514             .setCreateTime(Timestamp.newBuilder().build())
515             .setUpdateTime(Timestamp.newBuilder().build())
516             .setParent("parent-995424086")
517             .setDisplayName("displayName1714148973")
518             .setIndustryCategory(IndustryCategory.forNumber(0))
519             .setTimeZone("timeZone-2077180903")
520             .setCurrencyCode("currencyCode1004773790")
521             .setServiceLevel(ServiceLevel.forNumber(0))
522             .setDeleteTime(Timestamp.newBuilder().build())
523             .setExpireTime(Timestamp.newBuilder().build())
524             .setAccount(AccountName.of("[ACCOUNT]").toString())
525             .build();
526     mockService.addResponse(expectedResponse);
527 
528     PropertyName name = PropertyName.of("[PROPERTY]");
529 
530     Property actualResponse = client.getProperty(name);
531     Assert.assertEquals(expectedResponse, actualResponse);
532 
533     List<String> actualRequests = mockService.getRequestPaths();
534     Assert.assertEquals(1, actualRequests.size());
535 
536     String apiClientHeaderKey =
537         mockService
538             .getRequestHeaders()
539             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
540             .iterator()
541             .next();
542     Assert.assertTrue(
543         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
544             .matcher(apiClientHeaderKey)
545             .matches());
546   }
547 
548   @Test
getPropertyExceptionTest()549   public void getPropertyExceptionTest() throws Exception {
550     ApiException exception =
551         ApiExceptionFactory.createException(
552             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
553     mockService.addException(exception);
554 
555     try {
556       PropertyName name = PropertyName.of("[PROPERTY]");
557       client.getProperty(name);
558       Assert.fail("No exception raised");
559     } catch (InvalidArgumentException e) {
560       // Expected exception.
561     }
562   }
563 
564   @Test
getPropertyTest2()565   public void getPropertyTest2() throws Exception {
566     Property expectedResponse =
567         Property.newBuilder()
568             .setName(PropertyName.of("[PROPERTY]").toString())
569             .setPropertyType(PropertyType.forNumber(0))
570             .setCreateTime(Timestamp.newBuilder().build())
571             .setUpdateTime(Timestamp.newBuilder().build())
572             .setParent("parent-995424086")
573             .setDisplayName("displayName1714148973")
574             .setIndustryCategory(IndustryCategory.forNumber(0))
575             .setTimeZone("timeZone-2077180903")
576             .setCurrencyCode("currencyCode1004773790")
577             .setServiceLevel(ServiceLevel.forNumber(0))
578             .setDeleteTime(Timestamp.newBuilder().build())
579             .setExpireTime(Timestamp.newBuilder().build())
580             .setAccount(AccountName.of("[ACCOUNT]").toString())
581             .build();
582     mockService.addResponse(expectedResponse);
583 
584     String name = "properties/propertie-7337";
585 
586     Property actualResponse = client.getProperty(name);
587     Assert.assertEquals(expectedResponse, actualResponse);
588 
589     List<String> actualRequests = mockService.getRequestPaths();
590     Assert.assertEquals(1, actualRequests.size());
591 
592     String apiClientHeaderKey =
593         mockService
594             .getRequestHeaders()
595             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
596             .iterator()
597             .next();
598     Assert.assertTrue(
599         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
600             .matcher(apiClientHeaderKey)
601             .matches());
602   }
603 
604   @Test
getPropertyExceptionTest2()605   public void getPropertyExceptionTest2() throws Exception {
606     ApiException exception =
607         ApiExceptionFactory.createException(
608             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
609     mockService.addException(exception);
610 
611     try {
612       String name = "properties/propertie-7337";
613       client.getProperty(name);
614       Assert.fail("No exception raised");
615     } catch (InvalidArgumentException e) {
616       // Expected exception.
617     }
618   }
619 
620   @Test
listPropertiesTest()621   public void listPropertiesTest() throws Exception {
622     Property responsesElement = Property.newBuilder().build();
623     ListPropertiesResponse expectedResponse =
624         ListPropertiesResponse.newBuilder()
625             .setNextPageToken("")
626             .addAllProperties(Arrays.asList(responsesElement))
627             .build();
628     mockService.addResponse(expectedResponse);
629 
630     ListPropertiesRequest request =
631         ListPropertiesRequest.newBuilder()
632             .setFilter("filter-1274492040")
633             .setPageSize(883849137)
634             .setPageToken("pageToken873572522")
635             .setShowDeleted(true)
636             .build();
637 
638     ListPropertiesPagedResponse pagedListResponse = client.listProperties(request);
639 
640     List<Property> resources = Lists.newArrayList(pagedListResponse.iterateAll());
641 
642     Assert.assertEquals(1, resources.size());
643     Assert.assertEquals(expectedResponse.getPropertiesList().get(0), resources.get(0));
644 
645     List<String> actualRequests = mockService.getRequestPaths();
646     Assert.assertEquals(1, actualRequests.size());
647 
648     String apiClientHeaderKey =
649         mockService
650             .getRequestHeaders()
651             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
652             .iterator()
653             .next();
654     Assert.assertTrue(
655         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
656             .matcher(apiClientHeaderKey)
657             .matches());
658   }
659 
660   @Test
listPropertiesExceptionTest()661   public void listPropertiesExceptionTest() throws Exception {
662     ApiException exception =
663         ApiExceptionFactory.createException(
664             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
665     mockService.addException(exception);
666 
667     try {
668       ListPropertiesRequest request =
669           ListPropertiesRequest.newBuilder()
670               .setFilter("filter-1274492040")
671               .setPageSize(883849137)
672               .setPageToken("pageToken873572522")
673               .setShowDeleted(true)
674               .build();
675       client.listProperties(request);
676       Assert.fail("No exception raised");
677     } catch (InvalidArgumentException e) {
678       // Expected exception.
679     }
680   }
681 
682   @Test
createPropertyTest()683   public void createPropertyTest() throws Exception {
684     Property expectedResponse =
685         Property.newBuilder()
686             .setName(PropertyName.of("[PROPERTY]").toString())
687             .setPropertyType(PropertyType.forNumber(0))
688             .setCreateTime(Timestamp.newBuilder().build())
689             .setUpdateTime(Timestamp.newBuilder().build())
690             .setParent("parent-995424086")
691             .setDisplayName("displayName1714148973")
692             .setIndustryCategory(IndustryCategory.forNumber(0))
693             .setTimeZone("timeZone-2077180903")
694             .setCurrencyCode("currencyCode1004773790")
695             .setServiceLevel(ServiceLevel.forNumber(0))
696             .setDeleteTime(Timestamp.newBuilder().build())
697             .setExpireTime(Timestamp.newBuilder().build())
698             .setAccount(AccountName.of("[ACCOUNT]").toString())
699             .build();
700     mockService.addResponse(expectedResponse);
701 
702     Property property = Property.newBuilder().build();
703 
704     Property actualResponse = client.createProperty(property);
705     Assert.assertEquals(expectedResponse, actualResponse);
706 
707     List<String> actualRequests = mockService.getRequestPaths();
708     Assert.assertEquals(1, actualRequests.size());
709 
710     String apiClientHeaderKey =
711         mockService
712             .getRequestHeaders()
713             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
714             .iterator()
715             .next();
716     Assert.assertTrue(
717         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
718             .matcher(apiClientHeaderKey)
719             .matches());
720   }
721 
722   @Test
createPropertyExceptionTest()723   public void createPropertyExceptionTest() throws Exception {
724     ApiException exception =
725         ApiExceptionFactory.createException(
726             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
727     mockService.addException(exception);
728 
729     try {
730       Property property = Property.newBuilder().build();
731       client.createProperty(property);
732       Assert.fail("No exception raised");
733     } catch (InvalidArgumentException e) {
734       // Expected exception.
735     }
736   }
737 
738   @Test
deletePropertyTest()739   public void deletePropertyTest() throws Exception {
740     Property expectedResponse =
741         Property.newBuilder()
742             .setName(PropertyName.of("[PROPERTY]").toString())
743             .setPropertyType(PropertyType.forNumber(0))
744             .setCreateTime(Timestamp.newBuilder().build())
745             .setUpdateTime(Timestamp.newBuilder().build())
746             .setParent("parent-995424086")
747             .setDisplayName("displayName1714148973")
748             .setIndustryCategory(IndustryCategory.forNumber(0))
749             .setTimeZone("timeZone-2077180903")
750             .setCurrencyCode("currencyCode1004773790")
751             .setServiceLevel(ServiceLevel.forNumber(0))
752             .setDeleteTime(Timestamp.newBuilder().build())
753             .setExpireTime(Timestamp.newBuilder().build())
754             .setAccount(AccountName.of("[ACCOUNT]").toString())
755             .build();
756     mockService.addResponse(expectedResponse);
757 
758     PropertyName name = PropertyName.of("[PROPERTY]");
759 
760     Property actualResponse = client.deleteProperty(name);
761     Assert.assertEquals(expectedResponse, actualResponse);
762 
763     List<String> actualRequests = mockService.getRequestPaths();
764     Assert.assertEquals(1, actualRequests.size());
765 
766     String apiClientHeaderKey =
767         mockService
768             .getRequestHeaders()
769             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
770             .iterator()
771             .next();
772     Assert.assertTrue(
773         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
774             .matcher(apiClientHeaderKey)
775             .matches());
776   }
777 
778   @Test
deletePropertyExceptionTest()779   public void deletePropertyExceptionTest() throws Exception {
780     ApiException exception =
781         ApiExceptionFactory.createException(
782             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
783     mockService.addException(exception);
784 
785     try {
786       PropertyName name = PropertyName.of("[PROPERTY]");
787       client.deleteProperty(name);
788       Assert.fail("No exception raised");
789     } catch (InvalidArgumentException e) {
790       // Expected exception.
791     }
792   }
793 
794   @Test
deletePropertyTest2()795   public void deletePropertyTest2() throws Exception {
796     Property expectedResponse =
797         Property.newBuilder()
798             .setName(PropertyName.of("[PROPERTY]").toString())
799             .setPropertyType(PropertyType.forNumber(0))
800             .setCreateTime(Timestamp.newBuilder().build())
801             .setUpdateTime(Timestamp.newBuilder().build())
802             .setParent("parent-995424086")
803             .setDisplayName("displayName1714148973")
804             .setIndustryCategory(IndustryCategory.forNumber(0))
805             .setTimeZone("timeZone-2077180903")
806             .setCurrencyCode("currencyCode1004773790")
807             .setServiceLevel(ServiceLevel.forNumber(0))
808             .setDeleteTime(Timestamp.newBuilder().build())
809             .setExpireTime(Timestamp.newBuilder().build())
810             .setAccount(AccountName.of("[ACCOUNT]").toString())
811             .build();
812     mockService.addResponse(expectedResponse);
813 
814     String name = "properties/propertie-7337";
815 
816     Property actualResponse = client.deleteProperty(name);
817     Assert.assertEquals(expectedResponse, actualResponse);
818 
819     List<String> actualRequests = mockService.getRequestPaths();
820     Assert.assertEquals(1, actualRequests.size());
821 
822     String apiClientHeaderKey =
823         mockService
824             .getRequestHeaders()
825             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
826             .iterator()
827             .next();
828     Assert.assertTrue(
829         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
830             .matcher(apiClientHeaderKey)
831             .matches());
832   }
833 
834   @Test
deletePropertyExceptionTest2()835   public void deletePropertyExceptionTest2() throws Exception {
836     ApiException exception =
837         ApiExceptionFactory.createException(
838             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
839     mockService.addException(exception);
840 
841     try {
842       String name = "properties/propertie-7337";
843       client.deleteProperty(name);
844       Assert.fail("No exception raised");
845     } catch (InvalidArgumentException e) {
846       // Expected exception.
847     }
848   }
849 
850   @Test
updatePropertyTest()851   public void updatePropertyTest() throws Exception {
852     Property expectedResponse =
853         Property.newBuilder()
854             .setName(PropertyName.of("[PROPERTY]").toString())
855             .setPropertyType(PropertyType.forNumber(0))
856             .setCreateTime(Timestamp.newBuilder().build())
857             .setUpdateTime(Timestamp.newBuilder().build())
858             .setParent("parent-995424086")
859             .setDisplayName("displayName1714148973")
860             .setIndustryCategory(IndustryCategory.forNumber(0))
861             .setTimeZone("timeZone-2077180903")
862             .setCurrencyCode("currencyCode1004773790")
863             .setServiceLevel(ServiceLevel.forNumber(0))
864             .setDeleteTime(Timestamp.newBuilder().build())
865             .setExpireTime(Timestamp.newBuilder().build())
866             .setAccount(AccountName.of("[ACCOUNT]").toString())
867             .build();
868     mockService.addResponse(expectedResponse);
869 
870     Property property =
871         Property.newBuilder()
872             .setName(PropertyName.of("[PROPERTY]").toString())
873             .setPropertyType(PropertyType.forNumber(0))
874             .setCreateTime(Timestamp.newBuilder().build())
875             .setUpdateTime(Timestamp.newBuilder().build())
876             .setParent("parent-995424086")
877             .setDisplayName("displayName1714148973")
878             .setIndustryCategory(IndustryCategory.forNumber(0))
879             .setTimeZone("timeZone-2077180903")
880             .setCurrencyCode("currencyCode1004773790")
881             .setServiceLevel(ServiceLevel.forNumber(0))
882             .setDeleteTime(Timestamp.newBuilder().build())
883             .setExpireTime(Timestamp.newBuilder().build())
884             .setAccount(AccountName.of("[ACCOUNT]").toString())
885             .build();
886     FieldMask updateMask = FieldMask.newBuilder().build();
887 
888     Property actualResponse = client.updateProperty(property, updateMask);
889     Assert.assertEquals(expectedResponse, actualResponse);
890 
891     List<String> actualRequests = mockService.getRequestPaths();
892     Assert.assertEquals(1, actualRequests.size());
893 
894     String apiClientHeaderKey =
895         mockService
896             .getRequestHeaders()
897             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
898             .iterator()
899             .next();
900     Assert.assertTrue(
901         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
902             .matcher(apiClientHeaderKey)
903             .matches());
904   }
905 
906   @Test
updatePropertyExceptionTest()907   public void updatePropertyExceptionTest() throws Exception {
908     ApiException exception =
909         ApiExceptionFactory.createException(
910             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
911     mockService.addException(exception);
912 
913     try {
914       Property property =
915           Property.newBuilder()
916               .setName(PropertyName.of("[PROPERTY]").toString())
917               .setPropertyType(PropertyType.forNumber(0))
918               .setCreateTime(Timestamp.newBuilder().build())
919               .setUpdateTime(Timestamp.newBuilder().build())
920               .setParent("parent-995424086")
921               .setDisplayName("displayName1714148973")
922               .setIndustryCategory(IndustryCategory.forNumber(0))
923               .setTimeZone("timeZone-2077180903")
924               .setCurrencyCode("currencyCode1004773790")
925               .setServiceLevel(ServiceLevel.forNumber(0))
926               .setDeleteTime(Timestamp.newBuilder().build())
927               .setExpireTime(Timestamp.newBuilder().build())
928               .setAccount(AccountName.of("[ACCOUNT]").toString())
929               .build();
930       FieldMask updateMask = FieldMask.newBuilder().build();
931       client.updateProperty(property, updateMask);
932       Assert.fail("No exception raised");
933     } catch (InvalidArgumentException e) {
934       // Expected exception.
935     }
936   }
937 
938   @Test
createFirebaseLinkTest()939   public void createFirebaseLinkTest() throws Exception {
940     FirebaseLink expectedResponse =
941         FirebaseLink.newBuilder()
942             .setName(FirebaseLinkName.of("[PROPERTY]", "[FIREBASE_LINK]").toString())
943             .setProject("project-309310695")
944             .setCreateTime(Timestamp.newBuilder().build())
945             .build();
946     mockService.addResponse(expectedResponse);
947 
948     PropertyName parent = PropertyName.of("[PROPERTY]");
949     FirebaseLink firebaseLink = FirebaseLink.newBuilder().build();
950 
951     FirebaseLink actualResponse = client.createFirebaseLink(parent, firebaseLink);
952     Assert.assertEquals(expectedResponse, actualResponse);
953 
954     List<String> actualRequests = mockService.getRequestPaths();
955     Assert.assertEquals(1, actualRequests.size());
956 
957     String apiClientHeaderKey =
958         mockService
959             .getRequestHeaders()
960             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
961             .iterator()
962             .next();
963     Assert.assertTrue(
964         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
965             .matcher(apiClientHeaderKey)
966             .matches());
967   }
968 
969   @Test
createFirebaseLinkExceptionTest()970   public void createFirebaseLinkExceptionTest() throws Exception {
971     ApiException exception =
972         ApiExceptionFactory.createException(
973             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
974     mockService.addException(exception);
975 
976     try {
977       PropertyName parent = PropertyName.of("[PROPERTY]");
978       FirebaseLink firebaseLink = FirebaseLink.newBuilder().build();
979       client.createFirebaseLink(parent, firebaseLink);
980       Assert.fail("No exception raised");
981     } catch (InvalidArgumentException e) {
982       // Expected exception.
983     }
984   }
985 
986   @Test
createFirebaseLinkTest2()987   public void createFirebaseLinkTest2() throws Exception {
988     FirebaseLink expectedResponse =
989         FirebaseLink.newBuilder()
990             .setName(FirebaseLinkName.of("[PROPERTY]", "[FIREBASE_LINK]").toString())
991             .setProject("project-309310695")
992             .setCreateTime(Timestamp.newBuilder().build())
993             .build();
994     mockService.addResponse(expectedResponse);
995 
996     String parent = "properties/propertie-2024";
997     FirebaseLink firebaseLink = FirebaseLink.newBuilder().build();
998 
999     FirebaseLink actualResponse = client.createFirebaseLink(parent, firebaseLink);
1000     Assert.assertEquals(expectedResponse, actualResponse);
1001 
1002     List<String> actualRequests = mockService.getRequestPaths();
1003     Assert.assertEquals(1, actualRequests.size());
1004 
1005     String apiClientHeaderKey =
1006         mockService
1007             .getRequestHeaders()
1008             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1009             .iterator()
1010             .next();
1011     Assert.assertTrue(
1012         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1013             .matcher(apiClientHeaderKey)
1014             .matches());
1015   }
1016 
1017   @Test
createFirebaseLinkExceptionTest2()1018   public void createFirebaseLinkExceptionTest2() throws Exception {
1019     ApiException exception =
1020         ApiExceptionFactory.createException(
1021             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1022     mockService.addException(exception);
1023 
1024     try {
1025       String parent = "properties/propertie-2024";
1026       FirebaseLink firebaseLink = FirebaseLink.newBuilder().build();
1027       client.createFirebaseLink(parent, firebaseLink);
1028       Assert.fail("No exception raised");
1029     } catch (InvalidArgumentException e) {
1030       // Expected exception.
1031     }
1032   }
1033 
1034   @Test
deleteFirebaseLinkTest()1035   public void deleteFirebaseLinkTest() throws Exception {
1036     Empty expectedResponse = Empty.newBuilder().build();
1037     mockService.addResponse(expectedResponse);
1038 
1039     FirebaseLinkName name = FirebaseLinkName.of("[PROPERTY]", "[FIREBASE_LINK]");
1040 
1041     client.deleteFirebaseLink(name);
1042 
1043     List<String> actualRequests = mockService.getRequestPaths();
1044     Assert.assertEquals(1, actualRequests.size());
1045 
1046     String apiClientHeaderKey =
1047         mockService
1048             .getRequestHeaders()
1049             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1050             .iterator()
1051             .next();
1052     Assert.assertTrue(
1053         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1054             .matcher(apiClientHeaderKey)
1055             .matches());
1056   }
1057 
1058   @Test
deleteFirebaseLinkExceptionTest()1059   public void deleteFirebaseLinkExceptionTest() throws Exception {
1060     ApiException exception =
1061         ApiExceptionFactory.createException(
1062             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1063     mockService.addException(exception);
1064 
1065     try {
1066       FirebaseLinkName name = FirebaseLinkName.of("[PROPERTY]", "[FIREBASE_LINK]");
1067       client.deleteFirebaseLink(name);
1068       Assert.fail("No exception raised");
1069     } catch (InvalidArgumentException e) {
1070       // Expected exception.
1071     }
1072   }
1073 
1074   @Test
deleteFirebaseLinkTest2()1075   public void deleteFirebaseLinkTest2() throws Exception {
1076     Empty expectedResponse = Empty.newBuilder().build();
1077     mockService.addResponse(expectedResponse);
1078 
1079     String name = "properties/propertie-2649/firebaseLinks/firebaseLink-2649";
1080 
1081     client.deleteFirebaseLink(name);
1082 
1083     List<String> actualRequests = mockService.getRequestPaths();
1084     Assert.assertEquals(1, actualRequests.size());
1085 
1086     String apiClientHeaderKey =
1087         mockService
1088             .getRequestHeaders()
1089             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1090             .iterator()
1091             .next();
1092     Assert.assertTrue(
1093         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1094             .matcher(apiClientHeaderKey)
1095             .matches());
1096   }
1097 
1098   @Test
deleteFirebaseLinkExceptionTest2()1099   public void deleteFirebaseLinkExceptionTest2() throws Exception {
1100     ApiException exception =
1101         ApiExceptionFactory.createException(
1102             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1103     mockService.addException(exception);
1104 
1105     try {
1106       String name = "properties/propertie-2649/firebaseLinks/firebaseLink-2649";
1107       client.deleteFirebaseLink(name);
1108       Assert.fail("No exception raised");
1109     } catch (InvalidArgumentException e) {
1110       // Expected exception.
1111     }
1112   }
1113 
1114   @Test
listFirebaseLinksTest()1115   public void listFirebaseLinksTest() throws Exception {
1116     FirebaseLink responsesElement = FirebaseLink.newBuilder().build();
1117     ListFirebaseLinksResponse expectedResponse =
1118         ListFirebaseLinksResponse.newBuilder()
1119             .setNextPageToken("")
1120             .addAllFirebaseLinks(Arrays.asList(responsesElement))
1121             .build();
1122     mockService.addResponse(expectedResponse);
1123 
1124     PropertyName parent = PropertyName.of("[PROPERTY]");
1125 
1126     ListFirebaseLinksPagedResponse pagedListResponse = client.listFirebaseLinks(parent);
1127 
1128     List<FirebaseLink> resources = Lists.newArrayList(pagedListResponse.iterateAll());
1129 
1130     Assert.assertEquals(1, resources.size());
1131     Assert.assertEquals(expectedResponse.getFirebaseLinksList().get(0), resources.get(0));
1132 
1133     List<String> actualRequests = mockService.getRequestPaths();
1134     Assert.assertEquals(1, actualRequests.size());
1135 
1136     String apiClientHeaderKey =
1137         mockService
1138             .getRequestHeaders()
1139             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1140             .iterator()
1141             .next();
1142     Assert.assertTrue(
1143         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1144             .matcher(apiClientHeaderKey)
1145             .matches());
1146   }
1147 
1148   @Test
listFirebaseLinksExceptionTest()1149   public void listFirebaseLinksExceptionTest() throws Exception {
1150     ApiException exception =
1151         ApiExceptionFactory.createException(
1152             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1153     mockService.addException(exception);
1154 
1155     try {
1156       PropertyName parent = PropertyName.of("[PROPERTY]");
1157       client.listFirebaseLinks(parent);
1158       Assert.fail("No exception raised");
1159     } catch (InvalidArgumentException e) {
1160       // Expected exception.
1161     }
1162   }
1163 
1164   @Test
listFirebaseLinksTest2()1165   public void listFirebaseLinksTest2() throws Exception {
1166     FirebaseLink responsesElement = FirebaseLink.newBuilder().build();
1167     ListFirebaseLinksResponse expectedResponse =
1168         ListFirebaseLinksResponse.newBuilder()
1169             .setNextPageToken("")
1170             .addAllFirebaseLinks(Arrays.asList(responsesElement))
1171             .build();
1172     mockService.addResponse(expectedResponse);
1173 
1174     String parent = "properties/propertie-2024";
1175 
1176     ListFirebaseLinksPagedResponse pagedListResponse = client.listFirebaseLinks(parent);
1177 
1178     List<FirebaseLink> resources = Lists.newArrayList(pagedListResponse.iterateAll());
1179 
1180     Assert.assertEquals(1, resources.size());
1181     Assert.assertEquals(expectedResponse.getFirebaseLinksList().get(0), resources.get(0));
1182 
1183     List<String> actualRequests = mockService.getRequestPaths();
1184     Assert.assertEquals(1, actualRequests.size());
1185 
1186     String apiClientHeaderKey =
1187         mockService
1188             .getRequestHeaders()
1189             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1190             .iterator()
1191             .next();
1192     Assert.assertTrue(
1193         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1194             .matcher(apiClientHeaderKey)
1195             .matches());
1196   }
1197 
1198   @Test
listFirebaseLinksExceptionTest2()1199   public void listFirebaseLinksExceptionTest2() throws Exception {
1200     ApiException exception =
1201         ApiExceptionFactory.createException(
1202             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1203     mockService.addException(exception);
1204 
1205     try {
1206       String parent = "properties/propertie-2024";
1207       client.listFirebaseLinks(parent);
1208       Assert.fail("No exception raised");
1209     } catch (InvalidArgumentException e) {
1210       // Expected exception.
1211     }
1212   }
1213 
1214   @Test
createGoogleAdsLinkTest()1215   public void createGoogleAdsLinkTest() throws Exception {
1216     GoogleAdsLink expectedResponse =
1217         GoogleAdsLink.newBuilder()
1218             .setName(GoogleAdsLinkName.of("[PROPERTY]", "[GOOGLE_ADS_LINK]").toString())
1219             .setCustomerId("customerId-1581184615")
1220             .setCanManageClients(true)
1221             .setAdsPersonalizationEnabled(BoolValue.newBuilder().build())
1222             .setCreateTime(Timestamp.newBuilder().build())
1223             .setUpdateTime(Timestamp.newBuilder().build())
1224             .setCreatorEmailAddress("creatorEmailAddress67752708")
1225             .build();
1226     mockService.addResponse(expectedResponse);
1227 
1228     PropertyName parent = PropertyName.of("[PROPERTY]");
1229     GoogleAdsLink googleAdsLink = GoogleAdsLink.newBuilder().build();
1230 
1231     GoogleAdsLink actualResponse = client.createGoogleAdsLink(parent, googleAdsLink);
1232     Assert.assertEquals(expectedResponse, actualResponse);
1233 
1234     List<String> actualRequests = mockService.getRequestPaths();
1235     Assert.assertEquals(1, actualRequests.size());
1236 
1237     String apiClientHeaderKey =
1238         mockService
1239             .getRequestHeaders()
1240             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1241             .iterator()
1242             .next();
1243     Assert.assertTrue(
1244         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1245             .matcher(apiClientHeaderKey)
1246             .matches());
1247   }
1248 
1249   @Test
createGoogleAdsLinkExceptionTest()1250   public void createGoogleAdsLinkExceptionTest() throws Exception {
1251     ApiException exception =
1252         ApiExceptionFactory.createException(
1253             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1254     mockService.addException(exception);
1255 
1256     try {
1257       PropertyName parent = PropertyName.of("[PROPERTY]");
1258       GoogleAdsLink googleAdsLink = GoogleAdsLink.newBuilder().build();
1259       client.createGoogleAdsLink(parent, googleAdsLink);
1260       Assert.fail("No exception raised");
1261     } catch (InvalidArgumentException e) {
1262       // Expected exception.
1263     }
1264   }
1265 
1266   @Test
createGoogleAdsLinkTest2()1267   public void createGoogleAdsLinkTest2() throws Exception {
1268     GoogleAdsLink expectedResponse =
1269         GoogleAdsLink.newBuilder()
1270             .setName(GoogleAdsLinkName.of("[PROPERTY]", "[GOOGLE_ADS_LINK]").toString())
1271             .setCustomerId("customerId-1581184615")
1272             .setCanManageClients(true)
1273             .setAdsPersonalizationEnabled(BoolValue.newBuilder().build())
1274             .setCreateTime(Timestamp.newBuilder().build())
1275             .setUpdateTime(Timestamp.newBuilder().build())
1276             .setCreatorEmailAddress("creatorEmailAddress67752708")
1277             .build();
1278     mockService.addResponse(expectedResponse);
1279 
1280     String parent = "properties/propertie-2024";
1281     GoogleAdsLink googleAdsLink = GoogleAdsLink.newBuilder().build();
1282 
1283     GoogleAdsLink actualResponse = client.createGoogleAdsLink(parent, googleAdsLink);
1284     Assert.assertEquals(expectedResponse, actualResponse);
1285 
1286     List<String> actualRequests = mockService.getRequestPaths();
1287     Assert.assertEquals(1, actualRequests.size());
1288 
1289     String apiClientHeaderKey =
1290         mockService
1291             .getRequestHeaders()
1292             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1293             .iterator()
1294             .next();
1295     Assert.assertTrue(
1296         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1297             .matcher(apiClientHeaderKey)
1298             .matches());
1299   }
1300 
1301   @Test
createGoogleAdsLinkExceptionTest2()1302   public void createGoogleAdsLinkExceptionTest2() throws Exception {
1303     ApiException exception =
1304         ApiExceptionFactory.createException(
1305             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1306     mockService.addException(exception);
1307 
1308     try {
1309       String parent = "properties/propertie-2024";
1310       GoogleAdsLink googleAdsLink = GoogleAdsLink.newBuilder().build();
1311       client.createGoogleAdsLink(parent, googleAdsLink);
1312       Assert.fail("No exception raised");
1313     } catch (InvalidArgumentException e) {
1314       // Expected exception.
1315     }
1316   }
1317 
1318   @Test
updateGoogleAdsLinkTest()1319   public void updateGoogleAdsLinkTest() throws Exception {
1320     GoogleAdsLink expectedResponse =
1321         GoogleAdsLink.newBuilder()
1322             .setName(GoogleAdsLinkName.of("[PROPERTY]", "[GOOGLE_ADS_LINK]").toString())
1323             .setCustomerId("customerId-1581184615")
1324             .setCanManageClients(true)
1325             .setAdsPersonalizationEnabled(BoolValue.newBuilder().build())
1326             .setCreateTime(Timestamp.newBuilder().build())
1327             .setUpdateTime(Timestamp.newBuilder().build())
1328             .setCreatorEmailAddress("creatorEmailAddress67752708")
1329             .build();
1330     mockService.addResponse(expectedResponse);
1331 
1332     GoogleAdsLink googleAdsLink =
1333         GoogleAdsLink.newBuilder()
1334             .setName(GoogleAdsLinkName.of("[PROPERTY]", "[GOOGLE_ADS_LINK]").toString())
1335             .setCustomerId("customerId-1581184615")
1336             .setCanManageClients(true)
1337             .setAdsPersonalizationEnabled(BoolValue.newBuilder().build())
1338             .setCreateTime(Timestamp.newBuilder().build())
1339             .setUpdateTime(Timestamp.newBuilder().build())
1340             .setCreatorEmailAddress("creatorEmailAddress67752708")
1341             .build();
1342     FieldMask updateMask = FieldMask.newBuilder().build();
1343 
1344     GoogleAdsLink actualResponse = client.updateGoogleAdsLink(googleAdsLink, updateMask);
1345     Assert.assertEquals(expectedResponse, actualResponse);
1346 
1347     List<String> actualRequests = mockService.getRequestPaths();
1348     Assert.assertEquals(1, actualRequests.size());
1349 
1350     String apiClientHeaderKey =
1351         mockService
1352             .getRequestHeaders()
1353             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1354             .iterator()
1355             .next();
1356     Assert.assertTrue(
1357         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1358             .matcher(apiClientHeaderKey)
1359             .matches());
1360   }
1361 
1362   @Test
updateGoogleAdsLinkExceptionTest()1363   public void updateGoogleAdsLinkExceptionTest() throws Exception {
1364     ApiException exception =
1365         ApiExceptionFactory.createException(
1366             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1367     mockService.addException(exception);
1368 
1369     try {
1370       GoogleAdsLink googleAdsLink =
1371           GoogleAdsLink.newBuilder()
1372               .setName(GoogleAdsLinkName.of("[PROPERTY]", "[GOOGLE_ADS_LINK]").toString())
1373               .setCustomerId("customerId-1581184615")
1374               .setCanManageClients(true)
1375               .setAdsPersonalizationEnabled(BoolValue.newBuilder().build())
1376               .setCreateTime(Timestamp.newBuilder().build())
1377               .setUpdateTime(Timestamp.newBuilder().build())
1378               .setCreatorEmailAddress("creatorEmailAddress67752708")
1379               .build();
1380       FieldMask updateMask = FieldMask.newBuilder().build();
1381       client.updateGoogleAdsLink(googleAdsLink, updateMask);
1382       Assert.fail("No exception raised");
1383     } catch (InvalidArgumentException e) {
1384       // Expected exception.
1385     }
1386   }
1387 
1388   @Test
deleteGoogleAdsLinkTest()1389   public void deleteGoogleAdsLinkTest() throws Exception {
1390     Empty expectedResponse = Empty.newBuilder().build();
1391     mockService.addResponse(expectedResponse);
1392 
1393     GoogleAdsLinkName name = GoogleAdsLinkName.of("[PROPERTY]", "[GOOGLE_ADS_LINK]");
1394 
1395     client.deleteGoogleAdsLink(name);
1396 
1397     List<String> actualRequests = mockService.getRequestPaths();
1398     Assert.assertEquals(1, actualRequests.size());
1399 
1400     String apiClientHeaderKey =
1401         mockService
1402             .getRequestHeaders()
1403             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1404             .iterator()
1405             .next();
1406     Assert.assertTrue(
1407         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1408             .matcher(apiClientHeaderKey)
1409             .matches());
1410   }
1411 
1412   @Test
deleteGoogleAdsLinkExceptionTest()1413   public void deleteGoogleAdsLinkExceptionTest() throws Exception {
1414     ApiException exception =
1415         ApiExceptionFactory.createException(
1416             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1417     mockService.addException(exception);
1418 
1419     try {
1420       GoogleAdsLinkName name = GoogleAdsLinkName.of("[PROPERTY]", "[GOOGLE_ADS_LINK]");
1421       client.deleteGoogleAdsLink(name);
1422       Assert.fail("No exception raised");
1423     } catch (InvalidArgumentException e) {
1424       // Expected exception.
1425     }
1426   }
1427 
1428   @Test
deleteGoogleAdsLinkTest2()1429   public void deleteGoogleAdsLinkTest2() throws Exception {
1430     Empty expectedResponse = Empty.newBuilder().build();
1431     mockService.addResponse(expectedResponse);
1432 
1433     String name = "properties/propertie-1267/googleAdsLinks/googleAdsLink-1267";
1434 
1435     client.deleteGoogleAdsLink(name);
1436 
1437     List<String> actualRequests = mockService.getRequestPaths();
1438     Assert.assertEquals(1, actualRequests.size());
1439 
1440     String apiClientHeaderKey =
1441         mockService
1442             .getRequestHeaders()
1443             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1444             .iterator()
1445             .next();
1446     Assert.assertTrue(
1447         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1448             .matcher(apiClientHeaderKey)
1449             .matches());
1450   }
1451 
1452   @Test
deleteGoogleAdsLinkExceptionTest2()1453   public void deleteGoogleAdsLinkExceptionTest2() throws Exception {
1454     ApiException exception =
1455         ApiExceptionFactory.createException(
1456             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1457     mockService.addException(exception);
1458 
1459     try {
1460       String name = "properties/propertie-1267/googleAdsLinks/googleAdsLink-1267";
1461       client.deleteGoogleAdsLink(name);
1462       Assert.fail("No exception raised");
1463     } catch (InvalidArgumentException e) {
1464       // Expected exception.
1465     }
1466   }
1467 
1468   @Test
listGoogleAdsLinksTest()1469   public void listGoogleAdsLinksTest() throws Exception {
1470     GoogleAdsLink responsesElement = GoogleAdsLink.newBuilder().build();
1471     ListGoogleAdsLinksResponse expectedResponse =
1472         ListGoogleAdsLinksResponse.newBuilder()
1473             .setNextPageToken("")
1474             .addAllGoogleAdsLinks(Arrays.asList(responsesElement))
1475             .build();
1476     mockService.addResponse(expectedResponse);
1477 
1478     PropertyName parent = PropertyName.of("[PROPERTY]");
1479 
1480     ListGoogleAdsLinksPagedResponse pagedListResponse = client.listGoogleAdsLinks(parent);
1481 
1482     List<GoogleAdsLink> resources = Lists.newArrayList(pagedListResponse.iterateAll());
1483 
1484     Assert.assertEquals(1, resources.size());
1485     Assert.assertEquals(expectedResponse.getGoogleAdsLinksList().get(0), resources.get(0));
1486 
1487     List<String> actualRequests = mockService.getRequestPaths();
1488     Assert.assertEquals(1, actualRequests.size());
1489 
1490     String apiClientHeaderKey =
1491         mockService
1492             .getRequestHeaders()
1493             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1494             .iterator()
1495             .next();
1496     Assert.assertTrue(
1497         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1498             .matcher(apiClientHeaderKey)
1499             .matches());
1500   }
1501 
1502   @Test
listGoogleAdsLinksExceptionTest()1503   public void listGoogleAdsLinksExceptionTest() throws Exception {
1504     ApiException exception =
1505         ApiExceptionFactory.createException(
1506             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1507     mockService.addException(exception);
1508 
1509     try {
1510       PropertyName parent = PropertyName.of("[PROPERTY]");
1511       client.listGoogleAdsLinks(parent);
1512       Assert.fail("No exception raised");
1513     } catch (InvalidArgumentException e) {
1514       // Expected exception.
1515     }
1516   }
1517 
1518   @Test
listGoogleAdsLinksTest2()1519   public void listGoogleAdsLinksTest2() throws Exception {
1520     GoogleAdsLink responsesElement = GoogleAdsLink.newBuilder().build();
1521     ListGoogleAdsLinksResponse expectedResponse =
1522         ListGoogleAdsLinksResponse.newBuilder()
1523             .setNextPageToken("")
1524             .addAllGoogleAdsLinks(Arrays.asList(responsesElement))
1525             .build();
1526     mockService.addResponse(expectedResponse);
1527 
1528     String parent = "properties/propertie-2024";
1529 
1530     ListGoogleAdsLinksPagedResponse pagedListResponse = client.listGoogleAdsLinks(parent);
1531 
1532     List<GoogleAdsLink> resources = Lists.newArrayList(pagedListResponse.iterateAll());
1533 
1534     Assert.assertEquals(1, resources.size());
1535     Assert.assertEquals(expectedResponse.getGoogleAdsLinksList().get(0), resources.get(0));
1536 
1537     List<String> actualRequests = mockService.getRequestPaths();
1538     Assert.assertEquals(1, actualRequests.size());
1539 
1540     String apiClientHeaderKey =
1541         mockService
1542             .getRequestHeaders()
1543             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1544             .iterator()
1545             .next();
1546     Assert.assertTrue(
1547         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1548             .matcher(apiClientHeaderKey)
1549             .matches());
1550   }
1551 
1552   @Test
listGoogleAdsLinksExceptionTest2()1553   public void listGoogleAdsLinksExceptionTest2() throws Exception {
1554     ApiException exception =
1555         ApiExceptionFactory.createException(
1556             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1557     mockService.addException(exception);
1558 
1559     try {
1560       String parent = "properties/propertie-2024";
1561       client.listGoogleAdsLinks(parent);
1562       Assert.fail("No exception raised");
1563     } catch (InvalidArgumentException e) {
1564       // Expected exception.
1565     }
1566   }
1567 
1568   @Test
getDataSharingSettingsTest()1569   public void getDataSharingSettingsTest() throws Exception {
1570     DataSharingSettings expectedResponse =
1571         DataSharingSettings.newBuilder()
1572             .setName(DataSharingSettingsName.of("[ACCOUNT]").toString())
1573             .setSharingWithGoogleSupportEnabled(true)
1574             .setSharingWithGoogleAssignedSalesEnabled(true)
1575             .setSharingWithGoogleAnySalesEnabled(true)
1576             .setSharingWithGoogleProductsEnabled(true)
1577             .setSharingWithOthersEnabled(true)
1578             .build();
1579     mockService.addResponse(expectedResponse);
1580 
1581     DataSharingSettingsName name = DataSharingSettingsName.of("[ACCOUNT]");
1582 
1583     DataSharingSettings actualResponse = client.getDataSharingSettings(name);
1584     Assert.assertEquals(expectedResponse, actualResponse);
1585 
1586     List<String> actualRequests = mockService.getRequestPaths();
1587     Assert.assertEquals(1, actualRequests.size());
1588 
1589     String apiClientHeaderKey =
1590         mockService
1591             .getRequestHeaders()
1592             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1593             .iterator()
1594             .next();
1595     Assert.assertTrue(
1596         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1597             .matcher(apiClientHeaderKey)
1598             .matches());
1599   }
1600 
1601   @Test
getDataSharingSettingsExceptionTest()1602   public void getDataSharingSettingsExceptionTest() throws Exception {
1603     ApiException exception =
1604         ApiExceptionFactory.createException(
1605             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1606     mockService.addException(exception);
1607 
1608     try {
1609       DataSharingSettingsName name = DataSharingSettingsName.of("[ACCOUNT]");
1610       client.getDataSharingSettings(name);
1611       Assert.fail("No exception raised");
1612     } catch (InvalidArgumentException e) {
1613       // Expected exception.
1614     }
1615   }
1616 
1617   @Test
getDataSharingSettingsTest2()1618   public void getDataSharingSettingsTest2() throws Exception {
1619     DataSharingSettings expectedResponse =
1620         DataSharingSettings.newBuilder()
1621             .setName(DataSharingSettingsName.of("[ACCOUNT]").toString())
1622             .setSharingWithGoogleSupportEnabled(true)
1623             .setSharingWithGoogleAssignedSalesEnabled(true)
1624             .setSharingWithGoogleAnySalesEnabled(true)
1625             .setSharingWithGoogleProductsEnabled(true)
1626             .setSharingWithOthersEnabled(true)
1627             .build();
1628     mockService.addResponse(expectedResponse);
1629 
1630     String name = "accounts/account-7122/dataSharingSettings";
1631 
1632     DataSharingSettings actualResponse = client.getDataSharingSettings(name);
1633     Assert.assertEquals(expectedResponse, actualResponse);
1634 
1635     List<String> actualRequests = mockService.getRequestPaths();
1636     Assert.assertEquals(1, actualRequests.size());
1637 
1638     String apiClientHeaderKey =
1639         mockService
1640             .getRequestHeaders()
1641             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1642             .iterator()
1643             .next();
1644     Assert.assertTrue(
1645         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1646             .matcher(apiClientHeaderKey)
1647             .matches());
1648   }
1649 
1650   @Test
getDataSharingSettingsExceptionTest2()1651   public void getDataSharingSettingsExceptionTest2() throws Exception {
1652     ApiException exception =
1653         ApiExceptionFactory.createException(
1654             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1655     mockService.addException(exception);
1656 
1657     try {
1658       String name = "accounts/account-7122/dataSharingSettings";
1659       client.getDataSharingSettings(name);
1660       Assert.fail("No exception raised");
1661     } catch (InvalidArgumentException e) {
1662       // Expected exception.
1663     }
1664   }
1665 
1666   @Test
getMeasurementProtocolSecretTest()1667   public void getMeasurementProtocolSecretTest() throws Exception {
1668     MeasurementProtocolSecret expectedResponse =
1669         MeasurementProtocolSecret.newBuilder()
1670             .setName(
1671                 MeasurementProtocolSecretName.of(
1672                         "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]")
1673                     .toString())
1674             .setDisplayName("displayName1714148973")
1675             .setSecretValue("secretValue-2044460895")
1676             .build();
1677     mockService.addResponse(expectedResponse);
1678 
1679     MeasurementProtocolSecretName name =
1680         MeasurementProtocolSecretName.of(
1681             "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]");
1682 
1683     MeasurementProtocolSecret actualResponse = client.getMeasurementProtocolSecret(name);
1684     Assert.assertEquals(expectedResponse, actualResponse);
1685 
1686     List<String> actualRequests = mockService.getRequestPaths();
1687     Assert.assertEquals(1, actualRequests.size());
1688 
1689     String apiClientHeaderKey =
1690         mockService
1691             .getRequestHeaders()
1692             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1693             .iterator()
1694             .next();
1695     Assert.assertTrue(
1696         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1697             .matcher(apiClientHeaderKey)
1698             .matches());
1699   }
1700 
1701   @Test
getMeasurementProtocolSecretExceptionTest()1702   public void getMeasurementProtocolSecretExceptionTest() throws Exception {
1703     ApiException exception =
1704         ApiExceptionFactory.createException(
1705             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1706     mockService.addException(exception);
1707 
1708     try {
1709       MeasurementProtocolSecretName name =
1710           MeasurementProtocolSecretName.of(
1711               "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]");
1712       client.getMeasurementProtocolSecret(name);
1713       Assert.fail("No exception raised");
1714     } catch (InvalidArgumentException e) {
1715       // Expected exception.
1716     }
1717   }
1718 
1719   @Test
getMeasurementProtocolSecretTest2()1720   public void getMeasurementProtocolSecretTest2() throws Exception {
1721     MeasurementProtocolSecret expectedResponse =
1722         MeasurementProtocolSecret.newBuilder()
1723             .setName(
1724                 MeasurementProtocolSecretName.of(
1725                         "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]")
1726                     .toString())
1727             .setDisplayName("displayName1714148973")
1728             .setSecretValue("secretValue-2044460895")
1729             .build();
1730     mockService.addResponse(expectedResponse);
1731 
1732     String name =
1733         "properties/propertie-6357/dataStreams/dataStream-6357/measurementProtocolSecrets/measurementProtocolSecret-6357";
1734 
1735     MeasurementProtocolSecret actualResponse = client.getMeasurementProtocolSecret(name);
1736     Assert.assertEquals(expectedResponse, actualResponse);
1737 
1738     List<String> actualRequests = mockService.getRequestPaths();
1739     Assert.assertEquals(1, actualRequests.size());
1740 
1741     String apiClientHeaderKey =
1742         mockService
1743             .getRequestHeaders()
1744             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1745             .iterator()
1746             .next();
1747     Assert.assertTrue(
1748         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1749             .matcher(apiClientHeaderKey)
1750             .matches());
1751   }
1752 
1753   @Test
getMeasurementProtocolSecretExceptionTest2()1754   public void getMeasurementProtocolSecretExceptionTest2() throws Exception {
1755     ApiException exception =
1756         ApiExceptionFactory.createException(
1757             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1758     mockService.addException(exception);
1759 
1760     try {
1761       String name =
1762           "properties/propertie-6357/dataStreams/dataStream-6357/measurementProtocolSecrets/measurementProtocolSecret-6357";
1763       client.getMeasurementProtocolSecret(name);
1764       Assert.fail("No exception raised");
1765     } catch (InvalidArgumentException e) {
1766       // Expected exception.
1767     }
1768   }
1769 
1770   @Test
listMeasurementProtocolSecretsTest()1771   public void listMeasurementProtocolSecretsTest() throws Exception {
1772     MeasurementProtocolSecret responsesElement = MeasurementProtocolSecret.newBuilder().build();
1773     ListMeasurementProtocolSecretsResponse expectedResponse =
1774         ListMeasurementProtocolSecretsResponse.newBuilder()
1775             .setNextPageToken("")
1776             .addAllMeasurementProtocolSecrets(Arrays.asList(responsesElement))
1777             .build();
1778     mockService.addResponse(expectedResponse);
1779 
1780     DataStreamName parent = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]");
1781 
1782     ListMeasurementProtocolSecretsPagedResponse pagedListResponse =
1783         client.listMeasurementProtocolSecrets(parent);
1784 
1785     List<MeasurementProtocolSecret> resources = Lists.newArrayList(pagedListResponse.iterateAll());
1786 
1787     Assert.assertEquals(1, resources.size());
1788     Assert.assertEquals(
1789         expectedResponse.getMeasurementProtocolSecretsList().get(0), resources.get(0));
1790 
1791     List<String> actualRequests = mockService.getRequestPaths();
1792     Assert.assertEquals(1, actualRequests.size());
1793 
1794     String apiClientHeaderKey =
1795         mockService
1796             .getRequestHeaders()
1797             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1798             .iterator()
1799             .next();
1800     Assert.assertTrue(
1801         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1802             .matcher(apiClientHeaderKey)
1803             .matches());
1804   }
1805 
1806   @Test
listMeasurementProtocolSecretsExceptionTest()1807   public void listMeasurementProtocolSecretsExceptionTest() throws Exception {
1808     ApiException exception =
1809         ApiExceptionFactory.createException(
1810             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1811     mockService.addException(exception);
1812 
1813     try {
1814       DataStreamName parent = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]");
1815       client.listMeasurementProtocolSecrets(parent);
1816       Assert.fail("No exception raised");
1817     } catch (InvalidArgumentException e) {
1818       // Expected exception.
1819     }
1820   }
1821 
1822   @Test
listMeasurementProtocolSecretsTest2()1823   public void listMeasurementProtocolSecretsTest2() throws Exception {
1824     MeasurementProtocolSecret responsesElement = MeasurementProtocolSecret.newBuilder().build();
1825     ListMeasurementProtocolSecretsResponse expectedResponse =
1826         ListMeasurementProtocolSecretsResponse.newBuilder()
1827             .setNextPageToken("")
1828             .addAllMeasurementProtocolSecrets(Arrays.asList(responsesElement))
1829             .build();
1830     mockService.addResponse(expectedResponse);
1831 
1832     String parent = "properties/propertie-9651/dataStreams/dataStream-9651";
1833 
1834     ListMeasurementProtocolSecretsPagedResponse pagedListResponse =
1835         client.listMeasurementProtocolSecrets(parent);
1836 
1837     List<MeasurementProtocolSecret> resources = Lists.newArrayList(pagedListResponse.iterateAll());
1838 
1839     Assert.assertEquals(1, resources.size());
1840     Assert.assertEquals(
1841         expectedResponse.getMeasurementProtocolSecretsList().get(0), resources.get(0));
1842 
1843     List<String> actualRequests = mockService.getRequestPaths();
1844     Assert.assertEquals(1, actualRequests.size());
1845 
1846     String apiClientHeaderKey =
1847         mockService
1848             .getRequestHeaders()
1849             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1850             .iterator()
1851             .next();
1852     Assert.assertTrue(
1853         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1854             .matcher(apiClientHeaderKey)
1855             .matches());
1856   }
1857 
1858   @Test
listMeasurementProtocolSecretsExceptionTest2()1859   public void listMeasurementProtocolSecretsExceptionTest2() throws Exception {
1860     ApiException exception =
1861         ApiExceptionFactory.createException(
1862             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1863     mockService.addException(exception);
1864 
1865     try {
1866       String parent = "properties/propertie-9651/dataStreams/dataStream-9651";
1867       client.listMeasurementProtocolSecrets(parent);
1868       Assert.fail("No exception raised");
1869     } catch (InvalidArgumentException e) {
1870       // Expected exception.
1871     }
1872   }
1873 
1874   @Test
createMeasurementProtocolSecretTest()1875   public void createMeasurementProtocolSecretTest() throws Exception {
1876     MeasurementProtocolSecret expectedResponse =
1877         MeasurementProtocolSecret.newBuilder()
1878             .setName(
1879                 MeasurementProtocolSecretName.of(
1880                         "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]")
1881                     .toString())
1882             .setDisplayName("displayName1714148973")
1883             .setSecretValue("secretValue-2044460895")
1884             .build();
1885     mockService.addResponse(expectedResponse);
1886 
1887     DataStreamName parent = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]");
1888     MeasurementProtocolSecret measurementProtocolSecret =
1889         MeasurementProtocolSecret.newBuilder().build();
1890 
1891     MeasurementProtocolSecret actualResponse =
1892         client.createMeasurementProtocolSecret(parent, measurementProtocolSecret);
1893     Assert.assertEquals(expectedResponse, actualResponse);
1894 
1895     List<String> actualRequests = mockService.getRequestPaths();
1896     Assert.assertEquals(1, actualRequests.size());
1897 
1898     String apiClientHeaderKey =
1899         mockService
1900             .getRequestHeaders()
1901             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1902             .iterator()
1903             .next();
1904     Assert.assertTrue(
1905         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1906             .matcher(apiClientHeaderKey)
1907             .matches());
1908   }
1909 
1910   @Test
createMeasurementProtocolSecretExceptionTest()1911   public void createMeasurementProtocolSecretExceptionTest() throws Exception {
1912     ApiException exception =
1913         ApiExceptionFactory.createException(
1914             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1915     mockService.addException(exception);
1916 
1917     try {
1918       DataStreamName parent = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]");
1919       MeasurementProtocolSecret measurementProtocolSecret =
1920           MeasurementProtocolSecret.newBuilder().build();
1921       client.createMeasurementProtocolSecret(parent, measurementProtocolSecret);
1922       Assert.fail("No exception raised");
1923     } catch (InvalidArgumentException e) {
1924       // Expected exception.
1925     }
1926   }
1927 
1928   @Test
createMeasurementProtocolSecretTest2()1929   public void createMeasurementProtocolSecretTest2() throws Exception {
1930     MeasurementProtocolSecret expectedResponse =
1931         MeasurementProtocolSecret.newBuilder()
1932             .setName(
1933                 MeasurementProtocolSecretName.of(
1934                         "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]")
1935                     .toString())
1936             .setDisplayName("displayName1714148973")
1937             .setSecretValue("secretValue-2044460895")
1938             .build();
1939     mockService.addResponse(expectedResponse);
1940 
1941     String parent = "properties/propertie-9651/dataStreams/dataStream-9651";
1942     MeasurementProtocolSecret measurementProtocolSecret =
1943         MeasurementProtocolSecret.newBuilder().build();
1944 
1945     MeasurementProtocolSecret actualResponse =
1946         client.createMeasurementProtocolSecret(parent, measurementProtocolSecret);
1947     Assert.assertEquals(expectedResponse, actualResponse);
1948 
1949     List<String> actualRequests = mockService.getRequestPaths();
1950     Assert.assertEquals(1, actualRequests.size());
1951 
1952     String apiClientHeaderKey =
1953         mockService
1954             .getRequestHeaders()
1955             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
1956             .iterator()
1957             .next();
1958     Assert.assertTrue(
1959         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
1960             .matcher(apiClientHeaderKey)
1961             .matches());
1962   }
1963 
1964   @Test
createMeasurementProtocolSecretExceptionTest2()1965   public void createMeasurementProtocolSecretExceptionTest2() throws Exception {
1966     ApiException exception =
1967         ApiExceptionFactory.createException(
1968             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
1969     mockService.addException(exception);
1970 
1971     try {
1972       String parent = "properties/propertie-9651/dataStreams/dataStream-9651";
1973       MeasurementProtocolSecret measurementProtocolSecret =
1974           MeasurementProtocolSecret.newBuilder().build();
1975       client.createMeasurementProtocolSecret(parent, measurementProtocolSecret);
1976       Assert.fail("No exception raised");
1977     } catch (InvalidArgumentException e) {
1978       // Expected exception.
1979     }
1980   }
1981 
1982   @Test
deleteMeasurementProtocolSecretTest()1983   public void deleteMeasurementProtocolSecretTest() throws Exception {
1984     Empty expectedResponse = Empty.newBuilder().build();
1985     mockService.addResponse(expectedResponse);
1986 
1987     MeasurementProtocolSecretName name =
1988         MeasurementProtocolSecretName.of(
1989             "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]");
1990 
1991     client.deleteMeasurementProtocolSecret(name);
1992 
1993     List<String> actualRequests = mockService.getRequestPaths();
1994     Assert.assertEquals(1, actualRequests.size());
1995 
1996     String apiClientHeaderKey =
1997         mockService
1998             .getRequestHeaders()
1999             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2000             .iterator()
2001             .next();
2002     Assert.assertTrue(
2003         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2004             .matcher(apiClientHeaderKey)
2005             .matches());
2006   }
2007 
2008   @Test
deleteMeasurementProtocolSecretExceptionTest()2009   public void deleteMeasurementProtocolSecretExceptionTest() throws Exception {
2010     ApiException exception =
2011         ApiExceptionFactory.createException(
2012             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2013     mockService.addException(exception);
2014 
2015     try {
2016       MeasurementProtocolSecretName name =
2017           MeasurementProtocolSecretName.of(
2018               "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]");
2019       client.deleteMeasurementProtocolSecret(name);
2020       Assert.fail("No exception raised");
2021     } catch (InvalidArgumentException e) {
2022       // Expected exception.
2023     }
2024   }
2025 
2026   @Test
deleteMeasurementProtocolSecretTest2()2027   public void deleteMeasurementProtocolSecretTest2() throws Exception {
2028     Empty expectedResponse = Empty.newBuilder().build();
2029     mockService.addResponse(expectedResponse);
2030 
2031     String name =
2032         "properties/propertie-6357/dataStreams/dataStream-6357/measurementProtocolSecrets/measurementProtocolSecret-6357";
2033 
2034     client.deleteMeasurementProtocolSecret(name);
2035 
2036     List<String> actualRequests = mockService.getRequestPaths();
2037     Assert.assertEquals(1, actualRequests.size());
2038 
2039     String apiClientHeaderKey =
2040         mockService
2041             .getRequestHeaders()
2042             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2043             .iterator()
2044             .next();
2045     Assert.assertTrue(
2046         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2047             .matcher(apiClientHeaderKey)
2048             .matches());
2049   }
2050 
2051   @Test
deleteMeasurementProtocolSecretExceptionTest2()2052   public void deleteMeasurementProtocolSecretExceptionTest2() throws Exception {
2053     ApiException exception =
2054         ApiExceptionFactory.createException(
2055             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2056     mockService.addException(exception);
2057 
2058     try {
2059       String name =
2060           "properties/propertie-6357/dataStreams/dataStream-6357/measurementProtocolSecrets/measurementProtocolSecret-6357";
2061       client.deleteMeasurementProtocolSecret(name);
2062       Assert.fail("No exception raised");
2063     } catch (InvalidArgumentException e) {
2064       // Expected exception.
2065     }
2066   }
2067 
2068   @Test
updateMeasurementProtocolSecretTest()2069   public void updateMeasurementProtocolSecretTest() throws Exception {
2070     MeasurementProtocolSecret expectedResponse =
2071         MeasurementProtocolSecret.newBuilder()
2072             .setName(
2073                 MeasurementProtocolSecretName.of(
2074                         "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]")
2075                     .toString())
2076             .setDisplayName("displayName1714148973")
2077             .setSecretValue("secretValue-2044460895")
2078             .build();
2079     mockService.addResponse(expectedResponse);
2080 
2081     MeasurementProtocolSecret measurementProtocolSecret =
2082         MeasurementProtocolSecret.newBuilder()
2083             .setName(
2084                 MeasurementProtocolSecretName.of(
2085                         "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]")
2086                     .toString())
2087             .setDisplayName("displayName1714148973")
2088             .setSecretValue("secretValue-2044460895")
2089             .build();
2090     FieldMask updateMask = FieldMask.newBuilder().build();
2091 
2092     MeasurementProtocolSecret actualResponse =
2093         client.updateMeasurementProtocolSecret(measurementProtocolSecret, updateMask);
2094     Assert.assertEquals(expectedResponse, actualResponse);
2095 
2096     List<String> actualRequests = mockService.getRequestPaths();
2097     Assert.assertEquals(1, actualRequests.size());
2098 
2099     String apiClientHeaderKey =
2100         mockService
2101             .getRequestHeaders()
2102             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2103             .iterator()
2104             .next();
2105     Assert.assertTrue(
2106         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2107             .matcher(apiClientHeaderKey)
2108             .matches());
2109   }
2110 
2111   @Test
updateMeasurementProtocolSecretExceptionTest()2112   public void updateMeasurementProtocolSecretExceptionTest() throws Exception {
2113     ApiException exception =
2114         ApiExceptionFactory.createException(
2115             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2116     mockService.addException(exception);
2117 
2118     try {
2119       MeasurementProtocolSecret measurementProtocolSecret =
2120           MeasurementProtocolSecret.newBuilder()
2121               .setName(
2122                   MeasurementProtocolSecretName.of(
2123                           "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]")
2124                       .toString())
2125               .setDisplayName("displayName1714148973")
2126               .setSecretValue("secretValue-2044460895")
2127               .build();
2128       FieldMask updateMask = FieldMask.newBuilder().build();
2129       client.updateMeasurementProtocolSecret(measurementProtocolSecret, updateMask);
2130       Assert.fail("No exception raised");
2131     } catch (InvalidArgumentException e) {
2132       // Expected exception.
2133     }
2134   }
2135 
2136   @Test
acknowledgeUserDataCollectionTest()2137   public void acknowledgeUserDataCollectionTest() throws Exception {
2138     AcknowledgeUserDataCollectionResponse expectedResponse =
2139         AcknowledgeUserDataCollectionResponse.newBuilder().build();
2140     mockService.addResponse(expectedResponse);
2141 
2142     AcknowledgeUserDataCollectionRequest request =
2143         AcknowledgeUserDataCollectionRequest.newBuilder()
2144             .setProperty(PropertyName.of("[PROPERTY]").toString())
2145             .setAcknowledgement("acknowledgement1769490938")
2146             .build();
2147 
2148     AcknowledgeUserDataCollectionResponse actualResponse =
2149         client.acknowledgeUserDataCollection(request);
2150     Assert.assertEquals(expectedResponse, actualResponse);
2151 
2152     List<String> actualRequests = mockService.getRequestPaths();
2153     Assert.assertEquals(1, actualRequests.size());
2154 
2155     String apiClientHeaderKey =
2156         mockService
2157             .getRequestHeaders()
2158             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2159             .iterator()
2160             .next();
2161     Assert.assertTrue(
2162         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2163             .matcher(apiClientHeaderKey)
2164             .matches());
2165   }
2166 
2167   @Test
acknowledgeUserDataCollectionExceptionTest()2168   public void acknowledgeUserDataCollectionExceptionTest() throws Exception {
2169     ApiException exception =
2170         ApiExceptionFactory.createException(
2171             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2172     mockService.addException(exception);
2173 
2174     try {
2175       AcknowledgeUserDataCollectionRequest request =
2176           AcknowledgeUserDataCollectionRequest.newBuilder()
2177               .setProperty(PropertyName.of("[PROPERTY]").toString())
2178               .setAcknowledgement("acknowledgement1769490938")
2179               .build();
2180       client.acknowledgeUserDataCollection(request);
2181       Assert.fail("No exception raised");
2182     } catch (InvalidArgumentException e) {
2183       // Expected exception.
2184     }
2185   }
2186 
2187   @Test
searchChangeHistoryEventsTest()2188   public void searchChangeHistoryEventsTest() throws Exception {
2189     ChangeHistoryEvent responsesElement = ChangeHistoryEvent.newBuilder().build();
2190     SearchChangeHistoryEventsResponse expectedResponse =
2191         SearchChangeHistoryEventsResponse.newBuilder()
2192             .setNextPageToken("")
2193             .addAllChangeHistoryEvents(Arrays.asList(responsesElement))
2194             .build();
2195     mockService.addResponse(expectedResponse);
2196 
2197     SearchChangeHistoryEventsRequest request =
2198         SearchChangeHistoryEventsRequest.newBuilder()
2199             .setAccount(AccountName.of("[ACCOUNT]").toString())
2200             .setProperty(PropertyName.of("[PROPERTY]").toString())
2201             .addAllResourceType(new ArrayList<ChangeHistoryResourceType>())
2202             .addAllAction(new ArrayList<ActionType>())
2203             .addAllActorEmail(new ArrayList<String>())
2204             .setEarliestChangeTime(Timestamp.newBuilder().build())
2205             .setLatestChangeTime(Timestamp.newBuilder().build())
2206             .setPageSize(883849137)
2207             .setPageToken("pageToken873572522")
2208             .build();
2209 
2210     SearchChangeHistoryEventsPagedResponse pagedListResponse =
2211         client.searchChangeHistoryEvents(request);
2212 
2213     List<ChangeHistoryEvent> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2214 
2215     Assert.assertEquals(1, resources.size());
2216     Assert.assertEquals(expectedResponse.getChangeHistoryEventsList().get(0), resources.get(0));
2217 
2218     List<String> actualRequests = mockService.getRequestPaths();
2219     Assert.assertEquals(1, actualRequests.size());
2220 
2221     String apiClientHeaderKey =
2222         mockService
2223             .getRequestHeaders()
2224             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2225             .iterator()
2226             .next();
2227     Assert.assertTrue(
2228         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2229             .matcher(apiClientHeaderKey)
2230             .matches());
2231   }
2232 
2233   @Test
searchChangeHistoryEventsExceptionTest()2234   public void searchChangeHistoryEventsExceptionTest() throws Exception {
2235     ApiException exception =
2236         ApiExceptionFactory.createException(
2237             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2238     mockService.addException(exception);
2239 
2240     try {
2241       SearchChangeHistoryEventsRequest request =
2242           SearchChangeHistoryEventsRequest.newBuilder()
2243               .setAccount(AccountName.of("[ACCOUNT]").toString())
2244               .setProperty(PropertyName.of("[PROPERTY]").toString())
2245               .addAllResourceType(new ArrayList<ChangeHistoryResourceType>())
2246               .addAllAction(new ArrayList<ActionType>())
2247               .addAllActorEmail(new ArrayList<String>())
2248               .setEarliestChangeTime(Timestamp.newBuilder().build())
2249               .setLatestChangeTime(Timestamp.newBuilder().build())
2250               .setPageSize(883849137)
2251               .setPageToken("pageToken873572522")
2252               .build();
2253       client.searchChangeHistoryEvents(request);
2254       Assert.fail("No exception raised");
2255     } catch (InvalidArgumentException e) {
2256       // Expected exception.
2257     }
2258   }
2259 
2260   @Test
createConversionEventTest()2261   public void createConversionEventTest() throws Exception {
2262     ConversionEvent expectedResponse =
2263         ConversionEvent.newBuilder()
2264             .setName(ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]").toString())
2265             .setEventName("eventName31228997")
2266             .setCreateTime(Timestamp.newBuilder().build())
2267             .setDeletable(true)
2268             .setCustom(true)
2269             .build();
2270     mockService.addResponse(expectedResponse);
2271 
2272     PropertyName parent = PropertyName.of("[PROPERTY]");
2273     ConversionEvent conversionEvent = ConversionEvent.newBuilder().build();
2274 
2275     ConversionEvent actualResponse = client.createConversionEvent(parent, conversionEvent);
2276     Assert.assertEquals(expectedResponse, actualResponse);
2277 
2278     List<String> actualRequests = mockService.getRequestPaths();
2279     Assert.assertEquals(1, actualRequests.size());
2280 
2281     String apiClientHeaderKey =
2282         mockService
2283             .getRequestHeaders()
2284             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2285             .iterator()
2286             .next();
2287     Assert.assertTrue(
2288         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2289             .matcher(apiClientHeaderKey)
2290             .matches());
2291   }
2292 
2293   @Test
createConversionEventExceptionTest()2294   public void createConversionEventExceptionTest() throws Exception {
2295     ApiException exception =
2296         ApiExceptionFactory.createException(
2297             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2298     mockService.addException(exception);
2299 
2300     try {
2301       PropertyName parent = PropertyName.of("[PROPERTY]");
2302       ConversionEvent conversionEvent = ConversionEvent.newBuilder().build();
2303       client.createConversionEvent(parent, conversionEvent);
2304       Assert.fail("No exception raised");
2305     } catch (InvalidArgumentException e) {
2306       // Expected exception.
2307     }
2308   }
2309 
2310   @Test
createConversionEventTest2()2311   public void createConversionEventTest2() throws Exception {
2312     ConversionEvent expectedResponse =
2313         ConversionEvent.newBuilder()
2314             .setName(ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]").toString())
2315             .setEventName("eventName31228997")
2316             .setCreateTime(Timestamp.newBuilder().build())
2317             .setDeletable(true)
2318             .setCustom(true)
2319             .build();
2320     mockService.addResponse(expectedResponse);
2321 
2322     String parent = "properties/propertie-2024";
2323     ConversionEvent conversionEvent = ConversionEvent.newBuilder().build();
2324 
2325     ConversionEvent actualResponse = client.createConversionEvent(parent, conversionEvent);
2326     Assert.assertEquals(expectedResponse, actualResponse);
2327 
2328     List<String> actualRequests = mockService.getRequestPaths();
2329     Assert.assertEquals(1, actualRequests.size());
2330 
2331     String apiClientHeaderKey =
2332         mockService
2333             .getRequestHeaders()
2334             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2335             .iterator()
2336             .next();
2337     Assert.assertTrue(
2338         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2339             .matcher(apiClientHeaderKey)
2340             .matches());
2341   }
2342 
2343   @Test
createConversionEventExceptionTest2()2344   public void createConversionEventExceptionTest2() throws Exception {
2345     ApiException exception =
2346         ApiExceptionFactory.createException(
2347             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2348     mockService.addException(exception);
2349 
2350     try {
2351       String parent = "properties/propertie-2024";
2352       ConversionEvent conversionEvent = ConversionEvent.newBuilder().build();
2353       client.createConversionEvent(parent, conversionEvent);
2354       Assert.fail("No exception raised");
2355     } catch (InvalidArgumentException e) {
2356       // Expected exception.
2357     }
2358   }
2359 
2360   @Test
getConversionEventTest()2361   public void getConversionEventTest() throws Exception {
2362     ConversionEvent expectedResponse =
2363         ConversionEvent.newBuilder()
2364             .setName(ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]").toString())
2365             .setEventName("eventName31228997")
2366             .setCreateTime(Timestamp.newBuilder().build())
2367             .setDeletable(true)
2368             .setCustom(true)
2369             .build();
2370     mockService.addResponse(expectedResponse);
2371 
2372     ConversionEventName name = ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]");
2373 
2374     ConversionEvent actualResponse = client.getConversionEvent(name);
2375     Assert.assertEquals(expectedResponse, actualResponse);
2376 
2377     List<String> actualRequests = mockService.getRequestPaths();
2378     Assert.assertEquals(1, actualRequests.size());
2379 
2380     String apiClientHeaderKey =
2381         mockService
2382             .getRequestHeaders()
2383             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2384             .iterator()
2385             .next();
2386     Assert.assertTrue(
2387         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2388             .matcher(apiClientHeaderKey)
2389             .matches());
2390   }
2391 
2392   @Test
getConversionEventExceptionTest()2393   public void getConversionEventExceptionTest() throws Exception {
2394     ApiException exception =
2395         ApiExceptionFactory.createException(
2396             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2397     mockService.addException(exception);
2398 
2399     try {
2400       ConversionEventName name = ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]");
2401       client.getConversionEvent(name);
2402       Assert.fail("No exception raised");
2403     } catch (InvalidArgumentException e) {
2404       // Expected exception.
2405     }
2406   }
2407 
2408   @Test
getConversionEventTest2()2409   public void getConversionEventTest2() throws Exception {
2410     ConversionEvent expectedResponse =
2411         ConversionEvent.newBuilder()
2412             .setName(ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]").toString())
2413             .setEventName("eventName31228997")
2414             .setCreateTime(Timestamp.newBuilder().build())
2415             .setDeletable(true)
2416             .setCustom(true)
2417             .build();
2418     mockService.addResponse(expectedResponse);
2419 
2420     String name = "properties/propertie-4144/conversionEvents/conversionEvent-4144";
2421 
2422     ConversionEvent actualResponse = client.getConversionEvent(name);
2423     Assert.assertEquals(expectedResponse, actualResponse);
2424 
2425     List<String> actualRequests = mockService.getRequestPaths();
2426     Assert.assertEquals(1, actualRequests.size());
2427 
2428     String apiClientHeaderKey =
2429         mockService
2430             .getRequestHeaders()
2431             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2432             .iterator()
2433             .next();
2434     Assert.assertTrue(
2435         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2436             .matcher(apiClientHeaderKey)
2437             .matches());
2438   }
2439 
2440   @Test
getConversionEventExceptionTest2()2441   public void getConversionEventExceptionTest2() throws Exception {
2442     ApiException exception =
2443         ApiExceptionFactory.createException(
2444             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2445     mockService.addException(exception);
2446 
2447     try {
2448       String name = "properties/propertie-4144/conversionEvents/conversionEvent-4144";
2449       client.getConversionEvent(name);
2450       Assert.fail("No exception raised");
2451     } catch (InvalidArgumentException e) {
2452       // Expected exception.
2453     }
2454   }
2455 
2456   @Test
deleteConversionEventTest()2457   public void deleteConversionEventTest() throws Exception {
2458     Empty expectedResponse = Empty.newBuilder().build();
2459     mockService.addResponse(expectedResponse);
2460 
2461     ConversionEventName name = ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]");
2462 
2463     client.deleteConversionEvent(name);
2464 
2465     List<String> actualRequests = mockService.getRequestPaths();
2466     Assert.assertEquals(1, actualRequests.size());
2467 
2468     String apiClientHeaderKey =
2469         mockService
2470             .getRequestHeaders()
2471             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2472             .iterator()
2473             .next();
2474     Assert.assertTrue(
2475         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2476             .matcher(apiClientHeaderKey)
2477             .matches());
2478   }
2479 
2480   @Test
deleteConversionEventExceptionTest()2481   public void deleteConversionEventExceptionTest() throws Exception {
2482     ApiException exception =
2483         ApiExceptionFactory.createException(
2484             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2485     mockService.addException(exception);
2486 
2487     try {
2488       ConversionEventName name = ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]");
2489       client.deleteConversionEvent(name);
2490       Assert.fail("No exception raised");
2491     } catch (InvalidArgumentException e) {
2492       // Expected exception.
2493     }
2494   }
2495 
2496   @Test
deleteConversionEventTest2()2497   public void deleteConversionEventTest2() throws Exception {
2498     Empty expectedResponse = Empty.newBuilder().build();
2499     mockService.addResponse(expectedResponse);
2500 
2501     String name = "properties/propertie-4144/conversionEvents/conversionEvent-4144";
2502 
2503     client.deleteConversionEvent(name);
2504 
2505     List<String> actualRequests = mockService.getRequestPaths();
2506     Assert.assertEquals(1, actualRequests.size());
2507 
2508     String apiClientHeaderKey =
2509         mockService
2510             .getRequestHeaders()
2511             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2512             .iterator()
2513             .next();
2514     Assert.assertTrue(
2515         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2516             .matcher(apiClientHeaderKey)
2517             .matches());
2518   }
2519 
2520   @Test
deleteConversionEventExceptionTest2()2521   public void deleteConversionEventExceptionTest2() throws Exception {
2522     ApiException exception =
2523         ApiExceptionFactory.createException(
2524             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2525     mockService.addException(exception);
2526 
2527     try {
2528       String name = "properties/propertie-4144/conversionEvents/conversionEvent-4144";
2529       client.deleteConversionEvent(name);
2530       Assert.fail("No exception raised");
2531     } catch (InvalidArgumentException e) {
2532       // Expected exception.
2533     }
2534   }
2535 
2536   @Test
listConversionEventsTest()2537   public void listConversionEventsTest() throws Exception {
2538     ConversionEvent responsesElement = ConversionEvent.newBuilder().build();
2539     ListConversionEventsResponse expectedResponse =
2540         ListConversionEventsResponse.newBuilder()
2541             .setNextPageToken("")
2542             .addAllConversionEvents(Arrays.asList(responsesElement))
2543             .build();
2544     mockService.addResponse(expectedResponse);
2545 
2546     PropertyName parent = PropertyName.of("[PROPERTY]");
2547 
2548     ListConversionEventsPagedResponse pagedListResponse = client.listConversionEvents(parent);
2549 
2550     List<ConversionEvent> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2551 
2552     Assert.assertEquals(1, resources.size());
2553     Assert.assertEquals(expectedResponse.getConversionEventsList().get(0), resources.get(0));
2554 
2555     List<String> actualRequests = mockService.getRequestPaths();
2556     Assert.assertEquals(1, actualRequests.size());
2557 
2558     String apiClientHeaderKey =
2559         mockService
2560             .getRequestHeaders()
2561             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2562             .iterator()
2563             .next();
2564     Assert.assertTrue(
2565         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2566             .matcher(apiClientHeaderKey)
2567             .matches());
2568   }
2569 
2570   @Test
listConversionEventsExceptionTest()2571   public void listConversionEventsExceptionTest() throws Exception {
2572     ApiException exception =
2573         ApiExceptionFactory.createException(
2574             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2575     mockService.addException(exception);
2576 
2577     try {
2578       PropertyName parent = PropertyName.of("[PROPERTY]");
2579       client.listConversionEvents(parent);
2580       Assert.fail("No exception raised");
2581     } catch (InvalidArgumentException e) {
2582       // Expected exception.
2583     }
2584   }
2585 
2586   @Test
listConversionEventsTest2()2587   public void listConversionEventsTest2() throws Exception {
2588     ConversionEvent responsesElement = ConversionEvent.newBuilder().build();
2589     ListConversionEventsResponse expectedResponse =
2590         ListConversionEventsResponse.newBuilder()
2591             .setNextPageToken("")
2592             .addAllConversionEvents(Arrays.asList(responsesElement))
2593             .build();
2594     mockService.addResponse(expectedResponse);
2595 
2596     String parent = "properties/propertie-2024";
2597 
2598     ListConversionEventsPagedResponse pagedListResponse = client.listConversionEvents(parent);
2599 
2600     List<ConversionEvent> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2601 
2602     Assert.assertEquals(1, resources.size());
2603     Assert.assertEquals(expectedResponse.getConversionEventsList().get(0), resources.get(0));
2604 
2605     List<String> actualRequests = mockService.getRequestPaths();
2606     Assert.assertEquals(1, actualRequests.size());
2607 
2608     String apiClientHeaderKey =
2609         mockService
2610             .getRequestHeaders()
2611             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2612             .iterator()
2613             .next();
2614     Assert.assertTrue(
2615         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2616             .matcher(apiClientHeaderKey)
2617             .matches());
2618   }
2619 
2620   @Test
listConversionEventsExceptionTest2()2621   public void listConversionEventsExceptionTest2() throws Exception {
2622     ApiException exception =
2623         ApiExceptionFactory.createException(
2624             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2625     mockService.addException(exception);
2626 
2627     try {
2628       String parent = "properties/propertie-2024";
2629       client.listConversionEvents(parent);
2630       Assert.fail("No exception raised");
2631     } catch (InvalidArgumentException e) {
2632       // Expected exception.
2633     }
2634   }
2635 
2636   @Test
createCustomDimensionTest()2637   public void createCustomDimensionTest() throws Exception {
2638     CustomDimension expectedResponse =
2639         CustomDimension.newBuilder()
2640             .setName(CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]").toString())
2641             .setParameterName("parameterName-379607596")
2642             .setDisplayName("displayName1714148973")
2643             .setDescription("description-1724546052")
2644             .setDisallowAdsPersonalization(true)
2645             .build();
2646     mockService.addResponse(expectedResponse);
2647 
2648     PropertyName parent = PropertyName.of("[PROPERTY]");
2649     CustomDimension customDimension = CustomDimension.newBuilder().build();
2650 
2651     CustomDimension actualResponse = client.createCustomDimension(parent, customDimension);
2652     Assert.assertEquals(expectedResponse, actualResponse);
2653 
2654     List<String> actualRequests = mockService.getRequestPaths();
2655     Assert.assertEquals(1, actualRequests.size());
2656 
2657     String apiClientHeaderKey =
2658         mockService
2659             .getRequestHeaders()
2660             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2661             .iterator()
2662             .next();
2663     Assert.assertTrue(
2664         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2665             .matcher(apiClientHeaderKey)
2666             .matches());
2667   }
2668 
2669   @Test
createCustomDimensionExceptionTest()2670   public void createCustomDimensionExceptionTest() throws Exception {
2671     ApiException exception =
2672         ApiExceptionFactory.createException(
2673             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2674     mockService.addException(exception);
2675 
2676     try {
2677       PropertyName parent = PropertyName.of("[PROPERTY]");
2678       CustomDimension customDimension = CustomDimension.newBuilder().build();
2679       client.createCustomDimension(parent, customDimension);
2680       Assert.fail("No exception raised");
2681     } catch (InvalidArgumentException e) {
2682       // Expected exception.
2683     }
2684   }
2685 
2686   @Test
createCustomDimensionTest2()2687   public void createCustomDimensionTest2() throws Exception {
2688     CustomDimension expectedResponse =
2689         CustomDimension.newBuilder()
2690             .setName(CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]").toString())
2691             .setParameterName("parameterName-379607596")
2692             .setDisplayName("displayName1714148973")
2693             .setDescription("description-1724546052")
2694             .setDisallowAdsPersonalization(true)
2695             .build();
2696     mockService.addResponse(expectedResponse);
2697 
2698     String parent = "properties/propertie-2024";
2699     CustomDimension customDimension = CustomDimension.newBuilder().build();
2700 
2701     CustomDimension actualResponse = client.createCustomDimension(parent, customDimension);
2702     Assert.assertEquals(expectedResponse, actualResponse);
2703 
2704     List<String> actualRequests = mockService.getRequestPaths();
2705     Assert.assertEquals(1, actualRequests.size());
2706 
2707     String apiClientHeaderKey =
2708         mockService
2709             .getRequestHeaders()
2710             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2711             .iterator()
2712             .next();
2713     Assert.assertTrue(
2714         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2715             .matcher(apiClientHeaderKey)
2716             .matches());
2717   }
2718 
2719   @Test
createCustomDimensionExceptionTest2()2720   public void createCustomDimensionExceptionTest2() throws Exception {
2721     ApiException exception =
2722         ApiExceptionFactory.createException(
2723             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2724     mockService.addException(exception);
2725 
2726     try {
2727       String parent = "properties/propertie-2024";
2728       CustomDimension customDimension = CustomDimension.newBuilder().build();
2729       client.createCustomDimension(parent, customDimension);
2730       Assert.fail("No exception raised");
2731     } catch (InvalidArgumentException e) {
2732       // Expected exception.
2733     }
2734   }
2735 
2736   @Test
updateCustomDimensionTest()2737   public void updateCustomDimensionTest() throws Exception {
2738     CustomDimension expectedResponse =
2739         CustomDimension.newBuilder()
2740             .setName(CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]").toString())
2741             .setParameterName("parameterName-379607596")
2742             .setDisplayName("displayName1714148973")
2743             .setDescription("description-1724546052")
2744             .setDisallowAdsPersonalization(true)
2745             .build();
2746     mockService.addResponse(expectedResponse);
2747 
2748     CustomDimension customDimension =
2749         CustomDimension.newBuilder()
2750             .setName(CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]").toString())
2751             .setParameterName("parameterName-379607596")
2752             .setDisplayName("displayName1714148973")
2753             .setDescription("description-1724546052")
2754             .setDisallowAdsPersonalization(true)
2755             .build();
2756     FieldMask updateMask = FieldMask.newBuilder().build();
2757 
2758     CustomDimension actualResponse = client.updateCustomDimension(customDimension, updateMask);
2759     Assert.assertEquals(expectedResponse, actualResponse);
2760 
2761     List<String> actualRequests = mockService.getRequestPaths();
2762     Assert.assertEquals(1, actualRequests.size());
2763 
2764     String apiClientHeaderKey =
2765         mockService
2766             .getRequestHeaders()
2767             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2768             .iterator()
2769             .next();
2770     Assert.assertTrue(
2771         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2772             .matcher(apiClientHeaderKey)
2773             .matches());
2774   }
2775 
2776   @Test
updateCustomDimensionExceptionTest()2777   public void updateCustomDimensionExceptionTest() throws Exception {
2778     ApiException exception =
2779         ApiExceptionFactory.createException(
2780             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2781     mockService.addException(exception);
2782 
2783     try {
2784       CustomDimension customDimension =
2785           CustomDimension.newBuilder()
2786               .setName(CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]").toString())
2787               .setParameterName("parameterName-379607596")
2788               .setDisplayName("displayName1714148973")
2789               .setDescription("description-1724546052")
2790               .setDisallowAdsPersonalization(true)
2791               .build();
2792       FieldMask updateMask = FieldMask.newBuilder().build();
2793       client.updateCustomDimension(customDimension, updateMask);
2794       Assert.fail("No exception raised");
2795     } catch (InvalidArgumentException e) {
2796       // Expected exception.
2797     }
2798   }
2799 
2800   @Test
listCustomDimensionsTest()2801   public void listCustomDimensionsTest() throws Exception {
2802     CustomDimension responsesElement = CustomDimension.newBuilder().build();
2803     ListCustomDimensionsResponse expectedResponse =
2804         ListCustomDimensionsResponse.newBuilder()
2805             .setNextPageToken("")
2806             .addAllCustomDimensions(Arrays.asList(responsesElement))
2807             .build();
2808     mockService.addResponse(expectedResponse);
2809 
2810     PropertyName parent = PropertyName.of("[PROPERTY]");
2811 
2812     ListCustomDimensionsPagedResponse pagedListResponse = client.listCustomDimensions(parent);
2813 
2814     List<CustomDimension> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2815 
2816     Assert.assertEquals(1, resources.size());
2817     Assert.assertEquals(expectedResponse.getCustomDimensionsList().get(0), resources.get(0));
2818 
2819     List<String> actualRequests = mockService.getRequestPaths();
2820     Assert.assertEquals(1, actualRequests.size());
2821 
2822     String apiClientHeaderKey =
2823         mockService
2824             .getRequestHeaders()
2825             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2826             .iterator()
2827             .next();
2828     Assert.assertTrue(
2829         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2830             .matcher(apiClientHeaderKey)
2831             .matches());
2832   }
2833 
2834   @Test
listCustomDimensionsExceptionTest()2835   public void listCustomDimensionsExceptionTest() throws Exception {
2836     ApiException exception =
2837         ApiExceptionFactory.createException(
2838             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2839     mockService.addException(exception);
2840 
2841     try {
2842       PropertyName parent = PropertyName.of("[PROPERTY]");
2843       client.listCustomDimensions(parent);
2844       Assert.fail("No exception raised");
2845     } catch (InvalidArgumentException e) {
2846       // Expected exception.
2847     }
2848   }
2849 
2850   @Test
listCustomDimensionsTest2()2851   public void listCustomDimensionsTest2() throws Exception {
2852     CustomDimension responsesElement = CustomDimension.newBuilder().build();
2853     ListCustomDimensionsResponse expectedResponse =
2854         ListCustomDimensionsResponse.newBuilder()
2855             .setNextPageToken("")
2856             .addAllCustomDimensions(Arrays.asList(responsesElement))
2857             .build();
2858     mockService.addResponse(expectedResponse);
2859 
2860     String parent = "properties/propertie-2024";
2861 
2862     ListCustomDimensionsPagedResponse pagedListResponse = client.listCustomDimensions(parent);
2863 
2864     List<CustomDimension> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2865 
2866     Assert.assertEquals(1, resources.size());
2867     Assert.assertEquals(expectedResponse.getCustomDimensionsList().get(0), resources.get(0));
2868 
2869     List<String> actualRequests = mockService.getRequestPaths();
2870     Assert.assertEquals(1, actualRequests.size());
2871 
2872     String apiClientHeaderKey =
2873         mockService
2874             .getRequestHeaders()
2875             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2876             .iterator()
2877             .next();
2878     Assert.assertTrue(
2879         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2880             .matcher(apiClientHeaderKey)
2881             .matches());
2882   }
2883 
2884   @Test
listCustomDimensionsExceptionTest2()2885   public void listCustomDimensionsExceptionTest2() throws Exception {
2886     ApiException exception =
2887         ApiExceptionFactory.createException(
2888             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2889     mockService.addException(exception);
2890 
2891     try {
2892       String parent = "properties/propertie-2024";
2893       client.listCustomDimensions(parent);
2894       Assert.fail("No exception raised");
2895     } catch (InvalidArgumentException e) {
2896       // Expected exception.
2897     }
2898   }
2899 
2900   @Test
archiveCustomDimensionTest()2901   public void archiveCustomDimensionTest() throws Exception {
2902     Empty expectedResponse = Empty.newBuilder().build();
2903     mockService.addResponse(expectedResponse);
2904 
2905     CustomDimensionName name = CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]");
2906 
2907     client.archiveCustomDimension(name);
2908 
2909     List<String> actualRequests = mockService.getRequestPaths();
2910     Assert.assertEquals(1, actualRequests.size());
2911 
2912     String apiClientHeaderKey =
2913         mockService
2914             .getRequestHeaders()
2915             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2916             .iterator()
2917             .next();
2918     Assert.assertTrue(
2919         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2920             .matcher(apiClientHeaderKey)
2921             .matches());
2922   }
2923 
2924   @Test
archiveCustomDimensionExceptionTest()2925   public void archiveCustomDimensionExceptionTest() throws Exception {
2926     ApiException exception =
2927         ApiExceptionFactory.createException(
2928             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2929     mockService.addException(exception);
2930 
2931     try {
2932       CustomDimensionName name = CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]");
2933       client.archiveCustomDimension(name);
2934       Assert.fail("No exception raised");
2935     } catch (InvalidArgumentException e) {
2936       // Expected exception.
2937     }
2938   }
2939 
2940   @Test
archiveCustomDimensionTest2()2941   public void archiveCustomDimensionTest2() throws Exception {
2942     Empty expectedResponse = Empty.newBuilder().build();
2943     mockService.addResponse(expectedResponse);
2944 
2945     String name = "properties/propertie-447/customDimensions/customDimension-447";
2946 
2947     client.archiveCustomDimension(name);
2948 
2949     List<String> actualRequests = mockService.getRequestPaths();
2950     Assert.assertEquals(1, actualRequests.size());
2951 
2952     String apiClientHeaderKey =
2953         mockService
2954             .getRequestHeaders()
2955             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
2956             .iterator()
2957             .next();
2958     Assert.assertTrue(
2959         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
2960             .matcher(apiClientHeaderKey)
2961             .matches());
2962   }
2963 
2964   @Test
archiveCustomDimensionExceptionTest2()2965   public void archiveCustomDimensionExceptionTest2() throws Exception {
2966     ApiException exception =
2967         ApiExceptionFactory.createException(
2968             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
2969     mockService.addException(exception);
2970 
2971     try {
2972       String name = "properties/propertie-447/customDimensions/customDimension-447";
2973       client.archiveCustomDimension(name);
2974       Assert.fail("No exception raised");
2975     } catch (InvalidArgumentException e) {
2976       // Expected exception.
2977     }
2978   }
2979 
2980   @Test
getCustomDimensionTest()2981   public void getCustomDimensionTest() throws Exception {
2982     CustomDimension expectedResponse =
2983         CustomDimension.newBuilder()
2984             .setName(CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]").toString())
2985             .setParameterName("parameterName-379607596")
2986             .setDisplayName("displayName1714148973")
2987             .setDescription("description-1724546052")
2988             .setDisallowAdsPersonalization(true)
2989             .build();
2990     mockService.addResponse(expectedResponse);
2991 
2992     CustomDimensionName name = CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]");
2993 
2994     CustomDimension actualResponse = client.getCustomDimension(name);
2995     Assert.assertEquals(expectedResponse, actualResponse);
2996 
2997     List<String> actualRequests = mockService.getRequestPaths();
2998     Assert.assertEquals(1, actualRequests.size());
2999 
3000     String apiClientHeaderKey =
3001         mockService
3002             .getRequestHeaders()
3003             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3004             .iterator()
3005             .next();
3006     Assert.assertTrue(
3007         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3008             .matcher(apiClientHeaderKey)
3009             .matches());
3010   }
3011 
3012   @Test
getCustomDimensionExceptionTest()3013   public void getCustomDimensionExceptionTest() throws Exception {
3014     ApiException exception =
3015         ApiExceptionFactory.createException(
3016             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3017     mockService.addException(exception);
3018 
3019     try {
3020       CustomDimensionName name = CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]");
3021       client.getCustomDimension(name);
3022       Assert.fail("No exception raised");
3023     } catch (InvalidArgumentException e) {
3024       // Expected exception.
3025     }
3026   }
3027 
3028   @Test
getCustomDimensionTest2()3029   public void getCustomDimensionTest2() throws Exception {
3030     CustomDimension expectedResponse =
3031         CustomDimension.newBuilder()
3032             .setName(CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]").toString())
3033             .setParameterName("parameterName-379607596")
3034             .setDisplayName("displayName1714148973")
3035             .setDescription("description-1724546052")
3036             .setDisallowAdsPersonalization(true)
3037             .build();
3038     mockService.addResponse(expectedResponse);
3039 
3040     String name = "properties/propertie-447/customDimensions/customDimension-447";
3041 
3042     CustomDimension actualResponse = client.getCustomDimension(name);
3043     Assert.assertEquals(expectedResponse, actualResponse);
3044 
3045     List<String> actualRequests = mockService.getRequestPaths();
3046     Assert.assertEquals(1, actualRequests.size());
3047 
3048     String apiClientHeaderKey =
3049         mockService
3050             .getRequestHeaders()
3051             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3052             .iterator()
3053             .next();
3054     Assert.assertTrue(
3055         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3056             .matcher(apiClientHeaderKey)
3057             .matches());
3058   }
3059 
3060   @Test
getCustomDimensionExceptionTest2()3061   public void getCustomDimensionExceptionTest2() throws Exception {
3062     ApiException exception =
3063         ApiExceptionFactory.createException(
3064             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3065     mockService.addException(exception);
3066 
3067     try {
3068       String name = "properties/propertie-447/customDimensions/customDimension-447";
3069       client.getCustomDimension(name);
3070       Assert.fail("No exception raised");
3071     } catch (InvalidArgumentException e) {
3072       // Expected exception.
3073     }
3074   }
3075 
3076   @Test
createCustomMetricTest()3077   public void createCustomMetricTest() throws Exception {
3078     CustomMetric expectedResponse =
3079         CustomMetric.newBuilder()
3080             .setName(CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]").toString())
3081             .setParameterName("parameterName-379607596")
3082             .setDisplayName("displayName1714148973")
3083             .setDescription("description-1724546052")
3084             .addAllRestrictedMetricType(new ArrayList<CustomMetric.RestrictedMetricType>())
3085             .build();
3086     mockService.addResponse(expectedResponse);
3087 
3088     PropertyName parent = PropertyName.of("[PROPERTY]");
3089     CustomMetric customMetric = CustomMetric.newBuilder().build();
3090 
3091     CustomMetric actualResponse = client.createCustomMetric(parent, customMetric);
3092     Assert.assertEquals(expectedResponse, actualResponse);
3093 
3094     List<String> actualRequests = mockService.getRequestPaths();
3095     Assert.assertEquals(1, actualRequests.size());
3096 
3097     String apiClientHeaderKey =
3098         mockService
3099             .getRequestHeaders()
3100             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3101             .iterator()
3102             .next();
3103     Assert.assertTrue(
3104         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3105             .matcher(apiClientHeaderKey)
3106             .matches());
3107   }
3108 
3109   @Test
createCustomMetricExceptionTest()3110   public void createCustomMetricExceptionTest() throws Exception {
3111     ApiException exception =
3112         ApiExceptionFactory.createException(
3113             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3114     mockService.addException(exception);
3115 
3116     try {
3117       PropertyName parent = PropertyName.of("[PROPERTY]");
3118       CustomMetric customMetric = CustomMetric.newBuilder().build();
3119       client.createCustomMetric(parent, customMetric);
3120       Assert.fail("No exception raised");
3121     } catch (InvalidArgumentException e) {
3122       // Expected exception.
3123     }
3124   }
3125 
3126   @Test
createCustomMetricTest2()3127   public void createCustomMetricTest2() throws Exception {
3128     CustomMetric expectedResponse =
3129         CustomMetric.newBuilder()
3130             .setName(CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]").toString())
3131             .setParameterName("parameterName-379607596")
3132             .setDisplayName("displayName1714148973")
3133             .setDescription("description-1724546052")
3134             .addAllRestrictedMetricType(new ArrayList<CustomMetric.RestrictedMetricType>())
3135             .build();
3136     mockService.addResponse(expectedResponse);
3137 
3138     String parent = "properties/propertie-2024";
3139     CustomMetric customMetric = CustomMetric.newBuilder().build();
3140 
3141     CustomMetric actualResponse = client.createCustomMetric(parent, customMetric);
3142     Assert.assertEquals(expectedResponse, actualResponse);
3143 
3144     List<String> actualRequests = mockService.getRequestPaths();
3145     Assert.assertEquals(1, actualRequests.size());
3146 
3147     String apiClientHeaderKey =
3148         mockService
3149             .getRequestHeaders()
3150             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3151             .iterator()
3152             .next();
3153     Assert.assertTrue(
3154         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3155             .matcher(apiClientHeaderKey)
3156             .matches());
3157   }
3158 
3159   @Test
createCustomMetricExceptionTest2()3160   public void createCustomMetricExceptionTest2() throws Exception {
3161     ApiException exception =
3162         ApiExceptionFactory.createException(
3163             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3164     mockService.addException(exception);
3165 
3166     try {
3167       String parent = "properties/propertie-2024";
3168       CustomMetric customMetric = CustomMetric.newBuilder().build();
3169       client.createCustomMetric(parent, customMetric);
3170       Assert.fail("No exception raised");
3171     } catch (InvalidArgumentException e) {
3172       // Expected exception.
3173     }
3174   }
3175 
3176   @Test
updateCustomMetricTest()3177   public void updateCustomMetricTest() throws Exception {
3178     CustomMetric expectedResponse =
3179         CustomMetric.newBuilder()
3180             .setName(CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]").toString())
3181             .setParameterName("parameterName-379607596")
3182             .setDisplayName("displayName1714148973")
3183             .setDescription("description-1724546052")
3184             .addAllRestrictedMetricType(new ArrayList<CustomMetric.RestrictedMetricType>())
3185             .build();
3186     mockService.addResponse(expectedResponse);
3187 
3188     CustomMetric customMetric =
3189         CustomMetric.newBuilder()
3190             .setName(CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]").toString())
3191             .setParameterName("parameterName-379607596")
3192             .setDisplayName("displayName1714148973")
3193             .setDescription("description-1724546052")
3194             .addAllRestrictedMetricType(new ArrayList<CustomMetric.RestrictedMetricType>())
3195             .build();
3196     FieldMask updateMask = FieldMask.newBuilder().build();
3197 
3198     CustomMetric actualResponse = client.updateCustomMetric(customMetric, updateMask);
3199     Assert.assertEquals(expectedResponse, actualResponse);
3200 
3201     List<String> actualRequests = mockService.getRequestPaths();
3202     Assert.assertEquals(1, actualRequests.size());
3203 
3204     String apiClientHeaderKey =
3205         mockService
3206             .getRequestHeaders()
3207             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3208             .iterator()
3209             .next();
3210     Assert.assertTrue(
3211         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3212             .matcher(apiClientHeaderKey)
3213             .matches());
3214   }
3215 
3216   @Test
updateCustomMetricExceptionTest()3217   public void updateCustomMetricExceptionTest() throws Exception {
3218     ApiException exception =
3219         ApiExceptionFactory.createException(
3220             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3221     mockService.addException(exception);
3222 
3223     try {
3224       CustomMetric customMetric =
3225           CustomMetric.newBuilder()
3226               .setName(CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]").toString())
3227               .setParameterName("parameterName-379607596")
3228               .setDisplayName("displayName1714148973")
3229               .setDescription("description-1724546052")
3230               .addAllRestrictedMetricType(new ArrayList<CustomMetric.RestrictedMetricType>())
3231               .build();
3232       FieldMask updateMask = FieldMask.newBuilder().build();
3233       client.updateCustomMetric(customMetric, updateMask);
3234       Assert.fail("No exception raised");
3235     } catch (InvalidArgumentException e) {
3236       // Expected exception.
3237     }
3238   }
3239 
3240   @Test
listCustomMetricsTest()3241   public void listCustomMetricsTest() throws Exception {
3242     CustomMetric responsesElement = CustomMetric.newBuilder().build();
3243     ListCustomMetricsResponse expectedResponse =
3244         ListCustomMetricsResponse.newBuilder()
3245             .setNextPageToken("")
3246             .addAllCustomMetrics(Arrays.asList(responsesElement))
3247             .build();
3248     mockService.addResponse(expectedResponse);
3249 
3250     PropertyName parent = PropertyName.of("[PROPERTY]");
3251 
3252     ListCustomMetricsPagedResponse pagedListResponse = client.listCustomMetrics(parent);
3253 
3254     List<CustomMetric> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3255 
3256     Assert.assertEquals(1, resources.size());
3257     Assert.assertEquals(expectedResponse.getCustomMetricsList().get(0), resources.get(0));
3258 
3259     List<String> actualRequests = mockService.getRequestPaths();
3260     Assert.assertEquals(1, actualRequests.size());
3261 
3262     String apiClientHeaderKey =
3263         mockService
3264             .getRequestHeaders()
3265             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3266             .iterator()
3267             .next();
3268     Assert.assertTrue(
3269         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3270             .matcher(apiClientHeaderKey)
3271             .matches());
3272   }
3273 
3274   @Test
listCustomMetricsExceptionTest()3275   public void listCustomMetricsExceptionTest() throws Exception {
3276     ApiException exception =
3277         ApiExceptionFactory.createException(
3278             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3279     mockService.addException(exception);
3280 
3281     try {
3282       PropertyName parent = PropertyName.of("[PROPERTY]");
3283       client.listCustomMetrics(parent);
3284       Assert.fail("No exception raised");
3285     } catch (InvalidArgumentException e) {
3286       // Expected exception.
3287     }
3288   }
3289 
3290   @Test
listCustomMetricsTest2()3291   public void listCustomMetricsTest2() throws Exception {
3292     CustomMetric responsesElement = CustomMetric.newBuilder().build();
3293     ListCustomMetricsResponse expectedResponse =
3294         ListCustomMetricsResponse.newBuilder()
3295             .setNextPageToken("")
3296             .addAllCustomMetrics(Arrays.asList(responsesElement))
3297             .build();
3298     mockService.addResponse(expectedResponse);
3299 
3300     String parent = "properties/propertie-2024";
3301 
3302     ListCustomMetricsPagedResponse pagedListResponse = client.listCustomMetrics(parent);
3303 
3304     List<CustomMetric> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3305 
3306     Assert.assertEquals(1, resources.size());
3307     Assert.assertEquals(expectedResponse.getCustomMetricsList().get(0), resources.get(0));
3308 
3309     List<String> actualRequests = mockService.getRequestPaths();
3310     Assert.assertEquals(1, actualRequests.size());
3311 
3312     String apiClientHeaderKey =
3313         mockService
3314             .getRequestHeaders()
3315             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3316             .iterator()
3317             .next();
3318     Assert.assertTrue(
3319         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3320             .matcher(apiClientHeaderKey)
3321             .matches());
3322   }
3323 
3324   @Test
listCustomMetricsExceptionTest2()3325   public void listCustomMetricsExceptionTest2() throws Exception {
3326     ApiException exception =
3327         ApiExceptionFactory.createException(
3328             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3329     mockService.addException(exception);
3330 
3331     try {
3332       String parent = "properties/propertie-2024";
3333       client.listCustomMetrics(parent);
3334       Assert.fail("No exception raised");
3335     } catch (InvalidArgumentException e) {
3336       // Expected exception.
3337     }
3338   }
3339 
3340   @Test
archiveCustomMetricTest()3341   public void archiveCustomMetricTest() throws Exception {
3342     Empty expectedResponse = Empty.newBuilder().build();
3343     mockService.addResponse(expectedResponse);
3344 
3345     CustomMetricName name = CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]");
3346 
3347     client.archiveCustomMetric(name);
3348 
3349     List<String> actualRequests = mockService.getRequestPaths();
3350     Assert.assertEquals(1, actualRequests.size());
3351 
3352     String apiClientHeaderKey =
3353         mockService
3354             .getRequestHeaders()
3355             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3356             .iterator()
3357             .next();
3358     Assert.assertTrue(
3359         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3360             .matcher(apiClientHeaderKey)
3361             .matches());
3362   }
3363 
3364   @Test
archiveCustomMetricExceptionTest()3365   public void archiveCustomMetricExceptionTest() throws Exception {
3366     ApiException exception =
3367         ApiExceptionFactory.createException(
3368             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3369     mockService.addException(exception);
3370 
3371     try {
3372       CustomMetricName name = CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]");
3373       client.archiveCustomMetric(name);
3374       Assert.fail("No exception raised");
3375     } catch (InvalidArgumentException e) {
3376       // Expected exception.
3377     }
3378   }
3379 
3380   @Test
archiveCustomMetricTest2()3381   public void archiveCustomMetricTest2() throws Exception {
3382     Empty expectedResponse = Empty.newBuilder().build();
3383     mockService.addResponse(expectedResponse);
3384 
3385     String name = "properties/propertie-2999/customMetrics/customMetric-2999";
3386 
3387     client.archiveCustomMetric(name);
3388 
3389     List<String> actualRequests = mockService.getRequestPaths();
3390     Assert.assertEquals(1, actualRequests.size());
3391 
3392     String apiClientHeaderKey =
3393         mockService
3394             .getRequestHeaders()
3395             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3396             .iterator()
3397             .next();
3398     Assert.assertTrue(
3399         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3400             .matcher(apiClientHeaderKey)
3401             .matches());
3402   }
3403 
3404   @Test
archiveCustomMetricExceptionTest2()3405   public void archiveCustomMetricExceptionTest2() throws Exception {
3406     ApiException exception =
3407         ApiExceptionFactory.createException(
3408             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3409     mockService.addException(exception);
3410 
3411     try {
3412       String name = "properties/propertie-2999/customMetrics/customMetric-2999";
3413       client.archiveCustomMetric(name);
3414       Assert.fail("No exception raised");
3415     } catch (InvalidArgumentException e) {
3416       // Expected exception.
3417     }
3418   }
3419 
3420   @Test
getCustomMetricTest()3421   public void getCustomMetricTest() throws Exception {
3422     CustomMetric expectedResponse =
3423         CustomMetric.newBuilder()
3424             .setName(CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]").toString())
3425             .setParameterName("parameterName-379607596")
3426             .setDisplayName("displayName1714148973")
3427             .setDescription("description-1724546052")
3428             .addAllRestrictedMetricType(new ArrayList<CustomMetric.RestrictedMetricType>())
3429             .build();
3430     mockService.addResponse(expectedResponse);
3431 
3432     CustomMetricName name = CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]");
3433 
3434     CustomMetric actualResponse = client.getCustomMetric(name);
3435     Assert.assertEquals(expectedResponse, actualResponse);
3436 
3437     List<String> actualRequests = mockService.getRequestPaths();
3438     Assert.assertEquals(1, actualRequests.size());
3439 
3440     String apiClientHeaderKey =
3441         mockService
3442             .getRequestHeaders()
3443             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3444             .iterator()
3445             .next();
3446     Assert.assertTrue(
3447         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3448             .matcher(apiClientHeaderKey)
3449             .matches());
3450   }
3451 
3452   @Test
getCustomMetricExceptionTest()3453   public void getCustomMetricExceptionTest() throws Exception {
3454     ApiException exception =
3455         ApiExceptionFactory.createException(
3456             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3457     mockService.addException(exception);
3458 
3459     try {
3460       CustomMetricName name = CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]");
3461       client.getCustomMetric(name);
3462       Assert.fail("No exception raised");
3463     } catch (InvalidArgumentException e) {
3464       // Expected exception.
3465     }
3466   }
3467 
3468   @Test
getCustomMetricTest2()3469   public void getCustomMetricTest2() throws Exception {
3470     CustomMetric expectedResponse =
3471         CustomMetric.newBuilder()
3472             .setName(CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]").toString())
3473             .setParameterName("parameterName-379607596")
3474             .setDisplayName("displayName1714148973")
3475             .setDescription("description-1724546052")
3476             .addAllRestrictedMetricType(new ArrayList<CustomMetric.RestrictedMetricType>())
3477             .build();
3478     mockService.addResponse(expectedResponse);
3479 
3480     String name = "properties/propertie-2999/customMetrics/customMetric-2999";
3481 
3482     CustomMetric actualResponse = client.getCustomMetric(name);
3483     Assert.assertEquals(expectedResponse, actualResponse);
3484 
3485     List<String> actualRequests = mockService.getRequestPaths();
3486     Assert.assertEquals(1, actualRequests.size());
3487 
3488     String apiClientHeaderKey =
3489         mockService
3490             .getRequestHeaders()
3491             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3492             .iterator()
3493             .next();
3494     Assert.assertTrue(
3495         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3496             .matcher(apiClientHeaderKey)
3497             .matches());
3498   }
3499 
3500   @Test
getCustomMetricExceptionTest2()3501   public void getCustomMetricExceptionTest2() throws Exception {
3502     ApiException exception =
3503         ApiExceptionFactory.createException(
3504             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3505     mockService.addException(exception);
3506 
3507     try {
3508       String name = "properties/propertie-2999/customMetrics/customMetric-2999";
3509       client.getCustomMetric(name);
3510       Assert.fail("No exception raised");
3511     } catch (InvalidArgumentException e) {
3512       // Expected exception.
3513     }
3514   }
3515 
3516   @Test
getDataRetentionSettingsTest()3517   public void getDataRetentionSettingsTest() throws Exception {
3518     DataRetentionSettings expectedResponse =
3519         DataRetentionSettings.newBuilder()
3520             .setName(DataRetentionSettingsName.of("[PROPERTY]").toString())
3521             .setResetUserDataOnNewActivity(true)
3522             .build();
3523     mockService.addResponse(expectedResponse);
3524 
3525     DataRetentionSettingsName name = DataRetentionSettingsName.of("[PROPERTY]");
3526 
3527     DataRetentionSettings actualResponse = client.getDataRetentionSettings(name);
3528     Assert.assertEquals(expectedResponse, actualResponse);
3529 
3530     List<String> actualRequests = mockService.getRequestPaths();
3531     Assert.assertEquals(1, actualRequests.size());
3532 
3533     String apiClientHeaderKey =
3534         mockService
3535             .getRequestHeaders()
3536             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3537             .iterator()
3538             .next();
3539     Assert.assertTrue(
3540         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3541             .matcher(apiClientHeaderKey)
3542             .matches());
3543   }
3544 
3545   @Test
getDataRetentionSettingsExceptionTest()3546   public void getDataRetentionSettingsExceptionTest() throws Exception {
3547     ApiException exception =
3548         ApiExceptionFactory.createException(
3549             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3550     mockService.addException(exception);
3551 
3552     try {
3553       DataRetentionSettingsName name = DataRetentionSettingsName.of("[PROPERTY]");
3554       client.getDataRetentionSettings(name);
3555       Assert.fail("No exception raised");
3556     } catch (InvalidArgumentException e) {
3557       // Expected exception.
3558     }
3559   }
3560 
3561   @Test
getDataRetentionSettingsTest2()3562   public void getDataRetentionSettingsTest2() throws Exception {
3563     DataRetentionSettings expectedResponse =
3564         DataRetentionSettings.newBuilder()
3565             .setName(DataRetentionSettingsName.of("[PROPERTY]").toString())
3566             .setResetUserDataOnNewActivity(true)
3567             .build();
3568     mockService.addResponse(expectedResponse);
3569 
3570     String name = "properties/propertie-2463/dataRetentionSettings";
3571 
3572     DataRetentionSettings actualResponse = client.getDataRetentionSettings(name);
3573     Assert.assertEquals(expectedResponse, actualResponse);
3574 
3575     List<String> actualRequests = mockService.getRequestPaths();
3576     Assert.assertEquals(1, actualRequests.size());
3577 
3578     String apiClientHeaderKey =
3579         mockService
3580             .getRequestHeaders()
3581             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3582             .iterator()
3583             .next();
3584     Assert.assertTrue(
3585         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3586             .matcher(apiClientHeaderKey)
3587             .matches());
3588   }
3589 
3590   @Test
getDataRetentionSettingsExceptionTest2()3591   public void getDataRetentionSettingsExceptionTest2() throws Exception {
3592     ApiException exception =
3593         ApiExceptionFactory.createException(
3594             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3595     mockService.addException(exception);
3596 
3597     try {
3598       String name = "properties/propertie-2463/dataRetentionSettings";
3599       client.getDataRetentionSettings(name);
3600       Assert.fail("No exception raised");
3601     } catch (InvalidArgumentException e) {
3602       // Expected exception.
3603     }
3604   }
3605 
3606   @Test
updateDataRetentionSettingsTest()3607   public void updateDataRetentionSettingsTest() throws Exception {
3608     DataRetentionSettings expectedResponse =
3609         DataRetentionSettings.newBuilder()
3610             .setName(DataRetentionSettingsName.of("[PROPERTY]").toString())
3611             .setResetUserDataOnNewActivity(true)
3612             .build();
3613     mockService.addResponse(expectedResponse);
3614 
3615     DataRetentionSettings dataRetentionSettings =
3616         DataRetentionSettings.newBuilder()
3617             .setName(DataRetentionSettingsName.of("[PROPERTY]").toString())
3618             .setResetUserDataOnNewActivity(true)
3619             .build();
3620     FieldMask updateMask = FieldMask.newBuilder().build();
3621 
3622     DataRetentionSettings actualResponse =
3623         client.updateDataRetentionSettings(dataRetentionSettings, updateMask);
3624     Assert.assertEquals(expectedResponse, actualResponse);
3625 
3626     List<String> actualRequests = mockService.getRequestPaths();
3627     Assert.assertEquals(1, actualRequests.size());
3628 
3629     String apiClientHeaderKey =
3630         mockService
3631             .getRequestHeaders()
3632             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3633             .iterator()
3634             .next();
3635     Assert.assertTrue(
3636         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3637             .matcher(apiClientHeaderKey)
3638             .matches());
3639   }
3640 
3641   @Test
updateDataRetentionSettingsExceptionTest()3642   public void updateDataRetentionSettingsExceptionTest() throws Exception {
3643     ApiException exception =
3644         ApiExceptionFactory.createException(
3645             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3646     mockService.addException(exception);
3647 
3648     try {
3649       DataRetentionSettings dataRetentionSettings =
3650           DataRetentionSettings.newBuilder()
3651               .setName(DataRetentionSettingsName.of("[PROPERTY]").toString())
3652               .setResetUserDataOnNewActivity(true)
3653               .build();
3654       FieldMask updateMask = FieldMask.newBuilder().build();
3655       client.updateDataRetentionSettings(dataRetentionSettings, updateMask);
3656       Assert.fail("No exception raised");
3657     } catch (InvalidArgumentException e) {
3658       // Expected exception.
3659     }
3660   }
3661 
3662   @Test
createDataStreamTest()3663   public void createDataStreamTest() throws Exception {
3664     DataStream expectedResponse =
3665         DataStream.newBuilder()
3666             .setName(DataStreamName.of("[PROPERTY]", "[DATA_STREAM]").toString())
3667             .setDisplayName("displayName1714148973")
3668             .setCreateTime(Timestamp.newBuilder().build())
3669             .setUpdateTime(Timestamp.newBuilder().build())
3670             .build();
3671     mockService.addResponse(expectedResponse);
3672 
3673     PropertyName parent = PropertyName.of("[PROPERTY]");
3674     DataStream dataStream = DataStream.newBuilder().build();
3675 
3676     DataStream actualResponse = client.createDataStream(parent, dataStream);
3677     Assert.assertEquals(expectedResponse, actualResponse);
3678 
3679     List<String> actualRequests = mockService.getRequestPaths();
3680     Assert.assertEquals(1, actualRequests.size());
3681 
3682     String apiClientHeaderKey =
3683         mockService
3684             .getRequestHeaders()
3685             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3686             .iterator()
3687             .next();
3688     Assert.assertTrue(
3689         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3690             .matcher(apiClientHeaderKey)
3691             .matches());
3692   }
3693 
3694   @Test
createDataStreamExceptionTest()3695   public void createDataStreamExceptionTest() throws Exception {
3696     ApiException exception =
3697         ApiExceptionFactory.createException(
3698             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3699     mockService.addException(exception);
3700 
3701     try {
3702       PropertyName parent = PropertyName.of("[PROPERTY]");
3703       DataStream dataStream = DataStream.newBuilder().build();
3704       client.createDataStream(parent, dataStream);
3705       Assert.fail("No exception raised");
3706     } catch (InvalidArgumentException e) {
3707       // Expected exception.
3708     }
3709   }
3710 
3711   @Test
createDataStreamTest2()3712   public void createDataStreamTest2() throws Exception {
3713     DataStream expectedResponse =
3714         DataStream.newBuilder()
3715             .setName(DataStreamName.of("[PROPERTY]", "[DATA_STREAM]").toString())
3716             .setDisplayName("displayName1714148973")
3717             .setCreateTime(Timestamp.newBuilder().build())
3718             .setUpdateTime(Timestamp.newBuilder().build())
3719             .build();
3720     mockService.addResponse(expectedResponse);
3721 
3722     String parent = "properties/propertie-2024";
3723     DataStream dataStream = DataStream.newBuilder().build();
3724 
3725     DataStream actualResponse = client.createDataStream(parent, dataStream);
3726     Assert.assertEquals(expectedResponse, actualResponse);
3727 
3728     List<String> actualRequests = mockService.getRequestPaths();
3729     Assert.assertEquals(1, actualRequests.size());
3730 
3731     String apiClientHeaderKey =
3732         mockService
3733             .getRequestHeaders()
3734             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3735             .iterator()
3736             .next();
3737     Assert.assertTrue(
3738         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3739             .matcher(apiClientHeaderKey)
3740             .matches());
3741   }
3742 
3743   @Test
createDataStreamExceptionTest2()3744   public void createDataStreamExceptionTest2() throws Exception {
3745     ApiException exception =
3746         ApiExceptionFactory.createException(
3747             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3748     mockService.addException(exception);
3749 
3750     try {
3751       String parent = "properties/propertie-2024";
3752       DataStream dataStream = DataStream.newBuilder().build();
3753       client.createDataStream(parent, dataStream);
3754       Assert.fail("No exception raised");
3755     } catch (InvalidArgumentException e) {
3756       // Expected exception.
3757     }
3758   }
3759 
3760   @Test
deleteDataStreamTest()3761   public void deleteDataStreamTest() throws Exception {
3762     Empty expectedResponse = Empty.newBuilder().build();
3763     mockService.addResponse(expectedResponse);
3764 
3765     DataStreamName name = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]");
3766 
3767     client.deleteDataStream(name);
3768 
3769     List<String> actualRequests = mockService.getRequestPaths();
3770     Assert.assertEquals(1, actualRequests.size());
3771 
3772     String apiClientHeaderKey =
3773         mockService
3774             .getRequestHeaders()
3775             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3776             .iterator()
3777             .next();
3778     Assert.assertTrue(
3779         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3780             .matcher(apiClientHeaderKey)
3781             .matches());
3782   }
3783 
3784   @Test
deleteDataStreamExceptionTest()3785   public void deleteDataStreamExceptionTest() throws Exception {
3786     ApiException exception =
3787         ApiExceptionFactory.createException(
3788             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3789     mockService.addException(exception);
3790 
3791     try {
3792       DataStreamName name = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]");
3793       client.deleteDataStream(name);
3794       Assert.fail("No exception raised");
3795     } catch (InvalidArgumentException e) {
3796       // Expected exception.
3797     }
3798   }
3799 
3800   @Test
deleteDataStreamTest2()3801   public void deleteDataStreamTest2() throws Exception {
3802     Empty expectedResponse = Empty.newBuilder().build();
3803     mockService.addResponse(expectedResponse);
3804 
3805     String name = "properties/propertie-9806/dataStreams/dataStream-9806";
3806 
3807     client.deleteDataStream(name);
3808 
3809     List<String> actualRequests = mockService.getRequestPaths();
3810     Assert.assertEquals(1, actualRequests.size());
3811 
3812     String apiClientHeaderKey =
3813         mockService
3814             .getRequestHeaders()
3815             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3816             .iterator()
3817             .next();
3818     Assert.assertTrue(
3819         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3820             .matcher(apiClientHeaderKey)
3821             .matches());
3822   }
3823 
3824   @Test
deleteDataStreamExceptionTest2()3825   public void deleteDataStreamExceptionTest2() throws Exception {
3826     ApiException exception =
3827         ApiExceptionFactory.createException(
3828             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3829     mockService.addException(exception);
3830 
3831     try {
3832       String name = "properties/propertie-9806/dataStreams/dataStream-9806";
3833       client.deleteDataStream(name);
3834       Assert.fail("No exception raised");
3835     } catch (InvalidArgumentException e) {
3836       // Expected exception.
3837     }
3838   }
3839 
3840   @Test
updateDataStreamTest()3841   public void updateDataStreamTest() throws Exception {
3842     DataStream expectedResponse =
3843         DataStream.newBuilder()
3844             .setName(DataStreamName.of("[PROPERTY]", "[DATA_STREAM]").toString())
3845             .setDisplayName("displayName1714148973")
3846             .setCreateTime(Timestamp.newBuilder().build())
3847             .setUpdateTime(Timestamp.newBuilder().build())
3848             .build();
3849     mockService.addResponse(expectedResponse);
3850 
3851     DataStream dataStream =
3852         DataStream.newBuilder()
3853             .setName(DataStreamName.of("[PROPERTY]", "[DATA_STREAM]").toString())
3854             .setDisplayName("displayName1714148973")
3855             .setCreateTime(Timestamp.newBuilder().build())
3856             .setUpdateTime(Timestamp.newBuilder().build())
3857             .build();
3858     FieldMask updateMask = FieldMask.newBuilder().build();
3859 
3860     DataStream actualResponse = client.updateDataStream(dataStream, updateMask);
3861     Assert.assertEquals(expectedResponse, actualResponse);
3862 
3863     List<String> actualRequests = mockService.getRequestPaths();
3864     Assert.assertEquals(1, actualRequests.size());
3865 
3866     String apiClientHeaderKey =
3867         mockService
3868             .getRequestHeaders()
3869             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3870             .iterator()
3871             .next();
3872     Assert.assertTrue(
3873         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3874             .matcher(apiClientHeaderKey)
3875             .matches());
3876   }
3877 
3878   @Test
updateDataStreamExceptionTest()3879   public void updateDataStreamExceptionTest() throws Exception {
3880     ApiException exception =
3881         ApiExceptionFactory.createException(
3882             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3883     mockService.addException(exception);
3884 
3885     try {
3886       DataStream dataStream =
3887           DataStream.newBuilder()
3888               .setName(DataStreamName.of("[PROPERTY]", "[DATA_STREAM]").toString())
3889               .setDisplayName("displayName1714148973")
3890               .setCreateTime(Timestamp.newBuilder().build())
3891               .setUpdateTime(Timestamp.newBuilder().build())
3892               .build();
3893       FieldMask updateMask = FieldMask.newBuilder().build();
3894       client.updateDataStream(dataStream, updateMask);
3895       Assert.fail("No exception raised");
3896     } catch (InvalidArgumentException e) {
3897       // Expected exception.
3898     }
3899   }
3900 
3901   @Test
listDataStreamsTest()3902   public void listDataStreamsTest() throws Exception {
3903     DataStream responsesElement = DataStream.newBuilder().build();
3904     ListDataStreamsResponse expectedResponse =
3905         ListDataStreamsResponse.newBuilder()
3906             .setNextPageToken("")
3907             .addAllDataStreams(Arrays.asList(responsesElement))
3908             .build();
3909     mockService.addResponse(expectedResponse);
3910 
3911     PropertyName parent = PropertyName.of("[PROPERTY]");
3912 
3913     ListDataStreamsPagedResponse pagedListResponse = client.listDataStreams(parent);
3914 
3915     List<DataStream> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3916 
3917     Assert.assertEquals(1, resources.size());
3918     Assert.assertEquals(expectedResponse.getDataStreamsList().get(0), resources.get(0));
3919 
3920     List<String> actualRequests = mockService.getRequestPaths();
3921     Assert.assertEquals(1, actualRequests.size());
3922 
3923     String apiClientHeaderKey =
3924         mockService
3925             .getRequestHeaders()
3926             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3927             .iterator()
3928             .next();
3929     Assert.assertTrue(
3930         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3931             .matcher(apiClientHeaderKey)
3932             .matches());
3933   }
3934 
3935   @Test
listDataStreamsExceptionTest()3936   public void listDataStreamsExceptionTest() throws Exception {
3937     ApiException exception =
3938         ApiExceptionFactory.createException(
3939             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3940     mockService.addException(exception);
3941 
3942     try {
3943       PropertyName parent = PropertyName.of("[PROPERTY]");
3944       client.listDataStreams(parent);
3945       Assert.fail("No exception raised");
3946     } catch (InvalidArgumentException e) {
3947       // Expected exception.
3948     }
3949   }
3950 
3951   @Test
listDataStreamsTest2()3952   public void listDataStreamsTest2() throws Exception {
3953     DataStream responsesElement = DataStream.newBuilder().build();
3954     ListDataStreamsResponse expectedResponse =
3955         ListDataStreamsResponse.newBuilder()
3956             .setNextPageToken("")
3957             .addAllDataStreams(Arrays.asList(responsesElement))
3958             .build();
3959     mockService.addResponse(expectedResponse);
3960 
3961     String parent = "properties/propertie-2024";
3962 
3963     ListDataStreamsPagedResponse pagedListResponse = client.listDataStreams(parent);
3964 
3965     List<DataStream> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3966 
3967     Assert.assertEquals(1, resources.size());
3968     Assert.assertEquals(expectedResponse.getDataStreamsList().get(0), resources.get(0));
3969 
3970     List<String> actualRequests = mockService.getRequestPaths();
3971     Assert.assertEquals(1, actualRequests.size());
3972 
3973     String apiClientHeaderKey =
3974         mockService
3975             .getRequestHeaders()
3976             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
3977             .iterator()
3978             .next();
3979     Assert.assertTrue(
3980         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
3981             .matcher(apiClientHeaderKey)
3982             .matches());
3983   }
3984 
3985   @Test
listDataStreamsExceptionTest2()3986   public void listDataStreamsExceptionTest2() throws Exception {
3987     ApiException exception =
3988         ApiExceptionFactory.createException(
3989             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
3990     mockService.addException(exception);
3991 
3992     try {
3993       String parent = "properties/propertie-2024";
3994       client.listDataStreams(parent);
3995       Assert.fail("No exception raised");
3996     } catch (InvalidArgumentException e) {
3997       // Expected exception.
3998     }
3999   }
4000 
4001   @Test
getDataStreamTest()4002   public void getDataStreamTest() throws Exception {
4003     DataStream expectedResponse =
4004         DataStream.newBuilder()
4005             .setName(DataStreamName.of("[PROPERTY]", "[DATA_STREAM]").toString())
4006             .setDisplayName("displayName1714148973")
4007             .setCreateTime(Timestamp.newBuilder().build())
4008             .setUpdateTime(Timestamp.newBuilder().build())
4009             .build();
4010     mockService.addResponse(expectedResponse);
4011 
4012     DataStreamName name = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]");
4013 
4014     DataStream actualResponse = client.getDataStream(name);
4015     Assert.assertEquals(expectedResponse, actualResponse);
4016 
4017     List<String> actualRequests = mockService.getRequestPaths();
4018     Assert.assertEquals(1, actualRequests.size());
4019 
4020     String apiClientHeaderKey =
4021         mockService
4022             .getRequestHeaders()
4023             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4024             .iterator()
4025             .next();
4026     Assert.assertTrue(
4027         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4028             .matcher(apiClientHeaderKey)
4029             .matches());
4030   }
4031 
4032   @Test
getDataStreamExceptionTest()4033   public void getDataStreamExceptionTest() throws Exception {
4034     ApiException exception =
4035         ApiExceptionFactory.createException(
4036             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4037     mockService.addException(exception);
4038 
4039     try {
4040       DataStreamName name = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]");
4041       client.getDataStream(name);
4042       Assert.fail("No exception raised");
4043     } catch (InvalidArgumentException e) {
4044       // Expected exception.
4045     }
4046   }
4047 
4048   @Test
getDataStreamTest2()4049   public void getDataStreamTest2() throws Exception {
4050     DataStream expectedResponse =
4051         DataStream.newBuilder()
4052             .setName(DataStreamName.of("[PROPERTY]", "[DATA_STREAM]").toString())
4053             .setDisplayName("displayName1714148973")
4054             .setCreateTime(Timestamp.newBuilder().build())
4055             .setUpdateTime(Timestamp.newBuilder().build())
4056             .build();
4057     mockService.addResponse(expectedResponse);
4058 
4059     String name = "properties/propertie-9806/dataStreams/dataStream-9806";
4060 
4061     DataStream actualResponse = client.getDataStream(name);
4062     Assert.assertEquals(expectedResponse, actualResponse);
4063 
4064     List<String> actualRequests = mockService.getRequestPaths();
4065     Assert.assertEquals(1, actualRequests.size());
4066 
4067     String apiClientHeaderKey =
4068         mockService
4069             .getRequestHeaders()
4070             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4071             .iterator()
4072             .next();
4073     Assert.assertTrue(
4074         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4075             .matcher(apiClientHeaderKey)
4076             .matches());
4077   }
4078 
4079   @Test
getDataStreamExceptionTest2()4080   public void getDataStreamExceptionTest2() throws Exception {
4081     ApiException exception =
4082         ApiExceptionFactory.createException(
4083             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4084     mockService.addException(exception);
4085 
4086     try {
4087       String name = "properties/propertie-9806/dataStreams/dataStream-9806";
4088       client.getDataStream(name);
4089       Assert.fail("No exception raised");
4090     } catch (InvalidArgumentException e) {
4091       // Expected exception.
4092     }
4093   }
4094 
4095   @Test
runAccessReportTest()4096   public void runAccessReportTest() throws Exception {
4097     RunAccessReportResponse expectedResponse =
4098         RunAccessReportResponse.newBuilder()
4099             .addAllDimensionHeaders(new ArrayList<AccessDimensionHeader>())
4100             .addAllMetricHeaders(new ArrayList<AccessMetricHeader>())
4101             .addAllRows(new ArrayList<AccessRow>())
4102             .setRowCount(1340416618)
4103             .setQuota(AccessQuota.newBuilder().build())
4104             .build();
4105     mockService.addResponse(expectedResponse);
4106 
4107     RunAccessReportRequest request =
4108         RunAccessReportRequest.newBuilder()
4109             .setEntity("properties/propertie-4993")
4110             .addAllDimensions(new ArrayList<AccessDimension>())
4111             .addAllMetrics(new ArrayList<AccessMetric>())
4112             .addAllDateRanges(new ArrayList<AccessDateRange>())
4113             .setDimensionFilter(AccessFilterExpression.newBuilder().build())
4114             .setMetricFilter(AccessFilterExpression.newBuilder().build())
4115             .setOffset(-1019779949)
4116             .setLimit(102976443)
4117             .setTimeZone("timeZone-2077180903")
4118             .addAllOrderBys(new ArrayList<AccessOrderBy>())
4119             .setReturnEntityQuota(true)
4120             .build();
4121 
4122     RunAccessReportResponse actualResponse = client.runAccessReport(request);
4123     Assert.assertEquals(expectedResponse, actualResponse);
4124 
4125     List<String> actualRequests = mockService.getRequestPaths();
4126     Assert.assertEquals(1, actualRequests.size());
4127 
4128     String apiClientHeaderKey =
4129         mockService
4130             .getRequestHeaders()
4131             .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
4132             .iterator()
4133             .next();
4134     Assert.assertTrue(
4135         GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
4136             .matcher(apiClientHeaderKey)
4137             .matches());
4138   }
4139 
4140   @Test
runAccessReportExceptionTest()4141   public void runAccessReportExceptionTest() throws Exception {
4142     ApiException exception =
4143         ApiExceptionFactory.createException(
4144             new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
4145     mockService.addException(exception);
4146 
4147     try {
4148       RunAccessReportRequest request =
4149           RunAccessReportRequest.newBuilder()
4150               .setEntity("properties/propertie-4993")
4151               .addAllDimensions(new ArrayList<AccessDimension>())
4152               .addAllMetrics(new ArrayList<AccessMetric>())
4153               .addAllDateRanges(new ArrayList<AccessDateRange>())
4154               .setDimensionFilter(AccessFilterExpression.newBuilder().build())
4155               .setMetricFilter(AccessFilterExpression.newBuilder().build())
4156               .setOffset(-1019779949)
4157               .setLimit(102976443)
4158               .setTimeZone("timeZone-2077180903")
4159               .addAllOrderBys(new ArrayList<AccessOrderBy>())
4160               .setReturnEntityQuota(true)
4161               .build();
4162       client.runAccessReport(request);
4163       Assert.fail("No exception raised");
4164     } catch (InvalidArgumentException e) {
4165       // Expected exception.
4166     }
4167   }
4168 }
4169