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.v1alpha; 18 19 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.AuditUserLinksPagedResponse; 20 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListAccessBindingsPagedResponse; 21 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListAccountSummariesPagedResponse; 22 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListAccountsPagedResponse; 23 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListAudiencesPagedResponse; 24 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListBigQueryLinksPagedResponse; 25 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListChannelGroupsPagedResponse; 26 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListConversionEventsPagedResponse; 27 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListCustomDimensionsPagedResponse; 28 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListCustomMetricsPagedResponse; 29 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListDataStreamsPagedResponse; 30 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListDisplayVideo360AdvertiserLinkProposalsPagedResponse; 31 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListDisplayVideo360AdvertiserLinksPagedResponse; 32 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListExpandedDataSetsPagedResponse; 33 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListFirebaseLinksPagedResponse; 34 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListGoogleAdsLinksPagedResponse; 35 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListMeasurementProtocolSecretsPagedResponse; 36 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListPropertiesPagedResponse; 37 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListSearchAds360LinksPagedResponse; 38 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.ListUserLinksPagedResponse; 39 import static com.google.analytics.admin.v1alpha.AnalyticsAdminServiceClient.SearchChangeHistoryEventsPagedResponse; 40 41 import com.google.analytics.admin.v1alpha.stub.HttpJsonAnalyticsAdminServiceStub; 42 import com.google.api.gax.core.NoCredentialsProvider; 43 import com.google.api.gax.httpjson.GaxHttpJsonProperties; 44 import com.google.api.gax.httpjson.testing.MockHttpService; 45 import com.google.api.gax.rpc.ApiClientHeaderProvider; 46 import com.google.api.gax.rpc.ApiException; 47 import com.google.api.gax.rpc.ApiExceptionFactory; 48 import com.google.api.gax.rpc.InvalidArgumentException; 49 import com.google.api.gax.rpc.StatusCode; 50 import com.google.api.gax.rpc.testing.FakeStatusCode; 51 import com.google.common.collect.Lists; 52 import com.google.protobuf.BoolValue; 53 import com.google.protobuf.Empty; 54 import com.google.protobuf.FieldMask; 55 import com.google.protobuf.Timestamp; 56 import java.io.IOException; 57 import java.util.ArrayList; 58 import java.util.Arrays; 59 import java.util.List; 60 import javax.annotation.Generated; 61 import org.junit.After; 62 import org.junit.AfterClass; 63 import org.junit.Assert; 64 import org.junit.Before; 65 import org.junit.BeforeClass; 66 import org.junit.Test; 67 68 @Generated("by gapic-generator-java") 69 public class AnalyticsAdminServiceClientHttpJsonTest { 70 private static MockHttpService mockService; 71 private static AnalyticsAdminServiceClient client; 72 73 @BeforeClass startStaticServer()74 public static void startStaticServer() throws IOException { 75 mockService = 76 new MockHttpService( 77 HttpJsonAnalyticsAdminServiceStub.getMethodDescriptors(), 78 AnalyticsAdminServiceSettings.getDefaultEndpoint()); 79 AnalyticsAdminServiceSettings settings = 80 AnalyticsAdminServiceSettings.newHttpJsonBuilder() 81 .setTransportChannelProvider( 82 AnalyticsAdminServiceSettings.defaultHttpJsonTransportProviderBuilder() 83 .setHttpTransport(mockService) 84 .build()) 85 .setCredentialsProvider(NoCredentialsProvider.create()) 86 .build(); 87 client = AnalyticsAdminServiceClient.create(settings); 88 } 89 90 @AfterClass stopServer()91 public static void stopServer() { 92 client.close(); 93 } 94 95 @Before setUp()96 public void setUp() {} 97 98 @After tearDown()99 public void tearDown() throws Exception { 100 mockService.reset(); 101 } 102 103 @Test getAccountTest()104 public void getAccountTest() throws Exception { 105 Account expectedResponse = 106 Account.newBuilder() 107 .setName(AccountName.of("[ACCOUNT]").toString()) 108 .setCreateTime(Timestamp.newBuilder().build()) 109 .setUpdateTime(Timestamp.newBuilder().build()) 110 .setDisplayName("displayName1714148973") 111 .setRegionCode("regionCode-1991004415") 112 .setDeleted(true) 113 .build(); 114 mockService.addResponse(expectedResponse); 115 116 AccountName name = AccountName.of("[ACCOUNT]"); 117 118 Account actualResponse = client.getAccount(name); 119 Assert.assertEquals(expectedResponse, actualResponse); 120 121 List<String> actualRequests = mockService.getRequestPaths(); 122 Assert.assertEquals(1, actualRequests.size()); 123 124 String apiClientHeaderKey = 125 mockService 126 .getRequestHeaders() 127 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 128 .iterator() 129 .next(); 130 Assert.assertTrue( 131 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 132 .matcher(apiClientHeaderKey) 133 .matches()); 134 } 135 136 @Test getAccountExceptionTest()137 public void getAccountExceptionTest() throws Exception { 138 ApiException exception = 139 ApiExceptionFactory.createException( 140 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 141 mockService.addException(exception); 142 143 try { 144 AccountName name = AccountName.of("[ACCOUNT]"); 145 client.getAccount(name); 146 Assert.fail("No exception raised"); 147 } catch (InvalidArgumentException e) { 148 // Expected exception. 149 } 150 } 151 152 @Test getAccountTest2()153 public void getAccountTest2() throws Exception { 154 Account expectedResponse = 155 Account.newBuilder() 156 .setName(AccountName.of("[ACCOUNT]").toString()) 157 .setCreateTime(Timestamp.newBuilder().build()) 158 .setUpdateTime(Timestamp.newBuilder().build()) 159 .setDisplayName("displayName1714148973") 160 .setRegionCode("regionCode-1991004415") 161 .setDeleted(true) 162 .build(); 163 mockService.addResponse(expectedResponse); 164 165 String name = "accounts/account-3500"; 166 167 Account actualResponse = client.getAccount(name); 168 Assert.assertEquals(expectedResponse, actualResponse); 169 170 List<String> actualRequests = mockService.getRequestPaths(); 171 Assert.assertEquals(1, actualRequests.size()); 172 173 String apiClientHeaderKey = 174 mockService 175 .getRequestHeaders() 176 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 177 .iterator() 178 .next(); 179 Assert.assertTrue( 180 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 181 .matcher(apiClientHeaderKey) 182 .matches()); 183 } 184 185 @Test getAccountExceptionTest2()186 public void getAccountExceptionTest2() throws Exception { 187 ApiException exception = 188 ApiExceptionFactory.createException( 189 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 190 mockService.addException(exception); 191 192 try { 193 String name = "accounts/account-3500"; 194 client.getAccount(name); 195 Assert.fail("No exception raised"); 196 } catch (InvalidArgumentException e) { 197 // Expected exception. 198 } 199 } 200 201 @Test listAccountsTest()202 public void listAccountsTest() throws Exception { 203 Account responsesElement = Account.newBuilder().build(); 204 ListAccountsResponse expectedResponse = 205 ListAccountsResponse.newBuilder() 206 .setNextPageToken("") 207 .addAllAccounts(Arrays.asList(responsesElement)) 208 .build(); 209 mockService.addResponse(expectedResponse); 210 211 ListAccountsRequest request = 212 ListAccountsRequest.newBuilder() 213 .setPageSize(883849137) 214 .setPageToken("pageToken873572522") 215 .setShowDeleted(true) 216 .build(); 217 218 ListAccountsPagedResponse pagedListResponse = client.listAccounts(request); 219 220 List<Account> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 221 222 Assert.assertEquals(1, resources.size()); 223 Assert.assertEquals(expectedResponse.getAccountsList().get(0), resources.get(0)); 224 225 List<String> actualRequests = mockService.getRequestPaths(); 226 Assert.assertEquals(1, actualRequests.size()); 227 228 String apiClientHeaderKey = 229 mockService 230 .getRequestHeaders() 231 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 232 .iterator() 233 .next(); 234 Assert.assertTrue( 235 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 236 .matcher(apiClientHeaderKey) 237 .matches()); 238 } 239 240 @Test listAccountsExceptionTest()241 public void listAccountsExceptionTest() throws Exception { 242 ApiException exception = 243 ApiExceptionFactory.createException( 244 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 245 mockService.addException(exception); 246 247 try { 248 ListAccountsRequest request = 249 ListAccountsRequest.newBuilder() 250 .setPageSize(883849137) 251 .setPageToken("pageToken873572522") 252 .setShowDeleted(true) 253 .build(); 254 client.listAccounts(request); 255 Assert.fail("No exception raised"); 256 } catch (InvalidArgumentException e) { 257 // Expected exception. 258 } 259 } 260 261 @Test deleteAccountTest()262 public void deleteAccountTest() throws Exception { 263 Empty expectedResponse = Empty.newBuilder().build(); 264 mockService.addResponse(expectedResponse); 265 266 AccountName name = AccountName.of("[ACCOUNT]"); 267 268 client.deleteAccount(name); 269 270 List<String> actualRequests = mockService.getRequestPaths(); 271 Assert.assertEquals(1, actualRequests.size()); 272 273 String apiClientHeaderKey = 274 mockService 275 .getRequestHeaders() 276 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 277 .iterator() 278 .next(); 279 Assert.assertTrue( 280 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 281 .matcher(apiClientHeaderKey) 282 .matches()); 283 } 284 285 @Test deleteAccountExceptionTest()286 public void deleteAccountExceptionTest() throws Exception { 287 ApiException exception = 288 ApiExceptionFactory.createException( 289 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 290 mockService.addException(exception); 291 292 try { 293 AccountName name = AccountName.of("[ACCOUNT]"); 294 client.deleteAccount(name); 295 Assert.fail("No exception raised"); 296 } catch (InvalidArgumentException e) { 297 // Expected exception. 298 } 299 } 300 301 @Test deleteAccountTest2()302 public void deleteAccountTest2() throws Exception { 303 Empty expectedResponse = Empty.newBuilder().build(); 304 mockService.addResponse(expectedResponse); 305 306 String name = "accounts/account-3500"; 307 308 client.deleteAccount(name); 309 310 List<String> actualRequests = mockService.getRequestPaths(); 311 Assert.assertEquals(1, actualRequests.size()); 312 313 String apiClientHeaderKey = 314 mockService 315 .getRequestHeaders() 316 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 317 .iterator() 318 .next(); 319 Assert.assertTrue( 320 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 321 .matcher(apiClientHeaderKey) 322 .matches()); 323 } 324 325 @Test deleteAccountExceptionTest2()326 public void deleteAccountExceptionTest2() throws Exception { 327 ApiException exception = 328 ApiExceptionFactory.createException( 329 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 330 mockService.addException(exception); 331 332 try { 333 String name = "accounts/account-3500"; 334 client.deleteAccount(name); 335 Assert.fail("No exception raised"); 336 } catch (InvalidArgumentException e) { 337 // Expected exception. 338 } 339 } 340 341 @Test updateAccountTest()342 public void updateAccountTest() throws Exception { 343 Account expectedResponse = 344 Account.newBuilder() 345 .setName(AccountName.of("[ACCOUNT]").toString()) 346 .setCreateTime(Timestamp.newBuilder().build()) 347 .setUpdateTime(Timestamp.newBuilder().build()) 348 .setDisplayName("displayName1714148973") 349 .setRegionCode("regionCode-1991004415") 350 .setDeleted(true) 351 .build(); 352 mockService.addResponse(expectedResponse); 353 354 Account account = 355 Account.newBuilder() 356 .setName(AccountName.of("[ACCOUNT]").toString()) 357 .setCreateTime(Timestamp.newBuilder().build()) 358 .setUpdateTime(Timestamp.newBuilder().build()) 359 .setDisplayName("displayName1714148973") 360 .setRegionCode("regionCode-1991004415") 361 .setDeleted(true) 362 .build(); 363 FieldMask updateMask = FieldMask.newBuilder().build(); 364 365 Account actualResponse = client.updateAccount(account, updateMask); 366 Assert.assertEquals(expectedResponse, actualResponse); 367 368 List<String> actualRequests = mockService.getRequestPaths(); 369 Assert.assertEquals(1, actualRequests.size()); 370 371 String apiClientHeaderKey = 372 mockService 373 .getRequestHeaders() 374 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 375 .iterator() 376 .next(); 377 Assert.assertTrue( 378 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 379 .matcher(apiClientHeaderKey) 380 .matches()); 381 } 382 383 @Test updateAccountExceptionTest()384 public void updateAccountExceptionTest() throws Exception { 385 ApiException exception = 386 ApiExceptionFactory.createException( 387 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 388 mockService.addException(exception); 389 390 try { 391 Account account = 392 Account.newBuilder() 393 .setName(AccountName.of("[ACCOUNT]").toString()) 394 .setCreateTime(Timestamp.newBuilder().build()) 395 .setUpdateTime(Timestamp.newBuilder().build()) 396 .setDisplayName("displayName1714148973") 397 .setRegionCode("regionCode-1991004415") 398 .setDeleted(true) 399 .build(); 400 FieldMask updateMask = FieldMask.newBuilder().build(); 401 client.updateAccount(account, updateMask); 402 Assert.fail("No exception raised"); 403 } catch (InvalidArgumentException e) { 404 // Expected exception. 405 } 406 } 407 408 @Test provisionAccountTicketTest()409 public void provisionAccountTicketTest() throws Exception { 410 ProvisionAccountTicketResponse expectedResponse = 411 ProvisionAccountTicketResponse.newBuilder() 412 .setAccountTicketId("accountTicketId-1576709484") 413 .build(); 414 mockService.addResponse(expectedResponse); 415 416 ProvisionAccountTicketRequest request = 417 ProvisionAccountTicketRequest.newBuilder() 418 .setAccount(Account.newBuilder().build()) 419 .setRedirectUri("redirectUri1970337776") 420 .build(); 421 422 ProvisionAccountTicketResponse actualResponse = client.provisionAccountTicket(request); 423 Assert.assertEquals(expectedResponse, actualResponse); 424 425 List<String> actualRequests = mockService.getRequestPaths(); 426 Assert.assertEquals(1, actualRequests.size()); 427 428 String apiClientHeaderKey = 429 mockService 430 .getRequestHeaders() 431 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 432 .iterator() 433 .next(); 434 Assert.assertTrue( 435 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 436 .matcher(apiClientHeaderKey) 437 .matches()); 438 } 439 440 @Test provisionAccountTicketExceptionTest()441 public void provisionAccountTicketExceptionTest() throws Exception { 442 ApiException exception = 443 ApiExceptionFactory.createException( 444 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 445 mockService.addException(exception); 446 447 try { 448 ProvisionAccountTicketRequest request = 449 ProvisionAccountTicketRequest.newBuilder() 450 .setAccount(Account.newBuilder().build()) 451 .setRedirectUri("redirectUri1970337776") 452 .build(); 453 client.provisionAccountTicket(request); 454 Assert.fail("No exception raised"); 455 } catch (InvalidArgumentException e) { 456 // Expected exception. 457 } 458 } 459 460 @Test listAccountSummariesTest()461 public void listAccountSummariesTest() throws Exception { 462 AccountSummary responsesElement = AccountSummary.newBuilder().build(); 463 ListAccountSummariesResponse expectedResponse = 464 ListAccountSummariesResponse.newBuilder() 465 .setNextPageToken("") 466 .addAllAccountSummaries(Arrays.asList(responsesElement)) 467 .build(); 468 mockService.addResponse(expectedResponse); 469 470 ListAccountSummariesRequest request = 471 ListAccountSummariesRequest.newBuilder() 472 .setPageSize(883849137) 473 .setPageToken("pageToken873572522") 474 .build(); 475 476 ListAccountSummariesPagedResponse pagedListResponse = client.listAccountSummaries(request); 477 478 List<AccountSummary> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 479 480 Assert.assertEquals(1, resources.size()); 481 Assert.assertEquals(expectedResponse.getAccountSummariesList().get(0), resources.get(0)); 482 483 List<String> actualRequests = mockService.getRequestPaths(); 484 Assert.assertEquals(1, actualRequests.size()); 485 486 String apiClientHeaderKey = 487 mockService 488 .getRequestHeaders() 489 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 490 .iterator() 491 .next(); 492 Assert.assertTrue( 493 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 494 .matcher(apiClientHeaderKey) 495 .matches()); 496 } 497 498 @Test listAccountSummariesExceptionTest()499 public void listAccountSummariesExceptionTest() throws Exception { 500 ApiException exception = 501 ApiExceptionFactory.createException( 502 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 503 mockService.addException(exception); 504 505 try { 506 ListAccountSummariesRequest request = 507 ListAccountSummariesRequest.newBuilder() 508 .setPageSize(883849137) 509 .setPageToken("pageToken873572522") 510 .build(); 511 client.listAccountSummaries(request); 512 Assert.fail("No exception raised"); 513 } catch (InvalidArgumentException e) { 514 // Expected exception. 515 } 516 } 517 518 @Test getPropertyTest()519 public void getPropertyTest() throws Exception { 520 Property expectedResponse = 521 Property.newBuilder() 522 .setName(PropertyName.of("[PROPERTY]").toString()) 523 .setPropertyType(PropertyType.forNumber(0)) 524 .setCreateTime(Timestamp.newBuilder().build()) 525 .setUpdateTime(Timestamp.newBuilder().build()) 526 .setParent("parent-995424086") 527 .setDisplayName("displayName1714148973") 528 .setIndustryCategory(IndustryCategory.forNumber(0)) 529 .setTimeZone("timeZone-2077180903") 530 .setCurrencyCode("currencyCode1004773790") 531 .setServiceLevel(ServiceLevel.forNumber(0)) 532 .setDeleteTime(Timestamp.newBuilder().build()) 533 .setExpireTime(Timestamp.newBuilder().build()) 534 .setAccount(AccountName.of("[ACCOUNT]").toString()) 535 .build(); 536 mockService.addResponse(expectedResponse); 537 538 PropertyName name = PropertyName.of("[PROPERTY]"); 539 540 Property actualResponse = client.getProperty(name); 541 Assert.assertEquals(expectedResponse, actualResponse); 542 543 List<String> actualRequests = mockService.getRequestPaths(); 544 Assert.assertEquals(1, actualRequests.size()); 545 546 String apiClientHeaderKey = 547 mockService 548 .getRequestHeaders() 549 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 550 .iterator() 551 .next(); 552 Assert.assertTrue( 553 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 554 .matcher(apiClientHeaderKey) 555 .matches()); 556 } 557 558 @Test getPropertyExceptionTest()559 public void getPropertyExceptionTest() throws Exception { 560 ApiException exception = 561 ApiExceptionFactory.createException( 562 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 563 mockService.addException(exception); 564 565 try { 566 PropertyName name = PropertyName.of("[PROPERTY]"); 567 client.getProperty(name); 568 Assert.fail("No exception raised"); 569 } catch (InvalidArgumentException e) { 570 // Expected exception. 571 } 572 } 573 574 @Test getPropertyTest2()575 public void getPropertyTest2() throws Exception { 576 Property expectedResponse = 577 Property.newBuilder() 578 .setName(PropertyName.of("[PROPERTY]").toString()) 579 .setPropertyType(PropertyType.forNumber(0)) 580 .setCreateTime(Timestamp.newBuilder().build()) 581 .setUpdateTime(Timestamp.newBuilder().build()) 582 .setParent("parent-995424086") 583 .setDisplayName("displayName1714148973") 584 .setIndustryCategory(IndustryCategory.forNumber(0)) 585 .setTimeZone("timeZone-2077180903") 586 .setCurrencyCode("currencyCode1004773790") 587 .setServiceLevel(ServiceLevel.forNumber(0)) 588 .setDeleteTime(Timestamp.newBuilder().build()) 589 .setExpireTime(Timestamp.newBuilder().build()) 590 .setAccount(AccountName.of("[ACCOUNT]").toString()) 591 .build(); 592 mockService.addResponse(expectedResponse); 593 594 String name = "properties/propertie-7337"; 595 596 Property actualResponse = client.getProperty(name); 597 Assert.assertEquals(expectedResponse, actualResponse); 598 599 List<String> actualRequests = mockService.getRequestPaths(); 600 Assert.assertEquals(1, actualRequests.size()); 601 602 String apiClientHeaderKey = 603 mockService 604 .getRequestHeaders() 605 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 606 .iterator() 607 .next(); 608 Assert.assertTrue( 609 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 610 .matcher(apiClientHeaderKey) 611 .matches()); 612 } 613 614 @Test getPropertyExceptionTest2()615 public void getPropertyExceptionTest2() throws Exception { 616 ApiException exception = 617 ApiExceptionFactory.createException( 618 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 619 mockService.addException(exception); 620 621 try { 622 String name = "properties/propertie-7337"; 623 client.getProperty(name); 624 Assert.fail("No exception raised"); 625 } catch (InvalidArgumentException e) { 626 // Expected exception. 627 } 628 } 629 630 @Test listPropertiesTest()631 public void listPropertiesTest() throws Exception { 632 Property responsesElement = Property.newBuilder().build(); 633 ListPropertiesResponse expectedResponse = 634 ListPropertiesResponse.newBuilder() 635 .setNextPageToken("") 636 .addAllProperties(Arrays.asList(responsesElement)) 637 .build(); 638 mockService.addResponse(expectedResponse); 639 640 ListPropertiesRequest request = 641 ListPropertiesRequest.newBuilder() 642 .setFilter("filter-1274492040") 643 .setPageSize(883849137) 644 .setPageToken("pageToken873572522") 645 .setShowDeleted(true) 646 .build(); 647 648 ListPropertiesPagedResponse pagedListResponse = client.listProperties(request); 649 650 List<Property> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 651 652 Assert.assertEquals(1, resources.size()); 653 Assert.assertEquals(expectedResponse.getPropertiesList().get(0), resources.get(0)); 654 655 List<String> actualRequests = mockService.getRequestPaths(); 656 Assert.assertEquals(1, actualRequests.size()); 657 658 String apiClientHeaderKey = 659 mockService 660 .getRequestHeaders() 661 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 662 .iterator() 663 .next(); 664 Assert.assertTrue( 665 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 666 .matcher(apiClientHeaderKey) 667 .matches()); 668 } 669 670 @Test listPropertiesExceptionTest()671 public void listPropertiesExceptionTest() throws Exception { 672 ApiException exception = 673 ApiExceptionFactory.createException( 674 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 675 mockService.addException(exception); 676 677 try { 678 ListPropertiesRequest request = 679 ListPropertiesRequest.newBuilder() 680 .setFilter("filter-1274492040") 681 .setPageSize(883849137) 682 .setPageToken("pageToken873572522") 683 .setShowDeleted(true) 684 .build(); 685 client.listProperties(request); 686 Assert.fail("No exception raised"); 687 } catch (InvalidArgumentException e) { 688 // Expected exception. 689 } 690 } 691 692 @Test createPropertyTest()693 public void createPropertyTest() throws Exception { 694 Property expectedResponse = 695 Property.newBuilder() 696 .setName(PropertyName.of("[PROPERTY]").toString()) 697 .setPropertyType(PropertyType.forNumber(0)) 698 .setCreateTime(Timestamp.newBuilder().build()) 699 .setUpdateTime(Timestamp.newBuilder().build()) 700 .setParent("parent-995424086") 701 .setDisplayName("displayName1714148973") 702 .setIndustryCategory(IndustryCategory.forNumber(0)) 703 .setTimeZone("timeZone-2077180903") 704 .setCurrencyCode("currencyCode1004773790") 705 .setServiceLevel(ServiceLevel.forNumber(0)) 706 .setDeleteTime(Timestamp.newBuilder().build()) 707 .setExpireTime(Timestamp.newBuilder().build()) 708 .setAccount(AccountName.of("[ACCOUNT]").toString()) 709 .build(); 710 mockService.addResponse(expectedResponse); 711 712 Property property = Property.newBuilder().build(); 713 714 Property actualResponse = client.createProperty(property); 715 Assert.assertEquals(expectedResponse, actualResponse); 716 717 List<String> actualRequests = mockService.getRequestPaths(); 718 Assert.assertEquals(1, actualRequests.size()); 719 720 String apiClientHeaderKey = 721 mockService 722 .getRequestHeaders() 723 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 724 .iterator() 725 .next(); 726 Assert.assertTrue( 727 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 728 .matcher(apiClientHeaderKey) 729 .matches()); 730 } 731 732 @Test createPropertyExceptionTest()733 public void createPropertyExceptionTest() throws Exception { 734 ApiException exception = 735 ApiExceptionFactory.createException( 736 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 737 mockService.addException(exception); 738 739 try { 740 Property property = Property.newBuilder().build(); 741 client.createProperty(property); 742 Assert.fail("No exception raised"); 743 } catch (InvalidArgumentException e) { 744 // Expected exception. 745 } 746 } 747 748 @Test deletePropertyTest()749 public void deletePropertyTest() throws Exception { 750 Property expectedResponse = 751 Property.newBuilder() 752 .setName(PropertyName.of("[PROPERTY]").toString()) 753 .setPropertyType(PropertyType.forNumber(0)) 754 .setCreateTime(Timestamp.newBuilder().build()) 755 .setUpdateTime(Timestamp.newBuilder().build()) 756 .setParent("parent-995424086") 757 .setDisplayName("displayName1714148973") 758 .setIndustryCategory(IndustryCategory.forNumber(0)) 759 .setTimeZone("timeZone-2077180903") 760 .setCurrencyCode("currencyCode1004773790") 761 .setServiceLevel(ServiceLevel.forNumber(0)) 762 .setDeleteTime(Timestamp.newBuilder().build()) 763 .setExpireTime(Timestamp.newBuilder().build()) 764 .setAccount(AccountName.of("[ACCOUNT]").toString()) 765 .build(); 766 mockService.addResponse(expectedResponse); 767 768 PropertyName name = PropertyName.of("[PROPERTY]"); 769 770 Property actualResponse = client.deleteProperty(name); 771 Assert.assertEquals(expectedResponse, actualResponse); 772 773 List<String> actualRequests = mockService.getRequestPaths(); 774 Assert.assertEquals(1, actualRequests.size()); 775 776 String apiClientHeaderKey = 777 mockService 778 .getRequestHeaders() 779 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 780 .iterator() 781 .next(); 782 Assert.assertTrue( 783 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 784 .matcher(apiClientHeaderKey) 785 .matches()); 786 } 787 788 @Test deletePropertyExceptionTest()789 public void deletePropertyExceptionTest() throws Exception { 790 ApiException exception = 791 ApiExceptionFactory.createException( 792 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 793 mockService.addException(exception); 794 795 try { 796 PropertyName name = PropertyName.of("[PROPERTY]"); 797 client.deleteProperty(name); 798 Assert.fail("No exception raised"); 799 } catch (InvalidArgumentException e) { 800 // Expected exception. 801 } 802 } 803 804 @Test deletePropertyTest2()805 public void deletePropertyTest2() throws Exception { 806 Property expectedResponse = 807 Property.newBuilder() 808 .setName(PropertyName.of("[PROPERTY]").toString()) 809 .setPropertyType(PropertyType.forNumber(0)) 810 .setCreateTime(Timestamp.newBuilder().build()) 811 .setUpdateTime(Timestamp.newBuilder().build()) 812 .setParent("parent-995424086") 813 .setDisplayName("displayName1714148973") 814 .setIndustryCategory(IndustryCategory.forNumber(0)) 815 .setTimeZone("timeZone-2077180903") 816 .setCurrencyCode("currencyCode1004773790") 817 .setServiceLevel(ServiceLevel.forNumber(0)) 818 .setDeleteTime(Timestamp.newBuilder().build()) 819 .setExpireTime(Timestamp.newBuilder().build()) 820 .setAccount(AccountName.of("[ACCOUNT]").toString()) 821 .build(); 822 mockService.addResponse(expectedResponse); 823 824 String name = "properties/propertie-7337"; 825 826 Property actualResponse = client.deleteProperty(name); 827 Assert.assertEquals(expectedResponse, actualResponse); 828 829 List<String> actualRequests = mockService.getRequestPaths(); 830 Assert.assertEquals(1, actualRequests.size()); 831 832 String apiClientHeaderKey = 833 mockService 834 .getRequestHeaders() 835 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 836 .iterator() 837 .next(); 838 Assert.assertTrue( 839 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 840 .matcher(apiClientHeaderKey) 841 .matches()); 842 } 843 844 @Test deletePropertyExceptionTest2()845 public void deletePropertyExceptionTest2() throws Exception { 846 ApiException exception = 847 ApiExceptionFactory.createException( 848 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 849 mockService.addException(exception); 850 851 try { 852 String name = "properties/propertie-7337"; 853 client.deleteProperty(name); 854 Assert.fail("No exception raised"); 855 } catch (InvalidArgumentException e) { 856 // Expected exception. 857 } 858 } 859 860 @Test updatePropertyTest()861 public void updatePropertyTest() throws Exception { 862 Property expectedResponse = 863 Property.newBuilder() 864 .setName(PropertyName.of("[PROPERTY]").toString()) 865 .setPropertyType(PropertyType.forNumber(0)) 866 .setCreateTime(Timestamp.newBuilder().build()) 867 .setUpdateTime(Timestamp.newBuilder().build()) 868 .setParent("parent-995424086") 869 .setDisplayName("displayName1714148973") 870 .setIndustryCategory(IndustryCategory.forNumber(0)) 871 .setTimeZone("timeZone-2077180903") 872 .setCurrencyCode("currencyCode1004773790") 873 .setServiceLevel(ServiceLevel.forNumber(0)) 874 .setDeleteTime(Timestamp.newBuilder().build()) 875 .setExpireTime(Timestamp.newBuilder().build()) 876 .setAccount(AccountName.of("[ACCOUNT]").toString()) 877 .build(); 878 mockService.addResponse(expectedResponse); 879 880 Property property = 881 Property.newBuilder() 882 .setName(PropertyName.of("[PROPERTY]").toString()) 883 .setPropertyType(PropertyType.forNumber(0)) 884 .setCreateTime(Timestamp.newBuilder().build()) 885 .setUpdateTime(Timestamp.newBuilder().build()) 886 .setParent("parent-995424086") 887 .setDisplayName("displayName1714148973") 888 .setIndustryCategory(IndustryCategory.forNumber(0)) 889 .setTimeZone("timeZone-2077180903") 890 .setCurrencyCode("currencyCode1004773790") 891 .setServiceLevel(ServiceLevel.forNumber(0)) 892 .setDeleteTime(Timestamp.newBuilder().build()) 893 .setExpireTime(Timestamp.newBuilder().build()) 894 .setAccount(AccountName.of("[ACCOUNT]").toString()) 895 .build(); 896 FieldMask updateMask = FieldMask.newBuilder().build(); 897 898 Property actualResponse = client.updateProperty(property, updateMask); 899 Assert.assertEquals(expectedResponse, actualResponse); 900 901 List<String> actualRequests = mockService.getRequestPaths(); 902 Assert.assertEquals(1, actualRequests.size()); 903 904 String apiClientHeaderKey = 905 mockService 906 .getRequestHeaders() 907 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 908 .iterator() 909 .next(); 910 Assert.assertTrue( 911 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 912 .matcher(apiClientHeaderKey) 913 .matches()); 914 } 915 916 @Test updatePropertyExceptionTest()917 public void updatePropertyExceptionTest() throws Exception { 918 ApiException exception = 919 ApiExceptionFactory.createException( 920 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 921 mockService.addException(exception); 922 923 try { 924 Property property = 925 Property.newBuilder() 926 .setName(PropertyName.of("[PROPERTY]").toString()) 927 .setPropertyType(PropertyType.forNumber(0)) 928 .setCreateTime(Timestamp.newBuilder().build()) 929 .setUpdateTime(Timestamp.newBuilder().build()) 930 .setParent("parent-995424086") 931 .setDisplayName("displayName1714148973") 932 .setIndustryCategory(IndustryCategory.forNumber(0)) 933 .setTimeZone("timeZone-2077180903") 934 .setCurrencyCode("currencyCode1004773790") 935 .setServiceLevel(ServiceLevel.forNumber(0)) 936 .setDeleteTime(Timestamp.newBuilder().build()) 937 .setExpireTime(Timestamp.newBuilder().build()) 938 .setAccount(AccountName.of("[ACCOUNT]").toString()) 939 .build(); 940 FieldMask updateMask = FieldMask.newBuilder().build(); 941 client.updateProperty(property, updateMask); 942 Assert.fail("No exception raised"); 943 } catch (InvalidArgumentException e) { 944 // Expected exception. 945 } 946 } 947 948 @Test getUserLinkTest()949 public void getUserLinkTest() throws Exception { 950 UserLink expectedResponse = 951 UserLink.newBuilder() 952 .setName(UserLinkName.ofAccountUserLinkName("[ACCOUNT]", "[USER_LINK]").toString()) 953 .setEmailAddress("emailAddress-1070931784") 954 .addAllDirectRoles(new ArrayList<String>()) 955 .build(); 956 mockService.addResponse(expectedResponse); 957 958 UserLinkName name = UserLinkName.ofAccountUserLinkName("[ACCOUNT]", "[USER_LINK]"); 959 960 UserLink actualResponse = client.getUserLink(name); 961 Assert.assertEquals(expectedResponse, actualResponse); 962 963 List<String> actualRequests = mockService.getRequestPaths(); 964 Assert.assertEquals(1, actualRequests.size()); 965 966 String apiClientHeaderKey = 967 mockService 968 .getRequestHeaders() 969 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 970 .iterator() 971 .next(); 972 Assert.assertTrue( 973 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 974 .matcher(apiClientHeaderKey) 975 .matches()); 976 } 977 978 @Test getUserLinkExceptionTest()979 public void getUserLinkExceptionTest() throws Exception { 980 ApiException exception = 981 ApiExceptionFactory.createException( 982 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 983 mockService.addException(exception); 984 985 try { 986 UserLinkName name = UserLinkName.ofAccountUserLinkName("[ACCOUNT]", "[USER_LINK]"); 987 client.getUserLink(name); 988 Assert.fail("No exception raised"); 989 } catch (InvalidArgumentException e) { 990 // Expected exception. 991 } 992 } 993 994 @Test getUserLinkTest2()995 public void getUserLinkTest2() throws Exception { 996 UserLink expectedResponse = 997 UserLink.newBuilder() 998 .setName(UserLinkName.ofAccountUserLinkName("[ACCOUNT]", "[USER_LINK]").toString()) 999 .setEmailAddress("emailAddress-1070931784") 1000 .addAllDirectRoles(new ArrayList<String>()) 1001 .build(); 1002 mockService.addResponse(expectedResponse); 1003 1004 String name = "accounts/account-2326/userLinks/userLink-2326"; 1005 1006 UserLink actualResponse = client.getUserLink(name); 1007 Assert.assertEquals(expectedResponse, actualResponse); 1008 1009 List<String> actualRequests = mockService.getRequestPaths(); 1010 Assert.assertEquals(1, actualRequests.size()); 1011 1012 String apiClientHeaderKey = 1013 mockService 1014 .getRequestHeaders() 1015 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1016 .iterator() 1017 .next(); 1018 Assert.assertTrue( 1019 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1020 .matcher(apiClientHeaderKey) 1021 .matches()); 1022 } 1023 1024 @Test getUserLinkExceptionTest2()1025 public void getUserLinkExceptionTest2() throws Exception { 1026 ApiException exception = 1027 ApiExceptionFactory.createException( 1028 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1029 mockService.addException(exception); 1030 1031 try { 1032 String name = "accounts/account-2326/userLinks/userLink-2326"; 1033 client.getUserLink(name); 1034 Assert.fail("No exception raised"); 1035 } catch (InvalidArgumentException e) { 1036 // Expected exception. 1037 } 1038 } 1039 1040 @Test batchGetUserLinksTest()1041 public void batchGetUserLinksTest() throws Exception { 1042 BatchGetUserLinksResponse expectedResponse = 1043 BatchGetUserLinksResponse.newBuilder().addAllUserLinks(new ArrayList<UserLink>()).build(); 1044 mockService.addResponse(expectedResponse); 1045 1046 BatchGetUserLinksRequest request = 1047 BatchGetUserLinksRequest.newBuilder() 1048 .setParent(AccountName.of("[ACCOUNT]").toString()) 1049 .addAllNames(new ArrayList<String>()) 1050 .build(); 1051 1052 BatchGetUserLinksResponse actualResponse = client.batchGetUserLinks(request); 1053 Assert.assertEquals(expectedResponse, actualResponse); 1054 1055 List<String> actualRequests = mockService.getRequestPaths(); 1056 Assert.assertEquals(1, actualRequests.size()); 1057 1058 String apiClientHeaderKey = 1059 mockService 1060 .getRequestHeaders() 1061 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1062 .iterator() 1063 .next(); 1064 Assert.assertTrue( 1065 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1066 .matcher(apiClientHeaderKey) 1067 .matches()); 1068 } 1069 1070 @Test batchGetUserLinksExceptionTest()1071 public void batchGetUserLinksExceptionTest() throws Exception { 1072 ApiException exception = 1073 ApiExceptionFactory.createException( 1074 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1075 mockService.addException(exception); 1076 1077 try { 1078 BatchGetUserLinksRequest request = 1079 BatchGetUserLinksRequest.newBuilder() 1080 .setParent(AccountName.of("[ACCOUNT]").toString()) 1081 .addAllNames(new ArrayList<String>()) 1082 .build(); 1083 client.batchGetUserLinks(request); 1084 Assert.fail("No exception raised"); 1085 } catch (InvalidArgumentException e) { 1086 // Expected exception. 1087 } 1088 } 1089 1090 @Test listUserLinksTest()1091 public void listUserLinksTest() throws Exception { 1092 UserLink responsesElement = UserLink.newBuilder().build(); 1093 ListUserLinksResponse expectedResponse = 1094 ListUserLinksResponse.newBuilder() 1095 .setNextPageToken("") 1096 .addAllUserLinks(Arrays.asList(responsesElement)) 1097 .build(); 1098 mockService.addResponse(expectedResponse); 1099 1100 AccountName parent = AccountName.of("[ACCOUNT]"); 1101 1102 ListUserLinksPagedResponse pagedListResponse = client.listUserLinks(parent); 1103 1104 List<UserLink> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 1105 1106 Assert.assertEquals(1, resources.size()); 1107 Assert.assertEquals(expectedResponse.getUserLinksList().get(0), resources.get(0)); 1108 1109 List<String> actualRequests = mockService.getRequestPaths(); 1110 Assert.assertEquals(1, actualRequests.size()); 1111 1112 String apiClientHeaderKey = 1113 mockService 1114 .getRequestHeaders() 1115 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1116 .iterator() 1117 .next(); 1118 Assert.assertTrue( 1119 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1120 .matcher(apiClientHeaderKey) 1121 .matches()); 1122 } 1123 1124 @Test listUserLinksExceptionTest()1125 public void listUserLinksExceptionTest() throws Exception { 1126 ApiException exception = 1127 ApiExceptionFactory.createException( 1128 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1129 mockService.addException(exception); 1130 1131 try { 1132 AccountName parent = AccountName.of("[ACCOUNT]"); 1133 client.listUserLinks(parent); 1134 Assert.fail("No exception raised"); 1135 } catch (InvalidArgumentException e) { 1136 // Expected exception. 1137 } 1138 } 1139 1140 @Test listUserLinksTest2()1141 public void listUserLinksTest2() throws Exception { 1142 UserLink responsesElement = UserLink.newBuilder().build(); 1143 ListUserLinksResponse expectedResponse = 1144 ListUserLinksResponse.newBuilder() 1145 .setNextPageToken("") 1146 .addAllUserLinks(Arrays.asList(responsesElement)) 1147 .build(); 1148 mockService.addResponse(expectedResponse); 1149 1150 PropertyName parent = PropertyName.of("[PROPERTY]"); 1151 1152 ListUserLinksPagedResponse pagedListResponse = client.listUserLinks(parent); 1153 1154 List<UserLink> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 1155 1156 Assert.assertEquals(1, resources.size()); 1157 Assert.assertEquals(expectedResponse.getUserLinksList().get(0), resources.get(0)); 1158 1159 List<String> actualRequests = mockService.getRequestPaths(); 1160 Assert.assertEquals(1, actualRequests.size()); 1161 1162 String apiClientHeaderKey = 1163 mockService 1164 .getRequestHeaders() 1165 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1166 .iterator() 1167 .next(); 1168 Assert.assertTrue( 1169 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1170 .matcher(apiClientHeaderKey) 1171 .matches()); 1172 } 1173 1174 @Test listUserLinksExceptionTest2()1175 public void listUserLinksExceptionTest2() throws Exception { 1176 ApiException exception = 1177 ApiExceptionFactory.createException( 1178 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1179 mockService.addException(exception); 1180 1181 try { 1182 PropertyName parent = PropertyName.of("[PROPERTY]"); 1183 client.listUserLinks(parent); 1184 Assert.fail("No exception raised"); 1185 } catch (InvalidArgumentException e) { 1186 // Expected exception. 1187 } 1188 } 1189 1190 @Test listUserLinksTest3()1191 public void listUserLinksTest3() throws Exception { 1192 UserLink responsesElement = UserLink.newBuilder().build(); 1193 ListUserLinksResponse expectedResponse = 1194 ListUserLinksResponse.newBuilder() 1195 .setNextPageToken("") 1196 .addAllUserLinks(Arrays.asList(responsesElement)) 1197 .build(); 1198 mockService.addResponse(expectedResponse); 1199 1200 String parent = "accounts/account-4811"; 1201 1202 ListUserLinksPagedResponse pagedListResponse = client.listUserLinks(parent); 1203 1204 List<UserLink> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 1205 1206 Assert.assertEquals(1, resources.size()); 1207 Assert.assertEquals(expectedResponse.getUserLinksList().get(0), resources.get(0)); 1208 1209 List<String> actualRequests = mockService.getRequestPaths(); 1210 Assert.assertEquals(1, actualRequests.size()); 1211 1212 String apiClientHeaderKey = 1213 mockService 1214 .getRequestHeaders() 1215 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1216 .iterator() 1217 .next(); 1218 Assert.assertTrue( 1219 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1220 .matcher(apiClientHeaderKey) 1221 .matches()); 1222 } 1223 1224 @Test listUserLinksExceptionTest3()1225 public void listUserLinksExceptionTest3() throws Exception { 1226 ApiException exception = 1227 ApiExceptionFactory.createException( 1228 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1229 mockService.addException(exception); 1230 1231 try { 1232 String parent = "accounts/account-4811"; 1233 client.listUserLinks(parent); 1234 Assert.fail("No exception raised"); 1235 } catch (InvalidArgumentException e) { 1236 // Expected exception. 1237 } 1238 } 1239 1240 @Test auditUserLinksTest()1241 public void auditUserLinksTest() throws Exception { 1242 AuditUserLink responsesElement = AuditUserLink.newBuilder().build(); 1243 AuditUserLinksResponse expectedResponse = 1244 AuditUserLinksResponse.newBuilder() 1245 .setNextPageToken("") 1246 .addAllUserLinks(Arrays.asList(responsesElement)) 1247 .build(); 1248 mockService.addResponse(expectedResponse); 1249 1250 AuditUserLinksRequest request = 1251 AuditUserLinksRequest.newBuilder() 1252 .setParent(AccountName.of("[ACCOUNT]").toString()) 1253 .setPageSize(883849137) 1254 .setPageToken("pageToken873572522") 1255 .build(); 1256 1257 AuditUserLinksPagedResponse pagedListResponse = client.auditUserLinks(request); 1258 1259 List<AuditUserLink> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 1260 1261 Assert.assertEquals(1, resources.size()); 1262 Assert.assertEquals(expectedResponse.getUserLinksList().get(0), resources.get(0)); 1263 1264 List<String> actualRequests = mockService.getRequestPaths(); 1265 Assert.assertEquals(1, actualRequests.size()); 1266 1267 String apiClientHeaderKey = 1268 mockService 1269 .getRequestHeaders() 1270 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1271 .iterator() 1272 .next(); 1273 Assert.assertTrue( 1274 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1275 .matcher(apiClientHeaderKey) 1276 .matches()); 1277 } 1278 1279 @Test auditUserLinksExceptionTest()1280 public void auditUserLinksExceptionTest() throws Exception { 1281 ApiException exception = 1282 ApiExceptionFactory.createException( 1283 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1284 mockService.addException(exception); 1285 1286 try { 1287 AuditUserLinksRequest request = 1288 AuditUserLinksRequest.newBuilder() 1289 .setParent(AccountName.of("[ACCOUNT]").toString()) 1290 .setPageSize(883849137) 1291 .setPageToken("pageToken873572522") 1292 .build(); 1293 client.auditUserLinks(request); 1294 Assert.fail("No exception raised"); 1295 } catch (InvalidArgumentException e) { 1296 // Expected exception. 1297 } 1298 } 1299 1300 @Test createUserLinkTest()1301 public void createUserLinkTest() throws Exception { 1302 UserLink expectedResponse = 1303 UserLink.newBuilder() 1304 .setName(UserLinkName.ofAccountUserLinkName("[ACCOUNT]", "[USER_LINK]").toString()) 1305 .setEmailAddress("emailAddress-1070931784") 1306 .addAllDirectRoles(new ArrayList<String>()) 1307 .build(); 1308 mockService.addResponse(expectedResponse); 1309 1310 AccountName parent = AccountName.of("[ACCOUNT]"); 1311 UserLink userLink = UserLink.newBuilder().build(); 1312 1313 UserLink actualResponse = client.createUserLink(parent, userLink); 1314 Assert.assertEquals(expectedResponse, actualResponse); 1315 1316 List<String> actualRequests = mockService.getRequestPaths(); 1317 Assert.assertEquals(1, actualRequests.size()); 1318 1319 String apiClientHeaderKey = 1320 mockService 1321 .getRequestHeaders() 1322 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1323 .iterator() 1324 .next(); 1325 Assert.assertTrue( 1326 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1327 .matcher(apiClientHeaderKey) 1328 .matches()); 1329 } 1330 1331 @Test createUserLinkExceptionTest()1332 public void createUserLinkExceptionTest() throws Exception { 1333 ApiException exception = 1334 ApiExceptionFactory.createException( 1335 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1336 mockService.addException(exception); 1337 1338 try { 1339 AccountName parent = AccountName.of("[ACCOUNT]"); 1340 UserLink userLink = UserLink.newBuilder().build(); 1341 client.createUserLink(parent, userLink); 1342 Assert.fail("No exception raised"); 1343 } catch (InvalidArgumentException e) { 1344 // Expected exception. 1345 } 1346 } 1347 1348 @Test createUserLinkTest2()1349 public void createUserLinkTest2() throws Exception { 1350 UserLink expectedResponse = 1351 UserLink.newBuilder() 1352 .setName(UserLinkName.ofAccountUserLinkName("[ACCOUNT]", "[USER_LINK]").toString()) 1353 .setEmailAddress("emailAddress-1070931784") 1354 .addAllDirectRoles(new ArrayList<String>()) 1355 .build(); 1356 mockService.addResponse(expectedResponse); 1357 1358 PropertyName parent = PropertyName.of("[PROPERTY]"); 1359 UserLink userLink = UserLink.newBuilder().build(); 1360 1361 UserLink actualResponse = client.createUserLink(parent, userLink); 1362 Assert.assertEquals(expectedResponse, actualResponse); 1363 1364 List<String> actualRequests = mockService.getRequestPaths(); 1365 Assert.assertEquals(1, actualRequests.size()); 1366 1367 String apiClientHeaderKey = 1368 mockService 1369 .getRequestHeaders() 1370 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1371 .iterator() 1372 .next(); 1373 Assert.assertTrue( 1374 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1375 .matcher(apiClientHeaderKey) 1376 .matches()); 1377 } 1378 1379 @Test createUserLinkExceptionTest2()1380 public void createUserLinkExceptionTest2() throws Exception { 1381 ApiException exception = 1382 ApiExceptionFactory.createException( 1383 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1384 mockService.addException(exception); 1385 1386 try { 1387 PropertyName parent = PropertyName.of("[PROPERTY]"); 1388 UserLink userLink = UserLink.newBuilder().build(); 1389 client.createUserLink(parent, userLink); 1390 Assert.fail("No exception raised"); 1391 } catch (InvalidArgumentException e) { 1392 // Expected exception. 1393 } 1394 } 1395 1396 @Test createUserLinkTest3()1397 public void createUserLinkTest3() throws Exception { 1398 UserLink expectedResponse = 1399 UserLink.newBuilder() 1400 .setName(UserLinkName.ofAccountUserLinkName("[ACCOUNT]", "[USER_LINK]").toString()) 1401 .setEmailAddress("emailAddress-1070931784") 1402 .addAllDirectRoles(new ArrayList<String>()) 1403 .build(); 1404 mockService.addResponse(expectedResponse); 1405 1406 String parent = "accounts/account-4811"; 1407 UserLink userLink = UserLink.newBuilder().build(); 1408 1409 UserLink actualResponse = client.createUserLink(parent, userLink); 1410 Assert.assertEquals(expectedResponse, actualResponse); 1411 1412 List<String> actualRequests = mockService.getRequestPaths(); 1413 Assert.assertEquals(1, actualRequests.size()); 1414 1415 String apiClientHeaderKey = 1416 mockService 1417 .getRequestHeaders() 1418 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1419 .iterator() 1420 .next(); 1421 Assert.assertTrue( 1422 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1423 .matcher(apiClientHeaderKey) 1424 .matches()); 1425 } 1426 1427 @Test createUserLinkExceptionTest3()1428 public void createUserLinkExceptionTest3() throws Exception { 1429 ApiException exception = 1430 ApiExceptionFactory.createException( 1431 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1432 mockService.addException(exception); 1433 1434 try { 1435 String parent = "accounts/account-4811"; 1436 UserLink userLink = UserLink.newBuilder().build(); 1437 client.createUserLink(parent, userLink); 1438 Assert.fail("No exception raised"); 1439 } catch (InvalidArgumentException e) { 1440 // Expected exception. 1441 } 1442 } 1443 1444 @Test batchCreateUserLinksTest()1445 public void batchCreateUserLinksTest() throws Exception { 1446 BatchCreateUserLinksResponse expectedResponse = 1447 BatchCreateUserLinksResponse.newBuilder() 1448 .addAllUserLinks(new ArrayList<UserLink>()) 1449 .build(); 1450 mockService.addResponse(expectedResponse); 1451 1452 BatchCreateUserLinksRequest request = 1453 BatchCreateUserLinksRequest.newBuilder() 1454 .setParent(AccountName.of("[ACCOUNT]").toString()) 1455 .setNotifyNewUsers(true) 1456 .addAllRequests(new ArrayList<CreateUserLinkRequest>()) 1457 .build(); 1458 1459 BatchCreateUserLinksResponse actualResponse = client.batchCreateUserLinks(request); 1460 Assert.assertEquals(expectedResponse, actualResponse); 1461 1462 List<String> actualRequests = mockService.getRequestPaths(); 1463 Assert.assertEquals(1, actualRequests.size()); 1464 1465 String apiClientHeaderKey = 1466 mockService 1467 .getRequestHeaders() 1468 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1469 .iterator() 1470 .next(); 1471 Assert.assertTrue( 1472 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1473 .matcher(apiClientHeaderKey) 1474 .matches()); 1475 } 1476 1477 @Test batchCreateUserLinksExceptionTest()1478 public void batchCreateUserLinksExceptionTest() throws Exception { 1479 ApiException exception = 1480 ApiExceptionFactory.createException( 1481 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1482 mockService.addException(exception); 1483 1484 try { 1485 BatchCreateUserLinksRequest request = 1486 BatchCreateUserLinksRequest.newBuilder() 1487 .setParent(AccountName.of("[ACCOUNT]").toString()) 1488 .setNotifyNewUsers(true) 1489 .addAllRequests(new ArrayList<CreateUserLinkRequest>()) 1490 .build(); 1491 client.batchCreateUserLinks(request); 1492 Assert.fail("No exception raised"); 1493 } catch (InvalidArgumentException e) { 1494 // Expected exception. 1495 } 1496 } 1497 1498 @Test updateUserLinkTest()1499 public void updateUserLinkTest() throws Exception { 1500 UserLink expectedResponse = 1501 UserLink.newBuilder() 1502 .setName(UserLinkName.ofAccountUserLinkName("[ACCOUNT]", "[USER_LINK]").toString()) 1503 .setEmailAddress("emailAddress-1070931784") 1504 .addAllDirectRoles(new ArrayList<String>()) 1505 .build(); 1506 mockService.addResponse(expectedResponse); 1507 1508 UserLink userLink = 1509 UserLink.newBuilder() 1510 .setName(UserLinkName.ofAccountUserLinkName("[ACCOUNT]", "[USER_LINK]").toString()) 1511 .setEmailAddress("emailAddress-1070931784") 1512 .addAllDirectRoles(new ArrayList<String>()) 1513 .build(); 1514 1515 UserLink actualResponse = client.updateUserLink(userLink); 1516 Assert.assertEquals(expectedResponse, actualResponse); 1517 1518 List<String> actualRequests = mockService.getRequestPaths(); 1519 Assert.assertEquals(1, actualRequests.size()); 1520 1521 String apiClientHeaderKey = 1522 mockService 1523 .getRequestHeaders() 1524 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1525 .iterator() 1526 .next(); 1527 Assert.assertTrue( 1528 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1529 .matcher(apiClientHeaderKey) 1530 .matches()); 1531 } 1532 1533 @Test updateUserLinkExceptionTest()1534 public void updateUserLinkExceptionTest() throws Exception { 1535 ApiException exception = 1536 ApiExceptionFactory.createException( 1537 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1538 mockService.addException(exception); 1539 1540 try { 1541 UserLink userLink = 1542 UserLink.newBuilder() 1543 .setName(UserLinkName.ofAccountUserLinkName("[ACCOUNT]", "[USER_LINK]").toString()) 1544 .setEmailAddress("emailAddress-1070931784") 1545 .addAllDirectRoles(new ArrayList<String>()) 1546 .build(); 1547 client.updateUserLink(userLink); 1548 Assert.fail("No exception raised"); 1549 } catch (InvalidArgumentException e) { 1550 // Expected exception. 1551 } 1552 } 1553 1554 @Test batchUpdateUserLinksTest()1555 public void batchUpdateUserLinksTest() throws Exception { 1556 BatchUpdateUserLinksResponse expectedResponse = 1557 BatchUpdateUserLinksResponse.newBuilder() 1558 .addAllUserLinks(new ArrayList<UserLink>()) 1559 .build(); 1560 mockService.addResponse(expectedResponse); 1561 1562 BatchUpdateUserLinksRequest request = 1563 BatchUpdateUserLinksRequest.newBuilder() 1564 .setParent(AccountName.of("[ACCOUNT]").toString()) 1565 .addAllRequests(new ArrayList<UpdateUserLinkRequest>()) 1566 .build(); 1567 1568 BatchUpdateUserLinksResponse actualResponse = client.batchUpdateUserLinks(request); 1569 Assert.assertEquals(expectedResponse, actualResponse); 1570 1571 List<String> actualRequests = mockService.getRequestPaths(); 1572 Assert.assertEquals(1, actualRequests.size()); 1573 1574 String apiClientHeaderKey = 1575 mockService 1576 .getRequestHeaders() 1577 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1578 .iterator() 1579 .next(); 1580 Assert.assertTrue( 1581 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1582 .matcher(apiClientHeaderKey) 1583 .matches()); 1584 } 1585 1586 @Test batchUpdateUserLinksExceptionTest()1587 public void batchUpdateUserLinksExceptionTest() throws Exception { 1588 ApiException exception = 1589 ApiExceptionFactory.createException( 1590 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1591 mockService.addException(exception); 1592 1593 try { 1594 BatchUpdateUserLinksRequest request = 1595 BatchUpdateUserLinksRequest.newBuilder() 1596 .setParent(AccountName.of("[ACCOUNT]").toString()) 1597 .addAllRequests(new ArrayList<UpdateUserLinkRequest>()) 1598 .build(); 1599 client.batchUpdateUserLinks(request); 1600 Assert.fail("No exception raised"); 1601 } catch (InvalidArgumentException e) { 1602 // Expected exception. 1603 } 1604 } 1605 1606 @Test deleteUserLinkTest()1607 public void deleteUserLinkTest() throws Exception { 1608 Empty expectedResponse = Empty.newBuilder().build(); 1609 mockService.addResponse(expectedResponse); 1610 1611 UserLinkName name = UserLinkName.ofAccountUserLinkName("[ACCOUNT]", "[USER_LINK]"); 1612 1613 client.deleteUserLink(name); 1614 1615 List<String> actualRequests = mockService.getRequestPaths(); 1616 Assert.assertEquals(1, actualRequests.size()); 1617 1618 String apiClientHeaderKey = 1619 mockService 1620 .getRequestHeaders() 1621 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1622 .iterator() 1623 .next(); 1624 Assert.assertTrue( 1625 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1626 .matcher(apiClientHeaderKey) 1627 .matches()); 1628 } 1629 1630 @Test deleteUserLinkExceptionTest()1631 public void deleteUserLinkExceptionTest() throws Exception { 1632 ApiException exception = 1633 ApiExceptionFactory.createException( 1634 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1635 mockService.addException(exception); 1636 1637 try { 1638 UserLinkName name = UserLinkName.ofAccountUserLinkName("[ACCOUNT]", "[USER_LINK]"); 1639 client.deleteUserLink(name); 1640 Assert.fail("No exception raised"); 1641 } catch (InvalidArgumentException e) { 1642 // Expected exception. 1643 } 1644 } 1645 1646 @Test deleteUserLinkTest2()1647 public void deleteUserLinkTest2() throws Exception { 1648 Empty expectedResponse = Empty.newBuilder().build(); 1649 mockService.addResponse(expectedResponse); 1650 1651 String name = "accounts/account-2326/userLinks/userLink-2326"; 1652 1653 client.deleteUserLink(name); 1654 1655 List<String> actualRequests = mockService.getRequestPaths(); 1656 Assert.assertEquals(1, actualRequests.size()); 1657 1658 String apiClientHeaderKey = 1659 mockService 1660 .getRequestHeaders() 1661 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1662 .iterator() 1663 .next(); 1664 Assert.assertTrue( 1665 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1666 .matcher(apiClientHeaderKey) 1667 .matches()); 1668 } 1669 1670 @Test deleteUserLinkExceptionTest2()1671 public void deleteUserLinkExceptionTest2() throws Exception { 1672 ApiException exception = 1673 ApiExceptionFactory.createException( 1674 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1675 mockService.addException(exception); 1676 1677 try { 1678 String name = "accounts/account-2326/userLinks/userLink-2326"; 1679 client.deleteUserLink(name); 1680 Assert.fail("No exception raised"); 1681 } catch (InvalidArgumentException e) { 1682 // Expected exception. 1683 } 1684 } 1685 1686 @Test batchDeleteUserLinksTest()1687 public void batchDeleteUserLinksTest() throws Exception { 1688 Empty expectedResponse = Empty.newBuilder().build(); 1689 mockService.addResponse(expectedResponse); 1690 1691 BatchDeleteUserLinksRequest request = 1692 BatchDeleteUserLinksRequest.newBuilder() 1693 .setParent(AccountName.of("[ACCOUNT]").toString()) 1694 .addAllRequests(new ArrayList<DeleteUserLinkRequest>()) 1695 .build(); 1696 1697 client.batchDeleteUserLinks(request); 1698 1699 List<String> actualRequests = mockService.getRequestPaths(); 1700 Assert.assertEquals(1, actualRequests.size()); 1701 1702 String apiClientHeaderKey = 1703 mockService 1704 .getRequestHeaders() 1705 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1706 .iterator() 1707 .next(); 1708 Assert.assertTrue( 1709 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1710 .matcher(apiClientHeaderKey) 1711 .matches()); 1712 } 1713 1714 @Test batchDeleteUserLinksExceptionTest()1715 public void batchDeleteUserLinksExceptionTest() throws Exception { 1716 ApiException exception = 1717 ApiExceptionFactory.createException( 1718 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1719 mockService.addException(exception); 1720 1721 try { 1722 BatchDeleteUserLinksRequest request = 1723 BatchDeleteUserLinksRequest.newBuilder() 1724 .setParent(AccountName.of("[ACCOUNT]").toString()) 1725 .addAllRequests(new ArrayList<DeleteUserLinkRequest>()) 1726 .build(); 1727 client.batchDeleteUserLinks(request); 1728 Assert.fail("No exception raised"); 1729 } catch (InvalidArgumentException e) { 1730 // Expected exception. 1731 } 1732 } 1733 1734 @Test createFirebaseLinkTest()1735 public void createFirebaseLinkTest() throws Exception { 1736 FirebaseLink expectedResponse = 1737 FirebaseLink.newBuilder() 1738 .setName(FirebaseLinkName.of("[PROPERTY]", "[FIREBASE_LINK]").toString()) 1739 .setProject("project-309310695") 1740 .setCreateTime(Timestamp.newBuilder().build()) 1741 .build(); 1742 mockService.addResponse(expectedResponse); 1743 1744 PropertyName parent = PropertyName.of("[PROPERTY]"); 1745 FirebaseLink firebaseLink = FirebaseLink.newBuilder().build(); 1746 1747 FirebaseLink actualResponse = client.createFirebaseLink(parent, firebaseLink); 1748 Assert.assertEquals(expectedResponse, actualResponse); 1749 1750 List<String> actualRequests = mockService.getRequestPaths(); 1751 Assert.assertEquals(1, actualRequests.size()); 1752 1753 String apiClientHeaderKey = 1754 mockService 1755 .getRequestHeaders() 1756 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1757 .iterator() 1758 .next(); 1759 Assert.assertTrue( 1760 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1761 .matcher(apiClientHeaderKey) 1762 .matches()); 1763 } 1764 1765 @Test createFirebaseLinkExceptionTest()1766 public void createFirebaseLinkExceptionTest() throws Exception { 1767 ApiException exception = 1768 ApiExceptionFactory.createException( 1769 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1770 mockService.addException(exception); 1771 1772 try { 1773 PropertyName parent = PropertyName.of("[PROPERTY]"); 1774 FirebaseLink firebaseLink = FirebaseLink.newBuilder().build(); 1775 client.createFirebaseLink(parent, firebaseLink); 1776 Assert.fail("No exception raised"); 1777 } catch (InvalidArgumentException e) { 1778 // Expected exception. 1779 } 1780 } 1781 1782 @Test createFirebaseLinkTest2()1783 public void createFirebaseLinkTest2() throws Exception { 1784 FirebaseLink expectedResponse = 1785 FirebaseLink.newBuilder() 1786 .setName(FirebaseLinkName.of("[PROPERTY]", "[FIREBASE_LINK]").toString()) 1787 .setProject("project-309310695") 1788 .setCreateTime(Timestamp.newBuilder().build()) 1789 .build(); 1790 mockService.addResponse(expectedResponse); 1791 1792 String parent = "properties/propertie-2024"; 1793 FirebaseLink firebaseLink = FirebaseLink.newBuilder().build(); 1794 1795 FirebaseLink actualResponse = client.createFirebaseLink(parent, firebaseLink); 1796 Assert.assertEquals(expectedResponse, actualResponse); 1797 1798 List<String> actualRequests = mockService.getRequestPaths(); 1799 Assert.assertEquals(1, actualRequests.size()); 1800 1801 String apiClientHeaderKey = 1802 mockService 1803 .getRequestHeaders() 1804 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1805 .iterator() 1806 .next(); 1807 Assert.assertTrue( 1808 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1809 .matcher(apiClientHeaderKey) 1810 .matches()); 1811 } 1812 1813 @Test createFirebaseLinkExceptionTest2()1814 public void createFirebaseLinkExceptionTest2() throws Exception { 1815 ApiException exception = 1816 ApiExceptionFactory.createException( 1817 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1818 mockService.addException(exception); 1819 1820 try { 1821 String parent = "properties/propertie-2024"; 1822 FirebaseLink firebaseLink = FirebaseLink.newBuilder().build(); 1823 client.createFirebaseLink(parent, firebaseLink); 1824 Assert.fail("No exception raised"); 1825 } catch (InvalidArgumentException e) { 1826 // Expected exception. 1827 } 1828 } 1829 1830 @Test deleteFirebaseLinkTest()1831 public void deleteFirebaseLinkTest() throws Exception { 1832 Empty expectedResponse = Empty.newBuilder().build(); 1833 mockService.addResponse(expectedResponse); 1834 1835 FirebaseLinkName name = FirebaseLinkName.of("[PROPERTY]", "[FIREBASE_LINK]"); 1836 1837 client.deleteFirebaseLink(name); 1838 1839 List<String> actualRequests = mockService.getRequestPaths(); 1840 Assert.assertEquals(1, actualRequests.size()); 1841 1842 String apiClientHeaderKey = 1843 mockService 1844 .getRequestHeaders() 1845 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1846 .iterator() 1847 .next(); 1848 Assert.assertTrue( 1849 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1850 .matcher(apiClientHeaderKey) 1851 .matches()); 1852 } 1853 1854 @Test deleteFirebaseLinkExceptionTest()1855 public void deleteFirebaseLinkExceptionTest() throws Exception { 1856 ApiException exception = 1857 ApiExceptionFactory.createException( 1858 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1859 mockService.addException(exception); 1860 1861 try { 1862 FirebaseLinkName name = FirebaseLinkName.of("[PROPERTY]", "[FIREBASE_LINK]"); 1863 client.deleteFirebaseLink(name); 1864 Assert.fail("No exception raised"); 1865 } catch (InvalidArgumentException e) { 1866 // Expected exception. 1867 } 1868 } 1869 1870 @Test deleteFirebaseLinkTest2()1871 public void deleteFirebaseLinkTest2() throws Exception { 1872 Empty expectedResponse = Empty.newBuilder().build(); 1873 mockService.addResponse(expectedResponse); 1874 1875 String name = "properties/propertie-2649/firebaseLinks/firebaseLink-2649"; 1876 1877 client.deleteFirebaseLink(name); 1878 1879 List<String> actualRequests = mockService.getRequestPaths(); 1880 Assert.assertEquals(1, actualRequests.size()); 1881 1882 String apiClientHeaderKey = 1883 mockService 1884 .getRequestHeaders() 1885 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1886 .iterator() 1887 .next(); 1888 Assert.assertTrue( 1889 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1890 .matcher(apiClientHeaderKey) 1891 .matches()); 1892 } 1893 1894 @Test deleteFirebaseLinkExceptionTest2()1895 public void deleteFirebaseLinkExceptionTest2() throws Exception { 1896 ApiException exception = 1897 ApiExceptionFactory.createException( 1898 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1899 mockService.addException(exception); 1900 1901 try { 1902 String name = "properties/propertie-2649/firebaseLinks/firebaseLink-2649"; 1903 client.deleteFirebaseLink(name); 1904 Assert.fail("No exception raised"); 1905 } catch (InvalidArgumentException e) { 1906 // Expected exception. 1907 } 1908 } 1909 1910 @Test listFirebaseLinksTest()1911 public void listFirebaseLinksTest() throws Exception { 1912 FirebaseLink responsesElement = FirebaseLink.newBuilder().build(); 1913 ListFirebaseLinksResponse expectedResponse = 1914 ListFirebaseLinksResponse.newBuilder() 1915 .setNextPageToken("") 1916 .addAllFirebaseLinks(Arrays.asList(responsesElement)) 1917 .build(); 1918 mockService.addResponse(expectedResponse); 1919 1920 PropertyName parent = PropertyName.of("[PROPERTY]"); 1921 1922 ListFirebaseLinksPagedResponse pagedListResponse = client.listFirebaseLinks(parent); 1923 1924 List<FirebaseLink> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 1925 1926 Assert.assertEquals(1, resources.size()); 1927 Assert.assertEquals(expectedResponse.getFirebaseLinksList().get(0), resources.get(0)); 1928 1929 List<String> actualRequests = mockService.getRequestPaths(); 1930 Assert.assertEquals(1, actualRequests.size()); 1931 1932 String apiClientHeaderKey = 1933 mockService 1934 .getRequestHeaders() 1935 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1936 .iterator() 1937 .next(); 1938 Assert.assertTrue( 1939 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1940 .matcher(apiClientHeaderKey) 1941 .matches()); 1942 } 1943 1944 @Test listFirebaseLinksExceptionTest()1945 public void listFirebaseLinksExceptionTest() throws Exception { 1946 ApiException exception = 1947 ApiExceptionFactory.createException( 1948 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1949 mockService.addException(exception); 1950 1951 try { 1952 PropertyName parent = PropertyName.of("[PROPERTY]"); 1953 client.listFirebaseLinks(parent); 1954 Assert.fail("No exception raised"); 1955 } catch (InvalidArgumentException e) { 1956 // Expected exception. 1957 } 1958 } 1959 1960 @Test listFirebaseLinksTest2()1961 public void listFirebaseLinksTest2() throws Exception { 1962 FirebaseLink responsesElement = FirebaseLink.newBuilder().build(); 1963 ListFirebaseLinksResponse expectedResponse = 1964 ListFirebaseLinksResponse.newBuilder() 1965 .setNextPageToken("") 1966 .addAllFirebaseLinks(Arrays.asList(responsesElement)) 1967 .build(); 1968 mockService.addResponse(expectedResponse); 1969 1970 String parent = "properties/propertie-2024"; 1971 1972 ListFirebaseLinksPagedResponse pagedListResponse = client.listFirebaseLinks(parent); 1973 1974 List<FirebaseLink> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 1975 1976 Assert.assertEquals(1, resources.size()); 1977 Assert.assertEquals(expectedResponse.getFirebaseLinksList().get(0), resources.get(0)); 1978 1979 List<String> actualRequests = mockService.getRequestPaths(); 1980 Assert.assertEquals(1, actualRequests.size()); 1981 1982 String apiClientHeaderKey = 1983 mockService 1984 .getRequestHeaders() 1985 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 1986 .iterator() 1987 .next(); 1988 Assert.assertTrue( 1989 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 1990 .matcher(apiClientHeaderKey) 1991 .matches()); 1992 } 1993 1994 @Test listFirebaseLinksExceptionTest2()1995 public void listFirebaseLinksExceptionTest2() throws Exception { 1996 ApiException exception = 1997 ApiExceptionFactory.createException( 1998 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 1999 mockService.addException(exception); 2000 2001 try { 2002 String parent = "properties/propertie-2024"; 2003 client.listFirebaseLinks(parent); 2004 Assert.fail("No exception raised"); 2005 } catch (InvalidArgumentException e) { 2006 // Expected exception. 2007 } 2008 } 2009 2010 @Test getGlobalSiteTagTest()2011 public void getGlobalSiteTagTest() throws Exception { 2012 GlobalSiteTag expectedResponse = 2013 GlobalSiteTag.newBuilder() 2014 .setName(GlobalSiteTagName.of("[PROPERTY]", "[DATA_STREAM]").toString()) 2015 .setSnippet("snippet-2061635299") 2016 .build(); 2017 mockService.addResponse(expectedResponse); 2018 2019 GlobalSiteTagName name = GlobalSiteTagName.of("[PROPERTY]", "[DATA_STREAM]"); 2020 2021 GlobalSiteTag actualResponse = client.getGlobalSiteTag(name); 2022 Assert.assertEquals(expectedResponse, actualResponse); 2023 2024 List<String> actualRequests = mockService.getRequestPaths(); 2025 Assert.assertEquals(1, actualRequests.size()); 2026 2027 String apiClientHeaderKey = 2028 mockService 2029 .getRequestHeaders() 2030 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2031 .iterator() 2032 .next(); 2033 Assert.assertTrue( 2034 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2035 .matcher(apiClientHeaderKey) 2036 .matches()); 2037 } 2038 2039 @Test getGlobalSiteTagExceptionTest()2040 public void getGlobalSiteTagExceptionTest() throws Exception { 2041 ApiException exception = 2042 ApiExceptionFactory.createException( 2043 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2044 mockService.addException(exception); 2045 2046 try { 2047 GlobalSiteTagName name = GlobalSiteTagName.of("[PROPERTY]", "[DATA_STREAM]"); 2048 client.getGlobalSiteTag(name); 2049 Assert.fail("No exception raised"); 2050 } catch (InvalidArgumentException e) { 2051 // Expected exception. 2052 } 2053 } 2054 2055 @Test getGlobalSiteTagTest2()2056 public void getGlobalSiteTagTest2() throws Exception { 2057 GlobalSiteTag expectedResponse = 2058 GlobalSiteTag.newBuilder() 2059 .setName(GlobalSiteTagName.of("[PROPERTY]", "[DATA_STREAM]").toString()) 2060 .setSnippet("snippet-2061635299") 2061 .build(); 2062 mockService.addResponse(expectedResponse); 2063 2064 String name = "properties/propertie-1615/dataStreams/dataStream-1615/globalSiteTag"; 2065 2066 GlobalSiteTag actualResponse = client.getGlobalSiteTag(name); 2067 Assert.assertEquals(expectedResponse, actualResponse); 2068 2069 List<String> actualRequests = mockService.getRequestPaths(); 2070 Assert.assertEquals(1, actualRequests.size()); 2071 2072 String apiClientHeaderKey = 2073 mockService 2074 .getRequestHeaders() 2075 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2076 .iterator() 2077 .next(); 2078 Assert.assertTrue( 2079 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2080 .matcher(apiClientHeaderKey) 2081 .matches()); 2082 } 2083 2084 @Test getGlobalSiteTagExceptionTest2()2085 public void getGlobalSiteTagExceptionTest2() throws Exception { 2086 ApiException exception = 2087 ApiExceptionFactory.createException( 2088 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2089 mockService.addException(exception); 2090 2091 try { 2092 String name = "properties/propertie-1615/dataStreams/dataStream-1615/globalSiteTag"; 2093 client.getGlobalSiteTag(name); 2094 Assert.fail("No exception raised"); 2095 } catch (InvalidArgumentException e) { 2096 // Expected exception. 2097 } 2098 } 2099 2100 @Test createGoogleAdsLinkTest()2101 public void createGoogleAdsLinkTest() throws Exception { 2102 GoogleAdsLink expectedResponse = 2103 GoogleAdsLink.newBuilder() 2104 .setName(GoogleAdsLinkName.of("[PROPERTY]", "[GOOGLE_ADS_LINK]").toString()) 2105 .setCustomerId("customerId-1581184615") 2106 .setCanManageClients(true) 2107 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 2108 .setCreateTime(Timestamp.newBuilder().build()) 2109 .setUpdateTime(Timestamp.newBuilder().build()) 2110 .setCreatorEmailAddress("creatorEmailAddress67752708") 2111 .build(); 2112 mockService.addResponse(expectedResponse); 2113 2114 PropertyName parent = PropertyName.of("[PROPERTY]"); 2115 GoogleAdsLink googleAdsLink = GoogleAdsLink.newBuilder().build(); 2116 2117 GoogleAdsLink actualResponse = client.createGoogleAdsLink(parent, googleAdsLink); 2118 Assert.assertEquals(expectedResponse, actualResponse); 2119 2120 List<String> actualRequests = mockService.getRequestPaths(); 2121 Assert.assertEquals(1, actualRequests.size()); 2122 2123 String apiClientHeaderKey = 2124 mockService 2125 .getRequestHeaders() 2126 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2127 .iterator() 2128 .next(); 2129 Assert.assertTrue( 2130 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2131 .matcher(apiClientHeaderKey) 2132 .matches()); 2133 } 2134 2135 @Test createGoogleAdsLinkExceptionTest()2136 public void createGoogleAdsLinkExceptionTest() throws Exception { 2137 ApiException exception = 2138 ApiExceptionFactory.createException( 2139 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2140 mockService.addException(exception); 2141 2142 try { 2143 PropertyName parent = PropertyName.of("[PROPERTY]"); 2144 GoogleAdsLink googleAdsLink = GoogleAdsLink.newBuilder().build(); 2145 client.createGoogleAdsLink(parent, googleAdsLink); 2146 Assert.fail("No exception raised"); 2147 } catch (InvalidArgumentException e) { 2148 // Expected exception. 2149 } 2150 } 2151 2152 @Test createGoogleAdsLinkTest2()2153 public void createGoogleAdsLinkTest2() throws Exception { 2154 GoogleAdsLink expectedResponse = 2155 GoogleAdsLink.newBuilder() 2156 .setName(GoogleAdsLinkName.of("[PROPERTY]", "[GOOGLE_ADS_LINK]").toString()) 2157 .setCustomerId("customerId-1581184615") 2158 .setCanManageClients(true) 2159 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 2160 .setCreateTime(Timestamp.newBuilder().build()) 2161 .setUpdateTime(Timestamp.newBuilder().build()) 2162 .setCreatorEmailAddress("creatorEmailAddress67752708") 2163 .build(); 2164 mockService.addResponse(expectedResponse); 2165 2166 String parent = "properties/propertie-2024"; 2167 GoogleAdsLink googleAdsLink = GoogleAdsLink.newBuilder().build(); 2168 2169 GoogleAdsLink actualResponse = client.createGoogleAdsLink(parent, googleAdsLink); 2170 Assert.assertEquals(expectedResponse, actualResponse); 2171 2172 List<String> actualRequests = mockService.getRequestPaths(); 2173 Assert.assertEquals(1, actualRequests.size()); 2174 2175 String apiClientHeaderKey = 2176 mockService 2177 .getRequestHeaders() 2178 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2179 .iterator() 2180 .next(); 2181 Assert.assertTrue( 2182 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2183 .matcher(apiClientHeaderKey) 2184 .matches()); 2185 } 2186 2187 @Test createGoogleAdsLinkExceptionTest2()2188 public void createGoogleAdsLinkExceptionTest2() throws Exception { 2189 ApiException exception = 2190 ApiExceptionFactory.createException( 2191 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2192 mockService.addException(exception); 2193 2194 try { 2195 String parent = "properties/propertie-2024"; 2196 GoogleAdsLink googleAdsLink = GoogleAdsLink.newBuilder().build(); 2197 client.createGoogleAdsLink(parent, googleAdsLink); 2198 Assert.fail("No exception raised"); 2199 } catch (InvalidArgumentException e) { 2200 // Expected exception. 2201 } 2202 } 2203 2204 @Test updateGoogleAdsLinkTest()2205 public void updateGoogleAdsLinkTest() throws Exception { 2206 GoogleAdsLink expectedResponse = 2207 GoogleAdsLink.newBuilder() 2208 .setName(GoogleAdsLinkName.of("[PROPERTY]", "[GOOGLE_ADS_LINK]").toString()) 2209 .setCustomerId("customerId-1581184615") 2210 .setCanManageClients(true) 2211 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 2212 .setCreateTime(Timestamp.newBuilder().build()) 2213 .setUpdateTime(Timestamp.newBuilder().build()) 2214 .setCreatorEmailAddress("creatorEmailAddress67752708") 2215 .build(); 2216 mockService.addResponse(expectedResponse); 2217 2218 GoogleAdsLink googleAdsLink = 2219 GoogleAdsLink.newBuilder() 2220 .setName(GoogleAdsLinkName.of("[PROPERTY]", "[GOOGLE_ADS_LINK]").toString()) 2221 .setCustomerId("customerId-1581184615") 2222 .setCanManageClients(true) 2223 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 2224 .setCreateTime(Timestamp.newBuilder().build()) 2225 .setUpdateTime(Timestamp.newBuilder().build()) 2226 .setCreatorEmailAddress("creatorEmailAddress67752708") 2227 .build(); 2228 FieldMask updateMask = FieldMask.newBuilder().build(); 2229 2230 GoogleAdsLink actualResponse = client.updateGoogleAdsLink(googleAdsLink, updateMask); 2231 Assert.assertEquals(expectedResponse, actualResponse); 2232 2233 List<String> actualRequests = mockService.getRequestPaths(); 2234 Assert.assertEquals(1, actualRequests.size()); 2235 2236 String apiClientHeaderKey = 2237 mockService 2238 .getRequestHeaders() 2239 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2240 .iterator() 2241 .next(); 2242 Assert.assertTrue( 2243 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2244 .matcher(apiClientHeaderKey) 2245 .matches()); 2246 } 2247 2248 @Test updateGoogleAdsLinkExceptionTest()2249 public void updateGoogleAdsLinkExceptionTest() throws Exception { 2250 ApiException exception = 2251 ApiExceptionFactory.createException( 2252 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2253 mockService.addException(exception); 2254 2255 try { 2256 GoogleAdsLink googleAdsLink = 2257 GoogleAdsLink.newBuilder() 2258 .setName(GoogleAdsLinkName.of("[PROPERTY]", "[GOOGLE_ADS_LINK]").toString()) 2259 .setCustomerId("customerId-1581184615") 2260 .setCanManageClients(true) 2261 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 2262 .setCreateTime(Timestamp.newBuilder().build()) 2263 .setUpdateTime(Timestamp.newBuilder().build()) 2264 .setCreatorEmailAddress("creatorEmailAddress67752708") 2265 .build(); 2266 FieldMask updateMask = FieldMask.newBuilder().build(); 2267 client.updateGoogleAdsLink(googleAdsLink, updateMask); 2268 Assert.fail("No exception raised"); 2269 } catch (InvalidArgumentException e) { 2270 // Expected exception. 2271 } 2272 } 2273 2274 @Test deleteGoogleAdsLinkTest()2275 public void deleteGoogleAdsLinkTest() throws Exception { 2276 Empty expectedResponse = Empty.newBuilder().build(); 2277 mockService.addResponse(expectedResponse); 2278 2279 GoogleAdsLinkName name = GoogleAdsLinkName.of("[PROPERTY]", "[GOOGLE_ADS_LINK]"); 2280 2281 client.deleteGoogleAdsLink(name); 2282 2283 List<String> actualRequests = mockService.getRequestPaths(); 2284 Assert.assertEquals(1, actualRequests.size()); 2285 2286 String apiClientHeaderKey = 2287 mockService 2288 .getRequestHeaders() 2289 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2290 .iterator() 2291 .next(); 2292 Assert.assertTrue( 2293 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2294 .matcher(apiClientHeaderKey) 2295 .matches()); 2296 } 2297 2298 @Test deleteGoogleAdsLinkExceptionTest()2299 public void deleteGoogleAdsLinkExceptionTest() throws Exception { 2300 ApiException exception = 2301 ApiExceptionFactory.createException( 2302 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2303 mockService.addException(exception); 2304 2305 try { 2306 GoogleAdsLinkName name = GoogleAdsLinkName.of("[PROPERTY]", "[GOOGLE_ADS_LINK]"); 2307 client.deleteGoogleAdsLink(name); 2308 Assert.fail("No exception raised"); 2309 } catch (InvalidArgumentException e) { 2310 // Expected exception. 2311 } 2312 } 2313 2314 @Test deleteGoogleAdsLinkTest2()2315 public void deleteGoogleAdsLinkTest2() throws Exception { 2316 Empty expectedResponse = Empty.newBuilder().build(); 2317 mockService.addResponse(expectedResponse); 2318 2319 String name = "properties/propertie-1267/googleAdsLinks/googleAdsLink-1267"; 2320 2321 client.deleteGoogleAdsLink(name); 2322 2323 List<String> actualRequests = mockService.getRequestPaths(); 2324 Assert.assertEquals(1, actualRequests.size()); 2325 2326 String apiClientHeaderKey = 2327 mockService 2328 .getRequestHeaders() 2329 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2330 .iterator() 2331 .next(); 2332 Assert.assertTrue( 2333 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2334 .matcher(apiClientHeaderKey) 2335 .matches()); 2336 } 2337 2338 @Test deleteGoogleAdsLinkExceptionTest2()2339 public void deleteGoogleAdsLinkExceptionTest2() throws Exception { 2340 ApiException exception = 2341 ApiExceptionFactory.createException( 2342 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2343 mockService.addException(exception); 2344 2345 try { 2346 String name = "properties/propertie-1267/googleAdsLinks/googleAdsLink-1267"; 2347 client.deleteGoogleAdsLink(name); 2348 Assert.fail("No exception raised"); 2349 } catch (InvalidArgumentException e) { 2350 // Expected exception. 2351 } 2352 } 2353 2354 @Test listGoogleAdsLinksTest()2355 public void listGoogleAdsLinksTest() throws Exception { 2356 GoogleAdsLink responsesElement = GoogleAdsLink.newBuilder().build(); 2357 ListGoogleAdsLinksResponse expectedResponse = 2358 ListGoogleAdsLinksResponse.newBuilder() 2359 .setNextPageToken("") 2360 .addAllGoogleAdsLinks(Arrays.asList(responsesElement)) 2361 .build(); 2362 mockService.addResponse(expectedResponse); 2363 2364 PropertyName parent = PropertyName.of("[PROPERTY]"); 2365 2366 ListGoogleAdsLinksPagedResponse pagedListResponse = client.listGoogleAdsLinks(parent); 2367 2368 List<GoogleAdsLink> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 2369 2370 Assert.assertEquals(1, resources.size()); 2371 Assert.assertEquals(expectedResponse.getGoogleAdsLinksList().get(0), resources.get(0)); 2372 2373 List<String> actualRequests = mockService.getRequestPaths(); 2374 Assert.assertEquals(1, actualRequests.size()); 2375 2376 String apiClientHeaderKey = 2377 mockService 2378 .getRequestHeaders() 2379 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2380 .iterator() 2381 .next(); 2382 Assert.assertTrue( 2383 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2384 .matcher(apiClientHeaderKey) 2385 .matches()); 2386 } 2387 2388 @Test listGoogleAdsLinksExceptionTest()2389 public void listGoogleAdsLinksExceptionTest() throws Exception { 2390 ApiException exception = 2391 ApiExceptionFactory.createException( 2392 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2393 mockService.addException(exception); 2394 2395 try { 2396 PropertyName parent = PropertyName.of("[PROPERTY]"); 2397 client.listGoogleAdsLinks(parent); 2398 Assert.fail("No exception raised"); 2399 } catch (InvalidArgumentException e) { 2400 // Expected exception. 2401 } 2402 } 2403 2404 @Test listGoogleAdsLinksTest2()2405 public void listGoogleAdsLinksTest2() throws Exception { 2406 GoogleAdsLink responsesElement = GoogleAdsLink.newBuilder().build(); 2407 ListGoogleAdsLinksResponse expectedResponse = 2408 ListGoogleAdsLinksResponse.newBuilder() 2409 .setNextPageToken("") 2410 .addAllGoogleAdsLinks(Arrays.asList(responsesElement)) 2411 .build(); 2412 mockService.addResponse(expectedResponse); 2413 2414 String parent = "properties/propertie-2024"; 2415 2416 ListGoogleAdsLinksPagedResponse pagedListResponse = client.listGoogleAdsLinks(parent); 2417 2418 List<GoogleAdsLink> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 2419 2420 Assert.assertEquals(1, resources.size()); 2421 Assert.assertEquals(expectedResponse.getGoogleAdsLinksList().get(0), resources.get(0)); 2422 2423 List<String> actualRequests = mockService.getRequestPaths(); 2424 Assert.assertEquals(1, actualRequests.size()); 2425 2426 String apiClientHeaderKey = 2427 mockService 2428 .getRequestHeaders() 2429 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2430 .iterator() 2431 .next(); 2432 Assert.assertTrue( 2433 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2434 .matcher(apiClientHeaderKey) 2435 .matches()); 2436 } 2437 2438 @Test listGoogleAdsLinksExceptionTest2()2439 public void listGoogleAdsLinksExceptionTest2() throws Exception { 2440 ApiException exception = 2441 ApiExceptionFactory.createException( 2442 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2443 mockService.addException(exception); 2444 2445 try { 2446 String parent = "properties/propertie-2024"; 2447 client.listGoogleAdsLinks(parent); 2448 Assert.fail("No exception raised"); 2449 } catch (InvalidArgumentException e) { 2450 // Expected exception. 2451 } 2452 } 2453 2454 @Test getDataSharingSettingsTest()2455 public void getDataSharingSettingsTest() throws Exception { 2456 DataSharingSettings expectedResponse = 2457 DataSharingSettings.newBuilder() 2458 .setName(DataSharingSettingsName.of("[ACCOUNT]").toString()) 2459 .setSharingWithGoogleSupportEnabled(true) 2460 .setSharingWithGoogleAssignedSalesEnabled(true) 2461 .setSharingWithGoogleAnySalesEnabled(true) 2462 .setSharingWithGoogleProductsEnabled(true) 2463 .setSharingWithOthersEnabled(true) 2464 .build(); 2465 mockService.addResponse(expectedResponse); 2466 2467 DataSharingSettingsName name = DataSharingSettingsName.of("[ACCOUNT]"); 2468 2469 DataSharingSettings actualResponse = client.getDataSharingSettings(name); 2470 Assert.assertEquals(expectedResponse, actualResponse); 2471 2472 List<String> actualRequests = mockService.getRequestPaths(); 2473 Assert.assertEquals(1, actualRequests.size()); 2474 2475 String apiClientHeaderKey = 2476 mockService 2477 .getRequestHeaders() 2478 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2479 .iterator() 2480 .next(); 2481 Assert.assertTrue( 2482 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2483 .matcher(apiClientHeaderKey) 2484 .matches()); 2485 } 2486 2487 @Test getDataSharingSettingsExceptionTest()2488 public void getDataSharingSettingsExceptionTest() throws Exception { 2489 ApiException exception = 2490 ApiExceptionFactory.createException( 2491 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2492 mockService.addException(exception); 2493 2494 try { 2495 DataSharingSettingsName name = DataSharingSettingsName.of("[ACCOUNT]"); 2496 client.getDataSharingSettings(name); 2497 Assert.fail("No exception raised"); 2498 } catch (InvalidArgumentException e) { 2499 // Expected exception. 2500 } 2501 } 2502 2503 @Test getDataSharingSettingsTest2()2504 public void getDataSharingSettingsTest2() throws Exception { 2505 DataSharingSettings expectedResponse = 2506 DataSharingSettings.newBuilder() 2507 .setName(DataSharingSettingsName.of("[ACCOUNT]").toString()) 2508 .setSharingWithGoogleSupportEnabled(true) 2509 .setSharingWithGoogleAssignedSalesEnabled(true) 2510 .setSharingWithGoogleAnySalesEnabled(true) 2511 .setSharingWithGoogleProductsEnabled(true) 2512 .setSharingWithOthersEnabled(true) 2513 .build(); 2514 mockService.addResponse(expectedResponse); 2515 2516 String name = "accounts/account-7122/dataSharingSettings"; 2517 2518 DataSharingSettings actualResponse = client.getDataSharingSettings(name); 2519 Assert.assertEquals(expectedResponse, actualResponse); 2520 2521 List<String> actualRequests = mockService.getRequestPaths(); 2522 Assert.assertEquals(1, actualRequests.size()); 2523 2524 String apiClientHeaderKey = 2525 mockService 2526 .getRequestHeaders() 2527 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2528 .iterator() 2529 .next(); 2530 Assert.assertTrue( 2531 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2532 .matcher(apiClientHeaderKey) 2533 .matches()); 2534 } 2535 2536 @Test getDataSharingSettingsExceptionTest2()2537 public void getDataSharingSettingsExceptionTest2() throws Exception { 2538 ApiException exception = 2539 ApiExceptionFactory.createException( 2540 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2541 mockService.addException(exception); 2542 2543 try { 2544 String name = "accounts/account-7122/dataSharingSettings"; 2545 client.getDataSharingSettings(name); 2546 Assert.fail("No exception raised"); 2547 } catch (InvalidArgumentException e) { 2548 // Expected exception. 2549 } 2550 } 2551 2552 @Test getMeasurementProtocolSecretTest()2553 public void getMeasurementProtocolSecretTest() throws Exception { 2554 MeasurementProtocolSecret expectedResponse = 2555 MeasurementProtocolSecret.newBuilder() 2556 .setName( 2557 MeasurementProtocolSecretName.of( 2558 "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]") 2559 .toString()) 2560 .setDisplayName("displayName1714148973") 2561 .setSecretValue("secretValue-2044460895") 2562 .build(); 2563 mockService.addResponse(expectedResponse); 2564 2565 MeasurementProtocolSecretName name = 2566 MeasurementProtocolSecretName.of( 2567 "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]"); 2568 2569 MeasurementProtocolSecret actualResponse = client.getMeasurementProtocolSecret(name); 2570 Assert.assertEquals(expectedResponse, actualResponse); 2571 2572 List<String> actualRequests = mockService.getRequestPaths(); 2573 Assert.assertEquals(1, actualRequests.size()); 2574 2575 String apiClientHeaderKey = 2576 mockService 2577 .getRequestHeaders() 2578 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2579 .iterator() 2580 .next(); 2581 Assert.assertTrue( 2582 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2583 .matcher(apiClientHeaderKey) 2584 .matches()); 2585 } 2586 2587 @Test getMeasurementProtocolSecretExceptionTest()2588 public void getMeasurementProtocolSecretExceptionTest() throws Exception { 2589 ApiException exception = 2590 ApiExceptionFactory.createException( 2591 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2592 mockService.addException(exception); 2593 2594 try { 2595 MeasurementProtocolSecretName name = 2596 MeasurementProtocolSecretName.of( 2597 "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]"); 2598 client.getMeasurementProtocolSecret(name); 2599 Assert.fail("No exception raised"); 2600 } catch (InvalidArgumentException e) { 2601 // Expected exception. 2602 } 2603 } 2604 2605 @Test getMeasurementProtocolSecretTest2()2606 public void getMeasurementProtocolSecretTest2() throws Exception { 2607 MeasurementProtocolSecret expectedResponse = 2608 MeasurementProtocolSecret.newBuilder() 2609 .setName( 2610 MeasurementProtocolSecretName.of( 2611 "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]") 2612 .toString()) 2613 .setDisplayName("displayName1714148973") 2614 .setSecretValue("secretValue-2044460895") 2615 .build(); 2616 mockService.addResponse(expectedResponse); 2617 2618 String name = 2619 "properties/propertie-6357/dataStreams/dataStream-6357/measurementProtocolSecrets/measurementProtocolSecret-6357"; 2620 2621 MeasurementProtocolSecret actualResponse = client.getMeasurementProtocolSecret(name); 2622 Assert.assertEquals(expectedResponse, actualResponse); 2623 2624 List<String> actualRequests = mockService.getRequestPaths(); 2625 Assert.assertEquals(1, actualRequests.size()); 2626 2627 String apiClientHeaderKey = 2628 mockService 2629 .getRequestHeaders() 2630 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2631 .iterator() 2632 .next(); 2633 Assert.assertTrue( 2634 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2635 .matcher(apiClientHeaderKey) 2636 .matches()); 2637 } 2638 2639 @Test getMeasurementProtocolSecretExceptionTest2()2640 public void getMeasurementProtocolSecretExceptionTest2() throws Exception { 2641 ApiException exception = 2642 ApiExceptionFactory.createException( 2643 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2644 mockService.addException(exception); 2645 2646 try { 2647 String name = 2648 "properties/propertie-6357/dataStreams/dataStream-6357/measurementProtocolSecrets/measurementProtocolSecret-6357"; 2649 client.getMeasurementProtocolSecret(name); 2650 Assert.fail("No exception raised"); 2651 } catch (InvalidArgumentException e) { 2652 // Expected exception. 2653 } 2654 } 2655 2656 @Test listMeasurementProtocolSecretsTest()2657 public void listMeasurementProtocolSecretsTest() throws Exception { 2658 MeasurementProtocolSecret responsesElement = MeasurementProtocolSecret.newBuilder().build(); 2659 ListMeasurementProtocolSecretsResponse expectedResponse = 2660 ListMeasurementProtocolSecretsResponse.newBuilder() 2661 .setNextPageToken("") 2662 .addAllMeasurementProtocolSecrets(Arrays.asList(responsesElement)) 2663 .build(); 2664 mockService.addResponse(expectedResponse); 2665 2666 DataStreamName parent = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]"); 2667 2668 ListMeasurementProtocolSecretsPagedResponse pagedListResponse = 2669 client.listMeasurementProtocolSecrets(parent); 2670 2671 List<MeasurementProtocolSecret> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 2672 2673 Assert.assertEquals(1, resources.size()); 2674 Assert.assertEquals( 2675 expectedResponse.getMeasurementProtocolSecretsList().get(0), resources.get(0)); 2676 2677 List<String> actualRequests = mockService.getRequestPaths(); 2678 Assert.assertEquals(1, actualRequests.size()); 2679 2680 String apiClientHeaderKey = 2681 mockService 2682 .getRequestHeaders() 2683 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2684 .iterator() 2685 .next(); 2686 Assert.assertTrue( 2687 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2688 .matcher(apiClientHeaderKey) 2689 .matches()); 2690 } 2691 2692 @Test listMeasurementProtocolSecretsExceptionTest()2693 public void listMeasurementProtocolSecretsExceptionTest() throws Exception { 2694 ApiException exception = 2695 ApiExceptionFactory.createException( 2696 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2697 mockService.addException(exception); 2698 2699 try { 2700 DataStreamName parent = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]"); 2701 client.listMeasurementProtocolSecrets(parent); 2702 Assert.fail("No exception raised"); 2703 } catch (InvalidArgumentException e) { 2704 // Expected exception. 2705 } 2706 } 2707 2708 @Test listMeasurementProtocolSecretsTest2()2709 public void listMeasurementProtocolSecretsTest2() throws Exception { 2710 MeasurementProtocolSecret responsesElement = MeasurementProtocolSecret.newBuilder().build(); 2711 ListMeasurementProtocolSecretsResponse expectedResponse = 2712 ListMeasurementProtocolSecretsResponse.newBuilder() 2713 .setNextPageToken("") 2714 .addAllMeasurementProtocolSecrets(Arrays.asList(responsesElement)) 2715 .build(); 2716 mockService.addResponse(expectedResponse); 2717 2718 String parent = "properties/propertie-9651/dataStreams/dataStream-9651"; 2719 2720 ListMeasurementProtocolSecretsPagedResponse pagedListResponse = 2721 client.listMeasurementProtocolSecrets(parent); 2722 2723 List<MeasurementProtocolSecret> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 2724 2725 Assert.assertEquals(1, resources.size()); 2726 Assert.assertEquals( 2727 expectedResponse.getMeasurementProtocolSecretsList().get(0), resources.get(0)); 2728 2729 List<String> actualRequests = mockService.getRequestPaths(); 2730 Assert.assertEquals(1, actualRequests.size()); 2731 2732 String apiClientHeaderKey = 2733 mockService 2734 .getRequestHeaders() 2735 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2736 .iterator() 2737 .next(); 2738 Assert.assertTrue( 2739 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2740 .matcher(apiClientHeaderKey) 2741 .matches()); 2742 } 2743 2744 @Test listMeasurementProtocolSecretsExceptionTest2()2745 public void listMeasurementProtocolSecretsExceptionTest2() throws Exception { 2746 ApiException exception = 2747 ApiExceptionFactory.createException( 2748 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2749 mockService.addException(exception); 2750 2751 try { 2752 String parent = "properties/propertie-9651/dataStreams/dataStream-9651"; 2753 client.listMeasurementProtocolSecrets(parent); 2754 Assert.fail("No exception raised"); 2755 } catch (InvalidArgumentException e) { 2756 // Expected exception. 2757 } 2758 } 2759 2760 @Test createMeasurementProtocolSecretTest()2761 public void createMeasurementProtocolSecretTest() throws Exception { 2762 MeasurementProtocolSecret expectedResponse = 2763 MeasurementProtocolSecret.newBuilder() 2764 .setName( 2765 MeasurementProtocolSecretName.of( 2766 "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]") 2767 .toString()) 2768 .setDisplayName("displayName1714148973") 2769 .setSecretValue("secretValue-2044460895") 2770 .build(); 2771 mockService.addResponse(expectedResponse); 2772 2773 DataStreamName parent = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]"); 2774 MeasurementProtocolSecret measurementProtocolSecret = 2775 MeasurementProtocolSecret.newBuilder().build(); 2776 2777 MeasurementProtocolSecret actualResponse = 2778 client.createMeasurementProtocolSecret(parent, measurementProtocolSecret); 2779 Assert.assertEquals(expectedResponse, actualResponse); 2780 2781 List<String> actualRequests = mockService.getRequestPaths(); 2782 Assert.assertEquals(1, actualRequests.size()); 2783 2784 String apiClientHeaderKey = 2785 mockService 2786 .getRequestHeaders() 2787 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2788 .iterator() 2789 .next(); 2790 Assert.assertTrue( 2791 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2792 .matcher(apiClientHeaderKey) 2793 .matches()); 2794 } 2795 2796 @Test createMeasurementProtocolSecretExceptionTest()2797 public void createMeasurementProtocolSecretExceptionTest() throws Exception { 2798 ApiException exception = 2799 ApiExceptionFactory.createException( 2800 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2801 mockService.addException(exception); 2802 2803 try { 2804 DataStreamName parent = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]"); 2805 MeasurementProtocolSecret measurementProtocolSecret = 2806 MeasurementProtocolSecret.newBuilder().build(); 2807 client.createMeasurementProtocolSecret(parent, measurementProtocolSecret); 2808 Assert.fail("No exception raised"); 2809 } catch (InvalidArgumentException e) { 2810 // Expected exception. 2811 } 2812 } 2813 2814 @Test createMeasurementProtocolSecretTest2()2815 public void createMeasurementProtocolSecretTest2() throws Exception { 2816 MeasurementProtocolSecret expectedResponse = 2817 MeasurementProtocolSecret.newBuilder() 2818 .setName( 2819 MeasurementProtocolSecretName.of( 2820 "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]") 2821 .toString()) 2822 .setDisplayName("displayName1714148973") 2823 .setSecretValue("secretValue-2044460895") 2824 .build(); 2825 mockService.addResponse(expectedResponse); 2826 2827 String parent = "properties/propertie-9651/dataStreams/dataStream-9651"; 2828 MeasurementProtocolSecret measurementProtocolSecret = 2829 MeasurementProtocolSecret.newBuilder().build(); 2830 2831 MeasurementProtocolSecret actualResponse = 2832 client.createMeasurementProtocolSecret(parent, measurementProtocolSecret); 2833 Assert.assertEquals(expectedResponse, actualResponse); 2834 2835 List<String> actualRequests = mockService.getRequestPaths(); 2836 Assert.assertEquals(1, actualRequests.size()); 2837 2838 String apiClientHeaderKey = 2839 mockService 2840 .getRequestHeaders() 2841 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2842 .iterator() 2843 .next(); 2844 Assert.assertTrue( 2845 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2846 .matcher(apiClientHeaderKey) 2847 .matches()); 2848 } 2849 2850 @Test createMeasurementProtocolSecretExceptionTest2()2851 public void createMeasurementProtocolSecretExceptionTest2() throws Exception { 2852 ApiException exception = 2853 ApiExceptionFactory.createException( 2854 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2855 mockService.addException(exception); 2856 2857 try { 2858 String parent = "properties/propertie-9651/dataStreams/dataStream-9651"; 2859 MeasurementProtocolSecret measurementProtocolSecret = 2860 MeasurementProtocolSecret.newBuilder().build(); 2861 client.createMeasurementProtocolSecret(parent, measurementProtocolSecret); 2862 Assert.fail("No exception raised"); 2863 } catch (InvalidArgumentException e) { 2864 // Expected exception. 2865 } 2866 } 2867 2868 @Test deleteMeasurementProtocolSecretTest()2869 public void deleteMeasurementProtocolSecretTest() throws Exception { 2870 Empty expectedResponse = Empty.newBuilder().build(); 2871 mockService.addResponse(expectedResponse); 2872 2873 MeasurementProtocolSecretName name = 2874 MeasurementProtocolSecretName.of( 2875 "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]"); 2876 2877 client.deleteMeasurementProtocolSecret(name); 2878 2879 List<String> actualRequests = mockService.getRequestPaths(); 2880 Assert.assertEquals(1, actualRequests.size()); 2881 2882 String apiClientHeaderKey = 2883 mockService 2884 .getRequestHeaders() 2885 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2886 .iterator() 2887 .next(); 2888 Assert.assertTrue( 2889 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2890 .matcher(apiClientHeaderKey) 2891 .matches()); 2892 } 2893 2894 @Test deleteMeasurementProtocolSecretExceptionTest()2895 public void deleteMeasurementProtocolSecretExceptionTest() throws Exception { 2896 ApiException exception = 2897 ApiExceptionFactory.createException( 2898 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2899 mockService.addException(exception); 2900 2901 try { 2902 MeasurementProtocolSecretName name = 2903 MeasurementProtocolSecretName.of( 2904 "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]"); 2905 client.deleteMeasurementProtocolSecret(name); 2906 Assert.fail("No exception raised"); 2907 } catch (InvalidArgumentException e) { 2908 // Expected exception. 2909 } 2910 } 2911 2912 @Test deleteMeasurementProtocolSecretTest2()2913 public void deleteMeasurementProtocolSecretTest2() throws Exception { 2914 Empty expectedResponse = Empty.newBuilder().build(); 2915 mockService.addResponse(expectedResponse); 2916 2917 String name = 2918 "properties/propertie-6357/dataStreams/dataStream-6357/measurementProtocolSecrets/measurementProtocolSecret-6357"; 2919 2920 client.deleteMeasurementProtocolSecret(name); 2921 2922 List<String> actualRequests = mockService.getRequestPaths(); 2923 Assert.assertEquals(1, actualRequests.size()); 2924 2925 String apiClientHeaderKey = 2926 mockService 2927 .getRequestHeaders() 2928 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2929 .iterator() 2930 .next(); 2931 Assert.assertTrue( 2932 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2933 .matcher(apiClientHeaderKey) 2934 .matches()); 2935 } 2936 2937 @Test deleteMeasurementProtocolSecretExceptionTest2()2938 public void deleteMeasurementProtocolSecretExceptionTest2() throws Exception { 2939 ApiException exception = 2940 ApiExceptionFactory.createException( 2941 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 2942 mockService.addException(exception); 2943 2944 try { 2945 String name = 2946 "properties/propertie-6357/dataStreams/dataStream-6357/measurementProtocolSecrets/measurementProtocolSecret-6357"; 2947 client.deleteMeasurementProtocolSecret(name); 2948 Assert.fail("No exception raised"); 2949 } catch (InvalidArgumentException e) { 2950 // Expected exception. 2951 } 2952 } 2953 2954 @Test updateMeasurementProtocolSecretTest()2955 public void updateMeasurementProtocolSecretTest() throws Exception { 2956 MeasurementProtocolSecret expectedResponse = 2957 MeasurementProtocolSecret.newBuilder() 2958 .setName( 2959 MeasurementProtocolSecretName.of( 2960 "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]") 2961 .toString()) 2962 .setDisplayName("displayName1714148973") 2963 .setSecretValue("secretValue-2044460895") 2964 .build(); 2965 mockService.addResponse(expectedResponse); 2966 2967 MeasurementProtocolSecret measurementProtocolSecret = 2968 MeasurementProtocolSecret.newBuilder() 2969 .setName( 2970 MeasurementProtocolSecretName.of( 2971 "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]") 2972 .toString()) 2973 .setDisplayName("displayName1714148973") 2974 .setSecretValue("secretValue-2044460895") 2975 .build(); 2976 FieldMask updateMask = FieldMask.newBuilder().build(); 2977 2978 MeasurementProtocolSecret actualResponse = 2979 client.updateMeasurementProtocolSecret(measurementProtocolSecret, updateMask); 2980 Assert.assertEquals(expectedResponse, actualResponse); 2981 2982 List<String> actualRequests = mockService.getRequestPaths(); 2983 Assert.assertEquals(1, actualRequests.size()); 2984 2985 String apiClientHeaderKey = 2986 mockService 2987 .getRequestHeaders() 2988 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 2989 .iterator() 2990 .next(); 2991 Assert.assertTrue( 2992 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 2993 .matcher(apiClientHeaderKey) 2994 .matches()); 2995 } 2996 2997 @Test updateMeasurementProtocolSecretExceptionTest()2998 public void updateMeasurementProtocolSecretExceptionTest() throws Exception { 2999 ApiException exception = 3000 ApiExceptionFactory.createException( 3001 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3002 mockService.addException(exception); 3003 3004 try { 3005 MeasurementProtocolSecret measurementProtocolSecret = 3006 MeasurementProtocolSecret.newBuilder() 3007 .setName( 3008 MeasurementProtocolSecretName.of( 3009 "[PROPERTY]", "[DATA_STREAM]", "[MEASUREMENT_PROTOCOL_SECRET]") 3010 .toString()) 3011 .setDisplayName("displayName1714148973") 3012 .setSecretValue("secretValue-2044460895") 3013 .build(); 3014 FieldMask updateMask = FieldMask.newBuilder().build(); 3015 client.updateMeasurementProtocolSecret(measurementProtocolSecret, updateMask); 3016 Assert.fail("No exception raised"); 3017 } catch (InvalidArgumentException e) { 3018 // Expected exception. 3019 } 3020 } 3021 3022 @Test acknowledgeUserDataCollectionTest()3023 public void acknowledgeUserDataCollectionTest() throws Exception { 3024 AcknowledgeUserDataCollectionResponse expectedResponse = 3025 AcknowledgeUserDataCollectionResponse.newBuilder().build(); 3026 mockService.addResponse(expectedResponse); 3027 3028 AcknowledgeUserDataCollectionRequest request = 3029 AcknowledgeUserDataCollectionRequest.newBuilder() 3030 .setProperty(PropertyName.of("[PROPERTY]").toString()) 3031 .setAcknowledgement("acknowledgement1769490938") 3032 .build(); 3033 3034 AcknowledgeUserDataCollectionResponse actualResponse = 3035 client.acknowledgeUserDataCollection(request); 3036 Assert.assertEquals(expectedResponse, actualResponse); 3037 3038 List<String> actualRequests = mockService.getRequestPaths(); 3039 Assert.assertEquals(1, actualRequests.size()); 3040 3041 String apiClientHeaderKey = 3042 mockService 3043 .getRequestHeaders() 3044 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3045 .iterator() 3046 .next(); 3047 Assert.assertTrue( 3048 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3049 .matcher(apiClientHeaderKey) 3050 .matches()); 3051 } 3052 3053 @Test acknowledgeUserDataCollectionExceptionTest()3054 public void acknowledgeUserDataCollectionExceptionTest() throws Exception { 3055 ApiException exception = 3056 ApiExceptionFactory.createException( 3057 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3058 mockService.addException(exception); 3059 3060 try { 3061 AcknowledgeUserDataCollectionRequest request = 3062 AcknowledgeUserDataCollectionRequest.newBuilder() 3063 .setProperty(PropertyName.of("[PROPERTY]").toString()) 3064 .setAcknowledgement("acknowledgement1769490938") 3065 .build(); 3066 client.acknowledgeUserDataCollection(request); 3067 Assert.fail("No exception raised"); 3068 } catch (InvalidArgumentException e) { 3069 // Expected exception. 3070 } 3071 } 3072 3073 @Test searchChangeHistoryEventsTest()3074 public void searchChangeHistoryEventsTest() throws Exception { 3075 ChangeHistoryEvent responsesElement = ChangeHistoryEvent.newBuilder().build(); 3076 SearchChangeHistoryEventsResponse expectedResponse = 3077 SearchChangeHistoryEventsResponse.newBuilder() 3078 .setNextPageToken("") 3079 .addAllChangeHistoryEvents(Arrays.asList(responsesElement)) 3080 .build(); 3081 mockService.addResponse(expectedResponse); 3082 3083 SearchChangeHistoryEventsRequest request = 3084 SearchChangeHistoryEventsRequest.newBuilder() 3085 .setAccount(AccountName.of("[ACCOUNT]").toString()) 3086 .setProperty(PropertyName.of("[PROPERTY]").toString()) 3087 .addAllResourceType(new ArrayList<ChangeHistoryResourceType>()) 3088 .addAllAction(new ArrayList<ActionType>()) 3089 .addAllActorEmail(new ArrayList<String>()) 3090 .setEarliestChangeTime(Timestamp.newBuilder().build()) 3091 .setLatestChangeTime(Timestamp.newBuilder().build()) 3092 .setPageSize(883849137) 3093 .setPageToken("pageToken873572522") 3094 .build(); 3095 3096 SearchChangeHistoryEventsPagedResponse pagedListResponse = 3097 client.searchChangeHistoryEvents(request); 3098 3099 List<ChangeHistoryEvent> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 3100 3101 Assert.assertEquals(1, resources.size()); 3102 Assert.assertEquals(expectedResponse.getChangeHistoryEventsList().get(0), resources.get(0)); 3103 3104 List<String> actualRequests = mockService.getRequestPaths(); 3105 Assert.assertEquals(1, actualRequests.size()); 3106 3107 String apiClientHeaderKey = 3108 mockService 3109 .getRequestHeaders() 3110 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3111 .iterator() 3112 .next(); 3113 Assert.assertTrue( 3114 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3115 .matcher(apiClientHeaderKey) 3116 .matches()); 3117 } 3118 3119 @Test searchChangeHistoryEventsExceptionTest()3120 public void searchChangeHistoryEventsExceptionTest() throws Exception { 3121 ApiException exception = 3122 ApiExceptionFactory.createException( 3123 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3124 mockService.addException(exception); 3125 3126 try { 3127 SearchChangeHistoryEventsRequest request = 3128 SearchChangeHistoryEventsRequest.newBuilder() 3129 .setAccount(AccountName.of("[ACCOUNT]").toString()) 3130 .setProperty(PropertyName.of("[PROPERTY]").toString()) 3131 .addAllResourceType(new ArrayList<ChangeHistoryResourceType>()) 3132 .addAllAction(new ArrayList<ActionType>()) 3133 .addAllActorEmail(new ArrayList<String>()) 3134 .setEarliestChangeTime(Timestamp.newBuilder().build()) 3135 .setLatestChangeTime(Timestamp.newBuilder().build()) 3136 .setPageSize(883849137) 3137 .setPageToken("pageToken873572522") 3138 .build(); 3139 client.searchChangeHistoryEvents(request); 3140 Assert.fail("No exception raised"); 3141 } catch (InvalidArgumentException e) { 3142 // Expected exception. 3143 } 3144 } 3145 3146 @Test getGoogleSignalsSettingsTest()3147 public void getGoogleSignalsSettingsTest() throws Exception { 3148 GoogleSignalsSettings expectedResponse = 3149 GoogleSignalsSettings.newBuilder() 3150 .setName(GoogleSignalsSettingsName.of("[PROPERTY]").toString()) 3151 .setState(GoogleSignalsState.forNumber(0)) 3152 .setConsent(GoogleSignalsConsent.forNumber(0)) 3153 .build(); 3154 mockService.addResponse(expectedResponse); 3155 3156 GoogleSignalsSettingsName name = GoogleSignalsSettingsName.of("[PROPERTY]"); 3157 3158 GoogleSignalsSettings actualResponse = client.getGoogleSignalsSettings(name); 3159 Assert.assertEquals(expectedResponse, actualResponse); 3160 3161 List<String> actualRequests = mockService.getRequestPaths(); 3162 Assert.assertEquals(1, actualRequests.size()); 3163 3164 String apiClientHeaderKey = 3165 mockService 3166 .getRequestHeaders() 3167 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3168 .iterator() 3169 .next(); 3170 Assert.assertTrue( 3171 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3172 .matcher(apiClientHeaderKey) 3173 .matches()); 3174 } 3175 3176 @Test getGoogleSignalsSettingsExceptionTest()3177 public void getGoogleSignalsSettingsExceptionTest() throws Exception { 3178 ApiException exception = 3179 ApiExceptionFactory.createException( 3180 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3181 mockService.addException(exception); 3182 3183 try { 3184 GoogleSignalsSettingsName name = GoogleSignalsSettingsName.of("[PROPERTY]"); 3185 client.getGoogleSignalsSettings(name); 3186 Assert.fail("No exception raised"); 3187 } catch (InvalidArgumentException e) { 3188 // Expected exception. 3189 } 3190 } 3191 3192 @Test getGoogleSignalsSettingsTest2()3193 public void getGoogleSignalsSettingsTest2() throws Exception { 3194 GoogleSignalsSettings expectedResponse = 3195 GoogleSignalsSettings.newBuilder() 3196 .setName(GoogleSignalsSettingsName.of("[PROPERTY]").toString()) 3197 .setState(GoogleSignalsState.forNumber(0)) 3198 .setConsent(GoogleSignalsConsent.forNumber(0)) 3199 .build(); 3200 mockService.addResponse(expectedResponse); 3201 3202 String name = "properties/propertie-7279/googleSignalsSettings"; 3203 3204 GoogleSignalsSettings actualResponse = client.getGoogleSignalsSettings(name); 3205 Assert.assertEquals(expectedResponse, actualResponse); 3206 3207 List<String> actualRequests = mockService.getRequestPaths(); 3208 Assert.assertEquals(1, actualRequests.size()); 3209 3210 String apiClientHeaderKey = 3211 mockService 3212 .getRequestHeaders() 3213 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3214 .iterator() 3215 .next(); 3216 Assert.assertTrue( 3217 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3218 .matcher(apiClientHeaderKey) 3219 .matches()); 3220 } 3221 3222 @Test getGoogleSignalsSettingsExceptionTest2()3223 public void getGoogleSignalsSettingsExceptionTest2() throws Exception { 3224 ApiException exception = 3225 ApiExceptionFactory.createException( 3226 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3227 mockService.addException(exception); 3228 3229 try { 3230 String name = "properties/propertie-7279/googleSignalsSettings"; 3231 client.getGoogleSignalsSettings(name); 3232 Assert.fail("No exception raised"); 3233 } catch (InvalidArgumentException e) { 3234 // Expected exception. 3235 } 3236 } 3237 3238 @Test updateGoogleSignalsSettingsTest()3239 public void updateGoogleSignalsSettingsTest() throws Exception { 3240 GoogleSignalsSettings expectedResponse = 3241 GoogleSignalsSettings.newBuilder() 3242 .setName(GoogleSignalsSettingsName.of("[PROPERTY]").toString()) 3243 .setState(GoogleSignalsState.forNumber(0)) 3244 .setConsent(GoogleSignalsConsent.forNumber(0)) 3245 .build(); 3246 mockService.addResponse(expectedResponse); 3247 3248 GoogleSignalsSettings googleSignalsSettings = 3249 GoogleSignalsSettings.newBuilder() 3250 .setName(GoogleSignalsSettingsName.of("[PROPERTY]").toString()) 3251 .setState(GoogleSignalsState.forNumber(0)) 3252 .setConsent(GoogleSignalsConsent.forNumber(0)) 3253 .build(); 3254 FieldMask updateMask = FieldMask.newBuilder().build(); 3255 3256 GoogleSignalsSettings actualResponse = 3257 client.updateGoogleSignalsSettings(googleSignalsSettings, updateMask); 3258 Assert.assertEquals(expectedResponse, actualResponse); 3259 3260 List<String> actualRequests = mockService.getRequestPaths(); 3261 Assert.assertEquals(1, actualRequests.size()); 3262 3263 String apiClientHeaderKey = 3264 mockService 3265 .getRequestHeaders() 3266 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3267 .iterator() 3268 .next(); 3269 Assert.assertTrue( 3270 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3271 .matcher(apiClientHeaderKey) 3272 .matches()); 3273 } 3274 3275 @Test updateGoogleSignalsSettingsExceptionTest()3276 public void updateGoogleSignalsSettingsExceptionTest() throws Exception { 3277 ApiException exception = 3278 ApiExceptionFactory.createException( 3279 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3280 mockService.addException(exception); 3281 3282 try { 3283 GoogleSignalsSettings googleSignalsSettings = 3284 GoogleSignalsSettings.newBuilder() 3285 .setName(GoogleSignalsSettingsName.of("[PROPERTY]").toString()) 3286 .setState(GoogleSignalsState.forNumber(0)) 3287 .setConsent(GoogleSignalsConsent.forNumber(0)) 3288 .build(); 3289 FieldMask updateMask = FieldMask.newBuilder().build(); 3290 client.updateGoogleSignalsSettings(googleSignalsSettings, updateMask); 3291 Assert.fail("No exception raised"); 3292 } catch (InvalidArgumentException e) { 3293 // Expected exception. 3294 } 3295 } 3296 3297 @Test createConversionEventTest()3298 public void createConversionEventTest() throws Exception { 3299 ConversionEvent expectedResponse = 3300 ConversionEvent.newBuilder() 3301 .setName(ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]").toString()) 3302 .setEventName("eventName31228997") 3303 .setCreateTime(Timestamp.newBuilder().build()) 3304 .setDeletable(true) 3305 .setCustom(true) 3306 .build(); 3307 mockService.addResponse(expectedResponse); 3308 3309 PropertyName parent = PropertyName.of("[PROPERTY]"); 3310 ConversionEvent conversionEvent = ConversionEvent.newBuilder().build(); 3311 3312 ConversionEvent actualResponse = client.createConversionEvent(parent, conversionEvent); 3313 Assert.assertEquals(expectedResponse, actualResponse); 3314 3315 List<String> actualRequests = mockService.getRequestPaths(); 3316 Assert.assertEquals(1, actualRequests.size()); 3317 3318 String apiClientHeaderKey = 3319 mockService 3320 .getRequestHeaders() 3321 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3322 .iterator() 3323 .next(); 3324 Assert.assertTrue( 3325 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3326 .matcher(apiClientHeaderKey) 3327 .matches()); 3328 } 3329 3330 @Test createConversionEventExceptionTest()3331 public void createConversionEventExceptionTest() throws Exception { 3332 ApiException exception = 3333 ApiExceptionFactory.createException( 3334 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3335 mockService.addException(exception); 3336 3337 try { 3338 PropertyName parent = PropertyName.of("[PROPERTY]"); 3339 ConversionEvent conversionEvent = ConversionEvent.newBuilder().build(); 3340 client.createConversionEvent(parent, conversionEvent); 3341 Assert.fail("No exception raised"); 3342 } catch (InvalidArgumentException e) { 3343 // Expected exception. 3344 } 3345 } 3346 3347 @Test createConversionEventTest2()3348 public void createConversionEventTest2() throws Exception { 3349 ConversionEvent expectedResponse = 3350 ConversionEvent.newBuilder() 3351 .setName(ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]").toString()) 3352 .setEventName("eventName31228997") 3353 .setCreateTime(Timestamp.newBuilder().build()) 3354 .setDeletable(true) 3355 .setCustom(true) 3356 .build(); 3357 mockService.addResponse(expectedResponse); 3358 3359 String parent = "properties/propertie-2024"; 3360 ConversionEvent conversionEvent = ConversionEvent.newBuilder().build(); 3361 3362 ConversionEvent actualResponse = client.createConversionEvent(parent, conversionEvent); 3363 Assert.assertEquals(expectedResponse, actualResponse); 3364 3365 List<String> actualRequests = mockService.getRequestPaths(); 3366 Assert.assertEquals(1, actualRequests.size()); 3367 3368 String apiClientHeaderKey = 3369 mockService 3370 .getRequestHeaders() 3371 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3372 .iterator() 3373 .next(); 3374 Assert.assertTrue( 3375 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3376 .matcher(apiClientHeaderKey) 3377 .matches()); 3378 } 3379 3380 @Test createConversionEventExceptionTest2()3381 public void createConversionEventExceptionTest2() throws Exception { 3382 ApiException exception = 3383 ApiExceptionFactory.createException( 3384 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3385 mockService.addException(exception); 3386 3387 try { 3388 String parent = "properties/propertie-2024"; 3389 ConversionEvent conversionEvent = ConversionEvent.newBuilder().build(); 3390 client.createConversionEvent(parent, conversionEvent); 3391 Assert.fail("No exception raised"); 3392 } catch (InvalidArgumentException e) { 3393 // Expected exception. 3394 } 3395 } 3396 3397 @Test getConversionEventTest()3398 public void getConversionEventTest() throws Exception { 3399 ConversionEvent expectedResponse = 3400 ConversionEvent.newBuilder() 3401 .setName(ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]").toString()) 3402 .setEventName("eventName31228997") 3403 .setCreateTime(Timestamp.newBuilder().build()) 3404 .setDeletable(true) 3405 .setCustom(true) 3406 .build(); 3407 mockService.addResponse(expectedResponse); 3408 3409 ConversionEventName name = ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]"); 3410 3411 ConversionEvent actualResponse = client.getConversionEvent(name); 3412 Assert.assertEquals(expectedResponse, actualResponse); 3413 3414 List<String> actualRequests = mockService.getRequestPaths(); 3415 Assert.assertEquals(1, actualRequests.size()); 3416 3417 String apiClientHeaderKey = 3418 mockService 3419 .getRequestHeaders() 3420 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3421 .iterator() 3422 .next(); 3423 Assert.assertTrue( 3424 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3425 .matcher(apiClientHeaderKey) 3426 .matches()); 3427 } 3428 3429 @Test getConversionEventExceptionTest()3430 public void getConversionEventExceptionTest() throws Exception { 3431 ApiException exception = 3432 ApiExceptionFactory.createException( 3433 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3434 mockService.addException(exception); 3435 3436 try { 3437 ConversionEventName name = ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]"); 3438 client.getConversionEvent(name); 3439 Assert.fail("No exception raised"); 3440 } catch (InvalidArgumentException e) { 3441 // Expected exception. 3442 } 3443 } 3444 3445 @Test getConversionEventTest2()3446 public void getConversionEventTest2() throws Exception { 3447 ConversionEvent expectedResponse = 3448 ConversionEvent.newBuilder() 3449 .setName(ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]").toString()) 3450 .setEventName("eventName31228997") 3451 .setCreateTime(Timestamp.newBuilder().build()) 3452 .setDeletable(true) 3453 .setCustom(true) 3454 .build(); 3455 mockService.addResponse(expectedResponse); 3456 3457 String name = "properties/propertie-4144/conversionEvents/conversionEvent-4144"; 3458 3459 ConversionEvent actualResponse = client.getConversionEvent(name); 3460 Assert.assertEquals(expectedResponse, actualResponse); 3461 3462 List<String> actualRequests = mockService.getRequestPaths(); 3463 Assert.assertEquals(1, actualRequests.size()); 3464 3465 String apiClientHeaderKey = 3466 mockService 3467 .getRequestHeaders() 3468 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3469 .iterator() 3470 .next(); 3471 Assert.assertTrue( 3472 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3473 .matcher(apiClientHeaderKey) 3474 .matches()); 3475 } 3476 3477 @Test getConversionEventExceptionTest2()3478 public void getConversionEventExceptionTest2() throws Exception { 3479 ApiException exception = 3480 ApiExceptionFactory.createException( 3481 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3482 mockService.addException(exception); 3483 3484 try { 3485 String name = "properties/propertie-4144/conversionEvents/conversionEvent-4144"; 3486 client.getConversionEvent(name); 3487 Assert.fail("No exception raised"); 3488 } catch (InvalidArgumentException e) { 3489 // Expected exception. 3490 } 3491 } 3492 3493 @Test deleteConversionEventTest()3494 public void deleteConversionEventTest() throws Exception { 3495 Empty expectedResponse = Empty.newBuilder().build(); 3496 mockService.addResponse(expectedResponse); 3497 3498 ConversionEventName name = ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]"); 3499 3500 client.deleteConversionEvent(name); 3501 3502 List<String> actualRequests = mockService.getRequestPaths(); 3503 Assert.assertEquals(1, actualRequests.size()); 3504 3505 String apiClientHeaderKey = 3506 mockService 3507 .getRequestHeaders() 3508 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3509 .iterator() 3510 .next(); 3511 Assert.assertTrue( 3512 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3513 .matcher(apiClientHeaderKey) 3514 .matches()); 3515 } 3516 3517 @Test deleteConversionEventExceptionTest()3518 public void deleteConversionEventExceptionTest() throws Exception { 3519 ApiException exception = 3520 ApiExceptionFactory.createException( 3521 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3522 mockService.addException(exception); 3523 3524 try { 3525 ConversionEventName name = ConversionEventName.of("[PROPERTY]", "[CONVERSION_EVENT]"); 3526 client.deleteConversionEvent(name); 3527 Assert.fail("No exception raised"); 3528 } catch (InvalidArgumentException e) { 3529 // Expected exception. 3530 } 3531 } 3532 3533 @Test deleteConversionEventTest2()3534 public void deleteConversionEventTest2() throws Exception { 3535 Empty expectedResponse = Empty.newBuilder().build(); 3536 mockService.addResponse(expectedResponse); 3537 3538 String name = "properties/propertie-4144/conversionEvents/conversionEvent-4144"; 3539 3540 client.deleteConversionEvent(name); 3541 3542 List<String> actualRequests = mockService.getRequestPaths(); 3543 Assert.assertEquals(1, actualRequests.size()); 3544 3545 String apiClientHeaderKey = 3546 mockService 3547 .getRequestHeaders() 3548 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3549 .iterator() 3550 .next(); 3551 Assert.assertTrue( 3552 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3553 .matcher(apiClientHeaderKey) 3554 .matches()); 3555 } 3556 3557 @Test deleteConversionEventExceptionTest2()3558 public void deleteConversionEventExceptionTest2() throws Exception { 3559 ApiException exception = 3560 ApiExceptionFactory.createException( 3561 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3562 mockService.addException(exception); 3563 3564 try { 3565 String name = "properties/propertie-4144/conversionEvents/conversionEvent-4144"; 3566 client.deleteConversionEvent(name); 3567 Assert.fail("No exception raised"); 3568 } catch (InvalidArgumentException e) { 3569 // Expected exception. 3570 } 3571 } 3572 3573 @Test listConversionEventsTest()3574 public void listConversionEventsTest() throws Exception { 3575 ConversionEvent responsesElement = ConversionEvent.newBuilder().build(); 3576 ListConversionEventsResponse expectedResponse = 3577 ListConversionEventsResponse.newBuilder() 3578 .setNextPageToken("") 3579 .addAllConversionEvents(Arrays.asList(responsesElement)) 3580 .build(); 3581 mockService.addResponse(expectedResponse); 3582 3583 PropertyName parent = PropertyName.of("[PROPERTY]"); 3584 3585 ListConversionEventsPagedResponse pagedListResponse = client.listConversionEvents(parent); 3586 3587 List<ConversionEvent> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 3588 3589 Assert.assertEquals(1, resources.size()); 3590 Assert.assertEquals(expectedResponse.getConversionEventsList().get(0), resources.get(0)); 3591 3592 List<String> actualRequests = mockService.getRequestPaths(); 3593 Assert.assertEquals(1, actualRequests.size()); 3594 3595 String apiClientHeaderKey = 3596 mockService 3597 .getRequestHeaders() 3598 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3599 .iterator() 3600 .next(); 3601 Assert.assertTrue( 3602 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3603 .matcher(apiClientHeaderKey) 3604 .matches()); 3605 } 3606 3607 @Test listConversionEventsExceptionTest()3608 public void listConversionEventsExceptionTest() throws Exception { 3609 ApiException exception = 3610 ApiExceptionFactory.createException( 3611 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3612 mockService.addException(exception); 3613 3614 try { 3615 PropertyName parent = PropertyName.of("[PROPERTY]"); 3616 client.listConversionEvents(parent); 3617 Assert.fail("No exception raised"); 3618 } catch (InvalidArgumentException e) { 3619 // Expected exception. 3620 } 3621 } 3622 3623 @Test listConversionEventsTest2()3624 public void listConversionEventsTest2() throws Exception { 3625 ConversionEvent responsesElement = ConversionEvent.newBuilder().build(); 3626 ListConversionEventsResponse expectedResponse = 3627 ListConversionEventsResponse.newBuilder() 3628 .setNextPageToken("") 3629 .addAllConversionEvents(Arrays.asList(responsesElement)) 3630 .build(); 3631 mockService.addResponse(expectedResponse); 3632 3633 String parent = "properties/propertie-2024"; 3634 3635 ListConversionEventsPagedResponse pagedListResponse = client.listConversionEvents(parent); 3636 3637 List<ConversionEvent> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 3638 3639 Assert.assertEquals(1, resources.size()); 3640 Assert.assertEquals(expectedResponse.getConversionEventsList().get(0), resources.get(0)); 3641 3642 List<String> actualRequests = mockService.getRequestPaths(); 3643 Assert.assertEquals(1, actualRequests.size()); 3644 3645 String apiClientHeaderKey = 3646 mockService 3647 .getRequestHeaders() 3648 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3649 .iterator() 3650 .next(); 3651 Assert.assertTrue( 3652 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3653 .matcher(apiClientHeaderKey) 3654 .matches()); 3655 } 3656 3657 @Test listConversionEventsExceptionTest2()3658 public void listConversionEventsExceptionTest2() throws Exception { 3659 ApiException exception = 3660 ApiExceptionFactory.createException( 3661 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3662 mockService.addException(exception); 3663 3664 try { 3665 String parent = "properties/propertie-2024"; 3666 client.listConversionEvents(parent); 3667 Assert.fail("No exception raised"); 3668 } catch (InvalidArgumentException e) { 3669 // Expected exception. 3670 } 3671 } 3672 3673 @Test getDisplayVideo360AdvertiserLinkTest()3674 public void getDisplayVideo360AdvertiserLinkTest() throws Exception { 3675 DisplayVideo360AdvertiserLink expectedResponse = 3676 DisplayVideo360AdvertiserLink.newBuilder() 3677 .setName( 3678 DisplayVideo360AdvertiserLinkName.of( 3679 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK]") 3680 .toString()) 3681 .setAdvertiserId("advertiserId550061990") 3682 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 3683 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 3684 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 3685 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 3686 .build(); 3687 mockService.addResponse(expectedResponse); 3688 3689 DisplayVideo360AdvertiserLinkName name = 3690 DisplayVideo360AdvertiserLinkName.of("[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK]"); 3691 3692 DisplayVideo360AdvertiserLink actualResponse = client.getDisplayVideo360AdvertiserLink(name); 3693 Assert.assertEquals(expectedResponse, actualResponse); 3694 3695 List<String> actualRequests = mockService.getRequestPaths(); 3696 Assert.assertEquals(1, actualRequests.size()); 3697 3698 String apiClientHeaderKey = 3699 mockService 3700 .getRequestHeaders() 3701 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3702 .iterator() 3703 .next(); 3704 Assert.assertTrue( 3705 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3706 .matcher(apiClientHeaderKey) 3707 .matches()); 3708 } 3709 3710 @Test getDisplayVideo360AdvertiserLinkExceptionTest()3711 public void getDisplayVideo360AdvertiserLinkExceptionTest() throws Exception { 3712 ApiException exception = 3713 ApiExceptionFactory.createException( 3714 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3715 mockService.addException(exception); 3716 3717 try { 3718 DisplayVideo360AdvertiserLinkName name = 3719 DisplayVideo360AdvertiserLinkName.of("[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK]"); 3720 client.getDisplayVideo360AdvertiserLink(name); 3721 Assert.fail("No exception raised"); 3722 } catch (InvalidArgumentException e) { 3723 // Expected exception. 3724 } 3725 } 3726 3727 @Test getDisplayVideo360AdvertiserLinkTest2()3728 public void getDisplayVideo360AdvertiserLinkTest2() throws Exception { 3729 DisplayVideo360AdvertiserLink expectedResponse = 3730 DisplayVideo360AdvertiserLink.newBuilder() 3731 .setName( 3732 DisplayVideo360AdvertiserLinkName.of( 3733 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK]") 3734 .toString()) 3735 .setAdvertiserId("advertiserId550061990") 3736 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 3737 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 3738 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 3739 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 3740 .build(); 3741 mockService.addResponse(expectedResponse); 3742 3743 String name = 3744 "properties/propertie-7275/displayVideo360AdvertiserLinks/displayVideo360AdvertiserLink-7275"; 3745 3746 DisplayVideo360AdvertiserLink actualResponse = client.getDisplayVideo360AdvertiserLink(name); 3747 Assert.assertEquals(expectedResponse, actualResponse); 3748 3749 List<String> actualRequests = mockService.getRequestPaths(); 3750 Assert.assertEquals(1, actualRequests.size()); 3751 3752 String apiClientHeaderKey = 3753 mockService 3754 .getRequestHeaders() 3755 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3756 .iterator() 3757 .next(); 3758 Assert.assertTrue( 3759 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3760 .matcher(apiClientHeaderKey) 3761 .matches()); 3762 } 3763 3764 @Test getDisplayVideo360AdvertiserLinkExceptionTest2()3765 public void getDisplayVideo360AdvertiserLinkExceptionTest2() throws Exception { 3766 ApiException exception = 3767 ApiExceptionFactory.createException( 3768 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3769 mockService.addException(exception); 3770 3771 try { 3772 String name = 3773 "properties/propertie-7275/displayVideo360AdvertiserLinks/displayVideo360AdvertiserLink-7275"; 3774 client.getDisplayVideo360AdvertiserLink(name); 3775 Assert.fail("No exception raised"); 3776 } catch (InvalidArgumentException e) { 3777 // Expected exception. 3778 } 3779 } 3780 3781 @Test listDisplayVideo360AdvertiserLinksTest()3782 public void listDisplayVideo360AdvertiserLinksTest() throws Exception { 3783 DisplayVideo360AdvertiserLink responsesElement = 3784 DisplayVideo360AdvertiserLink.newBuilder().build(); 3785 ListDisplayVideo360AdvertiserLinksResponse expectedResponse = 3786 ListDisplayVideo360AdvertiserLinksResponse.newBuilder() 3787 .setNextPageToken("") 3788 .addAllDisplayVideo360AdvertiserLinks(Arrays.asList(responsesElement)) 3789 .build(); 3790 mockService.addResponse(expectedResponse); 3791 3792 PropertyName parent = PropertyName.of("[PROPERTY]"); 3793 3794 ListDisplayVideo360AdvertiserLinksPagedResponse pagedListResponse = 3795 client.listDisplayVideo360AdvertiserLinks(parent); 3796 3797 List<DisplayVideo360AdvertiserLink> resources = 3798 Lists.newArrayList(pagedListResponse.iterateAll()); 3799 3800 Assert.assertEquals(1, resources.size()); 3801 Assert.assertEquals( 3802 expectedResponse.getDisplayVideo360AdvertiserLinksList().get(0), resources.get(0)); 3803 3804 List<String> actualRequests = mockService.getRequestPaths(); 3805 Assert.assertEquals(1, actualRequests.size()); 3806 3807 String apiClientHeaderKey = 3808 mockService 3809 .getRequestHeaders() 3810 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3811 .iterator() 3812 .next(); 3813 Assert.assertTrue( 3814 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3815 .matcher(apiClientHeaderKey) 3816 .matches()); 3817 } 3818 3819 @Test listDisplayVideo360AdvertiserLinksExceptionTest()3820 public void listDisplayVideo360AdvertiserLinksExceptionTest() throws Exception { 3821 ApiException exception = 3822 ApiExceptionFactory.createException( 3823 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3824 mockService.addException(exception); 3825 3826 try { 3827 PropertyName parent = PropertyName.of("[PROPERTY]"); 3828 client.listDisplayVideo360AdvertiserLinks(parent); 3829 Assert.fail("No exception raised"); 3830 } catch (InvalidArgumentException e) { 3831 // Expected exception. 3832 } 3833 } 3834 3835 @Test listDisplayVideo360AdvertiserLinksTest2()3836 public void listDisplayVideo360AdvertiserLinksTest2() throws Exception { 3837 DisplayVideo360AdvertiserLink responsesElement = 3838 DisplayVideo360AdvertiserLink.newBuilder().build(); 3839 ListDisplayVideo360AdvertiserLinksResponse expectedResponse = 3840 ListDisplayVideo360AdvertiserLinksResponse.newBuilder() 3841 .setNextPageToken("") 3842 .addAllDisplayVideo360AdvertiserLinks(Arrays.asList(responsesElement)) 3843 .build(); 3844 mockService.addResponse(expectedResponse); 3845 3846 String parent = "properties/propertie-2024"; 3847 3848 ListDisplayVideo360AdvertiserLinksPagedResponse pagedListResponse = 3849 client.listDisplayVideo360AdvertiserLinks(parent); 3850 3851 List<DisplayVideo360AdvertiserLink> resources = 3852 Lists.newArrayList(pagedListResponse.iterateAll()); 3853 3854 Assert.assertEquals(1, resources.size()); 3855 Assert.assertEquals( 3856 expectedResponse.getDisplayVideo360AdvertiserLinksList().get(0), resources.get(0)); 3857 3858 List<String> actualRequests = mockService.getRequestPaths(); 3859 Assert.assertEquals(1, actualRequests.size()); 3860 3861 String apiClientHeaderKey = 3862 mockService 3863 .getRequestHeaders() 3864 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3865 .iterator() 3866 .next(); 3867 Assert.assertTrue( 3868 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3869 .matcher(apiClientHeaderKey) 3870 .matches()); 3871 } 3872 3873 @Test listDisplayVideo360AdvertiserLinksExceptionTest2()3874 public void listDisplayVideo360AdvertiserLinksExceptionTest2() throws Exception { 3875 ApiException exception = 3876 ApiExceptionFactory.createException( 3877 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3878 mockService.addException(exception); 3879 3880 try { 3881 String parent = "properties/propertie-2024"; 3882 client.listDisplayVideo360AdvertiserLinks(parent); 3883 Assert.fail("No exception raised"); 3884 } catch (InvalidArgumentException e) { 3885 // Expected exception. 3886 } 3887 } 3888 3889 @Test createDisplayVideo360AdvertiserLinkTest()3890 public void createDisplayVideo360AdvertiserLinkTest() throws Exception { 3891 DisplayVideo360AdvertiserLink expectedResponse = 3892 DisplayVideo360AdvertiserLink.newBuilder() 3893 .setName( 3894 DisplayVideo360AdvertiserLinkName.of( 3895 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK]") 3896 .toString()) 3897 .setAdvertiserId("advertiserId550061990") 3898 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 3899 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 3900 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 3901 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 3902 .build(); 3903 mockService.addResponse(expectedResponse); 3904 3905 PropertyName parent = PropertyName.of("[PROPERTY]"); 3906 DisplayVideo360AdvertiserLink displayVideo360AdvertiserLink = 3907 DisplayVideo360AdvertiserLink.newBuilder().build(); 3908 3909 DisplayVideo360AdvertiserLink actualResponse = 3910 client.createDisplayVideo360AdvertiserLink(parent, displayVideo360AdvertiserLink); 3911 Assert.assertEquals(expectedResponse, actualResponse); 3912 3913 List<String> actualRequests = mockService.getRequestPaths(); 3914 Assert.assertEquals(1, actualRequests.size()); 3915 3916 String apiClientHeaderKey = 3917 mockService 3918 .getRequestHeaders() 3919 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 3920 .iterator() 3921 .next(); 3922 Assert.assertTrue( 3923 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 3924 .matcher(apiClientHeaderKey) 3925 .matches()); 3926 } 3927 3928 @Test createDisplayVideo360AdvertiserLinkExceptionTest()3929 public void createDisplayVideo360AdvertiserLinkExceptionTest() throws Exception { 3930 ApiException exception = 3931 ApiExceptionFactory.createException( 3932 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 3933 mockService.addException(exception); 3934 3935 try { 3936 PropertyName parent = PropertyName.of("[PROPERTY]"); 3937 DisplayVideo360AdvertiserLink displayVideo360AdvertiserLink = 3938 DisplayVideo360AdvertiserLink.newBuilder().build(); 3939 client.createDisplayVideo360AdvertiserLink(parent, displayVideo360AdvertiserLink); 3940 Assert.fail("No exception raised"); 3941 } catch (InvalidArgumentException e) { 3942 // Expected exception. 3943 } 3944 } 3945 3946 @Test createDisplayVideo360AdvertiserLinkTest2()3947 public void createDisplayVideo360AdvertiserLinkTest2() throws Exception { 3948 DisplayVideo360AdvertiserLink expectedResponse = 3949 DisplayVideo360AdvertiserLink.newBuilder() 3950 .setName( 3951 DisplayVideo360AdvertiserLinkName.of( 3952 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK]") 3953 .toString()) 3954 .setAdvertiserId("advertiserId550061990") 3955 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 3956 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 3957 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 3958 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 3959 .build(); 3960 mockService.addResponse(expectedResponse); 3961 3962 String parent = "properties/propertie-2024"; 3963 DisplayVideo360AdvertiserLink displayVideo360AdvertiserLink = 3964 DisplayVideo360AdvertiserLink.newBuilder().build(); 3965 3966 DisplayVideo360AdvertiserLink actualResponse = 3967 client.createDisplayVideo360AdvertiserLink(parent, displayVideo360AdvertiserLink); 3968 Assert.assertEquals(expectedResponse, actualResponse); 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 createDisplayVideo360AdvertiserLinkExceptionTest2()3986 public void createDisplayVideo360AdvertiserLinkExceptionTest2() 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 DisplayVideo360AdvertiserLink displayVideo360AdvertiserLink = 3995 DisplayVideo360AdvertiserLink.newBuilder().build(); 3996 client.createDisplayVideo360AdvertiserLink(parent, displayVideo360AdvertiserLink); 3997 Assert.fail("No exception raised"); 3998 } catch (InvalidArgumentException e) { 3999 // Expected exception. 4000 } 4001 } 4002 4003 @Test deleteDisplayVideo360AdvertiserLinkTest()4004 public void deleteDisplayVideo360AdvertiserLinkTest() throws Exception { 4005 Empty expectedResponse = Empty.newBuilder().build(); 4006 mockService.addResponse(expectedResponse); 4007 4008 DisplayVideo360AdvertiserLinkName name = 4009 DisplayVideo360AdvertiserLinkName.of("[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK]"); 4010 4011 client.deleteDisplayVideo360AdvertiserLink(name); 4012 4013 List<String> actualRequests = mockService.getRequestPaths(); 4014 Assert.assertEquals(1, actualRequests.size()); 4015 4016 String apiClientHeaderKey = 4017 mockService 4018 .getRequestHeaders() 4019 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4020 .iterator() 4021 .next(); 4022 Assert.assertTrue( 4023 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4024 .matcher(apiClientHeaderKey) 4025 .matches()); 4026 } 4027 4028 @Test deleteDisplayVideo360AdvertiserLinkExceptionTest()4029 public void deleteDisplayVideo360AdvertiserLinkExceptionTest() throws Exception { 4030 ApiException exception = 4031 ApiExceptionFactory.createException( 4032 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4033 mockService.addException(exception); 4034 4035 try { 4036 DisplayVideo360AdvertiserLinkName name = 4037 DisplayVideo360AdvertiserLinkName.of("[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK]"); 4038 client.deleteDisplayVideo360AdvertiserLink(name); 4039 Assert.fail("No exception raised"); 4040 } catch (InvalidArgumentException e) { 4041 // Expected exception. 4042 } 4043 } 4044 4045 @Test deleteDisplayVideo360AdvertiserLinkTest2()4046 public void deleteDisplayVideo360AdvertiserLinkTest2() throws Exception { 4047 Empty expectedResponse = Empty.newBuilder().build(); 4048 mockService.addResponse(expectedResponse); 4049 4050 String name = 4051 "properties/propertie-7275/displayVideo360AdvertiserLinks/displayVideo360AdvertiserLink-7275"; 4052 4053 client.deleteDisplayVideo360AdvertiserLink(name); 4054 4055 List<String> actualRequests = mockService.getRequestPaths(); 4056 Assert.assertEquals(1, actualRequests.size()); 4057 4058 String apiClientHeaderKey = 4059 mockService 4060 .getRequestHeaders() 4061 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4062 .iterator() 4063 .next(); 4064 Assert.assertTrue( 4065 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4066 .matcher(apiClientHeaderKey) 4067 .matches()); 4068 } 4069 4070 @Test deleteDisplayVideo360AdvertiserLinkExceptionTest2()4071 public void deleteDisplayVideo360AdvertiserLinkExceptionTest2() throws Exception { 4072 ApiException exception = 4073 ApiExceptionFactory.createException( 4074 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4075 mockService.addException(exception); 4076 4077 try { 4078 String name = 4079 "properties/propertie-7275/displayVideo360AdvertiserLinks/displayVideo360AdvertiserLink-7275"; 4080 client.deleteDisplayVideo360AdvertiserLink(name); 4081 Assert.fail("No exception raised"); 4082 } catch (InvalidArgumentException e) { 4083 // Expected exception. 4084 } 4085 } 4086 4087 @Test updateDisplayVideo360AdvertiserLinkTest()4088 public void updateDisplayVideo360AdvertiserLinkTest() throws Exception { 4089 DisplayVideo360AdvertiserLink expectedResponse = 4090 DisplayVideo360AdvertiserLink.newBuilder() 4091 .setName( 4092 DisplayVideo360AdvertiserLinkName.of( 4093 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK]") 4094 .toString()) 4095 .setAdvertiserId("advertiserId550061990") 4096 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 4097 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 4098 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 4099 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 4100 .build(); 4101 mockService.addResponse(expectedResponse); 4102 4103 DisplayVideo360AdvertiserLink displayVideo360AdvertiserLink = 4104 DisplayVideo360AdvertiserLink.newBuilder() 4105 .setName( 4106 DisplayVideo360AdvertiserLinkName.of( 4107 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK]") 4108 .toString()) 4109 .setAdvertiserId("advertiserId550061990") 4110 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 4111 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 4112 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 4113 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 4114 .build(); 4115 FieldMask updateMask = FieldMask.newBuilder().build(); 4116 4117 DisplayVideo360AdvertiserLink actualResponse = 4118 client.updateDisplayVideo360AdvertiserLink(displayVideo360AdvertiserLink, updateMask); 4119 Assert.assertEquals(expectedResponse, actualResponse); 4120 4121 List<String> actualRequests = mockService.getRequestPaths(); 4122 Assert.assertEquals(1, actualRequests.size()); 4123 4124 String apiClientHeaderKey = 4125 mockService 4126 .getRequestHeaders() 4127 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4128 .iterator() 4129 .next(); 4130 Assert.assertTrue( 4131 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4132 .matcher(apiClientHeaderKey) 4133 .matches()); 4134 } 4135 4136 @Test updateDisplayVideo360AdvertiserLinkExceptionTest()4137 public void updateDisplayVideo360AdvertiserLinkExceptionTest() throws Exception { 4138 ApiException exception = 4139 ApiExceptionFactory.createException( 4140 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4141 mockService.addException(exception); 4142 4143 try { 4144 DisplayVideo360AdvertiserLink displayVideo360AdvertiserLink = 4145 DisplayVideo360AdvertiserLink.newBuilder() 4146 .setName( 4147 DisplayVideo360AdvertiserLinkName.of( 4148 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK]") 4149 .toString()) 4150 .setAdvertiserId("advertiserId550061990") 4151 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 4152 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 4153 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 4154 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 4155 .build(); 4156 FieldMask updateMask = FieldMask.newBuilder().build(); 4157 client.updateDisplayVideo360AdvertiserLink(displayVideo360AdvertiserLink, updateMask); 4158 Assert.fail("No exception raised"); 4159 } catch (InvalidArgumentException e) { 4160 // Expected exception. 4161 } 4162 } 4163 4164 @Test getDisplayVideo360AdvertiserLinkProposalTest()4165 public void getDisplayVideo360AdvertiserLinkProposalTest() throws Exception { 4166 DisplayVideo360AdvertiserLinkProposal expectedResponse = 4167 DisplayVideo360AdvertiserLinkProposal.newBuilder() 4168 .setName( 4169 DisplayVideo360AdvertiserLinkProposalName.of( 4170 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK_PROPOSAL]") 4171 .toString()) 4172 .setAdvertiserId("advertiserId550061990") 4173 .setLinkProposalStatusDetails(LinkProposalStatusDetails.newBuilder().build()) 4174 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 4175 .setValidationEmail("validationEmail-94407005") 4176 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 4177 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 4178 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 4179 .build(); 4180 mockService.addResponse(expectedResponse); 4181 4182 DisplayVideo360AdvertiserLinkProposalName name = 4183 DisplayVideo360AdvertiserLinkProposalName.of( 4184 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK_PROPOSAL]"); 4185 4186 DisplayVideo360AdvertiserLinkProposal actualResponse = 4187 client.getDisplayVideo360AdvertiserLinkProposal(name); 4188 Assert.assertEquals(expectedResponse, actualResponse); 4189 4190 List<String> actualRequests = mockService.getRequestPaths(); 4191 Assert.assertEquals(1, actualRequests.size()); 4192 4193 String apiClientHeaderKey = 4194 mockService 4195 .getRequestHeaders() 4196 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4197 .iterator() 4198 .next(); 4199 Assert.assertTrue( 4200 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4201 .matcher(apiClientHeaderKey) 4202 .matches()); 4203 } 4204 4205 @Test getDisplayVideo360AdvertiserLinkProposalExceptionTest()4206 public void getDisplayVideo360AdvertiserLinkProposalExceptionTest() throws Exception { 4207 ApiException exception = 4208 ApiExceptionFactory.createException( 4209 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4210 mockService.addException(exception); 4211 4212 try { 4213 DisplayVideo360AdvertiserLinkProposalName name = 4214 DisplayVideo360AdvertiserLinkProposalName.of( 4215 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK_PROPOSAL]"); 4216 client.getDisplayVideo360AdvertiserLinkProposal(name); 4217 Assert.fail("No exception raised"); 4218 } catch (InvalidArgumentException e) { 4219 // Expected exception. 4220 } 4221 } 4222 4223 @Test getDisplayVideo360AdvertiserLinkProposalTest2()4224 public void getDisplayVideo360AdvertiserLinkProposalTest2() throws Exception { 4225 DisplayVideo360AdvertiserLinkProposal expectedResponse = 4226 DisplayVideo360AdvertiserLinkProposal.newBuilder() 4227 .setName( 4228 DisplayVideo360AdvertiserLinkProposalName.of( 4229 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK_PROPOSAL]") 4230 .toString()) 4231 .setAdvertiserId("advertiserId550061990") 4232 .setLinkProposalStatusDetails(LinkProposalStatusDetails.newBuilder().build()) 4233 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 4234 .setValidationEmail("validationEmail-94407005") 4235 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 4236 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 4237 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 4238 .build(); 4239 mockService.addResponse(expectedResponse); 4240 4241 String name = 4242 "properties/propertie-8473/displayVideo360AdvertiserLinkProposals/displayVideo360AdvertiserLinkProposal-8473"; 4243 4244 DisplayVideo360AdvertiserLinkProposal actualResponse = 4245 client.getDisplayVideo360AdvertiserLinkProposal(name); 4246 Assert.assertEquals(expectedResponse, actualResponse); 4247 4248 List<String> actualRequests = mockService.getRequestPaths(); 4249 Assert.assertEquals(1, actualRequests.size()); 4250 4251 String apiClientHeaderKey = 4252 mockService 4253 .getRequestHeaders() 4254 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4255 .iterator() 4256 .next(); 4257 Assert.assertTrue( 4258 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4259 .matcher(apiClientHeaderKey) 4260 .matches()); 4261 } 4262 4263 @Test getDisplayVideo360AdvertiserLinkProposalExceptionTest2()4264 public void getDisplayVideo360AdvertiserLinkProposalExceptionTest2() throws Exception { 4265 ApiException exception = 4266 ApiExceptionFactory.createException( 4267 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4268 mockService.addException(exception); 4269 4270 try { 4271 String name = 4272 "properties/propertie-8473/displayVideo360AdvertiserLinkProposals/displayVideo360AdvertiserLinkProposal-8473"; 4273 client.getDisplayVideo360AdvertiserLinkProposal(name); 4274 Assert.fail("No exception raised"); 4275 } catch (InvalidArgumentException e) { 4276 // Expected exception. 4277 } 4278 } 4279 4280 @Test listDisplayVideo360AdvertiserLinkProposalsTest()4281 public void listDisplayVideo360AdvertiserLinkProposalsTest() throws Exception { 4282 DisplayVideo360AdvertiserLinkProposal responsesElement = 4283 DisplayVideo360AdvertiserLinkProposal.newBuilder().build(); 4284 ListDisplayVideo360AdvertiserLinkProposalsResponse expectedResponse = 4285 ListDisplayVideo360AdvertiserLinkProposalsResponse.newBuilder() 4286 .setNextPageToken("") 4287 .addAllDisplayVideo360AdvertiserLinkProposals(Arrays.asList(responsesElement)) 4288 .build(); 4289 mockService.addResponse(expectedResponse); 4290 4291 PropertyName parent = PropertyName.of("[PROPERTY]"); 4292 4293 ListDisplayVideo360AdvertiserLinkProposalsPagedResponse pagedListResponse = 4294 client.listDisplayVideo360AdvertiserLinkProposals(parent); 4295 4296 List<DisplayVideo360AdvertiserLinkProposal> resources = 4297 Lists.newArrayList(pagedListResponse.iterateAll()); 4298 4299 Assert.assertEquals(1, resources.size()); 4300 Assert.assertEquals( 4301 expectedResponse.getDisplayVideo360AdvertiserLinkProposalsList().get(0), resources.get(0)); 4302 4303 List<String> actualRequests = mockService.getRequestPaths(); 4304 Assert.assertEquals(1, actualRequests.size()); 4305 4306 String apiClientHeaderKey = 4307 mockService 4308 .getRequestHeaders() 4309 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4310 .iterator() 4311 .next(); 4312 Assert.assertTrue( 4313 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4314 .matcher(apiClientHeaderKey) 4315 .matches()); 4316 } 4317 4318 @Test listDisplayVideo360AdvertiserLinkProposalsExceptionTest()4319 public void listDisplayVideo360AdvertiserLinkProposalsExceptionTest() throws Exception { 4320 ApiException exception = 4321 ApiExceptionFactory.createException( 4322 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4323 mockService.addException(exception); 4324 4325 try { 4326 PropertyName parent = PropertyName.of("[PROPERTY]"); 4327 client.listDisplayVideo360AdvertiserLinkProposals(parent); 4328 Assert.fail("No exception raised"); 4329 } catch (InvalidArgumentException e) { 4330 // Expected exception. 4331 } 4332 } 4333 4334 @Test listDisplayVideo360AdvertiserLinkProposalsTest2()4335 public void listDisplayVideo360AdvertiserLinkProposalsTest2() throws Exception { 4336 DisplayVideo360AdvertiserLinkProposal responsesElement = 4337 DisplayVideo360AdvertiserLinkProposal.newBuilder().build(); 4338 ListDisplayVideo360AdvertiserLinkProposalsResponse expectedResponse = 4339 ListDisplayVideo360AdvertiserLinkProposalsResponse.newBuilder() 4340 .setNextPageToken("") 4341 .addAllDisplayVideo360AdvertiserLinkProposals(Arrays.asList(responsesElement)) 4342 .build(); 4343 mockService.addResponse(expectedResponse); 4344 4345 String parent = "properties/propertie-2024"; 4346 4347 ListDisplayVideo360AdvertiserLinkProposalsPagedResponse pagedListResponse = 4348 client.listDisplayVideo360AdvertiserLinkProposals(parent); 4349 4350 List<DisplayVideo360AdvertiserLinkProposal> resources = 4351 Lists.newArrayList(pagedListResponse.iterateAll()); 4352 4353 Assert.assertEquals(1, resources.size()); 4354 Assert.assertEquals( 4355 expectedResponse.getDisplayVideo360AdvertiserLinkProposalsList().get(0), resources.get(0)); 4356 4357 List<String> actualRequests = mockService.getRequestPaths(); 4358 Assert.assertEquals(1, actualRequests.size()); 4359 4360 String apiClientHeaderKey = 4361 mockService 4362 .getRequestHeaders() 4363 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4364 .iterator() 4365 .next(); 4366 Assert.assertTrue( 4367 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4368 .matcher(apiClientHeaderKey) 4369 .matches()); 4370 } 4371 4372 @Test listDisplayVideo360AdvertiserLinkProposalsExceptionTest2()4373 public void listDisplayVideo360AdvertiserLinkProposalsExceptionTest2() throws Exception { 4374 ApiException exception = 4375 ApiExceptionFactory.createException( 4376 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4377 mockService.addException(exception); 4378 4379 try { 4380 String parent = "properties/propertie-2024"; 4381 client.listDisplayVideo360AdvertiserLinkProposals(parent); 4382 Assert.fail("No exception raised"); 4383 } catch (InvalidArgumentException e) { 4384 // Expected exception. 4385 } 4386 } 4387 4388 @Test createDisplayVideo360AdvertiserLinkProposalTest()4389 public void createDisplayVideo360AdvertiserLinkProposalTest() throws Exception { 4390 DisplayVideo360AdvertiserLinkProposal expectedResponse = 4391 DisplayVideo360AdvertiserLinkProposal.newBuilder() 4392 .setName( 4393 DisplayVideo360AdvertiserLinkProposalName.of( 4394 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK_PROPOSAL]") 4395 .toString()) 4396 .setAdvertiserId("advertiserId550061990") 4397 .setLinkProposalStatusDetails(LinkProposalStatusDetails.newBuilder().build()) 4398 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 4399 .setValidationEmail("validationEmail-94407005") 4400 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 4401 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 4402 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 4403 .build(); 4404 mockService.addResponse(expectedResponse); 4405 4406 PropertyName parent = PropertyName.of("[PROPERTY]"); 4407 DisplayVideo360AdvertiserLinkProposal displayVideo360AdvertiserLinkProposal = 4408 DisplayVideo360AdvertiserLinkProposal.newBuilder().build(); 4409 4410 DisplayVideo360AdvertiserLinkProposal actualResponse = 4411 client.createDisplayVideo360AdvertiserLinkProposal( 4412 parent, displayVideo360AdvertiserLinkProposal); 4413 Assert.assertEquals(expectedResponse, actualResponse); 4414 4415 List<String> actualRequests = mockService.getRequestPaths(); 4416 Assert.assertEquals(1, actualRequests.size()); 4417 4418 String apiClientHeaderKey = 4419 mockService 4420 .getRequestHeaders() 4421 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4422 .iterator() 4423 .next(); 4424 Assert.assertTrue( 4425 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4426 .matcher(apiClientHeaderKey) 4427 .matches()); 4428 } 4429 4430 @Test createDisplayVideo360AdvertiserLinkProposalExceptionTest()4431 public void createDisplayVideo360AdvertiserLinkProposalExceptionTest() throws Exception { 4432 ApiException exception = 4433 ApiExceptionFactory.createException( 4434 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4435 mockService.addException(exception); 4436 4437 try { 4438 PropertyName parent = PropertyName.of("[PROPERTY]"); 4439 DisplayVideo360AdvertiserLinkProposal displayVideo360AdvertiserLinkProposal = 4440 DisplayVideo360AdvertiserLinkProposal.newBuilder().build(); 4441 client.createDisplayVideo360AdvertiserLinkProposal( 4442 parent, displayVideo360AdvertiserLinkProposal); 4443 Assert.fail("No exception raised"); 4444 } catch (InvalidArgumentException e) { 4445 // Expected exception. 4446 } 4447 } 4448 4449 @Test createDisplayVideo360AdvertiserLinkProposalTest2()4450 public void createDisplayVideo360AdvertiserLinkProposalTest2() throws Exception { 4451 DisplayVideo360AdvertiserLinkProposal expectedResponse = 4452 DisplayVideo360AdvertiserLinkProposal.newBuilder() 4453 .setName( 4454 DisplayVideo360AdvertiserLinkProposalName.of( 4455 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK_PROPOSAL]") 4456 .toString()) 4457 .setAdvertiserId("advertiserId550061990") 4458 .setLinkProposalStatusDetails(LinkProposalStatusDetails.newBuilder().build()) 4459 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 4460 .setValidationEmail("validationEmail-94407005") 4461 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 4462 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 4463 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 4464 .build(); 4465 mockService.addResponse(expectedResponse); 4466 4467 String parent = "properties/propertie-2024"; 4468 DisplayVideo360AdvertiserLinkProposal displayVideo360AdvertiserLinkProposal = 4469 DisplayVideo360AdvertiserLinkProposal.newBuilder().build(); 4470 4471 DisplayVideo360AdvertiserLinkProposal actualResponse = 4472 client.createDisplayVideo360AdvertiserLinkProposal( 4473 parent, displayVideo360AdvertiserLinkProposal); 4474 Assert.assertEquals(expectedResponse, actualResponse); 4475 4476 List<String> actualRequests = mockService.getRequestPaths(); 4477 Assert.assertEquals(1, actualRequests.size()); 4478 4479 String apiClientHeaderKey = 4480 mockService 4481 .getRequestHeaders() 4482 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4483 .iterator() 4484 .next(); 4485 Assert.assertTrue( 4486 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4487 .matcher(apiClientHeaderKey) 4488 .matches()); 4489 } 4490 4491 @Test createDisplayVideo360AdvertiserLinkProposalExceptionTest2()4492 public void createDisplayVideo360AdvertiserLinkProposalExceptionTest2() throws Exception { 4493 ApiException exception = 4494 ApiExceptionFactory.createException( 4495 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4496 mockService.addException(exception); 4497 4498 try { 4499 String parent = "properties/propertie-2024"; 4500 DisplayVideo360AdvertiserLinkProposal displayVideo360AdvertiserLinkProposal = 4501 DisplayVideo360AdvertiserLinkProposal.newBuilder().build(); 4502 client.createDisplayVideo360AdvertiserLinkProposal( 4503 parent, displayVideo360AdvertiserLinkProposal); 4504 Assert.fail("No exception raised"); 4505 } catch (InvalidArgumentException e) { 4506 // Expected exception. 4507 } 4508 } 4509 4510 @Test deleteDisplayVideo360AdvertiserLinkProposalTest()4511 public void deleteDisplayVideo360AdvertiserLinkProposalTest() throws Exception { 4512 Empty expectedResponse = Empty.newBuilder().build(); 4513 mockService.addResponse(expectedResponse); 4514 4515 DisplayVideo360AdvertiserLinkProposalName name = 4516 DisplayVideo360AdvertiserLinkProposalName.of( 4517 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK_PROPOSAL]"); 4518 4519 client.deleteDisplayVideo360AdvertiserLinkProposal(name); 4520 4521 List<String> actualRequests = mockService.getRequestPaths(); 4522 Assert.assertEquals(1, actualRequests.size()); 4523 4524 String apiClientHeaderKey = 4525 mockService 4526 .getRequestHeaders() 4527 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4528 .iterator() 4529 .next(); 4530 Assert.assertTrue( 4531 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4532 .matcher(apiClientHeaderKey) 4533 .matches()); 4534 } 4535 4536 @Test deleteDisplayVideo360AdvertiserLinkProposalExceptionTest()4537 public void deleteDisplayVideo360AdvertiserLinkProposalExceptionTest() throws Exception { 4538 ApiException exception = 4539 ApiExceptionFactory.createException( 4540 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4541 mockService.addException(exception); 4542 4543 try { 4544 DisplayVideo360AdvertiserLinkProposalName name = 4545 DisplayVideo360AdvertiserLinkProposalName.of( 4546 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK_PROPOSAL]"); 4547 client.deleteDisplayVideo360AdvertiserLinkProposal(name); 4548 Assert.fail("No exception raised"); 4549 } catch (InvalidArgumentException e) { 4550 // Expected exception. 4551 } 4552 } 4553 4554 @Test deleteDisplayVideo360AdvertiserLinkProposalTest2()4555 public void deleteDisplayVideo360AdvertiserLinkProposalTest2() throws Exception { 4556 Empty expectedResponse = Empty.newBuilder().build(); 4557 mockService.addResponse(expectedResponse); 4558 4559 String name = 4560 "properties/propertie-8473/displayVideo360AdvertiserLinkProposals/displayVideo360AdvertiserLinkProposal-8473"; 4561 4562 client.deleteDisplayVideo360AdvertiserLinkProposal(name); 4563 4564 List<String> actualRequests = mockService.getRequestPaths(); 4565 Assert.assertEquals(1, actualRequests.size()); 4566 4567 String apiClientHeaderKey = 4568 mockService 4569 .getRequestHeaders() 4570 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4571 .iterator() 4572 .next(); 4573 Assert.assertTrue( 4574 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4575 .matcher(apiClientHeaderKey) 4576 .matches()); 4577 } 4578 4579 @Test deleteDisplayVideo360AdvertiserLinkProposalExceptionTest2()4580 public void deleteDisplayVideo360AdvertiserLinkProposalExceptionTest2() throws Exception { 4581 ApiException exception = 4582 ApiExceptionFactory.createException( 4583 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4584 mockService.addException(exception); 4585 4586 try { 4587 String name = 4588 "properties/propertie-8473/displayVideo360AdvertiserLinkProposals/displayVideo360AdvertiserLinkProposal-8473"; 4589 client.deleteDisplayVideo360AdvertiserLinkProposal(name); 4590 Assert.fail("No exception raised"); 4591 } catch (InvalidArgumentException e) { 4592 // Expected exception. 4593 } 4594 } 4595 4596 @Test approveDisplayVideo360AdvertiserLinkProposalTest()4597 public void approveDisplayVideo360AdvertiserLinkProposalTest() throws Exception { 4598 ApproveDisplayVideo360AdvertiserLinkProposalResponse expectedResponse = 4599 ApproveDisplayVideo360AdvertiserLinkProposalResponse.newBuilder() 4600 .setDisplayVideo360AdvertiserLink(DisplayVideo360AdvertiserLink.newBuilder().build()) 4601 .build(); 4602 mockService.addResponse(expectedResponse); 4603 4604 ApproveDisplayVideo360AdvertiserLinkProposalRequest request = 4605 ApproveDisplayVideo360AdvertiserLinkProposalRequest.newBuilder() 4606 .setName( 4607 DisplayVideo360AdvertiserLinkProposalName.of( 4608 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK_PROPOSAL]") 4609 .toString()) 4610 .build(); 4611 4612 ApproveDisplayVideo360AdvertiserLinkProposalResponse actualResponse = 4613 client.approveDisplayVideo360AdvertiserLinkProposal(request); 4614 Assert.assertEquals(expectedResponse, actualResponse); 4615 4616 List<String> actualRequests = mockService.getRequestPaths(); 4617 Assert.assertEquals(1, actualRequests.size()); 4618 4619 String apiClientHeaderKey = 4620 mockService 4621 .getRequestHeaders() 4622 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4623 .iterator() 4624 .next(); 4625 Assert.assertTrue( 4626 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4627 .matcher(apiClientHeaderKey) 4628 .matches()); 4629 } 4630 4631 @Test approveDisplayVideo360AdvertiserLinkProposalExceptionTest()4632 public void approveDisplayVideo360AdvertiserLinkProposalExceptionTest() throws Exception { 4633 ApiException exception = 4634 ApiExceptionFactory.createException( 4635 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4636 mockService.addException(exception); 4637 4638 try { 4639 ApproveDisplayVideo360AdvertiserLinkProposalRequest request = 4640 ApproveDisplayVideo360AdvertiserLinkProposalRequest.newBuilder() 4641 .setName( 4642 DisplayVideo360AdvertiserLinkProposalName.of( 4643 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK_PROPOSAL]") 4644 .toString()) 4645 .build(); 4646 client.approveDisplayVideo360AdvertiserLinkProposal(request); 4647 Assert.fail("No exception raised"); 4648 } catch (InvalidArgumentException e) { 4649 // Expected exception. 4650 } 4651 } 4652 4653 @Test cancelDisplayVideo360AdvertiserLinkProposalTest()4654 public void cancelDisplayVideo360AdvertiserLinkProposalTest() throws Exception { 4655 DisplayVideo360AdvertiserLinkProposal expectedResponse = 4656 DisplayVideo360AdvertiserLinkProposal.newBuilder() 4657 .setName( 4658 DisplayVideo360AdvertiserLinkProposalName.of( 4659 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK_PROPOSAL]") 4660 .toString()) 4661 .setAdvertiserId("advertiserId550061990") 4662 .setLinkProposalStatusDetails(LinkProposalStatusDetails.newBuilder().build()) 4663 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 4664 .setValidationEmail("validationEmail-94407005") 4665 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 4666 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 4667 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 4668 .build(); 4669 mockService.addResponse(expectedResponse); 4670 4671 CancelDisplayVideo360AdvertiserLinkProposalRequest request = 4672 CancelDisplayVideo360AdvertiserLinkProposalRequest.newBuilder() 4673 .setName( 4674 DisplayVideo360AdvertiserLinkProposalName.of( 4675 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK_PROPOSAL]") 4676 .toString()) 4677 .build(); 4678 4679 DisplayVideo360AdvertiserLinkProposal actualResponse = 4680 client.cancelDisplayVideo360AdvertiserLinkProposal(request); 4681 Assert.assertEquals(expectedResponse, actualResponse); 4682 4683 List<String> actualRequests = mockService.getRequestPaths(); 4684 Assert.assertEquals(1, actualRequests.size()); 4685 4686 String apiClientHeaderKey = 4687 mockService 4688 .getRequestHeaders() 4689 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4690 .iterator() 4691 .next(); 4692 Assert.assertTrue( 4693 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4694 .matcher(apiClientHeaderKey) 4695 .matches()); 4696 } 4697 4698 @Test cancelDisplayVideo360AdvertiserLinkProposalExceptionTest()4699 public void cancelDisplayVideo360AdvertiserLinkProposalExceptionTest() throws Exception { 4700 ApiException exception = 4701 ApiExceptionFactory.createException( 4702 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4703 mockService.addException(exception); 4704 4705 try { 4706 CancelDisplayVideo360AdvertiserLinkProposalRequest request = 4707 CancelDisplayVideo360AdvertiserLinkProposalRequest.newBuilder() 4708 .setName( 4709 DisplayVideo360AdvertiserLinkProposalName.of( 4710 "[PROPERTY]", "[DISPLAY_VIDEO_360_ADVERTISER_LINK_PROPOSAL]") 4711 .toString()) 4712 .build(); 4713 client.cancelDisplayVideo360AdvertiserLinkProposal(request); 4714 Assert.fail("No exception raised"); 4715 } catch (InvalidArgumentException e) { 4716 // Expected exception. 4717 } 4718 } 4719 4720 @Test createCustomDimensionTest()4721 public void createCustomDimensionTest() throws Exception { 4722 CustomDimension expectedResponse = 4723 CustomDimension.newBuilder() 4724 .setName(CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]").toString()) 4725 .setParameterName("parameterName-379607596") 4726 .setDisplayName("displayName1714148973") 4727 .setDescription("description-1724546052") 4728 .setDisallowAdsPersonalization(true) 4729 .build(); 4730 mockService.addResponse(expectedResponse); 4731 4732 PropertyName parent = PropertyName.of("[PROPERTY]"); 4733 CustomDimension customDimension = CustomDimension.newBuilder().build(); 4734 4735 CustomDimension actualResponse = client.createCustomDimension(parent, customDimension); 4736 Assert.assertEquals(expectedResponse, actualResponse); 4737 4738 List<String> actualRequests = mockService.getRequestPaths(); 4739 Assert.assertEquals(1, actualRequests.size()); 4740 4741 String apiClientHeaderKey = 4742 mockService 4743 .getRequestHeaders() 4744 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4745 .iterator() 4746 .next(); 4747 Assert.assertTrue( 4748 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4749 .matcher(apiClientHeaderKey) 4750 .matches()); 4751 } 4752 4753 @Test createCustomDimensionExceptionTest()4754 public void createCustomDimensionExceptionTest() throws Exception { 4755 ApiException exception = 4756 ApiExceptionFactory.createException( 4757 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4758 mockService.addException(exception); 4759 4760 try { 4761 PropertyName parent = PropertyName.of("[PROPERTY]"); 4762 CustomDimension customDimension = CustomDimension.newBuilder().build(); 4763 client.createCustomDimension(parent, customDimension); 4764 Assert.fail("No exception raised"); 4765 } catch (InvalidArgumentException e) { 4766 // Expected exception. 4767 } 4768 } 4769 4770 @Test createCustomDimensionTest2()4771 public void createCustomDimensionTest2() throws Exception { 4772 CustomDimension expectedResponse = 4773 CustomDimension.newBuilder() 4774 .setName(CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]").toString()) 4775 .setParameterName("parameterName-379607596") 4776 .setDisplayName("displayName1714148973") 4777 .setDescription("description-1724546052") 4778 .setDisallowAdsPersonalization(true) 4779 .build(); 4780 mockService.addResponse(expectedResponse); 4781 4782 String parent = "properties/propertie-2024"; 4783 CustomDimension customDimension = CustomDimension.newBuilder().build(); 4784 4785 CustomDimension actualResponse = client.createCustomDimension(parent, customDimension); 4786 Assert.assertEquals(expectedResponse, actualResponse); 4787 4788 List<String> actualRequests = mockService.getRequestPaths(); 4789 Assert.assertEquals(1, actualRequests.size()); 4790 4791 String apiClientHeaderKey = 4792 mockService 4793 .getRequestHeaders() 4794 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4795 .iterator() 4796 .next(); 4797 Assert.assertTrue( 4798 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4799 .matcher(apiClientHeaderKey) 4800 .matches()); 4801 } 4802 4803 @Test createCustomDimensionExceptionTest2()4804 public void createCustomDimensionExceptionTest2() throws Exception { 4805 ApiException exception = 4806 ApiExceptionFactory.createException( 4807 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4808 mockService.addException(exception); 4809 4810 try { 4811 String parent = "properties/propertie-2024"; 4812 CustomDimension customDimension = CustomDimension.newBuilder().build(); 4813 client.createCustomDimension(parent, customDimension); 4814 Assert.fail("No exception raised"); 4815 } catch (InvalidArgumentException e) { 4816 // Expected exception. 4817 } 4818 } 4819 4820 @Test updateCustomDimensionTest()4821 public void updateCustomDimensionTest() throws Exception { 4822 CustomDimension expectedResponse = 4823 CustomDimension.newBuilder() 4824 .setName(CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]").toString()) 4825 .setParameterName("parameterName-379607596") 4826 .setDisplayName("displayName1714148973") 4827 .setDescription("description-1724546052") 4828 .setDisallowAdsPersonalization(true) 4829 .build(); 4830 mockService.addResponse(expectedResponse); 4831 4832 CustomDimension customDimension = 4833 CustomDimension.newBuilder() 4834 .setName(CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]").toString()) 4835 .setParameterName("parameterName-379607596") 4836 .setDisplayName("displayName1714148973") 4837 .setDescription("description-1724546052") 4838 .setDisallowAdsPersonalization(true) 4839 .build(); 4840 FieldMask updateMask = FieldMask.newBuilder().build(); 4841 4842 CustomDimension actualResponse = client.updateCustomDimension(customDimension, updateMask); 4843 Assert.assertEquals(expectedResponse, actualResponse); 4844 4845 List<String> actualRequests = mockService.getRequestPaths(); 4846 Assert.assertEquals(1, actualRequests.size()); 4847 4848 String apiClientHeaderKey = 4849 mockService 4850 .getRequestHeaders() 4851 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4852 .iterator() 4853 .next(); 4854 Assert.assertTrue( 4855 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4856 .matcher(apiClientHeaderKey) 4857 .matches()); 4858 } 4859 4860 @Test updateCustomDimensionExceptionTest()4861 public void updateCustomDimensionExceptionTest() throws Exception { 4862 ApiException exception = 4863 ApiExceptionFactory.createException( 4864 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4865 mockService.addException(exception); 4866 4867 try { 4868 CustomDimension customDimension = 4869 CustomDimension.newBuilder() 4870 .setName(CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]").toString()) 4871 .setParameterName("parameterName-379607596") 4872 .setDisplayName("displayName1714148973") 4873 .setDescription("description-1724546052") 4874 .setDisallowAdsPersonalization(true) 4875 .build(); 4876 FieldMask updateMask = FieldMask.newBuilder().build(); 4877 client.updateCustomDimension(customDimension, updateMask); 4878 Assert.fail("No exception raised"); 4879 } catch (InvalidArgumentException e) { 4880 // Expected exception. 4881 } 4882 } 4883 4884 @Test listCustomDimensionsTest()4885 public void listCustomDimensionsTest() throws Exception { 4886 CustomDimension responsesElement = CustomDimension.newBuilder().build(); 4887 ListCustomDimensionsResponse expectedResponse = 4888 ListCustomDimensionsResponse.newBuilder() 4889 .setNextPageToken("") 4890 .addAllCustomDimensions(Arrays.asList(responsesElement)) 4891 .build(); 4892 mockService.addResponse(expectedResponse); 4893 4894 PropertyName parent = PropertyName.of("[PROPERTY]"); 4895 4896 ListCustomDimensionsPagedResponse pagedListResponse = client.listCustomDimensions(parent); 4897 4898 List<CustomDimension> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 4899 4900 Assert.assertEquals(1, resources.size()); 4901 Assert.assertEquals(expectedResponse.getCustomDimensionsList().get(0), resources.get(0)); 4902 4903 List<String> actualRequests = mockService.getRequestPaths(); 4904 Assert.assertEquals(1, actualRequests.size()); 4905 4906 String apiClientHeaderKey = 4907 mockService 4908 .getRequestHeaders() 4909 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4910 .iterator() 4911 .next(); 4912 Assert.assertTrue( 4913 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4914 .matcher(apiClientHeaderKey) 4915 .matches()); 4916 } 4917 4918 @Test listCustomDimensionsExceptionTest()4919 public void listCustomDimensionsExceptionTest() throws Exception { 4920 ApiException exception = 4921 ApiExceptionFactory.createException( 4922 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4923 mockService.addException(exception); 4924 4925 try { 4926 PropertyName parent = PropertyName.of("[PROPERTY]"); 4927 client.listCustomDimensions(parent); 4928 Assert.fail("No exception raised"); 4929 } catch (InvalidArgumentException e) { 4930 // Expected exception. 4931 } 4932 } 4933 4934 @Test listCustomDimensionsTest2()4935 public void listCustomDimensionsTest2() throws Exception { 4936 CustomDimension responsesElement = CustomDimension.newBuilder().build(); 4937 ListCustomDimensionsResponse expectedResponse = 4938 ListCustomDimensionsResponse.newBuilder() 4939 .setNextPageToken("") 4940 .addAllCustomDimensions(Arrays.asList(responsesElement)) 4941 .build(); 4942 mockService.addResponse(expectedResponse); 4943 4944 String parent = "properties/propertie-2024"; 4945 4946 ListCustomDimensionsPagedResponse pagedListResponse = client.listCustomDimensions(parent); 4947 4948 List<CustomDimension> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 4949 4950 Assert.assertEquals(1, resources.size()); 4951 Assert.assertEquals(expectedResponse.getCustomDimensionsList().get(0), resources.get(0)); 4952 4953 List<String> actualRequests = mockService.getRequestPaths(); 4954 Assert.assertEquals(1, actualRequests.size()); 4955 4956 String apiClientHeaderKey = 4957 mockService 4958 .getRequestHeaders() 4959 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 4960 .iterator() 4961 .next(); 4962 Assert.assertTrue( 4963 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 4964 .matcher(apiClientHeaderKey) 4965 .matches()); 4966 } 4967 4968 @Test listCustomDimensionsExceptionTest2()4969 public void listCustomDimensionsExceptionTest2() throws Exception { 4970 ApiException exception = 4971 ApiExceptionFactory.createException( 4972 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 4973 mockService.addException(exception); 4974 4975 try { 4976 String parent = "properties/propertie-2024"; 4977 client.listCustomDimensions(parent); 4978 Assert.fail("No exception raised"); 4979 } catch (InvalidArgumentException e) { 4980 // Expected exception. 4981 } 4982 } 4983 4984 @Test archiveCustomDimensionTest()4985 public void archiveCustomDimensionTest() throws Exception { 4986 Empty expectedResponse = Empty.newBuilder().build(); 4987 mockService.addResponse(expectedResponse); 4988 4989 CustomDimensionName name = CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]"); 4990 4991 client.archiveCustomDimension(name); 4992 4993 List<String> actualRequests = mockService.getRequestPaths(); 4994 Assert.assertEquals(1, actualRequests.size()); 4995 4996 String apiClientHeaderKey = 4997 mockService 4998 .getRequestHeaders() 4999 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5000 .iterator() 5001 .next(); 5002 Assert.assertTrue( 5003 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5004 .matcher(apiClientHeaderKey) 5005 .matches()); 5006 } 5007 5008 @Test archiveCustomDimensionExceptionTest()5009 public void archiveCustomDimensionExceptionTest() throws Exception { 5010 ApiException exception = 5011 ApiExceptionFactory.createException( 5012 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5013 mockService.addException(exception); 5014 5015 try { 5016 CustomDimensionName name = CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]"); 5017 client.archiveCustomDimension(name); 5018 Assert.fail("No exception raised"); 5019 } catch (InvalidArgumentException e) { 5020 // Expected exception. 5021 } 5022 } 5023 5024 @Test archiveCustomDimensionTest2()5025 public void archiveCustomDimensionTest2() throws Exception { 5026 Empty expectedResponse = Empty.newBuilder().build(); 5027 mockService.addResponse(expectedResponse); 5028 5029 String name = "properties/propertie-447/customDimensions/customDimension-447"; 5030 5031 client.archiveCustomDimension(name); 5032 5033 List<String> actualRequests = mockService.getRequestPaths(); 5034 Assert.assertEquals(1, actualRequests.size()); 5035 5036 String apiClientHeaderKey = 5037 mockService 5038 .getRequestHeaders() 5039 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5040 .iterator() 5041 .next(); 5042 Assert.assertTrue( 5043 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5044 .matcher(apiClientHeaderKey) 5045 .matches()); 5046 } 5047 5048 @Test archiveCustomDimensionExceptionTest2()5049 public void archiveCustomDimensionExceptionTest2() throws Exception { 5050 ApiException exception = 5051 ApiExceptionFactory.createException( 5052 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5053 mockService.addException(exception); 5054 5055 try { 5056 String name = "properties/propertie-447/customDimensions/customDimension-447"; 5057 client.archiveCustomDimension(name); 5058 Assert.fail("No exception raised"); 5059 } catch (InvalidArgumentException e) { 5060 // Expected exception. 5061 } 5062 } 5063 5064 @Test getCustomDimensionTest()5065 public void getCustomDimensionTest() throws Exception { 5066 CustomDimension expectedResponse = 5067 CustomDimension.newBuilder() 5068 .setName(CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]").toString()) 5069 .setParameterName("parameterName-379607596") 5070 .setDisplayName("displayName1714148973") 5071 .setDescription("description-1724546052") 5072 .setDisallowAdsPersonalization(true) 5073 .build(); 5074 mockService.addResponse(expectedResponse); 5075 5076 CustomDimensionName name = CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]"); 5077 5078 CustomDimension actualResponse = client.getCustomDimension(name); 5079 Assert.assertEquals(expectedResponse, actualResponse); 5080 5081 List<String> actualRequests = mockService.getRequestPaths(); 5082 Assert.assertEquals(1, actualRequests.size()); 5083 5084 String apiClientHeaderKey = 5085 mockService 5086 .getRequestHeaders() 5087 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5088 .iterator() 5089 .next(); 5090 Assert.assertTrue( 5091 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5092 .matcher(apiClientHeaderKey) 5093 .matches()); 5094 } 5095 5096 @Test getCustomDimensionExceptionTest()5097 public void getCustomDimensionExceptionTest() throws Exception { 5098 ApiException exception = 5099 ApiExceptionFactory.createException( 5100 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5101 mockService.addException(exception); 5102 5103 try { 5104 CustomDimensionName name = CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]"); 5105 client.getCustomDimension(name); 5106 Assert.fail("No exception raised"); 5107 } catch (InvalidArgumentException e) { 5108 // Expected exception. 5109 } 5110 } 5111 5112 @Test getCustomDimensionTest2()5113 public void getCustomDimensionTest2() throws Exception { 5114 CustomDimension expectedResponse = 5115 CustomDimension.newBuilder() 5116 .setName(CustomDimensionName.of("[PROPERTY]", "[CUSTOM_DIMENSION]").toString()) 5117 .setParameterName("parameterName-379607596") 5118 .setDisplayName("displayName1714148973") 5119 .setDescription("description-1724546052") 5120 .setDisallowAdsPersonalization(true) 5121 .build(); 5122 mockService.addResponse(expectedResponse); 5123 5124 String name = "properties/propertie-447/customDimensions/customDimension-447"; 5125 5126 CustomDimension actualResponse = client.getCustomDimension(name); 5127 Assert.assertEquals(expectedResponse, actualResponse); 5128 5129 List<String> actualRequests = mockService.getRequestPaths(); 5130 Assert.assertEquals(1, actualRequests.size()); 5131 5132 String apiClientHeaderKey = 5133 mockService 5134 .getRequestHeaders() 5135 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5136 .iterator() 5137 .next(); 5138 Assert.assertTrue( 5139 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5140 .matcher(apiClientHeaderKey) 5141 .matches()); 5142 } 5143 5144 @Test getCustomDimensionExceptionTest2()5145 public void getCustomDimensionExceptionTest2() throws Exception { 5146 ApiException exception = 5147 ApiExceptionFactory.createException( 5148 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5149 mockService.addException(exception); 5150 5151 try { 5152 String name = "properties/propertie-447/customDimensions/customDimension-447"; 5153 client.getCustomDimension(name); 5154 Assert.fail("No exception raised"); 5155 } catch (InvalidArgumentException e) { 5156 // Expected exception. 5157 } 5158 } 5159 5160 @Test createCustomMetricTest()5161 public void createCustomMetricTest() throws Exception { 5162 CustomMetric expectedResponse = 5163 CustomMetric.newBuilder() 5164 .setName(CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]").toString()) 5165 .setParameterName("parameterName-379607596") 5166 .setDisplayName("displayName1714148973") 5167 .setDescription("description-1724546052") 5168 .addAllRestrictedMetricType(new ArrayList<CustomMetric.RestrictedMetricType>()) 5169 .build(); 5170 mockService.addResponse(expectedResponse); 5171 5172 PropertyName parent = PropertyName.of("[PROPERTY]"); 5173 CustomMetric customMetric = CustomMetric.newBuilder().build(); 5174 5175 CustomMetric actualResponse = client.createCustomMetric(parent, customMetric); 5176 Assert.assertEquals(expectedResponse, actualResponse); 5177 5178 List<String> actualRequests = mockService.getRequestPaths(); 5179 Assert.assertEquals(1, actualRequests.size()); 5180 5181 String apiClientHeaderKey = 5182 mockService 5183 .getRequestHeaders() 5184 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5185 .iterator() 5186 .next(); 5187 Assert.assertTrue( 5188 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5189 .matcher(apiClientHeaderKey) 5190 .matches()); 5191 } 5192 5193 @Test createCustomMetricExceptionTest()5194 public void createCustomMetricExceptionTest() throws Exception { 5195 ApiException exception = 5196 ApiExceptionFactory.createException( 5197 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5198 mockService.addException(exception); 5199 5200 try { 5201 PropertyName parent = PropertyName.of("[PROPERTY]"); 5202 CustomMetric customMetric = CustomMetric.newBuilder().build(); 5203 client.createCustomMetric(parent, customMetric); 5204 Assert.fail("No exception raised"); 5205 } catch (InvalidArgumentException e) { 5206 // Expected exception. 5207 } 5208 } 5209 5210 @Test createCustomMetricTest2()5211 public void createCustomMetricTest2() throws Exception { 5212 CustomMetric expectedResponse = 5213 CustomMetric.newBuilder() 5214 .setName(CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]").toString()) 5215 .setParameterName("parameterName-379607596") 5216 .setDisplayName("displayName1714148973") 5217 .setDescription("description-1724546052") 5218 .addAllRestrictedMetricType(new ArrayList<CustomMetric.RestrictedMetricType>()) 5219 .build(); 5220 mockService.addResponse(expectedResponse); 5221 5222 String parent = "properties/propertie-2024"; 5223 CustomMetric customMetric = CustomMetric.newBuilder().build(); 5224 5225 CustomMetric actualResponse = client.createCustomMetric(parent, customMetric); 5226 Assert.assertEquals(expectedResponse, actualResponse); 5227 5228 List<String> actualRequests = mockService.getRequestPaths(); 5229 Assert.assertEquals(1, actualRequests.size()); 5230 5231 String apiClientHeaderKey = 5232 mockService 5233 .getRequestHeaders() 5234 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5235 .iterator() 5236 .next(); 5237 Assert.assertTrue( 5238 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5239 .matcher(apiClientHeaderKey) 5240 .matches()); 5241 } 5242 5243 @Test createCustomMetricExceptionTest2()5244 public void createCustomMetricExceptionTest2() throws Exception { 5245 ApiException exception = 5246 ApiExceptionFactory.createException( 5247 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5248 mockService.addException(exception); 5249 5250 try { 5251 String parent = "properties/propertie-2024"; 5252 CustomMetric customMetric = CustomMetric.newBuilder().build(); 5253 client.createCustomMetric(parent, customMetric); 5254 Assert.fail("No exception raised"); 5255 } catch (InvalidArgumentException e) { 5256 // Expected exception. 5257 } 5258 } 5259 5260 @Test updateCustomMetricTest()5261 public void updateCustomMetricTest() throws Exception { 5262 CustomMetric expectedResponse = 5263 CustomMetric.newBuilder() 5264 .setName(CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]").toString()) 5265 .setParameterName("parameterName-379607596") 5266 .setDisplayName("displayName1714148973") 5267 .setDescription("description-1724546052") 5268 .addAllRestrictedMetricType(new ArrayList<CustomMetric.RestrictedMetricType>()) 5269 .build(); 5270 mockService.addResponse(expectedResponse); 5271 5272 CustomMetric customMetric = 5273 CustomMetric.newBuilder() 5274 .setName(CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]").toString()) 5275 .setParameterName("parameterName-379607596") 5276 .setDisplayName("displayName1714148973") 5277 .setDescription("description-1724546052") 5278 .addAllRestrictedMetricType(new ArrayList<CustomMetric.RestrictedMetricType>()) 5279 .build(); 5280 FieldMask updateMask = FieldMask.newBuilder().build(); 5281 5282 CustomMetric actualResponse = client.updateCustomMetric(customMetric, updateMask); 5283 Assert.assertEquals(expectedResponse, actualResponse); 5284 5285 List<String> actualRequests = mockService.getRequestPaths(); 5286 Assert.assertEquals(1, actualRequests.size()); 5287 5288 String apiClientHeaderKey = 5289 mockService 5290 .getRequestHeaders() 5291 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5292 .iterator() 5293 .next(); 5294 Assert.assertTrue( 5295 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5296 .matcher(apiClientHeaderKey) 5297 .matches()); 5298 } 5299 5300 @Test updateCustomMetricExceptionTest()5301 public void updateCustomMetricExceptionTest() throws Exception { 5302 ApiException exception = 5303 ApiExceptionFactory.createException( 5304 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5305 mockService.addException(exception); 5306 5307 try { 5308 CustomMetric customMetric = 5309 CustomMetric.newBuilder() 5310 .setName(CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]").toString()) 5311 .setParameterName("parameterName-379607596") 5312 .setDisplayName("displayName1714148973") 5313 .setDescription("description-1724546052") 5314 .addAllRestrictedMetricType(new ArrayList<CustomMetric.RestrictedMetricType>()) 5315 .build(); 5316 FieldMask updateMask = FieldMask.newBuilder().build(); 5317 client.updateCustomMetric(customMetric, updateMask); 5318 Assert.fail("No exception raised"); 5319 } catch (InvalidArgumentException e) { 5320 // Expected exception. 5321 } 5322 } 5323 5324 @Test listCustomMetricsTest()5325 public void listCustomMetricsTest() throws Exception { 5326 CustomMetric responsesElement = CustomMetric.newBuilder().build(); 5327 ListCustomMetricsResponse expectedResponse = 5328 ListCustomMetricsResponse.newBuilder() 5329 .setNextPageToken("") 5330 .addAllCustomMetrics(Arrays.asList(responsesElement)) 5331 .build(); 5332 mockService.addResponse(expectedResponse); 5333 5334 PropertyName parent = PropertyName.of("[PROPERTY]"); 5335 5336 ListCustomMetricsPagedResponse pagedListResponse = client.listCustomMetrics(parent); 5337 5338 List<CustomMetric> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 5339 5340 Assert.assertEquals(1, resources.size()); 5341 Assert.assertEquals(expectedResponse.getCustomMetricsList().get(0), resources.get(0)); 5342 5343 List<String> actualRequests = mockService.getRequestPaths(); 5344 Assert.assertEquals(1, actualRequests.size()); 5345 5346 String apiClientHeaderKey = 5347 mockService 5348 .getRequestHeaders() 5349 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5350 .iterator() 5351 .next(); 5352 Assert.assertTrue( 5353 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5354 .matcher(apiClientHeaderKey) 5355 .matches()); 5356 } 5357 5358 @Test listCustomMetricsExceptionTest()5359 public void listCustomMetricsExceptionTest() throws Exception { 5360 ApiException exception = 5361 ApiExceptionFactory.createException( 5362 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5363 mockService.addException(exception); 5364 5365 try { 5366 PropertyName parent = PropertyName.of("[PROPERTY]"); 5367 client.listCustomMetrics(parent); 5368 Assert.fail("No exception raised"); 5369 } catch (InvalidArgumentException e) { 5370 // Expected exception. 5371 } 5372 } 5373 5374 @Test listCustomMetricsTest2()5375 public void listCustomMetricsTest2() throws Exception { 5376 CustomMetric responsesElement = CustomMetric.newBuilder().build(); 5377 ListCustomMetricsResponse expectedResponse = 5378 ListCustomMetricsResponse.newBuilder() 5379 .setNextPageToken("") 5380 .addAllCustomMetrics(Arrays.asList(responsesElement)) 5381 .build(); 5382 mockService.addResponse(expectedResponse); 5383 5384 String parent = "properties/propertie-2024"; 5385 5386 ListCustomMetricsPagedResponse pagedListResponse = client.listCustomMetrics(parent); 5387 5388 List<CustomMetric> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 5389 5390 Assert.assertEquals(1, resources.size()); 5391 Assert.assertEquals(expectedResponse.getCustomMetricsList().get(0), resources.get(0)); 5392 5393 List<String> actualRequests = mockService.getRequestPaths(); 5394 Assert.assertEquals(1, actualRequests.size()); 5395 5396 String apiClientHeaderKey = 5397 mockService 5398 .getRequestHeaders() 5399 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5400 .iterator() 5401 .next(); 5402 Assert.assertTrue( 5403 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5404 .matcher(apiClientHeaderKey) 5405 .matches()); 5406 } 5407 5408 @Test listCustomMetricsExceptionTest2()5409 public void listCustomMetricsExceptionTest2() throws Exception { 5410 ApiException exception = 5411 ApiExceptionFactory.createException( 5412 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5413 mockService.addException(exception); 5414 5415 try { 5416 String parent = "properties/propertie-2024"; 5417 client.listCustomMetrics(parent); 5418 Assert.fail("No exception raised"); 5419 } catch (InvalidArgumentException e) { 5420 // Expected exception. 5421 } 5422 } 5423 5424 @Test archiveCustomMetricTest()5425 public void archiveCustomMetricTest() throws Exception { 5426 Empty expectedResponse = Empty.newBuilder().build(); 5427 mockService.addResponse(expectedResponse); 5428 5429 CustomMetricName name = CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]"); 5430 5431 client.archiveCustomMetric(name); 5432 5433 List<String> actualRequests = mockService.getRequestPaths(); 5434 Assert.assertEquals(1, actualRequests.size()); 5435 5436 String apiClientHeaderKey = 5437 mockService 5438 .getRequestHeaders() 5439 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5440 .iterator() 5441 .next(); 5442 Assert.assertTrue( 5443 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5444 .matcher(apiClientHeaderKey) 5445 .matches()); 5446 } 5447 5448 @Test archiveCustomMetricExceptionTest()5449 public void archiveCustomMetricExceptionTest() throws Exception { 5450 ApiException exception = 5451 ApiExceptionFactory.createException( 5452 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5453 mockService.addException(exception); 5454 5455 try { 5456 CustomMetricName name = CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]"); 5457 client.archiveCustomMetric(name); 5458 Assert.fail("No exception raised"); 5459 } catch (InvalidArgumentException e) { 5460 // Expected exception. 5461 } 5462 } 5463 5464 @Test archiveCustomMetricTest2()5465 public void archiveCustomMetricTest2() throws Exception { 5466 Empty expectedResponse = Empty.newBuilder().build(); 5467 mockService.addResponse(expectedResponse); 5468 5469 String name = "properties/propertie-2999/customMetrics/customMetric-2999"; 5470 5471 client.archiveCustomMetric(name); 5472 5473 List<String> actualRequests = mockService.getRequestPaths(); 5474 Assert.assertEquals(1, actualRequests.size()); 5475 5476 String apiClientHeaderKey = 5477 mockService 5478 .getRequestHeaders() 5479 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5480 .iterator() 5481 .next(); 5482 Assert.assertTrue( 5483 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5484 .matcher(apiClientHeaderKey) 5485 .matches()); 5486 } 5487 5488 @Test archiveCustomMetricExceptionTest2()5489 public void archiveCustomMetricExceptionTest2() throws Exception { 5490 ApiException exception = 5491 ApiExceptionFactory.createException( 5492 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5493 mockService.addException(exception); 5494 5495 try { 5496 String name = "properties/propertie-2999/customMetrics/customMetric-2999"; 5497 client.archiveCustomMetric(name); 5498 Assert.fail("No exception raised"); 5499 } catch (InvalidArgumentException e) { 5500 // Expected exception. 5501 } 5502 } 5503 5504 @Test getCustomMetricTest()5505 public void getCustomMetricTest() throws Exception { 5506 CustomMetric expectedResponse = 5507 CustomMetric.newBuilder() 5508 .setName(CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]").toString()) 5509 .setParameterName("parameterName-379607596") 5510 .setDisplayName("displayName1714148973") 5511 .setDescription("description-1724546052") 5512 .addAllRestrictedMetricType(new ArrayList<CustomMetric.RestrictedMetricType>()) 5513 .build(); 5514 mockService.addResponse(expectedResponse); 5515 5516 CustomMetricName name = CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]"); 5517 5518 CustomMetric actualResponse = client.getCustomMetric(name); 5519 Assert.assertEquals(expectedResponse, actualResponse); 5520 5521 List<String> actualRequests = mockService.getRequestPaths(); 5522 Assert.assertEquals(1, actualRequests.size()); 5523 5524 String apiClientHeaderKey = 5525 mockService 5526 .getRequestHeaders() 5527 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5528 .iterator() 5529 .next(); 5530 Assert.assertTrue( 5531 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5532 .matcher(apiClientHeaderKey) 5533 .matches()); 5534 } 5535 5536 @Test getCustomMetricExceptionTest()5537 public void getCustomMetricExceptionTest() throws Exception { 5538 ApiException exception = 5539 ApiExceptionFactory.createException( 5540 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5541 mockService.addException(exception); 5542 5543 try { 5544 CustomMetricName name = CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]"); 5545 client.getCustomMetric(name); 5546 Assert.fail("No exception raised"); 5547 } catch (InvalidArgumentException e) { 5548 // Expected exception. 5549 } 5550 } 5551 5552 @Test getCustomMetricTest2()5553 public void getCustomMetricTest2() throws Exception { 5554 CustomMetric expectedResponse = 5555 CustomMetric.newBuilder() 5556 .setName(CustomMetricName.of("[PROPERTY]", "[CUSTOM_METRIC]").toString()) 5557 .setParameterName("parameterName-379607596") 5558 .setDisplayName("displayName1714148973") 5559 .setDescription("description-1724546052") 5560 .addAllRestrictedMetricType(new ArrayList<CustomMetric.RestrictedMetricType>()) 5561 .build(); 5562 mockService.addResponse(expectedResponse); 5563 5564 String name = "properties/propertie-2999/customMetrics/customMetric-2999"; 5565 5566 CustomMetric actualResponse = client.getCustomMetric(name); 5567 Assert.assertEquals(expectedResponse, actualResponse); 5568 5569 List<String> actualRequests = mockService.getRequestPaths(); 5570 Assert.assertEquals(1, actualRequests.size()); 5571 5572 String apiClientHeaderKey = 5573 mockService 5574 .getRequestHeaders() 5575 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5576 .iterator() 5577 .next(); 5578 Assert.assertTrue( 5579 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5580 .matcher(apiClientHeaderKey) 5581 .matches()); 5582 } 5583 5584 @Test getCustomMetricExceptionTest2()5585 public void getCustomMetricExceptionTest2() throws Exception { 5586 ApiException exception = 5587 ApiExceptionFactory.createException( 5588 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5589 mockService.addException(exception); 5590 5591 try { 5592 String name = "properties/propertie-2999/customMetrics/customMetric-2999"; 5593 client.getCustomMetric(name); 5594 Assert.fail("No exception raised"); 5595 } catch (InvalidArgumentException e) { 5596 // Expected exception. 5597 } 5598 } 5599 5600 @Test getDataRetentionSettingsTest()5601 public void getDataRetentionSettingsTest() throws Exception { 5602 DataRetentionSettings expectedResponse = 5603 DataRetentionSettings.newBuilder() 5604 .setName(DataRetentionSettingsName.of("[PROPERTY]").toString()) 5605 .setResetUserDataOnNewActivity(true) 5606 .build(); 5607 mockService.addResponse(expectedResponse); 5608 5609 DataRetentionSettingsName name = DataRetentionSettingsName.of("[PROPERTY]"); 5610 5611 DataRetentionSettings actualResponse = client.getDataRetentionSettings(name); 5612 Assert.assertEquals(expectedResponse, actualResponse); 5613 5614 List<String> actualRequests = mockService.getRequestPaths(); 5615 Assert.assertEquals(1, actualRequests.size()); 5616 5617 String apiClientHeaderKey = 5618 mockService 5619 .getRequestHeaders() 5620 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5621 .iterator() 5622 .next(); 5623 Assert.assertTrue( 5624 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5625 .matcher(apiClientHeaderKey) 5626 .matches()); 5627 } 5628 5629 @Test getDataRetentionSettingsExceptionTest()5630 public void getDataRetentionSettingsExceptionTest() throws Exception { 5631 ApiException exception = 5632 ApiExceptionFactory.createException( 5633 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5634 mockService.addException(exception); 5635 5636 try { 5637 DataRetentionSettingsName name = DataRetentionSettingsName.of("[PROPERTY]"); 5638 client.getDataRetentionSettings(name); 5639 Assert.fail("No exception raised"); 5640 } catch (InvalidArgumentException e) { 5641 // Expected exception. 5642 } 5643 } 5644 5645 @Test getDataRetentionSettingsTest2()5646 public void getDataRetentionSettingsTest2() throws Exception { 5647 DataRetentionSettings expectedResponse = 5648 DataRetentionSettings.newBuilder() 5649 .setName(DataRetentionSettingsName.of("[PROPERTY]").toString()) 5650 .setResetUserDataOnNewActivity(true) 5651 .build(); 5652 mockService.addResponse(expectedResponse); 5653 5654 String name = "properties/propertie-2463/dataRetentionSettings"; 5655 5656 DataRetentionSettings actualResponse = client.getDataRetentionSettings(name); 5657 Assert.assertEquals(expectedResponse, actualResponse); 5658 5659 List<String> actualRequests = mockService.getRequestPaths(); 5660 Assert.assertEquals(1, actualRequests.size()); 5661 5662 String apiClientHeaderKey = 5663 mockService 5664 .getRequestHeaders() 5665 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5666 .iterator() 5667 .next(); 5668 Assert.assertTrue( 5669 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5670 .matcher(apiClientHeaderKey) 5671 .matches()); 5672 } 5673 5674 @Test getDataRetentionSettingsExceptionTest2()5675 public void getDataRetentionSettingsExceptionTest2() throws Exception { 5676 ApiException exception = 5677 ApiExceptionFactory.createException( 5678 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5679 mockService.addException(exception); 5680 5681 try { 5682 String name = "properties/propertie-2463/dataRetentionSettings"; 5683 client.getDataRetentionSettings(name); 5684 Assert.fail("No exception raised"); 5685 } catch (InvalidArgumentException e) { 5686 // Expected exception. 5687 } 5688 } 5689 5690 @Test updateDataRetentionSettingsTest()5691 public void updateDataRetentionSettingsTest() throws Exception { 5692 DataRetentionSettings expectedResponse = 5693 DataRetentionSettings.newBuilder() 5694 .setName(DataRetentionSettingsName.of("[PROPERTY]").toString()) 5695 .setResetUserDataOnNewActivity(true) 5696 .build(); 5697 mockService.addResponse(expectedResponse); 5698 5699 DataRetentionSettings dataRetentionSettings = 5700 DataRetentionSettings.newBuilder() 5701 .setName(DataRetentionSettingsName.of("[PROPERTY]").toString()) 5702 .setResetUserDataOnNewActivity(true) 5703 .build(); 5704 FieldMask updateMask = FieldMask.newBuilder().build(); 5705 5706 DataRetentionSettings actualResponse = 5707 client.updateDataRetentionSettings(dataRetentionSettings, updateMask); 5708 Assert.assertEquals(expectedResponse, actualResponse); 5709 5710 List<String> actualRequests = mockService.getRequestPaths(); 5711 Assert.assertEquals(1, actualRequests.size()); 5712 5713 String apiClientHeaderKey = 5714 mockService 5715 .getRequestHeaders() 5716 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5717 .iterator() 5718 .next(); 5719 Assert.assertTrue( 5720 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5721 .matcher(apiClientHeaderKey) 5722 .matches()); 5723 } 5724 5725 @Test updateDataRetentionSettingsExceptionTest()5726 public void updateDataRetentionSettingsExceptionTest() throws Exception { 5727 ApiException exception = 5728 ApiExceptionFactory.createException( 5729 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5730 mockService.addException(exception); 5731 5732 try { 5733 DataRetentionSettings dataRetentionSettings = 5734 DataRetentionSettings.newBuilder() 5735 .setName(DataRetentionSettingsName.of("[PROPERTY]").toString()) 5736 .setResetUserDataOnNewActivity(true) 5737 .build(); 5738 FieldMask updateMask = FieldMask.newBuilder().build(); 5739 client.updateDataRetentionSettings(dataRetentionSettings, updateMask); 5740 Assert.fail("No exception raised"); 5741 } catch (InvalidArgumentException e) { 5742 // Expected exception. 5743 } 5744 } 5745 5746 @Test createDataStreamTest()5747 public void createDataStreamTest() throws Exception { 5748 DataStream expectedResponse = 5749 DataStream.newBuilder() 5750 .setName(DataStreamName.of("[PROPERTY]", "[DATA_STREAM]").toString()) 5751 .setDisplayName("displayName1714148973") 5752 .setCreateTime(Timestamp.newBuilder().build()) 5753 .setUpdateTime(Timestamp.newBuilder().build()) 5754 .build(); 5755 mockService.addResponse(expectedResponse); 5756 5757 PropertyName parent = PropertyName.of("[PROPERTY]"); 5758 DataStream dataStream = DataStream.newBuilder().build(); 5759 5760 DataStream actualResponse = client.createDataStream(parent, dataStream); 5761 Assert.assertEquals(expectedResponse, actualResponse); 5762 5763 List<String> actualRequests = mockService.getRequestPaths(); 5764 Assert.assertEquals(1, actualRequests.size()); 5765 5766 String apiClientHeaderKey = 5767 mockService 5768 .getRequestHeaders() 5769 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5770 .iterator() 5771 .next(); 5772 Assert.assertTrue( 5773 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5774 .matcher(apiClientHeaderKey) 5775 .matches()); 5776 } 5777 5778 @Test createDataStreamExceptionTest()5779 public void createDataStreamExceptionTest() throws Exception { 5780 ApiException exception = 5781 ApiExceptionFactory.createException( 5782 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5783 mockService.addException(exception); 5784 5785 try { 5786 PropertyName parent = PropertyName.of("[PROPERTY]"); 5787 DataStream dataStream = DataStream.newBuilder().build(); 5788 client.createDataStream(parent, dataStream); 5789 Assert.fail("No exception raised"); 5790 } catch (InvalidArgumentException e) { 5791 // Expected exception. 5792 } 5793 } 5794 5795 @Test createDataStreamTest2()5796 public void createDataStreamTest2() throws Exception { 5797 DataStream expectedResponse = 5798 DataStream.newBuilder() 5799 .setName(DataStreamName.of("[PROPERTY]", "[DATA_STREAM]").toString()) 5800 .setDisplayName("displayName1714148973") 5801 .setCreateTime(Timestamp.newBuilder().build()) 5802 .setUpdateTime(Timestamp.newBuilder().build()) 5803 .build(); 5804 mockService.addResponse(expectedResponse); 5805 5806 String parent = "properties/propertie-2024"; 5807 DataStream dataStream = DataStream.newBuilder().build(); 5808 5809 DataStream actualResponse = client.createDataStream(parent, dataStream); 5810 Assert.assertEquals(expectedResponse, actualResponse); 5811 5812 List<String> actualRequests = mockService.getRequestPaths(); 5813 Assert.assertEquals(1, actualRequests.size()); 5814 5815 String apiClientHeaderKey = 5816 mockService 5817 .getRequestHeaders() 5818 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5819 .iterator() 5820 .next(); 5821 Assert.assertTrue( 5822 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5823 .matcher(apiClientHeaderKey) 5824 .matches()); 5825 } 5826 5827 @Test createDataStreamExceptionTest2()5828 public void createDataStreamExceptionTest2() throws Exception { 5829 ApiException exception = 5830 ApiExceptionFactory.createException( 5831 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5832 mockService.addException(exception); 5833 5834 try { 5835 String parent = "properties/propertie-2024"; 5836 DataStream dataStream = DataStream.newBuilder().build(); 5837 client.createDataStream(parent, dataStream); 5838 Assert.fail("No exception raised"); 5839 } catch (InvalidArgumentException e) { 5840 // Expected exception. 5841 } 5842 } 5843 5844 @Test deleteDataStreamTest()5845 public void deleteDataStreamTest() throws Exception { 5846 Empty expectedResponse = Empty.newBuilder().build(); 5847 mockService.addResponse(expectedResponse); 5848 5849 DataStreamName name = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]"); 5850 5851 client.deleteDataStream(name); 5852 5853 List<String> actualRequests = mockService.getRequestPaths(); 5854 Assert.assertEquals(1, actualRequests.size()); 5855 5856 String apiClientHeaderKey = 5857 mockService 5858 .getRequestHeaders() 5859 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5860 .iterator() 5861 .next(); 5862 Assert.assertTrue( 5863 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5864 .matcher(apiClientHeaderKey) 5865 .matches()); 5866 } 5867 5868 @Test deleteDataStreamExceptionTest()5869 public void deleteDataStreamExceptionTest() throws Exception { 5870 ApiException exception = 5871 ApiExceptionFactory.createException( 5872 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5873 mockService.addException(exception); 5874 5875 try { 5876 DataStreamName name = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]"); 5877 client.deleteDataStream(name); 5878 Assert.fail("No exception raised"); 5879 } catch (InvalidArgumentException e) { 5880 // Expected exception. 5881 } 5882 } 5883 5884 @Test deleteDataStreamTest2()5885 public void deleteDataStreamTest2() throws Exception { 5886 Empty expectedResponse = Empty.newBuilder().build(); 5887 mockService.addResponse(expectedResponse); 5888 5889 String name = "properties/propertie-9806/dataStreams/dataStream-9806"; 5890 5891 client.deleteDataStream(name); 5892 5893 List<String> actualRequests = mockService.getRequestPaths(); 5894 Assert.assertEquals(1, actualRequests.size()); 5895 5896 String apiClientHeaderKey = 5897 mockService 5898 .getRequestHeaders() 5899 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5900 .iterator() 5901 .next(); 5902 Assert.assertTrue( 5903 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5904 .matcher(apiClientHeaderKey) 5905 .matches()); 5906 } 5907 5908 @Test deleteDataStreamExceptionTest2()5909 public void deleteDataStreamExceptionTest2() throws Exception { 5910 ApiException exception = 5911 ApiExceptionFactory.createException( 5912 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5913 mockService.addException(exception); 5914 5915 try { 5916 String name = "properties/propertie-9806/dataStreams/dataStream-9806"; 5917 client.deleteDataStream(name); 5918 Assert.fail("No exception raised"); 5919 } catch (InvalidArgumentException e) { 5920 // Expected exception. 5921 } 5922 } 5923 5924 @Test updateDataStreamTest()5925 public void updateDataStreamTest() throws Exception { 5926 DataStream expectedResponse = 5927 DataStream.newBuilder() 5928 .setName(DataStreamName.of("[PROPERTY]", "[DATA_STREAM]").toString()) 5929 .setDisplayName("displayName1714148973") 5930 .setCreateTime(Timestamp.newBuilder().build()) 5931 .setUpdateTime(Timestamp.newBuilder().build()) 5932 .build(); 5933 mockService.addResponse(expectedResponse); 5934 5935 DataStream dataStream = 5936 DataStream.newBuilder() 5937 .setName(DataStreamName.of("[PROPERTY]", "[DATA_STREAM]").toString()) 5938 .setDisplayName("displayName1714148973") 5939 .setCreateTime(Timestamp.newBuilder().build()) 5940 .setUpdateTime(Timestamp.newBuilder().build()) 5941 .build(); 5942 FieldMask updateMask = FieldMask.newBuilder().build(); 5943 5944 DataStream actualResponse = client.updateDataStream(dataStream, updateMask); 5945 Assert.assertEquals(expectedResponse, actualResponse); 5946 5947 List<String> actualRequests = mockService.getRequestPaths(); 5948 Assert.assertEquals(1, actualRequests.size()); 5949 5950 String apiClientHeaderKey = 5951 mockService 5952 .getRequestHeaders() 5953 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 5954 .iterator() 5955 .next(); 5956 Assert.assertTrue( 5957 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 5958 .matcher(apiClientHeaderKey) 5959 .matches()); 5960 } 5961 5962 @Test updateDataStreamExceptionTest()5963 public void updateDataStreamExceptionTest() throws Exception { 5964 ApiException exception = 5965 ApiExceptionFactory.createException( 5966 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 5967 mockService.addException(exception); 5968 5969 try { 5970 DataStream dataStream = 5971 DataStream.newBuilder() 5972 .setName(DataStreamName.of("[PROPERTY]", "[DATA_STREAM]").toString()) 5973 .setDisplayName("displayName1714148973") 5974 .setCreateTime(Timestamp.newBuilder().build()) 5975 .setUpdateTime(Timestamp.newBuilder().build()) 5976 .build(); 5977 FieldMask updateMask = FieldMask.newBuilder().build(); 5978 client.updateDataStream(dataStream, updateMask); 5979 Assert.fail("No exception raised"); 5980 } catch (InvalidArgumentException e) { 5981 // Expected exception. 5982 } 5983 } 5984 5985 @Test listDataStreamsTest()5986 public void listDataStreamsTest() throws Exception { 5987 DataStream responsesElement = DataStream.newBuilder().build(); 5988 ListDataStreamsResponse expectedResponse = 5989 ListDataStreamsResponse.newBuilder() 5990 .setNextPageToken("") 5991 .addAllDataStreams(Arrays.asList(responsesElement)) 5992 .build(); 5993 mockService.addResponse(expectedResponse); 5994 5995 PropertyName parent = PropertyName.of("[PROPERTY]"); 5996 5997 ListDataStreamsPagedResponse pagedListResponse = client.listDataStreams(parent); 5998 5999 List<DataStream> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 6000 6001 Assert.assertEquals(1, resources.size()); 6002 Assert.assertEquals(expectedResponse.getDataStreamsList().get(0), resources.get(0)); 6003 6004 List<String> actualRequests = mockService.getRequestPaths(); 6005 Assert.assertEquals(1, actualRequests.size()); 6006 6007 String apiClientHeaderKey = 6008 mockService 6009 .getRequestHeaders() 6010 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6011 .iterator() 6012 .next(); 6013 Assert.assertTrue( 6014 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6015 .matcher(apiClientHeaderKey) 6016 .matches()); 6017 } 6018 6019 @Test listDataStreamsExceptionTest()6020 public void listDataStreamsExceptionTest() throws Exception { 6021 ApiException exception = 6022 ApiExceptionFactory.createException( 6023 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6024 mockService.addException(exception); 6025 6026 try { 6027 PropertyName parent = PropertyName.of("[PROPERTY]"); 6028 client.listDataStreams(parent); 6029 Assert.fail("No exception raised"); 6030 } catch (InvalidArgumentException e) { 6031 // Expected exception. 6032 } 6033 } 6034 6035 @Test listDataStreamsTest2()6036 public void listDataStreamsTest2() throws Exception { 6037 DataStream responsesElement = DataStream.newBuilder().build(); 6038 ListDataStreamsResponse expectedResponse = 6039 ListDataStreamsResponse.newBuilder() 6040 .setNextPageToken("") 6041 .addAllDataStreams(Arrays.asList(responsesElement)) 6042 .build(); 6043 mockService.addResponse(expectedResponse); 6044 6045 String parent = "properties/propertie-2024"; 6046 6047 ListDataStreamsPagedResponse pagedListResponse = client.listDataStreams(parent); 6048 6049 List<DataStream> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 6050 6051 Assert.assertEquals(1, resources.size()); 6052 Assert.assertEquals(expectedResponse.getDataStreamsList().get(0), resources.get(0)); 6053 6054 List<String> actualRequests = mockService.getRequestPaths(); 6055 Assert.assertEquals(1, actualRequests.size()); 6056 6057 String apiClientHeaderKey = 6058 mockService 6059 .getRequestHeaders() 6060 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6061 .iterator() 6062 .next(); 6063 Assert.assertTrue( 6064 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6065 .matcher(apiClientHeaderKey) 6066 .matches()); 6067 } 6068 6069 @Test listDataStreamsExceptionTest2()6070 public void listDataStreamsExceptionTest2() throws Exception { 6071 ApiException exception = 6072 ApiExceptionFactory.createException( 6073 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6074 mockService.addException(exception); 6075 6076 try { 6077 String parent = "properties/propertie-2024"; 6078 client.listDataStreams(parent); 6079 Assert.fail("No exception raised"); 6080 } catch (InvalidArgumentException e) { 6081 // Expected exception. 6082 } 6083 } 6084 6085 @Test getDataStreamTest()6086 public void getDataStreamTest() throws Exception { 6087 DataStream expectedResponse = 6088 DataStream.newBuilder() 6089 .setName(DataStreamName.of("[PROPERTY]", "[DATA_STREAM]").toString()) 6090 .setDisplayName("displayName1714148973") 6091 .setCreateTime(Timestamp.newBuilder().build()) 6092 .setUpdateTime(Timestamp.newBuilder().build()) 6093 .build(); 6094 mockService.addResponse(expectedResponse); 6095 6096 DataStreamName name = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]"); 6097 6098 DataStream actualResponse = client.getDataStream(name); 6099 Assert.assertEquals(expectedResponse, actualResponse); 6100 6101 List<String> actualRequests = mockService.getRequestPaths(); 6102 Assert.assertEquals(1, actualRequests.size()); 6103 6104 String apiClientHeaderKey = 6105 mockService 6106 .getRequestHeaders() 6107 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6108 .iterator() 6109 .next(); 6110 Assert.assertTrue( 6111 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6112 .matcher(apiClientHeaderKey) 6113 .matches()); 6114 } 6115 6116 @Test getDataStreamExceptionTest()6117 public void getDataStreamExceptionTest() throws Exception { 6118 ApiException exception = 6119 ApiExceptionFactory.createException( 6120 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6121 mockService.addException(exception); 6122 6123 try { 6124 DataStreamName name = DataStreamName.of("[PROPERTY]", "[DATA_STREAM]"); 6125 client.getDataStream(name); 6126 Assert.fail("No exception raised"); 6127 } catch (InvalidArgumentException e) { 6128 // Expected exception. 6129 } 6130 } 6131 6132 @Test getDataStreamTest2()6133 public void getDataStreamTest2() throws Exception { 6134 DataStream expectedResponse = 6135 DataStream.newBuilder() 6136 .setName(DataStreamName.of("[PROPERTY]", "[DATA_STREAM]").toString()) 6137 .setDisplayName("displayName1714148973") 6138 .setCreateTime(Timestamp.newBuilder().build()) 6139 .setUpdateTime(Timestamp.newBuilder().build()) 6140 .build(); 6141 mockService.addResponse(expectedResponse); 6142 6143 String name = "properties/propertie-9806/dataStreams/dataStream-9806"; 6144 6145 DataStream actualResponse = client.getDataStream(name); 6146 Assert.assertEquals(expectedResponse, actualResponse); 6147 6148 List<String> actualRequests = mockService.getRequestPaths(); 6149 Assert.assertEquals(1, actualRequests.size()); 6150 6151 String apiClientHeaderKey = 6152 mockService 6153 .getRequestHeaders() 6154 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6155 .iterator() 6156 .next(); 6157 Assert.assertTrue( 6158 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6159 .matcher(apiClientHeaderKey) 6160 .matches()); 6161 } 6162 6163 @Test getDataStreamExceptionTest2()6164 public void getDataStreamExceptionTest2() throws Exception { 6165 ApiException exception = 6166 ApiExceptionFactory.createException( 6167 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6168 mockService.addException(exception); 6169 6170 try { 6171 String name = "properties/propertie-9806/dataStreams/dataStream-9806"; 6172 client.getDataStream(name); 6173 Assert.fail("No exception raised"); 6174 } catch (InvalidArgumentException e) { 6175 // Expected exception. 6176 } 6177 } 6178 6179 @Test getAudienceTest()6180 public void getAudienceTest() throws Exception { 6181 Audience expectedResponse = 6182 Audience.newBuilder() 6183 .setName(AudienceName.of("[PROPERTY]", "[AUDIENCE]").toString()) 6184 .setDisplayName("displayName1714148973") 6185 .setDescription("description-1724546052") 6186 .setMembershipDurationDays(1702404985) 6187 .setAdsPersonalizationEnabled(true) 6188 .setEventTrigger(AudienceEventTrigger.newBuilder().build()) 6189 .addAllFilterClauses(new ArrayList<AudienceFilterClause>()) 6190 .build(); 6191 mockService.addResponse(expectedResponse); 6192 6193 AudienceName name = AudienceName.of("[PROPERTY]", "[AUDIENCE]"); 6194 6195 Audience actualResponse = client.getAudience(name); 6196 Assert.assertEquals(expectedResponse, actualResponse); 6197 6198 List<String> actualRequests = mockService.getRequestPaths(); 6199 Assert.assertEquals(1, actualRequests.size()); 6200 6201 String apiClientHeaderKey = 6202 mockService 6203 .getRequestHeaders() 6204 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6205 .iterator() 6206 .next(); 6207 Assert.assertTrue( 6208 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6209 .matcher(apiClientHeaderKey) 6210 .matches()); 6211 } 6212 6213 @Test getAudienceExceptionTest()6214 public void getAudienceExceptionTest() throws Exception { 6215 ApiException exception = 6216 ApiExceptionFactory.createException( 6217 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6218 mockService.addException(exception); 6219 6220 try { 6221 AudienceName name = AudienceName.of("[PROPERTY]", "[AUDIENCE]"); 6222 client.getAudience(name); 6223 Assert.fail("No exception raised"); 6224 } catch (InvalidArgumentException e) { 6225 // Expected exception. 6226 } 6227 } 6228 6229 @Test getAudienceTest2()6230 public void getAudienceTest2() throws Exception { 6231 Audience expectedResponse = 6232 Audience.newBuilder() 6233 .setName(AudienceName.of("[PROPERTY]", "[AUDIENCE]").toString()) 6234 .setDisplayName("displayName1714148973") 6235 .setDescription("description-1724546052") 6236 .setMembershipDurationDays(1702404985) 6237 .setAdsPersonalizationEnabled(true) 6238 .setEventTrigger(AudienceEventTrigger.newBuilder().build()) 6239 .addAllFilterClauses(new ArrayList<AudienceFilterClause>()) 6240 .build(); 6241 mockService.addResponse(expectedResponse); 6242 6243 String name = "properties/propertie-2172/audiences/audience-2172"; 6244 6245 Audience actualResponse = client.getAudience(name); 6246 Assert.assertEquals(expectedResponse, actualResponse); 6247 6248 List<String> actualRequests = mockService.getRequestPaths(); 6249 Assert.assertEquals(1, actualRequests.size()); 6250 6251 String apiClientHeaderKey = 6252 mockService 6253 .getRequestHeaders() 6254 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6255 .iterator() 6256 .next(); 6257 Assert.assertTrue( 6258 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6259 .matcher(apiClientHeaderKey) 6260 .matches()); 6261 } 6262 6263 @Test getAudienceExceptionTest2()6264 public void getAudienceExceptionTest2() throws Exception { 6265 ApiException exception = 6266 ApiExceptionFactory.createException( 6267 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6268 mockService.addException(exception); 6269 6270 try { 6271 String name = "properties/propertie-2172/audiences/audience-2172"; 6272 client.getAudience(name); 6273 Assert.fail("No exception raised"); 6274 } catch (InvalidArgumentException e) { 6275 // Expected exception. 6276 } 6277 } 6278 6279 @Test listAudiencesTest()6280 public void listAudiencesTest() throws Exception { 6281 Audience responsesElement = Audience.newBuilder().build(); 6282 ListAudiencesResponse expectedResponse = 6283 ListAudiencesResponse.newBuilder() 6284 .setNextPageToken("") 6285 .addAllAudiences(Arrays.asList(responsesElement)) 6286 .build(); 6287 mockService.addResponse(expectedResponse); 6288 6289 PropertyName parent = PropertyName.of("[PROPERTY]"); 6290 6291 ListAudiencesPagedResponse pagedListResponse = client.listAudiences(parent); 6292 6293 List<Audience> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 6294 6295 Assert.assertEquals(1, resources.size()); 6296 Assert.assertEquals(expectedResponse.getAudiencesList().get(0), resources.get(0)); 6297 6298 List<String> actualRequests = mockService.getRequestPaths(); 6299 Assert.assertEquals(1, actualRequests.size()); 6300 6301 String apiClientHeaderKey = 6302 mockService 6303 .getRequestHeaders() 6304 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6305 .iterator() 6306 .next(); 6307 Assert.assertTrue( 6308 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6309 .matcher(apiClientHeaderKey) 6310 .matches()); 6311 } 6312 6313 @Test listAudiencesExceptionTest()6314 public void listAudiencesExceptionTest() throws Exception { 6315 ApiException exception = 6316 ApiExceptionFactory.createException( 6317 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6318 mockService.addException(exception); 6319 6320 try { 6321 PropertyName parent = PropertyName.of("[PROPERTY]"); 6322 client.listAudiences(parent); 6323 Assert.fail("No exception raised"); 6324 } catch (InvalidArgumentException e) { 6325 // Expected exception. 6326 } 6327 } 6328 6329 @Test listAudiencesTest2()6330 public void listAudiencesTest2() throws Exception { 6331 Audience responsesElement = Audience.newBuilder().build(); 6332 ListAudiencesResponse expectedResponse = 6333 ListAudiencesResponse.newBuilder() 6334 .setNextPageToken("") 6335 .addAllAudiences(Arrays.asList(responsesElement)) 6336 .build(); 6337 mockService.addResponse(expectedResponse); 6338 6339 String parent = "properties/propertie-2024"; 6340 6341 ListAudiencesPagedResponse pagedListResponse = client.listAudiences(parent); 6342 6343 List<Audience> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 6344 6345 Assert.assertEquals(1, resources.size()); 6346 Assert.assertEquals(expectedResponse.getAudiencesList().get(0), resources.get(0)); 6347 6348 List<String> actualRequests = mockService.getRequestPaths(); 6349 Assert.assertEquals(1, actualRequests.size()); 6350 6351 String apiClientHeaderKey = 6352 mockService 6353 .getRequestHeaders() 6354 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6355 .iterator() 6356 .next(); 6357 Assert.assertTrue( 6358 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6359 .matcher(apiClientHeaderKey) 6360 .matches()); 6361 } 6362 6363 @Test listAudiencesExceptionTest2()6364 public void listAudiencesExceptionTest2() throws Exception { 6365 ApiException exception = 6366 ApiExceptionFactory.createException( 6367 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6368 mockService.addException(exception); 6369 6370 try { 6371 String parent = "properties/propertie-2024"; 6372 client.listAudiences(parent); 6373 Assert.fail("No exception raised"); 6374 } catch (InvalidArgumentException e) { 6375 // Expected exception. 6376 } 6377 } 6378 6379 @Test createAudienceTest()6380 public void createAudienceTest() throws Exception { 6381 Audience expectedResponse = 6382 Audience.newBuilder() 6383 .setName(AudienceName.of("[PROPERTY]", "[AUDIENCE]").toString()) 6384 .setDisplayName("displayName1714148973") 6385 .setDescription("description-1724546052") 6386 .setMembershipDurationDays(1702404985) 6387 .setAdsPersonalizationEnabled(true) 6388 .setEventTrigger(AudienceEventTrigger.newBuilder().build()) 6389 .addAllFilterClauses(new ArrayList<AudienceFilterClause>()) 6390 .build(); 6391 mockService.addResponse(expectedResponse); 6392 6393 PropertyName parent = PropertyName.of("[PROPERTY]"); 6394 Audience audience = Audience.newBuilder().build(); 6395 6396 Audience actualResponse = client.createAudience(parent, audience); 6397 Assert.assertEquals(expectedResponse, actualResponse); 6398 6399 List<String> actualRequests = mockService.getRequestPaths(); 6400 Assert.assertEquals(1, actualRequests.size()); 6401 6402 String apiClientHeaderKey = 6403 mockService 6404 .getRequestHeaders() 6405 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6406 .iterator() 6407 .next(); 6408 Assert.assertTrue( 6409 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6410 .matcher(apiClientHeaderKey) 6411 .matches()); 6412 } 6413 6414 @Test createAudienceExceptionTest()6415 public void createAudienceExceptionTest() throws Exception { 6416 ApiException exception = 6417 ApiExceptionFactory.createException( 6418 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6419 mockService.addException(exception); 6420 6421 try { 6422 PropertyName parent = PropertyName.of("[PROPERTY]"); 6423 Audience audience = Audience.newBuilder().build(); 6424 client.createAudience(parent, audience); 6425 Assert.fail("No exception raised"); 6426 } catch (InvalidArgumentException e) { 6427 // Expected exception. 6428 } 6429 } 6430 6431 @Test createAudienceTest2()6432 public void createAudienceTest2() throws Exception { 6433 Audience expectedResponse = 6434 Audience.newBuilder() 6435 .setName(AudienceName.of("[PROPERTY]", "[AUDIENCE]").toString()) 6436 .setDisplayName("displayName1714148973") 6437 .setDescription("description-1724546052") 6438 .setMembershipDurationDays(1702404985) 6439 .setAdsPersonalizationEnabled(true) 6440 .setEventTrigger(AudienceEventTrigger.newBuilder().build()) 6441 .addAllFilterClauses(new ArrayList<AudienceFilterClause>()) 6442 .build(); 6443 mockService.addResponse(expectedResponse); 6444 6445 String parent = "properties/propertie-2024"; 6446 Audience audience = Audience.newBuilder().build(); 6447 6448 Audience actualResponse = client.createAudience(parent, audience); 6449 Assert.assertEquals(expectedResponse, actualResponse); 6450 6451 List<String> actualRequests = mockService.getRequestPaths(); 6452 Assert.assertEquals(1, actualRequests.size()); 6453 6454 String apiClientHeaderKey = 6455 mockService 6456 .getRequestHeaders() 6457 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6458 .iterator() 6459 .next(); 6460 Assert.assertTrue( 6461 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6462 .matcher(apiClientHeaderKey) 6463 .matches()); 6464 } 6465 6466 @Test createAudienceExceptionTest2()6467 public void createAudienceExceptionTest2() throws Exception { 6468 ApiException exception = 6469 ApiExceptionFactory.createException( 6470 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6471 mockService.addException(exception); 6472 6473 try { 6474 String parent = "properties/propertie-2024"; 6475 Audience audience = Audience.newBuilder().build(); 6476 client.createAudience(parent, audience); 6477 Assert.fail("No exception raised"); 6478 } catch (InvalidArgumentException e) { 6479 // Expected exception. 6480 } 6481 } 6482 6483 @Test updateAudienceTest()6484 public void updateAudienceTest() throws Exception { 6485 Audience expectedResponse = 6486 Audience.newBuilder() 6487 .setName(AudienceName.of("[PROPERTY]", "[AUDIENCE]").toString()) 6488 .setDisplayName("displayName1714148973") 6489 .setDescription("description-1724546052") 6490 .setMembershipDurationDays(1702404985) 6491 .setAdsPersonalizationEnabled(true) 6492 .setEventTrigger(AudienceEventTrigger.newBuilder().build()) 6493 .addAllFilterClauses(new ArrayList<AudienceFilterClause>()) 6494 .build(); 6495 mockService.addResponse(expectedResponse); 6496 6497 Audience audience = 6498 Audience.newBuilder() 6499 .setName(AudienceName.of("[PROPERTY]", "[AUDIENCE]").toString()) 6500 .setDisplayName("displayName1714148973") 6501 .setDescription("description-1724546052") 6502 .setMembershipDurationDays(1702404985) 6503 .setAdsPersonalizationEnabled(true) 6504 .setEventTrigger(AudienceEventTrigger.newBuilder().build()) 6505 .addAllFilterClauses(new ArrayList<AudienceFilterClause>()) 6506 .build(); 6507 FieldMask updateMask = FieldMask.newBuilder().build(); 6508 6509 Audience actualResponse = client.updateAudience(audience, updateMask); 6510 Assert.assertEquals(expectedResponse, actualResponse); 6511 6512 List<String> actualRequests = mockService.getRequestPaths(); 6513 Assert.assertEquals(1, actualRequests.size()); 6514 6515 String apiClientHeaderKey = 6516 mockService 6517 .getRequestHeaders() 6518 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6519 .iterator() 6520 .next(); 6521 Assert.assertTrue( 6522 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6523 .matcher(apiClientHeaderKey) 6524 .matches()); 6525 } 6526 6527 @Test updateAudienceExceptionTest()6528 public void updateAudienceExceptionTest() throws Exception { 6529 ApiException exception = 6530 ApiExceptionFactory.createException( 6531 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6532 mockService.addException(exception); 6533 6534 try { 6535 Audience audience = 6536 Audience.newBuilder() 6537 .setName(AudienceName.of("[PROPERTY]", "[AUDIENCE]").toString()) 6538 .setDisplayName("displayName1714148973") 6539 .setDescription("description-1724546052") 6540 .setMembershipDurationDays(1702404985) 6541 .setAdsPersonalizationEnabled(true) 6542 .setEventTrigger(AudienceEventTrigger.newBuilder().build()) 6543 .addAllFilterClauses(new ArrayList<AudienceFilterClause>()) 6544 .build(); 6545 FieldMask updateMask = FieldMask.newBuilder().build(); 6546 client.updateAudience(audience, updateMask); 6547 Assert.fail("No exception raised"); 6548 } catch (InvalidArgumentException e) { 6549 // Expected exception. 6550 } 6551 } 6552 6553 @Test archiveAudienceTest()6554 public void archiveAudienceTest() throws Exception { 6555 Empty expectedResponse = Empty.newBuilder().build(); 6556 mockService.addResponse(expectedResponse); 6557 6558 ArchiveAudienceRequest request = 6559 ArchiveAudienceRequest.newBuilder() 6560 .setName(PropertyName.of("[PROPERTY]").toString()) 6561 .build(); 6562 6563 client.archiveAudience(request); 6564 6565 List<String> actualRequests = mockService.getRequestPaths(); 6566 Assert.assertEquals(1, actualRequests.size()); 6567 6568 String apiClientHeaderKey = 6569 mockService 6570 .getRequestHeaders() 6571 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6572 .iterator() 6573 .next(); 6574 Assert.assertTrue( 6575 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6576 .matcher(apiClientHeaderKey) 6577 .matches()); 6578 } 6579 6580 @Test archiveAudienceExceptionTest()6581 public void archiveAudienceExceptionTest() throws Exception { 6582 ApiException exception = 6583 ApiExceptionFactory.createException( 6584 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6585 mockService.addException(exception); 6586 6587 try { 6588 ArchiveAudienceRequest request = 6589 ArchiveAudienceRequest.newBuilder() 6590 .setName(PropertyName.of("[PROPERTY]").toString()) 6591 .build(); 6592 client.archiveAudience(request); 6593 Assert.fail("No exception raised"); 6594 } catch (InvalidArgumentException e) { 6595 // Expected exception. 6596 } 6597 } 6598 6599 @Test getSearchAds360LinkTest()6600 public void getSearchAds360LinkTest() throws Exception { 6601 SearchAds360Link expectedResponse = 6602 SearchAds360Link.newBuilder() 6603 .setName(SearchAds360LinkName.of("[PROPERTY]", "[SEARCH_ADS_360_LINK]").toString()) 6604 .setAdvertiserId("advertiserId550061990") 6605 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 6606 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 6607 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 6608 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 6609 .setSiteStatsSharingEnabled(BoolValue.newBuilder().build()) 6610 .build(); 6611 mockService.addResponse(expectedResponse); 6612 6613 SearchAds360LinkName name = SearchAds360LinkName.of("[PROPERTY]", "[SEARCH_ADS_360_LINK]"); 6614 6615 SearchAds360Link actualResponse = client.getSearchAds360Link(name); 6616 Assert.assertEquals(expectedResponse, actualResponse); 6617 6618 List<String> actualRequests = mockService.getRequestPaths(); 6619 Assert.assertEquals(1, actualRequests.size()); 6620 6621 String apiClientHeaderKey = 6622 mockService 6623 .getRequestHeaders() 6624 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6625 .iterator() 6626 .next(); 6627 Assert.assertTrue( 6628 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6629 .matcher(apiClientHeaderKey) 6630 .matches()); 6631 } 6632 6633 @Test getSearchAds360LinkExceptionTest()6634 public void getSearchAds360LinkExceptionTest() throws Exception { 6635 ApiException exception = 6636 ApiExceptionFactory.createException( 6637 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6638 mockService.addException(exception); 6639 6640 try { 6641 SearchAds360LinkName name = SearchAds360LinkName.of("[PROPERTY]", "[SEARCH_ADS_360_LINK]"); 6642 client.getSearchAds360Link(name); 6643 Assert.fail("No exception raised"); 6644 } catch (InvalidArgumentException e) { 6645 // Expected exception. 6646 } 6647 } 6648 6649 @Test getSearchAds360LinkTest2()6650 public void getSearchAds360LinkTest2() throws Exception { 6651 SearchAds360Link expectedResponse = 6652 SearchAds360Link.newBuilder() 6653 .setName(SearchAds360LinkName.of("[PROPERTY]", "[SEARCH_ADS_360_LINK]").toString()) 6654 .setAdvertiserId("advertiserId550061990") 6655 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 6656 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 6657 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 6658 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 6659 .setSiteStatsSharingEnabled(BoolValue.newBuilder().build()) 6660 .build(); 6661 mockService.addResponse(expectedResponse); 6662 6663 String name = "properties/propertie-3689/searchAds360Links/searchAds360Link-3689"; 6664 6665 SearchAds360Link actualResponse = client.getSearchAds360Link(name); 6666 Assert.assertEquals(expectedResponse, actualResponse); 6667 6668 List<String> actualRequests = mockService.getRequestPaths(); 6669 Assert.assertEquals(1, actualRequests.size()); 6670 6671 String apiClientHeaderKey = 6672 mockService 6673 .getRequestHeaders() 6674 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6675 .iterator() 6676 .next(); 6677 Assert.assertTrue( 6678 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6679 .matcher(apiClientHeaderKey) 6680 .matches()); 6681 } 6682 6683 @Test getSearchAds360LinkExceptionTest2()6684 public void getSearchAds360LinkExceptionTest2() throws Exception { 6685 ApiException exception = 6686 ApiExceptionFactory.createException( 6687 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6688 mockService.addException(exception); 6689 6690 try { 6691 String name = "properties/propertie-3689/searchAds360Links/searchAds360Link-3689"; 6692 client.getSearchAds360Link(name); 6693 Assert.fail("No exception raised"); 6694 } catch (InvalidArgumentException e) { 6695 // Expected exception. 6696 } 6697 } 6698 6699 @Test listSearchAds360LinksTest()6700 public void listSearchAds360LinksTest() throws Exception { 6701 SearchAds360Link responsesElement = SearchAds360Link.newBuilder().build(); 6702 ListSearchAds360LinksResponse expectedResponse = 6703 ListSearchAds360LinksResponse.newBuilder() 6704 .setNextPageToken("") 6705 .addAllSearchAds360Links(Arrays.asList(responsesElement)) 6706 .build(); 6707 mockService.addResponse(expectedResponse); 6708 6709 PropertyName parent = PropertyName.of("[PROPERTY]"); 6710 6711 ListSearchAds360LinksPagedResponse pagedListResponse = client.listSearchAds360Links(parent); 6712 6713 List<SearchAds360Link> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 6714 6715 Assert.assertEquals(1, resources.size()); 6716 Assert.assertEquals(expectedResponse.getSearchAds360LinksList().get(0), resources.get(0)); 6717 6718 List<String> actualRequests = mockService.getRequestPaths(); 6719 Assert.assertEquals(1, actualRequests.size()); 6720 6721 String apiClientHeaderKey = 6722 mockService 6723 .getRequestHeaders() 6724 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6725 .iterator() 6726 .next(); 6727 Assert.assertTrue( 6728 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6729 .matcher(apiClientHeaderKey) 6730 .matches()); 6731 } 6732 6733 @Test listSearchAds360LinksExceptionTest()6734 public void listSearchAds360LinksExceptionTest() throws Exception { 6735 ApiException exception = 6736 ApiExceptionFactory.createException( 6737 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6738 mockService.addException(exception); 6739 6740 try { 6741 PropertyName parent = PropertyName.of("[PROPERTY]"); 6742 client.listSearchAds360Links(parent); 6743 Assert.fail("No exception raised"); 6744 } catch (InvalidArgumentException e) { 6745 // Expected exception. 6746 } 6747 } 6748 6749 @Test listSearchAds360LinksTest2()6750 public void listSearchAds360LinksTest2() throws Exception { 6751 SearchAds360Link responsesElement = SearchAds360Link.newBuilder().build(); 6752 ListSearchAds360LinksResponse expectedResponse = 6753 ListSearchAds360LinksResponse.newBuilder() 6754 .setNextPageToken("") 6755 .addAllSearchAds360Links(Arrays.asList(responsesElement)) 6756 .build(); 6757 mockService.addResponse(expectedResponse); 6758 6759 String parent = "properties/propertie-2024"; 6760 6761 ListSearchAds360LinksPagedResponse pagedListResponse = client.listSearchAds360Links(parent); 6762 6763 List<SearchAds360Link> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 6764 6765 Assert.assertEquals(1, resources.size()); 6766 Assert.assertEquals(expectedResponse.getSearchAds360LinksList().get(0), resources.get(0)); 6767 6768 List<String> actualRequests = mockService.getRequestPaths(); 6769 Assert.assertEquals(1, actualRequests.size()); 6770 6771 String apiClientHeaderKey = 6772 mockService 6773 .getRequestHeaders() 6774 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6775 .iterator() 6776 .next(); 6777 Assert.assertTrue( 6778 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6779 .matcher(apiClientHeaderKey) 6780 .matches()); 6781 } 6782 6783 @Test listSearchAds360LinksExceptionTest2()6784 public void listSearchAds360LinksExceptionTest2() throws Exception { 6785 ApiException exception = 6786 ApiExceptionFactory.createException( 6787 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6788 mockService.addException(exception); 6789 6790 try { 6791 String parent = "properties/propertie-2024"; 6792 client.listSearchAds360Links(parent); 6793 Assert.fail("No exception raised"); 6794 } catch (InvalidArgumentException e) { 6795 // Expected exception. 6796 } 6797 } 6798 6799 @Test createSearchAds360LinkTest()6800 public void createSearchAds360LinkTest() throws Exception { 6801 SearchAds360Link expectedResponse = 6802 SearchAds360Link.newBuilder() 6803 .setName(SearchAds360LinkName.of("[PROPERTY]", "[SEARCH_ADS_360_LINK]").toString()) 6804 .setAdvertiserId("advertiserId550061990") 6805 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 6806 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 6807 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 6808 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 6809 .setSiteStatsSharingEnabled(BoolValue.newBuilder().build()) 6810 .build(); 6811 mockService.addResponse(expectedResponse); 6812 6813 PropertyName parent = PropertyName.of("[PROPERTY]"); 6814 SearchAds360Link searchAds360Link = SearchAds360Link.newBuilder().build(); 6815 6816 SearchAds360Link actualResponse = client.createSearchAds360Link(parent, searchAds360Link); 6817 Assert.assertEquals(expectedResponse, actualResponse); 6818 6819 List<String> actualRequests = mockService.getRequestPaths(); 6820 Assert.assertEquals(1, actualRequests.size()); 6821 6822 String apiClientHeaderKey = 6823 mockService 6824 .getRequestHeaders() 6825 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6826 .iterator() 6827 .next(); 6828 Assert.assertTrue( 6829 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6830 .matcher(apiClientHeaderKey) 6831 .matches()); 6832 } 6833 6834 @Test createSearchAds360LinkExceptionTest()6835 public void createSearchAds360LinkExceptionTest() throws Exception { 6836 ApiException exception = 6837 ApiExceptionFactory.createException( 6838 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6839 mockService.addException(exception); 6840 6841 try { 6842 PropertyName parent = PropertyName.of("[PROPERTY]"); 6843 SearchAds360Link searchAds360Link = SearchAds360Link.newBuilder().build(); 6844 client.createSearchAds360Link(parent, searchAds360Link); 6845 Assert.fail("No exception raised"); 6846 } catch (InvalidArgumentException e) { 6847 // Expected exception. 6848 } 6849 } 6850 6851 @Test createSearchAds360LinkTest2()6852 public void createSearchAds360LinkTest2() throws Exception { 6853 SearchAds360Link expectedResponse = 6854 SearchAds360Link.newBuilder() 6855 .setName(SearchAds360LinkName.of("[PROPERTY]", "[SEARCH_ADS_360_LINK]").toString()) 6856 .setAdvertiserId("advertiserId550061990") 6857 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 6858 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 6859 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 6860 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 6861 .setSiteStatsSharingEnabled(BoolValue.newBuilder().build()) 6862 .build(); 6863 mockService.addResponse(expectedResponse); 6864 6865 String parent = "properties/propertie-2024"; 6866 SearchAds360Link searchAds360Link = SearchAds360Link.newBuilder().build(); 6867 6868 SearchAds360Link actualResponse = client.createSearchAds360Link(parent, searchAds360Link); 6869 Assert.assertEquals(expectedResponse, actualResponse); 6870 6871 List<String> actualRequests = mockService.getRequestPaths(); 6872 Assert.assertEquals(1, actualRequests.size()); 6873 6874 String apiClientHeaderKey = 6875 mockService 6876 .getRequestHeaders() 6877 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6878 .iterator() 6879 .next(); 6880 Assert.assertTrue( 6881 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6882 .matcher(apiClientHeaderKey) 6883 .matches()); 6884 } 6885 6886 @Test createSearchAds360LinkExceptionTest2()6887 public void createSearchAds360LinkExceptionTest2() throws Exception { 6888 ApiException exception = 6889 ApiExceptionFactory.createException( 6890 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6891 mockService.addException(exception); 6892 6893 try { 6894 String parent = "properties/propertie-2024"; 6895 SearchAds360Link searchAds360Link = SearchAds360Link.newBuilder().build(); 6896 client.createSearchAds360Link(parent, searchAds360Link); 6897 Assert.fail("No exception raised"); 6898 } catch (InvalidArgumentException e) { 6899 // Expected exception. 6900 } 6901 } 6902 6903 @Test deleteSearchAds360LinkTest()6904 public void deleteSearchAds360LinkTest() throws Exception { 6905 Empty expectedResponse = Empty.newBuilder().build(); 6906 mockService.addResponse(expectedResponse); 6907 6908 SearchAds360LinkName name = SearchAds360LinkName.of("[PROPERTY]", "[SEARCH_ADS_360_LINK]"); 6909 6910 client.deleteSearchAds360Link(name); 6911 6912 List<String> actualRequests = mockService.getRequestPaths(); 6913 Assert.assertEquals(1, actualRequests.size()); 6914 6915 String apiClientHeaderKey = 6916 mockService 6917 .getRequestHeaders() 6918 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6919 .iterator() 6920 .next(); 6921 Assert.assertTrue( 6922 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6923 .matcher(apiClientHeaderKey) 6924 .matches()); 6925 } 6926 6927 @Test deleteSearchAds360LinkExceptionTest()6928 public void deleteSearchAds360LinkExceptionTest() throws Exception { 6929 ApiException exception = 6930 ApiExceptionFactory.createException( 6931 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6932 mockService.addException(exception); 6933 6934 try { 6935 SearchAds360LinkName name = SearchAds360LinkName.of("[PROPERTY]", "[SEARCH_ADS_360_LINK]"); 6936 client.deleteSearchAds360Link(name); 6937 Assert.fail("No exception raised"); 6938 } catch (InvalidArgumentException e) { 6939 // Expected exception. 6940 } 6941 } 6942 6943 @Test deleteSearchAds360LinkTest2()6944 public void deleteSearchAds360LinkTest2() throws Exception { 6945 Empty expectedResponse = Empty.newBuilder().build(); 6946 mockService.addResponse(expectedResponse); 6947 6948 String name = "properties/propertie-3689/searchAds360Links/searchAds360Link-3689"; 6949 6950 client.deleteSearchAds360Link(name); 6951 6952 List<String> actualRequests = mockService.getRequestPaths(); 6953 Assert.assertEquals(1, actualRequests.size()); 6954 6955 String apiClientHeaderKey = 6956 mockService 6957 .getRequestHeaders() 6958 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 6959 .iterator() 6960 .next(); 6961 Assert.assertTrue( 6962 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 6963 .matcher(apiClientHeaderKey) 6964 .matches()); 6965 } 6966 6967 @Test deleteSearchAds360LinkExceptionTest2()6968 public void deleteSearchAds360LinkExceptionTest2() throws Exception { 6969 ApiException exception = 6970 ApiExceptionFactory.createException( 6971 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 6972 mockService.addException(exception); 6973 6974 try { 6975 String name = "properties/propertie-3689/searchAds360Links/searchAds360Link-3689"; 6976 client.deleteSearchAds360Link(name); 6977 Assert.fail("No exception raised"); 6978 } catch (InvalidArgumentException e) { 6979 // Expected exception. 6980 } 6981 } 6982 6983 @Test updateSearchAds360LinkTest()6984 public void updateSearchAds360LinkTest() throws Exception { 6985 SearchAds360Link expectedResponse = 6986 SearchAds360Link.newBuilder() 6987 .setName(SearchAds360LinkName.of("[PROPERTY]", "[SEARCH_ADS_360_LINK]").toString()) 6988 .setAdvertiserId("advertiserId550061990") 6989 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 6990 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 6991 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 6992 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 6993 .setSiteStatsSharingEnabled(BoolValue.newBuilder().build()) 6994 .build(); 6995 mockService.addResponse(expectedResponse); 6996 6997 SearchAds360Link searchAds360Link = 6998 SearchAds360Link.newBuilder() 6999 .setName(SearchAds360LinkName.of("[PROPERTY]", "[SEARCH_ADS_360_LINK]").toString()) 7000 .setAdvertiserId("advertiserId550061990") 7001 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 7002 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 7003 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 7004 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 7005 .setSiteStatsSharingEnabled(BoolValue.newBuilder().build()) 7006 .build(); 7007 FieldMask updateMask = FieldMask.newBuilder().build(); 7008 7009 SearchAds360Link actualResponse = client.updateSearchAds360Link(searchAds360Link, updateMask); 7010 Assert.assertEquals(expectedResponse, actualResponse); 7011 7012 List<String> actualRequests = mockService.getRequestPaths(); 7013 Assert.assertEquals(1, actualRequests.size()); 7014 7015 String apiClientHeaderKey = 7016 mockService 7017 .getRequestHeaders() 7018 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7019 .iterator() 7020 .next(); 7021 Assert.assertTrue( 7022 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7023 .matcher(apiClientHeaderKey) 7024 .matches()); 7025 } 7026 7027 @Test updateSearchAds360LinkExceptionTest()7028 public void updateSearchAds360LinkExceptionTest() throws Exception { 7029 ApiException exception = 7030 ApiExceptionFactory.createException( 7031 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7032 mockService.addException(exception); 7033 7034 try { 7035 SearchAds360Link searchAds360Link = 7036 SearchAds360Link.newBuilder() 7037 .setName(SearchAds360LinkName.of("[PROPERTY]", "[SEARCH_ADS_360_LINK]").toString()) 7038 .setAdvertiserId("advertiserId550061990") 7039 .setCampaignDataSharingEnabled(BoolValue.newBuilder().build()) 7040 .setCostDataSharingEnabled(BoolValue.newBuilder().build()) 7041 .setAdvertiserDisplayName("advertiserDisplayName1594116162") 7042 .setAdsPersonalizationEnabled(BoolValue.newBuilder().build()) 7043 .setSiteStatsSharingEnabled(BoolValue.newBuilder().build()) 7044 .build(); 7045 FieldMask updateMask = FieldMask.newBuilder().build(); 7046 client.updateSearchAds360Link(searchAds360Link, updateMask); 7047 Assert.fail("No exception raised"); 7048 } catch (InvalidArgumentException e) { 7049 // Expected exception. 7050 } 7051 } 7052 7053 @Test getAttributionSettingsTest()7054 public void getAttributionSettingsTest() throws Exception { 7055 AttributionSettings expectedResponse = 7056 AttributionSettings.newBuilder() 7057 .setName(AttributionSettingsName.of("[PROPERTY]").toString()) 7058 .build(); 7059 mockService.addResponse(expectedResponse); 7060 7061 AttributionSettingsName name = AttributionSettingsName.of("[PROPERTY]"); 7062 7063 AttributionSettings actualResponse = client.getAttributionSettings(name); 7064 Assert.assertEquals(expectedResponse, actualResponse); 7065 7066 List<String> actualRequests = mockService.getRequestPaths(); 7067 Assert.assertEquals(1, actualRequests.size()); 7068 7069 String apiClientHeaderKey = 7070 mockService 7071 .getRequestHeaders() 7072 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7073 .iterator() 7074 .next(); 7075 Assert.assertTrue( 7076 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7077 .matcher(apiClientHeaderKey) 7078 .matches()); 7079 } 7080 7081 @Test getAttributionSettingsExceptionTest()7082 public void getAttributionSettingsExceptionTest() throws Exception { 7083 ApiException exception = 7084 ApiExceptionFactory.createException( 7085 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7086 mockService.addException(exception); 7087 7088 try { 7089 AttributionSettingsName name = AttributionSettingsName.of("[PROPERTY]"); 7090 client.getAttributionSettings(name); 7091 Assert.fail("No exception raised"); 7092 } catch (InvalidArgumentException e) { 7093 // Expected exception. 7094 } 7095 } 7096 7097 @Test getAttributionSettingsTest2()7098 public void getAttributionSettingsTest2() throws Exception { 7099 AttributionSettings expectedResponse = 7100 AttributionSettings.newBuilder() 7101 .setName(AttributionSettingsName.of("[PROPERTY]").toString()) 7102 .build(); 7103 mockService.addResponse(expectedResponse); 7104 7105 String name = "properties/propertie-492/attributionSettings"; 7106 7107 AttributionSettings actualResponse = client.getAttributionSettings(name); 7108 Assert.assertEquals(expectedResponse, actualResponse); 7109 7110 List<String> actualRequests = mockService.getRequestPaths(); 7111 Assert.assertEquals(1, actualRequests.size()); 7112 7113 String apiClientHeaderKey = 7114 mockService 7115 .getRequestHeaders() 7116 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7117 .iterator() 7118 .next(); 7119 Assert.assertTrue( 7120 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7121 .matcher(apiClientHeaderKey) 7122 .matches()); 7123 } 7124 7125 @Test getAttributionSettingsExceptionTest2()7126 public void getAttributionSettingsExceptionTest2() throws Exception { 7127 ApiException exception = 7128 ApiExceptionFactory.createException( 7129 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7130 mockService.addException(exception); 7131 7132 try { 7133 String name = "properties/propertie-492/attributionSettings"; 7134 client.getAttributionSettings(name); 7135 Assert.fail("No exception raised"); 7136 } catch (InvalidArgumentException e) { 7137 // Expected exception. 7138 } 7139 } 7140 7141 @Test updateAttributionSettingsTest()7142 public void updateAttributionSettingsTest() throws Exception { 7143 AttributionSettings expectedResponse = 7144 AttributionSettings.newBuilder() 7145 .setName(AttributionSettingsName.of("[PROPERTY]").toString()) 7146 .build(); 7147 mockService.addResponse(expectedResponse); 7148 7149 AttributionSettings attributionSettings = 7150 AttributionSettings.newBuilder() 7151 .setName(AttributionSettingsName.of("[PROPERTY]").toString()) 7152 .build(); 7153 FieldMask updateMask = FieldMask.newBuilder().build(); 7154 7155 AttributionSettings actualResponse = 7156 client.updateAttributionSettings(attributionSettings, updateMask); 7157 Assert.assertEquals(expectedResponse, actualResponse); 7158 7159 List<String> actualRequests = mockService.getRequestPaths(); 7160 Assert.assertEquals(1, actualRequests.size()); 7161 7162 String apiClientHeaderKey = 7163 mockService 7164 .getRequestHeaders() 7165 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7166 .iterator() 7167 .next(); 7168 Assert.assertTrue( 7169 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7170 .matcher(apiClientHeaderKey) 7171 .matches()); 7172 } 7173 7174 @Test updateAttributionSettingsExceptionTest()7175 public void updateAttributionSettingsExceptionTest() throws Exception { 7176 ApiException exception = 7177 ApiExceptionFactory.createException( 7178 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7179 mockService.addException(exception); 7180 7181 try { 7182 AttributionSettings attributionSettings = 7183 AttributionSettings.newBuilder() 7184 .setName(AttributionSettingsName.of("[PROPERTY]").toString()) 7185 .build(); 7186 FieldMask updateMask = FieldMask.newBuilder().build(); 7187 client.updateAttributionSettings(attributionSettings, updateMask); 7188 Assert.fail("No exception raised"); 7189 } catch (InvalidArgumentException e) { 7190 // Expected exception. 7191 } 7192 } 7193 7194 @Test runAccessReportTest()7195 public void runAccessReportTest() throws Exception { 7196 RunAccessReportResponse expectedResponse = 7197 RunAccessReportResponse.newBuilder() 7198 .addAllDimensionHeaders(new ArrayList<AccessDimensionHeader>()) 7199 .addAllMetricHeaders(new ArrayList<AccessMetricHeader>()) 7200 .addAllRows(new ArrayList<AccessRow>()) 7201 .setRowCount(1340416618) 7202 .setQuota(AccessQuota.newBuilder().build()) 7203 .build(); 7204 mockService.addResponse(expectedResponse); 7205 7206 RunAccessReportRequest request = 7207 RunAccessReportRequest.newBuilder() 7208 .setEntity("properties/propertie-4993") 7209 .addAllDimensions(new ArrayList<AccessDimension>()) 7210 .addAllMetrics(new ArrayList<AccessMetric>()) 7211 .addAllDateRanges(new ArrayList<AccessDateRange>()) 7212 .setDimensionFilter(AccessFilterExpression.newBuilder().build()) 7213 .setMetricFilter(AccessFilterExpression.newBuilder().build()) 7214 .setOffset(-1019779949) 7215 .setLimit(102976443) 7216 .setTimeZone("timeZone-2077180903") 7217 .addAllOrderBys(new ArrayList<AccessOrderBy>()) 7218 .setReturnEntityQuota(true) 7219 .build(); 7220 7221 RunAccessReportResponse actualResponse = client.runAccessReport(request); 7222 Assert.assertEquals(expectedResponse, actualResponse); 7223 7224 List<String> actualRequests = mockService.getRequestPaths(); 7225 Assert.assertEquals(1, actualRequests.size()); 7226 7227 String apiClientHeaderKey = 7228 mockService 7229 .getRequestHeaders() 7230 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7231 .iterator() 7232 .next(); 7233 Assert.assertTrue( 7234 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7235 .matcher(apiClientHeaderKey) 7236 .matches()); 7237 } 7238 7239 @Test runAccessReportExceptionTest()7240 public void runAccessReportExceptionTest() throws Exception { 7241 ApiException exception = 7242 ApiExceptionFactory.createException( 7243 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7244 mockService.addException(exception); 7245 7246 try { 7247 RunAccessReportRequest request = 7248 RunAccessReportRequest.newBuilder() 7249 .setEntity("properties/propertie-4993") 7250 .addAllDimensions(new ArrayList<AccessDimension>()) 7251 .addAllMetrics(new ArrayList<AccessMetric>()) 7252 .addAllDateRanges(new ArrayList<AccessDateRange>()) 7253 .setDimensionFilter(AccessFilterExpression.newBuilder().build()) 7254 .setMetricFilter(AccessFilterExpression.newBuilder().build()) 7255 .setOffset(-1019779949) 7256 .setLimit(102976443) 7257 .setTimeZone("timeZone-2077180903") 7258 .addAllOrderBys(new ArrayList<AccessOrderBy>()) 7259 .setReturnEntityQuota(true) 7260 .build(); 7261 client.runAccessReport(request); 7262 Assert.fail("No exception raised"); 7263 } catch (InvalidArgumentException e) { 7264 // Expected exception. 7265 } 7266 } 7267 7268 @Test createAccessBindingTest()7269 public void createAccessBindingTest() throws Exception { 7270 AccessBinding expectedResponse = 7271 AccessBinding.newBuilder() 7272 .setName( 7273 AccessBindingName.ofAccountAccessBindingName("[ACCOUNT]", "[ACCESS_BINDING]") 7274 .toString()) 7275 .addAllRoles(new ArrayList<String>()) 7276 .build(); 7277 mockService.addResponse(expectedResponse); 7278 7279 AccountName parent = AccountName.of("[ACCOUNT]"); 7280 AccessBinding accessBinding = AccessBinding.newBuilder().build(); 7281 7282 AccessBinding actualResponse = client.createAccessBinding(parent, accessBinding); 7283 Assert.assertEquals(expectedResponse, actualResponse); 7284 7285 List<String> actualRequests = mockService.getRequestPaths(); 7286 Assert.assertEquals(1, actualRequests.size()); 7287 7288 String apiClientHeaderKey = 7289 mockService 7290 .getRequestHeaders() 7291 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7292 .iterator() 7293 .next(); 7294 Assert.assertTrue( 7295 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7296 .matcher(apiClientHeaderKey) 7297 .matches()); 7298 } 7299 7300 @Test createAccessBindingExceptionTest()7301 public void createAccessBindingExceptionTest() throws Exception { 7302 ApiException exception = 7303 ApiExceptionFactory.createException( 7304 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7305 mockService.addException(exception); 7306 7307 try { 7308 AccountName parent = AccountName.of("[ACCOUNT]"); 7309 AccessBinding accessBinding = AccessBinding.newBuilder().build(); 7310 client.createAccessBinding(parent, accessBinding); 7311 Assert.fail("No exception raised"); 7312 } catch (InvalidArgumentException e) { 7313 // Expected exception. 7314 } 7315 } 7316 7317 @Test createAccessBindingTest2()7318 public void createAccessBindingTest2() throws Exception { 7319 AccessBinding expectedResponse = 7320 AccessBinding.newBuilder() 7321 .setName( 7322 AccessBindingName.ofAccountAccessBindingName("[ACCOUNT]", "[ACCESS_BINDING]") 7323 .toString()) 7324 .addAllRoles(new ArrayList<String>()) 7325 .build(); 7326 mockService.addResponse(expectedResponse); 7327 7328 PropertyName parent = PropertyName.of("[PROPERTY]"); 7329 AccessBinding accessBinding = AccessBinding.newBuilder().build(); 7330 7331 AccessBinding actualResponse = client.createAccessBinding(parent, accessBinding); 7332 Assert.assertEquals(expectedResponse, actualResponse); 7333 7334 List<String> actualRequests = mockService.getRequestPaths(); 7335 Assert.assertEquals(1, actualRequests.size()); 7336 7337 String apiClientHeaderKey = 7338 mockService 7339 .getRequestHeaders() 7340 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7341 .iterator() 7342 .next(); 7343 Assert.assertTrue( 7344 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7345 .matcher(apiClientHeaderKey) 7346 .matches()); 7347 } 7348 7349 @Test createAccessBindingExceptionTest2()7350 public void createAccessBindingExceptionTest2() throws Exception { 7351 ApiException exception = 7352 ApiExceptionFactory.createException( 7353 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7354 mockService.addException(exception); 7355 7356 try { 7357 PropertyName parent = PropertyName.of("[PROPERTY]"); 7358 AccessBinding accessBinding = AccessBinding.newBuilder().build(); 7359 client.createAccessBinding(parent, accessBinding); 7360 Assert.fail("No exception raised"); 7361 } catch (InvalidArgumentException e) { 7362 // Expected exception. 7363 } 7364 } 7365 7366 @Test createAccessBindingTest3()7367 public void createAccessBindingTest3() throws Exception { 7368 AccessBinding expectedResponse = 7369 AccessBinding.newBuilder() 7370 .setName( 7371 AccessBindingName.ofAccountAccessBindingName("[ACCOUNT]", "[ACCESS_BINDING]") 7372 .toString()) 7373 .addAllRoles(new ArrayList<String>()) 7374 .build(); 7375 mockService.addResponse(expectedResponse); 7376 7377 String parent = "accounts/account-4811"; 7378 AccessBinding accessBinding = AccessBinding.newBuilder().build(); 7379 7380 AccessBinding actualResponse = client.createAccessBinding(parent, accessBinding); 7381 Assert.assertEquals(expectedResponse, actualResponse); 7382 7383 List<String> actualRequests = mockService.getRequestPaths(); 7384 Assert.assertEquals(1, actualRequests.size()); 7385 7386 String apiClientHeaderKey = 7387 mockService 7388 .getRequestHeaders() 7389 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7390 .iterator() 7391 .next(); 7392 Assert.assertTrue( 7393 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7394 .matcher(apiClientHeaderKey) 7395 .matches()); 7396 } 7397 7398 @Test createAccessBindingExceptionTest3()7399 public void createAccessBindingExceptionTest3() throws Exception { 7400 ApiException exception = 7401 ApiExceptionFactory.createException( 7402 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7403 mockService.addException(exception); 7404 7405 try { 7406 String parent = "accounts/account-4811"; 7407 AccessBinding accessBinding = AccessBinding.newBuilder().build(); 7408 client.createAccessBinding(parent, accessBinding); 7409 Assert.fail("No exception raised"); 7410 } catch (InvalidArgumentException e) { 7411 // Expected exception. 7412 } 7413 } 7414 7415 @Test getAccessBindingTest()7416 public void getAccessBindingTest() throws Exception { 7417 AccessBinding expectedResponse = 7418 AccessBinding.newBuilder() 7419 .setName( 7420 AccessBindingName.ofAccountAccessBindingName("[ACCOUNT]", "[ACCESS_BINDING]") 7421 .toString()) 7422 .addAllRoles(new ArrayList<String>()) 7423 .build(); 7424 mockService.addResponse(expectedResponse); 7425 7426 AccessBindingName name = 7427 AccessBindingName.ofAccountAccessBindingName("[ACCOUNT]", "[ACCESS_BINDING]"); 7428 7429 AccessBinding actualResponse = client.getAccessBinding(name); 7430 Assert.assertEquals(expectedResponse, actualResponse); 7431 7432 List<String> actualRequests = mockService.getRequestPaths(); 7433 Assert.assertEquals(1, actualRequests.size()); 7434 7435 String apiClientHeaderKey = 7436 mockService 7437 .getRequestHeaders() 7438 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7439 .iterator() 7440 .next(); 7441 Assert.assertTrue( 7442 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7443 .matcher(apiClientHeaderKey) 7444 .matches()); 7445 } 7446 7447 @Test getAccessBindingExceptionTest()7448 public void getAccessBindingExceptionTest() throws Exception { 7449 ApiException exception = 7450 ApiExceptionFactory.createException( 7451 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7452 mockService.addException(exception); 7453 7454 try { 7455 AccessBindingName name = 7456 AccessBindingName.ofAccountAccessBindingName("[ACCOUNT]", "[ACCESS_BINDING]"); 7457 client.getAccessBinding(name); 7458 Assert.fail("No exception raised"); 7459 } catch (InvalidArgumentException e) { 7460 // Expected exception. 7461 } 7462 } 7463 7464 @Test getAccessBindingTest2()7465 public void getAccessBindingTest2() throws Exception { 7466 AccessBinding expectedResponse = 7467 AccessBinding.newBuilder() 7468 .setName( 7469 AccessBindingName.ofAccountAccessBindingName("[ACCOUNT]", "[ACCESS_BINDING]") 7470 .toString()) 7471 .addAllRoles(new ArrayList<String>()) 7472 .build(); 7473 mockService.addResponse(expectedResponse); 7474 7475 String name = "accounts/account-3488/accessBindings/accessBinding-3488"; 7476 7477 AccessBinding actualResponse = client.getAccessBinding(name); 7478 Assert.assertEquals(expectedResponse, actualResponse); 7479 7480 List<String> actualRequests = mockService.getRequestPaths(); 7481 Assert.assertEquals(1, actualRequests.size()); 7482 7483 String apiClientHeaderKey = 7484 mockService 7485 .getRequestHeaders() 7486 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7487 .iterator() 7488 .next(); 7489 Assert.assertTrue( 7490 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7491 .matcher(apiClientHeaderKey) 7492 .matches()); 7493 } 7494 7495 @Test getAccessBindingExceptionTest2()7496 public void getAccessBindingExceptionTest2() throws Exception { 7497 ApiException exception = 7498 ApiExceptionFactory.createException( 7499 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7500 mockService.addException(exception); 7501 7502 try { 7503 String name = "accounts/account-3488/accessBindings/accessBinding-3488"; 7504 client.getAccessBinding(name); 7505 Assert.fail("No exception raised"); 7506 } catch (InvalidArgumentException e) { 7507 // Expected exception. 7508 } 7509 } 7510 7511 @Test updateAccessBindingTest()7512 public void updateAccessBindingTest() throws Exception { 7513 AccessBinding expectedResponse = 7514 AccessBinding.newBuilder() 7515 .setName( 7516 AccessBindingName.ofAccountAccessBindingName("[ACCOUNT]", "[ACCESS_BINDING]") 7517 .toString()) 7518 .addAllRoles(new ArrayList<String>()) 7519 .build(); 7520 mockService.addResponse(expectedResponse); 7521 7522 AccessBinding accessBinding = 7523 AccessBinding.newBuilder() 7524 .setName( 7525 AccessBindingName.ofAccountAccessBindingName("[ACCOUNT]", "[ACCESS_BINDING]") 7526 .toString()) 7527 .addAllRoles(new ArrayList<String>()) 7528 .build(); 7529 7530 AccessBinding actualResponse = client.updateAccessBinding(accessBinding); 7531 Assert.assertEquals(expectedResponse, actualResponse); 7532 7533 List<String> actualRequests = mockService.getRequestPaths(); 7534 Assert.assertEquals(1, actualRequests.size()); 7535 7536 String apiClientHeaderKey = 7537 mockService 7538 .getRequestHeaders() 7539 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7540 .iterator() 7541 .next(); 7542 Assert.assertTrue( 7543 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7544 .matcher(apiClientHeaderKey) 7545 .matches()); 7546 } 7547 7548 @Test updateAccessBindingExceptionTest()7549 public void updateAccessBindingExceptionTest() throws Exception { 7550 ApiException exception = 7551 ApiExceptionFactory.createException( 7552 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7553 mockService.addException(exception); 7554 7555 try { 7556 AccessBinding accessBinding = 7557 AccessBinding.newBuilder() 7558 .setName( 7559 AccessBindingName.ofAccountAccessBindingName("[ACCOUNT]", "[ACCESS_BINDING]") 7560 .toString()) 7561 .addAllRoles(new ArrayList<String>()) 7562 .build(); 7563 client.updateAccessBinding(accessBinding); 7564 Assert.fail("No exception raised"); 7565 } catch (InvalidArgumentException e) { 7566 // Expected exception. 7567 } 7568 } 7569 7570 @Test deleteAccessBindingTest()7571 public void deleteAccessBindingTest() throws Exception { 7572 Empty expectedResponse = Empty.newBuilder().build(); 7573 mockService.addResponse(expectedResponse); 7574 7575 AccessBindingName name = 7576 AccessBindingName.ofAccountAccessBindingName("[ACCOUNT]", "[ACCESS_BINDING]"); 7577 7578 client.deleteAccessBinding(name); 7579 7580 List<String> actualRequests = mockService.getRequestPaths(); 7581 Assert.assertEquals(1, actualRequests.size()); 7582 7583 String apiClientHeaderKey = 7584 mockService 7585 .getRequestHeaders() 7586 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7587 .iterator() 7588 .next(); 7589 Assert.assertTrue( 7590 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7591 .matcher(apiClientHeaderKey) 7592 .matches()); 7593 } 7594 7595 @Test deleteAccessBindingExceptionTest()7596 public void deleteAccessBindingExceptionTest() throws Exception { 7597 ApiException exception = 7598 ApiExceptionFactory.createException( 7599 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7600 mockService.addException(exception); 7601 7602 try { 7603 AccessBindingName name = 7604 AccessBindingName.ofAccountAccessBindingName("[ACCOUNT]", "[ACCESS_BINDING]"); 7605 client.deleteAccessBinding(name); 7606 Assert.fail("No exception raised"); 7607 } catch (InvalidArgumentException e) { 7608 // Expected exception. 7609 } 7610 } 7611 7612 @Test deleteAccessBindingTest2()7613 public void deleteAccessBindingTest2() throws Exception { 7614 Empty expectedResponse = Empty.newBuilder().build(); 7615 mockService.addResponse(expectedResponse); 7616 7617 String name = "accounts/account-3488/accessBindings/accessBinding-3488"; 7618 7619 client.deleteAccessBinding(name); 7620 7621 List<String> actualRequests = mockService.getRequestPaths(); 7622 Assert.assertEquals(1, actualRequests.size()); 7623 7624 String apiClientHeaderKey = 7625 mockService 7626 .getRequestHeaders() 7627 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7628 .iterator() 7629 .next(); 7630 Assert.assertTrue( 7631 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7632 .matcher(apiClientHeaderKey) 7633 .matches()); 7634 } 7635 7636 @Test deleteAccessBindingExceptionTest2()7637 public void deleteAccessBindingExceptionTest2() throws Exception { 7638 ApiException exception = 7639 ApiExceptionFactory.createException( 7640 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7641 mockService.addException(exception); 7642 7643 try { 7644 String name = "accounts/account-3488/accessBindings/accessBinding-3488"; 7645 client.deleteAccessBinding(name); 7646 Assert.fail("No exception raised"); 7647 } catch (InvalidArgumentException e) { 7648 // Expected exception. 7649 } 7650 } 7651 7652 @Test listAccessBindingsTest()7653 public void listAccessBindingsTest() throws Exception { 7654 AccessBinding responsesElement = AccessBinding.newBuilder().build(); 7655 ListAccessBindingsResponse expectedResponse = 7656 ListAccessBindingsResponse.newBuilder() 7657 .setNextPageToken("") 7658 .addAllAccessBindings(Arrays.asList(responsesElement)) 7659 .build(); 7660 mockService.addResponse(expectedResponse); 7661 7662 AccountName parent = AccountName.of("[ACCOUNT]"); 7663 7664 ListAccessBindingsPagedResponse pagedListResponse = client.listAccessBindings(parent); 7665 7666 List<AccessBinding> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 7667 7668 Assert.assertEquals(1, resources.size()); 7669 Assert.assertEquals(expectedResponse.getAccessBindingsList().get(0), resources.get(0)); 7670 7671 List<String> actualRequests = mockService.getRequestPaths(); 7672 Assert.assertEquals(1, actualRequests.size()); 7673 7674 String apiClientHeaderKey = 7675 mockService 7676 .getRequestHeaders() 7677 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7678 .iterator() 7679 .next(); 7680 Assert.assertTrue( 7681 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7682 .matcher(apiClientHeaderKey) 7683 .matches()); 7684 } 7685 7686 @Test listAccessBindingsExceptionTest()7687 public void listAccessBindingsExceptionTest() throws Exception { 7688 ApiException exception = 7689 ApiExceptionFactory.createException( 7690 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7691 mockService.addException(exception); 7692 7693 try { 7694 AccountName parent = AccountName.of("[ACCOUNT]"); 7695 client.listAccessBindings(parent); 7696 Assert.fail("No exception raised"); 7697 } catch (InvalidArgumentException e) { 7698 // Expected exception. 7699 } 7700 } 7701 7702 @Test listAccessBindingsTest2()7703 public void listAccessBindingsTest2() throws Exception { 7704 AccessBinding responsesElement = AccessBinding.newBuilder().build(); 7705 ListAccessBindingsResponse expectedResponse = 7706 ListAccessBindingsResponse.newBuilder() 7707 .setNextPageToken("") 7708 .addAllAccessBindings(Arrays.asList(responsesElement)) 7709 .build(); 7710 mockService.addResponse(expectedResponse); 7711 7712 PropertyName parent = PropertyName.of("[PROPERTY]"); 7713 7714 ListAccessBindingsPagedResponse pagedListResponse = client.listAccessBindings(parent); 7715 7716 List<AccessBinding> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 7717 7718 Assert.assertEquals(1, resources.size()); 7719 Assert.assertEquals(expectedResponse.getAccessBindingsList().get(0), resources.get(0)); 7720 7721 List<String> actualRequests = mockService.getRequestPaths(); 7722 Assert.assertEquals(1, actualRequests.size()); 7723 7724 String apiClientHeaderKey = 7725 mockService 7726 .getRequestHeaders() 7727 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7728 .iterator() 7729 .next(); 7730 Assert.assertTrue( 7731 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7732 .matcher(apiClientHeaderKey) 7733 .matches()); 7734 } 7735 7736 @Test listAccessBindingsExceptionTest2()7737 public void listAccessBindingsExceptionTest2() throws Exception { 7738 ApiException exception = 7739 ApiExceptionFactory.createException( 7740 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7741 mockService.addException(exception); 7742 7743 try { 7744 PropertyName parent = PropertyName.of("[PROPERTY]"); 7745 client.listAccessBindings(parent); 7746 Assert.fail("No exception raised"); 7747 } catch (InvalidArgumentException e) { 7748 // Expected exception. 7749 } 7750 } 7751 7752 @Test listAccessBindingsTest3()7753 public void listAccessBindingsTest3() throws Exception { 7754 AccessBinding responsesElement = AccessBinding.newBuilder().build(); 7755 ListAccessBindingsResponse expectedResponse = 7756 ListAccessBindingsResponse.newBuilder() 7757 .setNextPageToken("") 7758 .addAllAccessBindings(Arrays.asList(responsesElement)) 7759 .build(); 7760 mockService.addResponse(expectedResponse); 7761 7762 String parent = "accounts/account-4811"; 7763 7764 ListAccessBindingsPagedResponse pagedListResponse = client.listAccessBindings(parent); 7765 7766 List<AccessBinding> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 7767 7768 Assert.assertEquals(1, resources.size()); 7769 Assert.assertEquals(expectedResponse.getAccessBindingsList().get(0), resources.get(0)); 7770 7771 List<String> actualRequests = mockService.getRequestPaths(); 7772 Assert.assertEquals(1, actualRequests.size()); 7773 7774 String apiClientHeaderKey = 7775 mockService 7776 .getRequestHeaders() 7777 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7778 .iterator() 7779 .next(); 7780 Assert.assertTrue( 7781 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7782 .matcher(apiClientHeaderKey) 7783 .matches()); 7784 } 7785 7786 @Test listAccessBindingsExceptionTest3()7787 public void listAccessBindingsExceptionTest3() throws Exception { 7788 ApiException exception = 7789 ApiExceptionFactory.createException( 7790 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7791 mockService.addException(exception); 7792 7793 try { 7794 String parent = "accounts/account-4811"; 7795 client.listAccessBindings(parent); 7796 Assert.fail("No exception raised"); 7797 } catch (InvalidArgumentException e) { 7798 // Expected exception. 7799 } 7800 } 7801 7802 @Test batchCreateAccessBindingsTest()7803 public void batchCreateAccessBindingsTest() throws Exception { 7804 BatchCreateAccessBindingsResponse expectedResponse = 7805 BatchCreateAccessBindingsResponse.newBuilder() 7806 .addAllAccessBindings(new ArrayList<AccessBinding>()) 7807 .build(); 7808 mockService.addResponse(expectedResponse); 7809 7810 BatchCreateAccessBindingsRequest request = 7811 BatchCreateAccessBindingsRequest.newBuilder() 7812 .setParent(AccountName.of("[ACCOUNT]").toString()) 7813 .addAllRequests(new ArrayList<CreateAccessBindingRequest>()) 7814 .build(); 7815 7816 BatchCreateAccessBindingsResponse actualResponse = client.batchCreateAccessBindings(request); 7817 Assert.assertEquals(expectedResponse, actualResponse); 7818 7819 List<String> actualRequests = mockService.getRequestPaths(); 7820 Assert.assertEquals(1, actualRequests.size()); 7821 7822 String apiClientHeaderKey = 7823 mockService 7824 .getRequestHeaders() 7825 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7826 .iterator() 7827 .next(); 7828 Assert.assertTrue( 7829 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7830 .matcher(apiClientHeaderKey) 7831 .matches()); 7832 } 7833 7834 @Test batchCreateAccessBindingsExceptionTest()7835 public void batchCreateAccessBindingsExceptionTest() throws Exception { 7836 ApiException exception = 7837 ApiExceptionFactory.createException( 7838 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7839 mockService.addException(exception); 7840 7841 try { 7842 BatchCreateAccessBindingsRequest request = 7843 BatchCreateAccessBindingsRequest.newBuilder() 7844 .setParent(AccountName.of("[ACCOUNT]").toString()) 7845 .addAllRequests(new ArrayList<CreateAccessBindingRequest>()) 7846 .build(); 7847 client.batchCreateAccessBindings(request); 7848 Assert.fail("No exception raised"); 7849 } catch (InvalidArgumentException e) { 7850 // Expected exception. 7851 } 7852 } 7853 7854 @Test batchGetAccessBindingsTest()7855 public void batchGetAccessBindingsTest() throws Exception { 7856 BatchGetAccessBindingsResponse expectedResponse = 7857 BatchGetAccessBindingsResponse.newBuilder() 7858 .addAllAccessBindings(new ArrayList<AccessBinding>()) 7859 .build(); 7860 mockService.addResponse(expectedResponse); 7861 7862 BatchGetAccessBindingsRequest request = 7863 BatchGetAccessBindingsRequest.newBuilder() 7864 .setParent(AccountName.of("[ACCOUNT]").toString()) 7865 .addAllNames(new ArrayList<String>()) 7866 .build(); 7867 7868 BatchGetAccessBindingsResponse actualResponse = client.batchGetAccessBindings(request); 7869 Assert.assertEquals(expectedResponse, actualResponse); 7870 7871 List<String> actualRequests = mockService.getRequestPaths(); 7872 Assert.assertEquals(1, actualRequests.size()); 7873 7874 String apiClientHeaderKey = 7875 mockService 7876 .getRequestHeaders() 7877 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7878 .iterator() 7879 .next(); 7880 Assert.assertTrue( 7881 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7882 .matcher(apiClientHeaderKey) 7883 .matches()); 7884 } 7885 7886 @Test batchGetAccessBindingsExceptionTest()7887 public void batchGetAccessBindingsExceptionTest() throws Exception { 7888 ApiException exception = 7889 ApiExceptionFactory.createException( 7890 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7891 mockService.addException(exception); 7892 7893 try { 7894 BatchGetAccessBindingsRequest request = 7895 BatchGetAccessBindingsRequest.newBuilder() 7896 .setParent(AccountName.of("[ACCOUNT]").toString()) 7897 .addAllNames(new ArrayList<String>()) 7898 .build(); 7899 client.batchGetAccessBindings(request); 7900 Assert.fail("No exception raised"); 7901 } catch (InvalidArgumentException e) { 7902 // Expected exception. 7903 } 7904 } 7905 7906 @Test batchUpdateAccessBindingsTest()7907 public void batchUpdateAccessBindingsTest() throws Exception { 7908 BatchUpdateAccessBindingsResponse expectedResponse = 7909 BatchUpdateAccessBindingsResponse.newBuilder() 7910 .addAllAccessBindings(new ArrayList<AccessBinding>()) 7911 .build(); 7912 mockService.addResponse(expectedResponse); 7913 7914 BatchUpdateAccessBindingsRequest request = 7915 BatchUpdateAccessBindingsRequest.newBuilder() 7916 .setParent(AccountName.of("[ACCOUNT]").toString()) 7917 .addAllRequests(new ArrayList<UpdateAccessBindingRequest>()) 7918 .build(); 7919 7920 BatchUpdateAccessBindingsResponse actualResponse = client.batchUpdateAccessBindings(request); 7921 Assert.assertEquals(expectedResponse, actualResponse); 7922 7923 List<String> actualRequests = mockService.getRequestPaths(); 7924 Assert.assertEquals(1, actualRequests.size()); 7925 7926 String apiClientHeaderKey = 7927 mockService 7928 .getRequestHeaders() 7929 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7930 .iterator() 7931 .next(); 7932 Assert.assertTrue( 7933 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7934 .matcher(apiClientHeaderKey) 7935 .matches()); 7936 } 7937 7938 @Test batchUpdateAccessBindingsExceptionTest()7939 public void batchUpdateAccessBindingsExceptionTest() throws Exception { 7940 ApiException exception = 7941 ApiExceptionFactory.createException( 7942 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7943 mockService.addException(exception); 7944 7945 try { 7946 BatchUpdateAccessBindingsRequest request = 7947 BatchUpdateAccessBindingsRequest.newBuilder() 7948 .setParent(AccountName.of("[ACCOUNT]").toString()) 7949 .addAllRequests(new ArrayList<UpdateAccessBindingRequest>()) 7950 .build(); 7951 client.batchUpdateAccessBindings(request); 7952 Assert.fail("No exception raised"); 7953 } catch (InvalidArgumentException e) { 7954 // Expected exception. 7955 } 7956 } 7957 7958 @Test batchDeleteAccessBindingsTest()7959 public void batchDeleteAccessBindingsTest() throws Exception { 7960 Empty expectedResponse = Empty.newBuilder().build(); 7961 mockService.addResponse(expectedResponse); 7962 7963 BatchDeleteAccessBindingsRequest request = 7964 BatchDeleteAccessBindingsRequest.newBuilder() 7965 .setParent(AccountName.of("[ACCOUNT]").toString()) 7966 .addAllRequests(new ArrayList<DeleteAccessBindingRequest>()) 7967 .build(); 7968 7969 client.batchDeleteAccessBindings(request); 7970 7971 List<String> actualRequests = mockService.getRequestPaths(); 7972 Assert.assertEquals(1, actualRequests.size()); 7973 7974 String apiClientHeaderKey = 7975 mockService 7976 .getRequestHeaders() 7977 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 7978 .iterator() 7979 .next(); 7980 Assert.assertTrue( 7981 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 7982 .matcher(apiClientHeaderKey) 7983 .matches()); 7984 } 7985 7986 @Test batchDeleteAccessBindingsExceptionTest()7987 public void batchDeleteAccessBindingsExceptionTest() throws Exception { 7988 ApiException exception = 7989 ApiExceptionFactory.createException( 7990 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 7991 mockService.addException(exception); 7992 7993 try { 7994 BatchDeleteAccessBindingsRequest request = 7995 BatchDeleteAccessBindingsRequest.newBuilder() 7996 .setParent(AccountName.of("[ACCOUNT]").toString()) 7997 .addAllRequests(new ArrayList<DeleteAccessBindingRequest>()) 7998 .build(); 7999 client.batchDeleteAccessBindings(request); 8000 Assert.fail("No exception raised"); 8001 } catch (InvalidArgumentException e) { 8002 // Expected exception. 8003 } 8004 } 8005 8006 @Test getExpandedDataSetTest()8007 public void getExpandedDataSetTest() throws Exception { 8008 ExpandedDataSet expectedResponse = 8009 ExpandedDataSet.newBuilder() 8010 .setName(ExpandedDataSetName.of("[PROPERTY]", "[EXPANDED_DATA_SET]").toString()) 8011 .setDisplayName("displayName1714148973") 8012 .setDescription("description-1724546052") 8013 .addAllDimensionNames(new ArrayList<String>()) 8014 .addAllMetricNames(new ArrayList<String>()) 8015 .setDimensionFilterExpression(ExpandedDataSetFilterExpression.newBuilder().build()) 8016 .setDataCollectionStartTime(Timestamp.newBuilder().build()) 8017 .build(); 8018 mockService.addResponse(expectedResponse); 8019 8020 ExpandedDataSetName name = ExpandedDataSetName.of("[PROPERTY]", "[EXPANDED_DATA_SET]"); 8021 8022 ExpandedDataSet actualResponse = client.getExpandedDataSet(name); 8023 Assert.assertEquals(expectedResponse, actualResponse); 8024 8025 List<String> actualRequests = mockService.getRequestPaths(); 8026 Assert.assertEquals(1, actualRequests.size()); 8027 8028 String apiClientHeaderKey = 8029 mockService 8030 .getRequestHeaders() 8031 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8032 .iterator() 8033 .next(); 8034 Assert.assertTrue( 8035 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8036 .matcher(apiClientHeaderKey) 8037 .matches()); 8038 } 8039 8040 @Test getExpandedDataSetExceptionTest()8041 public void getExpandedDataSetExceptionTest() throws Exception { 8042 ApiException exception = 8043 ApiExceptionFactory.createException( 8044 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8045 mockService.addException(exception); 8046 8047 try { 8048 ExpandedDataSetName name = ExpandedDataSetName.of("[PROPERTY]", "[EXPANDED_DATA_SET]"); 8049 client.getExpandedDataSet(name); 8050 Assert.fail("No exception raised"); 8051 } catch (InvalidArgumentException e) { 8052 // Expected exception. 8053 } 8054 } 8055 8056 @Test getExpandedDataSetTest2()8057 public void getExpandedDataSetTest2() throws Exception { 8058 ExpandedDataSet expectedResponse = 8059 ExpandedDataSet.newBuilder() 8060 .setName(ExpandedDataSetName.of("[PROPERTY]", "[EXPANDED_DATA_SET]").toString()) 8061 .setDisplayName("displayName1714148973") 8062 .setDescription("description-1724546052") 8063 .addAllDimensionNames(new ArrayList<String>()) 8064 .addAllMetricNames(new ArrayList<String>()) 8065 .setDimensionFilterExpression(ExpandedDataSetFilterExpression.newBuilder().build()) 8066 .setDataCollectionStartTime(Timestamp.newBuilder().build()) 8067 .build(); 8068 mockService.addResponse(expectedResponse); 8069 8070 String name = "properties/propertie-4725/expandedDataSets/expandedDataSet-4725"; 8071 8072 ExpandedDataSet actualResponse = client.getExpandedDataSet(name); 8073 Assert.assertEquals(expectedResponse, actualResponse); 8074 8075 List<String> actualRequests = mockService.getRequestPaths(); 8076 Assert.assertEquals(1, actualRequests.size()); 8077 8078 String apiClientHeaderKey = 8079 mockService 8080 .getRequestHeaders() 8081 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8082 .iterator() 8083 .next(); 8084 Assert.assertTrue( 8085 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8086 .matcher(apiClientHeaderKey) 8087 .matches()); 8088 } 8089 8090 @Test getExpandedDataSetExceptionTest2()8091 public void getExpandedDataSetExceptionTest2() throws Exception { 8092 ApiException exception = 8093 ApiExceptionFactory.createException( 8094 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8095 mockService.addException(exception); 8096 8097 try { 8098 String name = "properties/propertie-4725/expandedDataSets/expandedDataSet-4725"; 8099 client.getExpandedDataSet(name); 8100 Assert.fail("No exception raised"); 8101 } catch (InvalidArgumentException e) { 8102 // Expected exception. 8103 } 8104 } 8105 8106 @Test listExpandedDataSetsTest()8107 public void listExpandedDataSetsTest() throws Exception { 8108 ExpandedDataSet responsesElement = ExpandedDataSet.newBuilder().build(); 8109 ListExpandedDataSetsResponse expectedResponse = 8110 ListExpandedDataSetsResponse.newBuilder() 8111 .setNextPageToken("") 8112 .addAllExpandedDataSets(Arrays.asList(responsesElement)) 8113 .build(); 8114 mockService.addResponse(expectedResponse); 8115 8116 PropertyName parent = PropertyName.of("[PROPERTY]"); 8117 8118 ListExpandedDataSetsPagedResponse pagedListResponse = client.listExpandedDataSets(parent); 8119 8120 List<ExpandedDataSet> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 8121 8122 Assert.assertEquals(1, resources.size()); 8123 Assert.assertEquals(expectedResponse.getExpandedDataSetsList().get(0), resources.get(0)); 8124 8125 List<String> actualRequests = mockService.getRequestPaths(); 8126 Assert.assertEquals(1, actualRequests.size()); 8127 8128 String apiClientHeaderKey = 8129 mockService 8130 .getRequestHeaders() 8131 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8132 .iterator() 8133 .next(); 8134 Assert.assertTrue( 8135 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8136 .matcher(apiClientHeaderKey) 8137 .matches()); 8138 } 8139 8140 @Test listExpandedDataSetsExceptionTest()8141 public void listExpandedDataSetsExceptionTest() throws Exception { 8142 ApiException exception = 8143 ApiExceptionFactory.createException( 8144 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8145 mockService.addException(exception); 8146 8147 try { 8148 PropertyName parent = PropertyName.of("[PROPERTY]"); 8149 client.listExpandedDataSets(parent); 8150 Assert.fail("No exception raised"); 8151 } catch (InvalidArgumentException e) { 8152 // Expected exception. 8153 } 8154 } 8155 8156 @Test listExpandedDataSetsTest2()8157 public void listExpandedDataSetsTest2() throws Exception { 8158 ExpandedDataSet responsesElement = ExpandedDataSet.newBuilder().build(); 8159 ListExpandedDataSetsResponse expectedResponse = 8160 ListExpandedDataSetsResponse.newBuilder() 8161 .setNextPageToken("") 8162 .addAllExpandedDataSets(Arrays.asList(responsesElement)) 8163 .build(); 8164 mockService.addResponse(expectedResponse); 8165 8166 String parent = "properties/propertie-2024"; 8167 8168 ListExpandedDataSetsPagedResponse pagedListResponse = client.listExpandedDataSets(parent); 8169 8170 List<ExpandedDataSet> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 8171 8172 Assert.assertEquals(1, resources.size()); 8173 Assert.assertEquals(expectedResponse.getExpandedDataSetsList().get(0), resources.get(0)); 8174 8175 List<String> actualRequests = mockService.getRequestPaths(); 8176 Assert.assertEquals(1, actualRequests.size()); 8177 8178 String apiClientHeaderKey = 8179 mockService 8180 .getRequestHeaders() 8181 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8182 .iterator() 8183 .next(); 8184 Assert.assertTrue( 8185 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8186 .matcher(apiClientHeaderKey) 8187 .matches()); 8188 } 8189 8190 @Test listExpandedDataSetsExceptionTest2()8191 public void listExpandedDataSetsExceptionTest2() throws Exception { 8192 ApiException exception = 8193 ApiExceptionFactory.createException( 8194 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8195 mockService.addException(exception); 8196 8197 try { 8198 String parent = "properties/propertie-2024"; 8199 client.listExpandedDataSets(parent); 8200 Assert.fail("No exception raised"); 8201 } catch (InvalidArgumentException e) { 8202 // Expected exception. 8203 } 8204 } 8205 8206 @Test createExpandedDataSetTest()8207 public void createExpandedDataSetTest() throws Exception { 8208 ExpandedDataSet expectedResponse = 8209 ExpandedDataSet.newBuilder() 8210 .setName(ExpandedDataSetName.of("[PROPERTY]", "[EXPANDED_DATA_SET]").toString()) 8211 .setDisplayName("displayName1714148973") 8212 .setDescription("description-1724546052") 8213 .addAllDimensionNames(new ArrayList<String>()) 8214 .addAllMetricNames(new ArrayList<String>()) 8215 .setDimensionFilterExpression(ExpandedDataSetFilterExpression.newBuilder().build()) 8216 .setDataCollectionStartTime(Timestamp.newBuilder().build()) 8217 .build(); 8218 mockService.addResponse(expectedResponse); 8219 8220 PropertyName parent = PropertyName.of("[PROPERTY]"); 8221 ExpandedDataSet expandedDataSet = ExpandedDataSet.newBuilder().build(); 8222 8223 ExpandedDataSet actualResponse = client.createExpandedDataSet(parent, expandedDataSet); 8224 Assert.assertEquals(expectedResponse, actualResponse); 8225 8226 List<String> actualRequests = mockService.getRequestPaths(); 8227 Assert.assertEquals(1, actualRequests.size()); 8228 8229 String apiClientHeaderKey = 8230 mockService 8231 .getRequestHeaders() 8232 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8233 .iterator() 8234 .next(); 8235 Assert.assertTrue( 8236 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8237 .matcher(apiClientHeaderKey) 8238 .matches()); 8239 } 8240 8241 @Test createExpandedDataSetExceptionTest()8242 public void createExpandedDataSetExceptionTest() throws Exception { 8243 ApiException exception = 8244 ApiExceptionFactory.createException( 8245 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8246 mockService.addException(exception); 8247 8248 try { 8249 PropertyName parent = PropertyName.of("[PROPERTY]"); 8250 ExpandedDataSet expandedDataSet = ExpandedDataSet.newBuilder().build(); 8251 client.createExpandedDataSet(parent, expandedDataSet); 8252 Assert.fail("No exception raised"); 8253 } catch (InvalidArgumentException e) { 8254 // Expected exception. 8255 } 8256 } 8257 8258 @Test createExpandedDataSetTest2()8259 public void createExpandedDataSetTest2() throws Exception { 8260 ExpandedDataSet expectedResponse = 8261 ExpandedDataSet.newBuilder() 8262 .setName(ExpandedDataSetName.of("[PROPERTY]", "[EXPANDED_DATA_SET]").toString()) 8263 .setDisplayName("displayName1714148973") 8264 .setDescription("description-1724546052") 8265 .addAllDimensionNames(new ArrayList<String>()) 8266 .addAllMetricNames(new ArrayList<String>()) 8267 .setDimensionFilterExpression(ExpandedDataSetFilterExpression.newBuilder().build()) 8268 .setDataCollectionStartTime(Timestamp.newBuilder().build()) 8269 .build(); 8270 mockService.addResponse(expectedResponse); 8271 8272 String parent = "properties/propertie-2024"; 8273 ExpandedDataSet expandedDataSet = ExpandedDataSet.newBuilder().build(); 8274 8275 ExpandedDataSet actualResponse = client.createExpandedDataSet(parent, expandedDataSet); 8276 Assert.assertEquals(expectedResponse, actualResponse); 8277 8278 List<String> actualRequests = mockService.getRequestPaths(); 8279 Assert.assertEquals(1, actualRequests.size()); 8280 8281 String apiClientHeaderKey = 8282 mockService 8283 .getRequestHeaders() 8284 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8285 .iterator() 8286 .next(); 8287 Assert.assertTrue( 8288 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8289 .matcher(apiClientHeaderKey) 8290 .matches()); 8291 } 8292 8293 @Test createExpandedDataSetExceptionTest2()8294 public void createExpandedDataSetExceptionTest2() throws Exception { 8295 ApiException exception = 8296 ApiExceptionFactory.createException( 8297 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8298 mockService.addException(exception); 8299 8300 try { 8301 String parent = "properties/propertie-2024"; 8302 ExpandedDataSet expandedDataSet = ExpandedDataSet.newBuilder().build(); 8303 client.createExpandedDataSet(parent, expandedDataSet); 8304 Assert.fail("No exception raised"); 8305 } catch (InvalidArgumentException e) { 8306 // Expected exception. 8307 } 8308 } 8309 8310 @Test updateExpandedDataSetTest()8311 public void updateExpandedDataSetTest() throws Exception { 8312 ExpandedDataSet expectedResponse = 8313 ExpandedDataSet.newBuilder() 8314 .setName(ExpandedDataSetName.of("[PROPERTY]", "[EXPANDED_DATA_SET]").toString()) 8315 .setDisplayName("displayName1714148973") 8316 .setDescription("description-1724546052") 8317 .addAllDimensionNames(new ArrayList<String>()) 8318 .addAllMetricNames(new ArrayList<String>()) 8319 .setDimensionFilterExpression(ExpandedDataSetFilterExpression.newBuilder().build()) 8320 .setDataCollectionStartTime(Timestamp.newBuilder().build()) 8321 .build(); 8322 mockService.addResponse(expectedResponse); 8323 8324 ExpandedDataSet expandedDataSet = 8325 ExpandedDataSet.newBuilder() 8326 .setName(ExpandedDataSetName.of("[PROPERTY]", "[EXPANDED_DATA_SET]").toString()) 8327 .setDisplayName("displayName1714148973") 8328 .setDescription("description-1724546052") 8329 .addAllDimensionNames(new ArrayList<String>()) 8330 .addAllMetricNames(new ArrayList<String>()) 8331 .setDimensionFilterExpression(ExpandedDataSetFilterExpression.newBuilder().build()) 8332 .setDataCollectionStartTime(Timestamp.newBuilder().build()) 8333 .build(); 8334 FieldMask updateMask = FieldMask.newBuilder().build(); 8335 8336 ExpandedDataSet actualResponse = client.updateExpandedDataSet(expandedDataSet, updateMask); 8337 Assert.assertEquals(expectedResponse, actualResponse); 8338 8339 List<String> actualRequests = mockService.getRequestPaths(); 8340 Assert.assertEquals(1, actualRequests.size()); 8341 8342 String apiClientHeaderKey = 8343 mockService 8344 .getRequestHeaders() 8345 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8346 .iterator() 8347 .next(); 8348 Assert.assertTrue( 8349 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8350 .matcher(apiClientHeaderKey) 8351 .matches()); 8352 } 8353 8354 @Test updateExpandedDataSetExceptionTest()8355 public void updateExpandedDataSetExceptionTest() throws Exception { 8356 ApiException exception = 8357 ApiExceptionFactory.createException( 8358 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8359 mockService.addException(exception); 8360 8361 try { 8362 ExpandedDataSet expandedDataSet = 8363 ExpandedDataSet.newBuilder() 8364 .setName(ExpandedDataSetName.of("[PROPERTY]", "[EXPANDED_DATA_SET]").toString()) 8365 .setDisplayName("displayName1714148973") 8366 .setDescription("description-1724546052") 8367 .addAllDimensionNames(new ArrayList<String>()) 8368 .addAllMetricNames(new ArrayList<String>()) 8369 .setDimensionFilterExpression(ExpandedDataSetFilterExpression.newBuilder().build()) 8370 .setDataCollectionStartTime(Timestamp.newBuilder().build()) 8371 .build(); 8372 FieldMask updateMask = FieldMask.newBuilder().build(); 8373 client.updateExpandedDataSet(expandedDataSet, updateMask); 8374 Assert.fail("No exception raised"); 8375 } catch (InvalidArgumentException e) { 8376 // Expected exception. 8377 } 8378 } 8379 8380 @Test deleteExpandedDataSetTest()8381 public void deleteExpandedDataSetTest() throws Exception { 8382 Empty expectedResponse = Empty.newBuilder().build(); 8383 mockService.addResponse(expectedResponse); 8384 8385 ExpandedDataSetName name = ExpandedDataSetName.of("[PROPERTY]", "[EXPANDED_DATA_SET]"); 8386 8387 client.deleteExpandedDataSet(name); 8388 8389 List<String> actualRequests = mockService.getRequestPaths(); 8390 Assert.assertEquals(1, actualRequests.size()); 8391 8392 String apiClientHeaderKey = 8393 mockService 8394 .getRequestHeaders() 8395 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8396 .iterator() 8397 .next(); 8398 Assert.assertTrue( 8399 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8400 .matcher(apiClientHeaderKey) 8401 .matches()); 8402 } 8403 8404 @Test deleteExpandedDataSetExceptionTest()8405 public void deleteExpandedDataSetExceptionTest() throws Exception { 8406 ApiException exception = 8407 ApiExceptionFactory.createException( 8408 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8409 mockService.addException(exception); 8410 8411 try { 8412 ExpandedDataSetName name = ExpandedDataSetName.of("[PROPERTY]", "[EXPANDED_DATA_SET]"); 8413 client.deleteExpandedDataSet(name); 8414 Assert.fail("No exception raised"); 8415 } catch (InvalidArgumentException e) { 8416 // Expected exception. 8417 } 8418 } 8419 8420 @Test deleteExpandedDataSetTest2()8421 public void deleteExpandedDataSetTest2() throws Exception { 8422 Empty expectedResponse = Empty.newBuilder().build(); 8423 mockService.addResponse(expectedResponse); 8424 8425 String name = "properties/propertie-4725/expandedDataSets/expandedDataSet-4725"; 8426 8427 client.deleteExpandedDataSet(name); 8428 8429 List<String> actualRequests = mockService.getRequestPaths(); 8430 Assert.assertEquals(1, actualRequests.size()); 8431 8432 String apiClientHeaderKey = 8433 mockService 8434 .getRequestHeaders() 8435 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8436 .iterator() 8437 .next(); 8438 Assert.assertTrue( 8439 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8440 .matcher(apiClientHeaderKey) 8441 .matches()); 8442 } 8443 8444 @Test deleteExpandedDataSetExceptionTest2()8445 public void deleteExpandedDataSetExceptionTest2() throws Exception { 8446 ApiException exception = 8447 ApiExceptionFactory.createException( 8448 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8449 mockService.addException(exception); 8450 8451 try { 8452 String name = "properties/propertie-4725/expandedDataSets/expandedDataSet-4725"; 8453 client.deleteExpandedDataSet(name); 8454 Assert.fail("No exception raised"); 8455 } catch (InvalidArgumentException e) { 8456 // Expected exception. 8457 } 8458 } 8459 8460 @Test getChannelGroupTest()8461 public void getChannelGroupTest() throws Exception { 8462 ChannelGroup expectedResponse = 8463 ChannelGroup.newBuilder() 8464 .setName(ChannelGroupName.of("[PROPERTY]", "[CHANNEL_GROUP]").toString()) 8465 .setDisplayName("displayName1714148973") 8466 .setDescription("description-1724546052") 8467 .addAllGroupingRule(new ArrayList<GroupingRule>()) 8468 .setSystemDefined(true) 8469 .build(); 8470 mockService.addResponse(expectedResponse); 8471 8472 ChannelGroupName name = ChannelGroupName.of("[PROPERTY]", "[CHANNEL_GROUP]"); 8473 8474 ChannelGroup actualResponse = client.getChannelGroup(name); 8475 Assert.assertEquals(expectedResponse, actualResponse); 8476 8477 List<String> actualRequests = mockService.getRequestPaths(); 8478 Assert.assertEquals(1, actualRequests.size()); 8479 8480 String apiClientHeaderKey = 8481 mockService 8482 .getRequestHeaders() 8483 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8484 .iterator() 8485 .next(); 8486 Assert.assertTrue( 8487 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8488 .matcher(apiClientHeaderKey) 8489 .matches()); 8490 } 8491 8492 @Test getChannelGroupExceptionTest()8493 public void getChannelGroupExceptionTest() throws Exception { 8494 ApiException exception = 8495 ApiExceptionFactory.createException( 8496 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8497 mockService.addException(exception); 8498 8499 try { 8500 ChannelGroupName name = ChannelGroupName.of("[PROPERTY]", "[CHANNEL_GROUP]"); 8501 client.getChannelGroup(name); 8502 Assert.fail("No exception raised"); 8503 } catch (InvalidArgumentException e) { 8504 // Expected exception. 8505 } 8506 } 8507 8508 @Test getChannelGroupTest2()8509 public void getChannelGroupTest2() throws Exception { 8510 ChannelGroup expectedResponse = 8511 ChannelGroup.newBuilder() 8512 .setName(ChannelGroupName.of("[PROPERTY]", "[CHANNEL_GROUP]").toString()) 8513 .setDisplayName("displayName1714148973") 8514 .setDescription("description-1724546052") 8515 .addAllGroupingRule(new ArrayList<GroupingRule>()) 8516 .setSystemDefined(true) 8517 .build(); 8518 mockService.addResponse(expectedResponse); 8519 8520 String name = "properties/propertie-836/channelGroups/channelGroup-836"; 8521 8522 ChannelGroup actualResponse = client.getChannelGroup(name); 8523 Assert.assertEquals(expectedResponse, actualResponse); 8524 8525 List<String> actualRequests = mockService.getRequestPaths(); 8526 Assert.assertEquals(1, actualRequests.size()); 8527 8528 String apiClientHeaderKey = 8529 mockService 8530 .getRequestHeaders() 8531 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8532 .iterator() 8533 .next(); 8534 Assert.assertTrue( 8535 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8536 .matcher(apiClientHeaderKey) 8537 .matches()); 8538 } 8539 8540 @Test getChannelGroupExceptionTest2()8541 public void getChannelGroupExceptionTest2() throws Exception { 8542 ApiException exception = 8543 ApiExceptionFactory.createException( 8544 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8545 mockService.addException(exception); 8546 8547 try { 8548 String name = "properties/propertie-836/channelGroups/channelGroup-836"; 8549 client.getChannelGroup(name); 8550 Assert.fail("No exception raised"); 8551 } catch (InvalidArgumentException e) { 8552 // Expected exception. 8553 } 8554 } 8555 8556 @Test listChannelGroupsTest()8557 public void listChannelGroupsTest() throws Exception { 8558 ChannelGroup responsesElement = ChannelGroup.newBuilder().build(); 8559 ListChannelGroupsResponse expectedResponse = 8560 ListChannelGroupsResponse.newBuilder() 8561 .setNextPageToken("") 8562 .addAllChannelGroups(Arrays.asList(responsesElement)) 8563 .build(); 8564 mockService.addResponse(expectedResponse); 8565 8566 PropertyName parent = PropertyName.of("[PROPERTY]"); 8567 8568 ListChannelGroupsPagedResponse pagedListResponse = client.listChannelGroups(parent); 8569 8570 List<ChannelGroup> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 8571 8572 Assert.assertEquals(1, resources.size()); 8573 Assert.assertEquals(expectedResponse.getChannelGroupsList().get(0), resources.get(0)); 8574 8575 List<String> actualRequests = mockService.getRequestPaths(); 8576 Assert.assertEquals(1, actualRequests.size()); 8577 8578 String apiClientHeaderKey = 8579 mockService 8580 .getRequestHeaders() 8581 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8582 .iterator() 8583 .next(); 8584 Assert.assertTrue( 8585 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8586 .matcher(apiClientHeaderKey) 8587 .matches()); 8588 } 8589 8590 @Test listChannelGroupsExceptionTest()8591 public void listChannelGroupsExceptionTest() throws Exception { 8592 ApiException exception = 8593 ApiExceptionFactory.createException( 8594 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8595 mockService.addException(exception); 8596 8597 try { 8598 PropertyName parent = PropertyName.of("[PROPERTY]"); 8599 client.listChannelGroups(parent); 8600 Assert.fail("No exception raised"); 8601 } catch (InvalidArgumentException e) { 8602 // Expected exception. 8603 } 8604 } 8605 8606 @Test listChannelGroupsTest2()8607 public void listChannelGroupsTest2() throws Exception { 8608 ChannelGroup responsesElement = ChannelGroup.newBuilder().build(); 8609 ListChannelGroupsResponse expectedResponse = 8610 ListChannelGroupsResponse.newBuilder() 8611 .setNextPageToken("") 8612 .addAllChannelGroups(Arrays.asList(responsesElement)) 8613 .build(); 8614 mockService.addResponse(expectedResponse); 8615 8616 String parent = "properties/propertie-2024"; 8617 8618 ListChannelGroupsPagedResponse pagedListResponse = client.listChannelGroups(parent); 8619 8620 List<ChannelGroup> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 8621 8622 Assert.assertEquals(1, resources.size()); 8623 Assert.assertEquals(expectedResponse.getChannelGroupsList().get(0), resources.get(0)); 8624 8625 List<String> actualRequests = mockService.getRequestPaths(); 8626 Assert.assertEquals(1, actualRequests.size()); 8627 8628 String apiClientHeaderKey = 8629 mockService 8630 .getRequestHeaders() 8631 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8632 .iterator() 8633 .next(); 8634 Assert.assertTrue( 8635 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8636 .matcher(apiClientHeaderKey) 8637 .matches()); 8638 } 8639 8640 @Test listChannelGroupsExceptionTest2()8641 public void listChannelGroupsExceptionTest2() throws Exception { 8642 ApiException exception = 8643 ApiExceptionFactory.createException( 8644 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8645 mockService.addException(exception); 8646 8647 try { 8648 String parent = "properties/propertie-2024"; 8649 client.listChannelGroups(parent); 8650 Assert.fail("No exception raised"); 8651 } catch (InvalidArgumentException e) { 8652 // Expected exception. 8653 } 8654 } 8655 8656 @Test createChannelGroupTest()8657 public void createChannelGroupTest() throws Exception { 8658 ChannelGroup expectedResponse = 8659 ChannelGroup.newBuilder() 8660 .setName(ChannelGroupName.of("[PROPERTY]", "[CHANNEL_GROUP]").toString()) 8661 .setDisplayName("displayName1714148973") 8662 .setDescription("description-1724546052") 8663 .addAllGroupingRule(new ArrayList<GroupingRule>()) 8664 .setSystemDefined(true) 8665 .build(); 8666 mockService.addResponse(expectedResponse); 8667 8668 PropertyName parent = PropertyName.of("[PROPERTY]"); 8669 ChannelGroup channelGroup = ChannelGroup.newBuilder().build(); 8670 8671 ChannelGroup actualResponse = client.createChannelGroup(parent, channelGroup); 8672 Assert.assertEquals(expectedResponse, actualResponse); 8673 8674 List<String> actualRequests = mockService.getRequestPaths(); 8675 Assert.assertEquals(1, actualRequests.size()); 8676 8677 String apiClientHeaderKey = 8678 mockService 8679 .getRequestHeaders() 8680 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8681 .iterator() 8682 .next(); 8683 Assert.assertTrue( 8684 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8685 .matcher(apiClientHeaderKey) 8686 .matches()); 8687 } 8688 8689 @Test createChannelGroupExceptionTest()8690 public void createChannelGroupExceptionTest() throws Exception { 8691 ApiException exception = 8692 ApiExceptionFactory.createException( 8693 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8694 mockService.addException(exception); 8695 8696 try { 8697 PropertyName parent = PropertyName.of("[PROPERTY]"); 8698 ChannelGroup channelGroup = ChannelGroup.newBuilder().build(); 8699 client.createChannelGroup(parent, channelGroup); 8700 Assert.fail("No exception raised"); 8701 } catch (InvalidArgumentException e) { 8702 // Expected exception. 8703 } 8704 } 8705 8706 @Test createChannelGroupTest2()8707 public void createChannelGroupTest2() throws Exception { 8708 ChannelGroup expectedResponse = 8709 ChannelGroup.newBuilder() 8710 .setName(ChannelGroupName.of("[PROPERTY]", "[CHANNEL_GROUP]").toString()) 8711 .setDisplayName("displayName1714148973") 8712 .setDescription("description-1724546052") 8713 .addAllGroupingRule(new ArrayList<GroupingRule>()) 8714 .setSystemDefined(true) 8715 .build(); 8716 mockService.addResponse(expectedResponse); 8717 8718 String parent = "properties/propertie-2024"; 8719 ChannelGroup channelGroup = ChannelGroup.newBuilder().build(); 8720 8721 ChannelGroup actualResponse = client.createChannelGroup(parent, channelGroup); 8722 Assert.assertEquals(expectedResponse, actualResponse); 8723 8724 List<String> actualRequests = mockService.getRequestPaths(); 8725 Assert.assertEquals(1, actualRequests.size()); 8726 8727 String apiClientHeaderKey = 8728 mockService 8729 .getRequestHeaders() 8730 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8731 .iterator() 8732 .next(); 8733 Assert.assertTrue( 8734 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8735 .matcher(apiClientHeaderKey) 8736 .matches()); 8737 } 8738 8739 @Test createChannelGroupExceptionTest2()8740 public void createChannelGroupExceptionTest2() throws Exception { 8741 ApiException exception = 8742 ApiExceptionFactory.createException( 8743 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8744 mockService.addException(exception); 8745 8746 try { 8747 String parent = "properties/propertie-2024"; 8748 ChannelGroup channelGroup = ChannelGroup.newBuilder().build(); 8749 client.createChannelGroup(parent, channelGroup); 8750 Assert.fail("No exception raised"); 8751 } catch (InvalidArgumentException e) { 8752 // Expected exception. 8753 } 8754 } 8755 8756 @Test updateChannelGroupTest()8757 public void updateChannelGroupTest() throws Exception { 8758 ChannelGroup expectedResponse = 8759 ChannelGroup.newBuilder() 8760 .setName(ChannelGroupName.of("[PROPERTY]", "[CHANNEL_GROUP]").toString()) 8761 .setDisplayName("displayName1714148973") 8762 .setDescription("description-1724546052") 8763 .addAllGroupingRule(new ArrayList<GroupingRule>()) 8764 .setSystemDefined(true) 8765 .build(); 8766 mockService.addResponse(expectedResponse); 8767 8768 ChannelGroup channelGroup = 8769 ChannelGroup.newBuilder() 8770 .setName(ChannelGroupName.of("[PROPERTY]", "[CHANNEL_GROUP]").toString()) 8771 .setDisplayName("displayName1714148973") 8772 .setDescription("description-1724546052") 8773 .addAllGroupingRule(new ArrayList<GroupingRule>()) 8774 .setSystemDefined(true) 8775 .build(); 8776 FieldMask updateMask = FieldMask.newBuilder().build(); 8777 8778 ChannelGroup actualResponse = client.updateChannelGroup(channelGroup, updateMask); 8779 Assert.assertEquals(expectedResponse, actualResponse); 8780 8781 List<String> actualRequests = mockService.getRequestPaths(); 8782 Assert.assertEquals(1, actualRequests.size()); 8783 8784 String apiClientHeaderKey = 8785 mockService 8786 .getRequestHeaders() 8787 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8788 .iterator() 8789 .next(); 8790 Assert.assertTrue( 8791 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8792 .matcher(apiClientHeaderKey) 8793 .matches()); 8794 } 8795 8796 @Test updateChannelGroupExceptionTest()8797 public void updateChannelGroupExceptionTest() throws Exception { 8798 ApiException exception = 8799 ApiExceptionFactory.createException( 8800 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8801 mockService.addException(exception); 8802 8803 try { 8804 ChannelGroup channelGroup = 8805 ChannelGroup.newBuilder() 8806 .setName(ChannelGroupName.of("[PROPERTY]", "[CHANNEL_GROUP]").toString()) 8807 .setDisplayName("displayName1714148973") 8808 .setDescription("description-1724546052") 8809 .addAllGroupingRule(new ArrayList<GroupingRule>()) 8810 .setSystemDefined(true) 8811 .build(); 8812 FieldMask updateMask = FieldMask.newBuilder().build(); 8813 client.updateChannelGroup(channelGroup, updateMask); 8814 Assert.fail("No exception raised"); 8815 } catch (InvalidArgumentException e) { 8816 // Expected exception. 8817 } 8818 } 8819 8820 @Test deleteChannelGroupTest()8821 public void deleteChannelGroupTest() throws Exception { 8822 Empty expectedResponse = Empty.newBuilder().build(); 8823 mockService.addResponse(expectedResponse); 8824 8825 ChannelGroupName name = ChannelGroupName.of("[PROPERTY]", "[CHANNEL_GROUP]"); 8826 8827 client.deleteChannelGroup(name); 8828 8829 List<String> actualRequests = mockService.getRequestPaths(); 8830 Assert.assertEquals(1, actualRequests.size()); 8831 8832 String apiClientHeaderKey = 8833 mockService 8834 .getRequestHeaders() 8835 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8836 .iterator() 8837 .next(); 8838 Assert.assertTrue( 8839 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8840 .matcher(apiClientHeaderKey) 8841 .matches()); 8842 } 8843 8844 @Test deleteChannelGroupExceptionTest()8845 public void deleteChannelGroupExceptionTest() throws Exception { 8846 ApiException exception = 8847 ApiExceptionFactory.createException( 8848 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8849 mockService.addException(exception); 8850 8851 try { 8852 ChannelGroupName name = ChannelGroupName.of("[PROPERTY]", "[CHANNEL_GROUP]"); 8853 client.deleteChannelGroup(name); 8854 Assert.fail("No exception raised"); 8855 } catch (InvalidArgumentException e) { 8856 // Expected exception. 8857 } 8858 } 8859 8860 @Test deleteChannelGroupTest2()8861 public void deleteChannelGroupTest2() throws Exception { 8862 Empty expectedResponse = Empty.newBuilder().build(); 8863 mockService.addResponse(expectedResponse); 8864 8865 String name = "properties/propertie-836/channelGroups/channelGroup-836"; 8866 8867 client.deleteChannelGroup(name); 8868 8869 List<String> actualRequests = mockService.getRequestPaths(); 8870 Assert.assertEquals(1, actualRequests.size()); 8871 8872 String apiClientHeaderKey = 8873 mockService 8874 .getRequestHeaders() 8875 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8876 .iterator() 8877 .next(); 8878 Assert.assertTrue( 8879 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8880 .matcher(apiClientHeaderKey) 8881 .matches()); 8882 } 8883 8884 @Test deleteChannelGroupExceptionTest2()8885 public void deleteChannelGroupExceptionTest2() throws Exception { 8886 ApiException exception = 8887 ApiExceptionFactory.createException( 8888 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8889 mockService.addException(exception); 8890 8891 try { 8892 String name = "properties/propertie-836/channelGroups/channelGroup-836"; 8893 client.deleteChannelGroup(name); 8894 Assert.fail("No exception raised"); 8895 } catch (InvalidArgumentException e) { 8896 // Expected exception. 8897 } 8898 } 8899 8900 @Test setAutomatedGa4ConfigurationOptOutTest()8901 public void setAutomatedGa4ConfigurationOptOutTest() throws Exception { 8902 SetAutomatedGa4ConfigurationOptOutResponse expectedResponse = 8903 SetAutomatedGa4ConfigurationOptOutResponse.newBuilder().build(); 8904 mockService.addResponse(expectedResponse); 8905 8906 SetAutomatedGa4ConfigurationOptOutRequest request = 8907 SetAutomatedGa4ConfigurationOptOutRequest.newBuilder() 8908 .setProperty("property-993141291") 8909 .setOptOut(true) 8910 .build(); 8911 8912 SetAutomatedGa4ConfigurationOptOutResponse actualResponse = 8913 client.setAutomatedGa4ConfigurationOptOut(request); 8914 Assert.assertEquals(expectedResponse, actualResponse); 8915 8916 List<String> actualRequests = mockService.getRequestPaths(); 8917 Assert.assertEquals(1, actualRequests.size()); 8918 8919 String apiClientHeaderKey = 8920 mockService 8921 .getRequestHeaders() 8922 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8923 .iterator() 8924 .next(); 8925 Assert.assertTrue( 8926 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8927 .matcher(apiClientHeaderKey) 8928 .matches()); 8929 } 8930 8931 @Test setAutomatedGa4ConfigurationOptOutExceptionTest()8932 public void setAutomatedGa4ConfigurationOptOutExceptionTest() throws Exception { 8933 ApiException exception = 8934 ApiExceptionFactory.createException( 8935 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8936 mockService.addException(exception); 8937 8938 try { 8939 SetAutomatedGa4ConfigurationOptOutRequest request = 8940 SetAutomatedGa4ConfigurationOptOutRequest.newBuilder() 8941 .setProperty("property-993141291") 8942 .setOptOut(true) 8943 .build(); 8944 client.setAutomatedGa4ConfigurationOptOut(request); 8945 Assert.fail("No exception raised"); 8946 } catch (InvalidArgumentException e) { 8947 // Expected exception. 8948 } 8949 } 8950 8951 @Test fetchAutomatedGa4ConfigurationOptOutTest()8952 public void fetchAutomatedGa4ConfigurationOptOutTest() throws Exception { 8953 FetchAutomatedGa4ConfigurationOptOutResponse expectedResponse = 8954 FetchAutomatedGa4ConfigurationOptOutResponse.newBuilder().setOptOut(true).build(); 8955 mockService.addResponse(expectedResponse); 8956 8957 FetchAutomatedGa4ConfigurationOptOutRequest request = 8958 FetchAutomatedGa4ConfigurationOptOutRequest.newBuilder() 8959 .setProperty("property-993141291") 8960 .build(); 8961 8962 FetchAutomatedGa4ConfigurationOptOutResponse actualResponse = 8963 client.fetchAutomatedGa4ConfigurationOptOut(request); 8964 Assert.assertEquals(expectedResponse, actualResponse); 8965 8966 List<String> actualRequests = mockService.getRequestPaths(); 8967 Assert.assertEquals(1, actualRequests.size()); 8968 8969 String apiClientHeaderKey = 8970 mockService 8971 .getRequestHeaders() 8972 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 8973 .iterator() 8974 .next(); 8975 Assert.assertTrue( 8976 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 8977 .matcher(apiClientHeaderKey) 8978 .matches()); 8979 } 8980 8981 @Test fetchAutomatedGa4ConfigurationOptOutExceptionTest()8982 public void fetchAutomatedGa4ConfigurationOptOutExceptionTest() throws Exception { 8983 ApiException exception = 8984 ApiExceptionFactory.createException( 8985 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 8986 mockService.addException(exception); 8987 8988 try { 8989 FetchAutomatedGa4ConfigurationOptOutRequest request = 8990 FetchAutomatedGa4ConfigurationOptOutRequest.newBuilder() 8991 .setProperty("property-993141291") 8992 .build(); 8993 client.fetchAutomatedGa4ConfigurationOptOut(request); 8994 Assert.fail("No exception raised"); 8995 } catch (InvalidArgumentException e) { 8996 // Expected exception. 8997 } 8998 } 8999 9000 @Test getBigQueryLinkTest()9001 public void getBigQueryLinkTest() throws Exception { 9002 BigQueryLink expectedResponse = 9003 BigQueryLink.newBuilder() 9004 .setName(BigQueryLinkName.of("[PROPERTY]", "[BIGQUERY_LINK]").toString()) 9005 .setProject("project-309310695") 9006 .setCreateTime(Timestamp.newBuilder().build()) 9007 .setDailyExportEnabled(true) 9008 .setStreamingExportEnabled(true) 9009 .setIntradayExportEnabled(true) 9010 .setIncludeAdvertisingId(true) 9011 .addAllExportStreams(new ArrayList<String>()) 9012 .addAllExcludedEvents(new ArrayList<String>()) 9013 .build(); 9014 mockService.addResponse(expectedResponse); 9015 9016 BigQueryLinkName name = BigQueryLinkName.of("[PROPERTY]", "[BIGQUERY_LINK]"); 9017 9018 BigQueryLink actualResponse = client.getBigQueryLink(name); 9019 Assert.assertEquals(expectedResponse, actualResponse); 9020 9021 List<String> actualRequests = mockService.getRequestPaths(); 9022 Assert.assertEquals(1, actualRequests.size()); 9023 9024 String apiClientHeaderKey = 9025 mockService 9026 .getRequestHeaders() 9027 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 9028 .iterator() 9029 .next(); 9030 Assert.assertTrue( 9031 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 9032 .matcher(apiClientHeaderKey) 9033 .matches()); 9034 } 9035 9036 @Test getBigQueryLinkExceptionTest()9037 public void getBigQueryLinkExceptionTest() throws Exception { 9038 ApiException exception = 9039 ApiExceptionFactory.createException( 9040 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 9041 mockService.addException(exception); 9042 9043 try { 9044 BigQueryLinkName name = BigQueryLinkName.of("[PROPERTY]", "[BIGQUERY_LINK]"); 9045 client.getBigQueryLink(name); 9046 Assert.fail("No exception raised"); 9047 } catch (InvalidArgumentException e) { 9048 // Expected exception. 9049 } 9050 } 9051 9052 @Test getBigQueryLinkTest2()9053 public void getBigQueryLinkTest2() throws Exception { 9054 BigQueryLink expectedResponse = 9055 BigQueryLink.newBuilder() 9056 .setName(BigQueryLinkName.of("[PROPERTY]", "[BIGQUERY_LINK]").toString()) 9057 .setProject("project-309310695") 9058 .setCreateTime(Timestamp.newBuilder().build()) 9059 .setDailyExportEnabled(true) 9060 .setStreamingExportEnabled(true) 9061 .setIntradayExportEnabled(true) 9062 .setIncludeAdvertisingId(true) 9063 .addAllExportStreams(new ArrayList<String>()) 9064 .addAllExcludedEvents(new ArrayList<String>()) 9065 .build(); 9066 mockService.addResponse(expectedResponse); 9067 9068 String name = "properties/propertie-7430/bigQueryLinks/bigQueryLink-7430"; 9069 9070 BigQueryLink actualResponse = client.getBigQueryLink(name); 9071 Assert.assertEquals(expectedResponse, actualResponse); 9072 9073 List<String> actualRequests = mockService.getRequestPaths(); 9074 Assert.assertEquals(1, actualRequests.size()); 9075 9076 String apiClientHeaderKey = 9077 mockService 9078 .getRequestHeaders() 9079 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 9080 .iterator() 9081 .next(); 9082 Assert.assertTrue( 9083 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 9084 .matcher(apiClientHeaderKey) 9085 .matches()); 9086 } 9087 9088 @Test getBigQueryLinkExceptionTest2()9089 public void getBigQueryLinkExceptionTest2() throws Exception { 9090 ApiException exception = 9091 ApiExceptionFactory.createException( 9092 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 9093 mockService.addException(exception); 9094 9095 try { 9096 String name = "properties/propertie-7430/bigQueryLinks/bigQueryLink-7430"; 9097 client.getBigQueryLink(name); 9098 Assert.fail("No exception raised"); 9099 } catch (InvalidArgumentException e) { 9100 // Expected exception. 9101 } 9102 } 9103 9104 @Test listBigQueryLinksTest()9105 public void listBigQueryLinksTest() throws Exception { 9106 BigQueryLink responsesElement = BigQueryLink.newBuilder().build(); 9107 ListBigQueryLinksResponse expectedResponse = 9108 ListBigQueryLinksResponse.newBuilder() 9109 .setNextPageToken("") 9110 .addAllBigqueryLinks(Arrays.asList(responsesElement)) 9111 .build(); 9112 mockService.addResponse(expectedResponse); 9113 9114 PropertyName parent = PropertyName.of("[PROPERTY]"); 9115 9116 ListBigQueryLinksPagedResponse pagedListResponse = client.listBigQueryLinks(parent); 9117 9118 List<BigQueryLink> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 9119 9120 Assert.assertEquals(1, resources.size()); 9121 Assert.assertEquals(expectedResponse.getBigqueryLinksList().get(0), resources.get(0)); 9122 9123 List<String> actualRequests = mockService.getRequestPaths(); 9124 Assert.assertEquals(1, actualRequests.size()); 9125 9126 String apiClientHeaderKey = 9127 mockService 9128 .getRequestHeaders() 9129 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 9130 .iterator() 9131 .next(); 9132 Assert.assertTrue( 9133 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 9134 .matcher(apiClientHeaderKey) 9135 .matches()); 9136 } 9137 9138 @Test listBigQueryLinksExceptionTest()9139 public void listBigQueryLinksExceptionTest() throws Exception { 9140 ApiException exception = 9141 ApiExceptionFactory.createException( 9142 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 9143 mockService.addException(exception); 9144 9145 try { 9146 PropertyName parent = PropertyName.of("[PROPERTY]"); 9147 client.listBigQueryLinks(parent); 9148 Assert.fail("No exception raised"); 9149 } catch (InvalidArgumentException e) { 9150 // Expected exception. 9151 } 9152 } 9153 9154 @Test listBigQueryLinksTest2()9155 public void listBigQueryLinksTest2() throws Exception { 9156 BigQueryLink responsesElement = BigQueryLink.newBuilder().build(); 9157 ListBigQueryLinksResponse expectedResponse = 9158 ListBigQueryLinksResponse.newBuilder() 9159 .setNextPageToken("") 9160 .addAllBigqueryLinks(Arrays.asList(responsesElement)) 9161 .build(); 9162 mockService.addResponse(expectedResponse); 9163 9164 String parent = "properties/propertie-2024"; 9165 9166 ListBigQueryLinksPagedResponse pagedListResponse = client.listBigQueryLinks(parent); 9167 9168 List<BigQueryLink> resources = Lists.newArrayList(pagedListResponse.iterateAll()); 9169 9170 Assert.assertEquals(1, resources.size()); 9171 Assert.assertEquals(expectedResponse.getBigqueryLinksList().get(0), resources.get(0)); 9172 9173 List<String> actualRequests = mockService.getRequestPaths(); 9174 Assert.assertEquals(1, actualRequests.size()); 9175 9176 String apiClientHeaderKey = 9177 mockService 9178 .getRequestHeaders() 9179 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 9180 .iterator() 9181 .next(); 9182 Assert.assertTrue( 9183 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 9184 .matcher(apiClientHeaderKey) 9185 .matches()); 9186 } 9187 9188 @Test listBigQueryLinksExceptionTest2()9189 public void listBigQueryLinksExceptionTest2() throws Exception { 9190 ApiException exception = 9191 ApiExceptionFactory.createException( 9192 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 9193 mockService.addException(exception); 9194 9195 try { 9196 String parent = "properties/propertie-2024"; 9197 client.listBigQueryLinks(parent); 9198 Assert.fail("No exception raised"); 9199 } catch (InvalidArgumentException e) { 9200 // Expected exception. 9201 } 9202 } 9203 9204 @Test getEnhancedMeasurementSettingsTest()9205 public void getEnhancedMeasurementSettingsTest() throws Exception { 9206 EnhancedMeasurementSettings expectedResponse = 9207 EnhancedMeasurementSettings.newBuilder() 9208 .setName(EnhancedMeasurementSettingsName.of("[PROPERTY]", "[DATA_STREAM]").toString()) 9209 .setStreamEnabled(true) 9210 .setScrollsEnabled(true) 9211 .setOutboundClicksEnabled(true) 9212 .setSiteSearchEnabled(true) 9213 .setVideoEngagementEnabled(true) 9214 .setFileDownloadsEnabled(true) 9215 .setPageChangesEnabled(true) 9216 .setFormInteractionsEnabled(true) 9217 .setSearchQueryParameter("searchQueryParameter-2012788855") 9218 .setUriQueryParameter("uriQueryParameter1580843085") 9219 .build(); 9220 mockService.addResponse(expectedResponse); 9221 9222 EnhancedMeasurementSettingsName name = 9223 EnhancedMeasurementSettingsName.of("[PROPERTY]", "[DATA_STREAM]"); 9224 9225 EnhancedMeasurementSettings actualResponse = client.getEnhancedMeasurementSettings(name); 9226 Assert.assertEquals(expectedResponse, actualResponse); 9227 9228 List<String> actualRequests = mockService.getRequestPaths(); 9229 Assert.assertEquals(1, actualRequests.size()); 9230 9231 String apiClientHeaderKey = 9232 mockService 9233 .getRequestHeaders() 9234 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 9235 .iterator() 9236 .next(); 9237 Assert.assertTrue( 9238 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 9239 .matcher(apiClientHeaderKey) 9240 .matches()); 9241 } 9242 9243 @Test getEnhancedMeasurementSettingsExceptionTest()9244 public void getEnhancedMeasurementSettingsExceptionTest() throws Exception { 9245 ApiException exception = 9246 ApiExceptionFactory.createException( 9247 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 9248 mockService.addException(exception); 9249 9250 try { 9251 EnhancedMeasurementSettingsName name = 9252 EnhancedMeasurementSettingsName.of("[PROPERTY]", "[DATA_STREAM]"); 9253 client.getEnhancedMeasurementSettings(name); 9254 Assert.fail("No exception raised"); 9255 } catch (InvalidArgumentException e) { 9256 // Expected exception. 9257 } 9258 } 9259 9260 @Test getEnhancedMeasurementSettingsTest2()9261 public void getEnhancedMeasurementSettingsTest2() throws Exception { 9262 EnhancedMeasurementSettings expectedResponse = 9263 EnhancedMeasurementSettings.newBuilder() 9264 .setName(EnhancedMeasurementSettingsName.of("[PROPERTY]", "[DATA_STREAM]").toString()) 9265 .setStreamEnabled(true) 9266 .setScrollsEnabled(true) 9267 .setOutboundClicksEnabled(true) 9268 .setSiteSearchEnabled(true) 9269 .setVideoEngagementEnabled(true) 9270 .setFileDownloadsEnabled(true) 9271 .setPageChangesEnabled(true) 9272 .setFormInteractionsEnabled(true) 9273 .setSearchQueryParameter("searchQueryParameter-2012788855") 9274 .setUriQueryParameter("uriQueryParameter1580843085") 9275 .build(); 9276 mockService.addResponse(expectedResponse); 9277 9278 String name = 9279 "properties/propertie-5816/dataStreams/dataStream-5816/enhancedMeasurementSettings"; 9280 9281 EnhancedMeasurementSettings actualResponse = client.getEnhancedMeasurementSettings(name); 9282 Assert.assertEquals(expectedResponse, actualResponse); 9283 9284 List<String> actualRequests = mockService.getRequestPaths(); 9285 Assert.assertEquals(1, actualRequests.size()); 9286 9287 String apiClientHeaderKey = 9288 mockService 9289 .getRequestHeaders() 9290 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 9291 .iterator() 9292 .next(); 9293 Assert.assertTrue( 9294 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 9295 .matcher(apiClientHeaderKey) 9296 .matches()); 9297 } 9298 9299 @Test getEnhancedMeasurementSettingsExceptionTest2()9300 public void getEnhancedMeasurementSettingsExceptionTest2() throws Exception { 9301 ApiException exception = 9302 ApiExceptionFactory.createException( 9303 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 9304 mockService.addException(exception); 9305 9306 try { 9307 String name = 9308 "properties/propertie-5816/dataStreams/dataStream-5816/enhancedMeasurementSettings"; 9309 client.getEnhancedMeasurementSettings(name); 9310 Assert.fail("No exception raised"); 9311 } catch (InvalidArgumentException e) { 9312 // Expected exception. 9313 } 9314 } 9315 9316 @Test updateEnhancedMeasurementSettingsTest()9317 public void updateEnhancedMeasurementSettingsTest() throws Exception { 9318 EnhancedMeasurementSettings expectedResponse = 9319 EnhancedMeasurementSettings.newBuilder() 9320 .setName(EnhancedMeasurementSettingsName.of("[PROPERTY]", "[DATA_STREAM]").toString()) 9321 .setStreamEnabled(true) 9322 .setScrollsEnabled(true) 9323 .setOutboundClicksEnabled(true) 9324 .setSiteSearchEnabled(true) 9325 .setVideoEngagementEnabled(true) 9326 .setFileDownloadsEnabled(true) 9327 .setPageChangesEnabled(true) 9328 .setFormInteractionsEnabled(true) 9329 .setSearchQueryParameter("searchQueryParameter-2012788855") 9330 .setUriQueryParameter("uriQueryParameter1580843085") 9331 .build(); 9332 mockService.addResponse(expectedResponse); 9333 9334 EnhancedMeasurementSettings enhancedMeasurementSettings = 9335 EnhancedMeasurementSettings.newBuilder() 9336 .setName(EnhancedMeasurementSettingsName.of("[PROPERTY]", "[DATA_STREAM]").toString()) 9337 .setStreamEnabled(true) 9338 .setScrollsEnabled(true) 9339 .setOutboundClicksEnabled(true) 9340 .setSiteSearchEnabled(true) 9341 .setVideoEngagementEnabled(true) 9342 .setFileDownloadsEnabled(true) 9343 .setPageChangesEnabled(true) 9344 .setFormInteractionsEnabled(true) 9345 .setSearchQueryParameter("searchQueryParameter-2012788855") 9346 .setUriQueryParameter("uriQueryParameter1580843085") 9347 .build(); 9348 FieldMask updateMask = FieldMask.newBuilder().build(); 9349 9350 EnhancedMeasurementSettings actualResponse = 9351 client.updateEnhancedMeasurementSettings(enhancedMeasurementSettings, updateMask); 9352 Assert.assertEquals(expectedResponse, actualResponse); 9353 9354 List<String> actualRequests = mockService.getRequestPaths(); 9355 Assert.assertEquals(1, actualRequests.size()); 9356 9357 String apiClientHeaderKey = 9358 mockService 9359 .getRequestHeaders() 9360 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 9361 .iterator() 9362 .next(); 9363 Assert.assertTrue( 9364 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 9365 .matcher(apiClientHeaderKey) 9366 .matches()); 9367 } 9368 9369 @Test updateEnhancedMeasurementSettingsExceptionTest()9370 public void updateEnhancedMeasurementSettingsExceptionTest() throws Exception { 9371 ApiException exception = 9372 ApiExceptionFactory.createException( 9373 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 9374 mockService.addException(exception); 9375 9376 try { 9377 EnhancedMeasurementSettings enhancedMeasurementSettings = 9378 EnhancedMeasurementSettings.newBuilder() 9379 .setName(EnhancedMeasurementSettingsName.of("[PROPERTY]", "[DATA_STREAM]").toString()) 9380 .setStreamEnabled(true) 9381 .setScrollsEnabled(true) 9382 .setOutboundClicksEnabled(true) 9383 .setSiteSearchEnabled(true) 9384 .setVideoEngagementEnabled(true) 9385 .setFileDownloadsEnabled(true) 9386 .setPageChangesEnabled(true) 9387 .setFormInteractionsEnabled(true) 9388 .setSearchQueryParameter("searchQueryParameter-2012788855") 9389 .setUriQueryParameter("uriQueryParameter1580843085") 9390 .build(); 9391 FieldMask updateMask = FieldMask.newBuilder().build(); 9392 client.updateEnhancedMeasurementSettings(enhancedMeasurementSettings, updateMask); 9393 Assert.fail("No exception raised"); 9394 } catch (InvalidArgumentException e) { 9395 // Expected exception. 9396 } 9397 } 9398 9399 @Test createConnectedSiteTagTest()9400 public void createConnectedSiteTagTest() throws Exception { 9401 CreateConnectedSiteTagResponse expectedResponse = 9402 CreateConnectedSiteTagResponse.newBuilder().build(); 9403 mockService.addResponse(expectedResponse); 9404 9405 CreateConnectedSiteTagRequest request = 9406 CreateConnectedSiteTagRequest.newBuilder() 9407 .setProperty("property-993141291") 9408 .setConnectedSiteTag(ConnectedSiteTag.newBuilder().build()) 9409 .build(); 9410 9411 CreateConnectedSiteTagResponse actualResponse = client.createConnectedSiteTag(request); 9412 Assert.assertEquals(expectedResponse, actualResponse); 9413 9414 List<String> actualRequests = mockService.getRequestPaths(); 9415 Assert.assertEquals(1, actualRequests.size()); 9416 9417 String apiClientHeaderKey = 9418 mockService 9419 .getRequestHeaders() 9420 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 9421 .iterator() 9422 .next(); 9423 Assert.assertTrue( 9424 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 9425 .matcher(apiClientHeaderKey) 9426 .matches()); 9427 } 9428 9429 @Test createConnectedSiteTagExceptionTest()9430 public void createConnectedSiteTagExceptionTest() throws Exception { 9431 ApiException exception = 9432 ApiExceptionFactory.createException( 9433 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 9434 mockService.addException(exception); 9435 9436 try { 9437 CreateConnectedSiteTagRequest request = 9438 CreateConnectedSiteTagRequest.newBuilder() 9439 .setProperty("property-993141291") 9440 .setConnectedSiteTag(ConnectedSiteTag.newBuilder().build()) 9441 .build(); 9442 client.createConnectedSiteTag(request); 9443 Assert.fail("No exception raised"); 9444 } catch (InvalidArgumentException e) { 9445 // Expected exception. 9446 } 9447 } 9448 9449 @Test deleteConnectedSiteTagTest()9450 public void deleteConnectedSiteTagTest() throws Exception { 9451 Empty expectedResponse = Empty.newBuilder().build(); 9452 mockService.addResponse(expectedResponse); 9453 9454 DeleteConnectedSiteTagRequest request = 9455 DeleteConnectedSiteTagRequest.newBuilder() 9456 .setProperty("property-993141291") 9457 .setTagId("tagId110119509") 9458 .build(); 9459 9460 client.deleteConnectedSiteTag(request); 9461 9462 List<String> actualRequests = mockService.getRequestPaths(); 9463 Assert.assertEquals(1, actualRequests.size()); 9464 9465 String apiClientHeaderKey = 9466 mockService 9467 .getRequestHeaders() 9468 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 9469 .iterator() 9470 .next(); 9471 Assert.assertTrue( 9472 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 9473 .matcher(apiClientHeaderKey) 9474 .matches()); 9475 } 9476 9477 @Test deleteConnectedSiteTagExceptionTest()9478 public void deleteConnectedSiteTagExceptionTest() throws Exception { 9479 ApiException exception = 9480 ApiExceptionFactory.createException( 9481 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 9482 mockService.addException(exception); 9483 9484 try { 9485 DeleteConnectedSiteTagRequest request = 9486 DeleteConnectedSiteTagRequest.newBuilder() 9487 .setProperty("property-993141291") 9488 .setTagId("tagId110119509") 9489 .build(); 9490 client.deleteConnectedSiteTag(request); 9491 Assert.fail("No exception raised"); 9492 } catch (InvalidArgumentException e) { 9493 // Expected exception. 9494 } 9495 } 9496 9497 @Test listConnectedSiteTagsTest()9498 public void listConnectedSiteTagsTest() throws Exception { 9499 ListConnectedSiteTagsResponse expectedResponse = 9500 ListConnectedSiteTagsResponse.newBuilder() 9501 .addAllConnectedSiteTags(new ArrayList<ConnectedSiteTag>()) 9502 .build(); 9503 mockService.addResponse(expectedResponse); 9504 9505 ListConnectedSiteTagsRequest request = 9506 ListConnectedSiteTagsRequest.newBuilder().setProperty("property-993141291").build(); 9507 9508 ListConnectedSiteTagsResponse actualResponse = client.listConnectedSiteTags(request); 9509 Assert.assertEquals(expectedResponse, actualResponse); 9510 9511 List<String> actualRequests = mockService.getRequestPaths(); 9512 Assert.assertEquals(1, actualRequests.size()); 9513 9514 String apiClientHeaderKey = 9515 mockService 9516 .getRequestHeaders() 9517 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 9518 .iterator() 9519 .next(); 9520 Assert.assertTrue( 9521 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 9522 .matcher(apiClientHeaderKey) 9523 .matches()); 9524 } 9525 9526 @Test listConnectedSiteTagsExceptionTest()9527 public void listConnectedSiteTagsExceptionTest() throws Exception { 9528 ApiException exception = 9529 ApiExceptionFactory.createException( 9530 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 9531 mockService.addException(exception); 9532 9533 try { 9534 ListConnectedSiteTagsRequest request = 9535 ListConnectedSiteTagsRequest.newBuilder().setProperty("property-993141291").build(); 9536 client.listConnectedSiteTags(request); 9537 Assert.fail("No exception raised"); 9538 } catch (InvalidArgumentException e) { 9539 // Expected exception. 9540 } 9541 } 9542 9543 @Test fetchConnectedGa4PropertyTest()9544 public void fetchConnectedGa4PropertyTest() throws Exception { 9545 FetchConnectedGa4PropertyResponse expectedResponse = 9546 FetchConnectedGa4PropertyResponse.newBuilder() 9547 .setProperty(PropertyName.of("[PROPERTY]").toString()) 9548 .build(); 9549 mockService.addResponse(expectedResponse); 9550 9551 FetchConnectedGa4PropertyRequest request = 9552 FetchConnectedGa4PropertyRequest.newBuilder() 9553 .setProperty(PropertyName.of("[PROPERTY]").toString()) 9554 .build(); 9555 9556 FetchConnectedGa4PropertyResponse actualResponse = client.fetchConnectedGa4Property(request); 9557 Assert.assertEquals(expectedResponse, actualResponse); 9558 9559 List<String> actualRequests = mockService.getRequestPaths(); 9560 Assert.assertEquals(1, actualRequests.size()); 9561 9562 String apiClientHeaderKey = 9563 mockService 9564 .getRequestHeaders() 9565 .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) 9566 .iterator() 9567 .next(); 9568 Assert.assertTrue( 9569 GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() 9570 .matcher(apiClientHeaderKey) 9571 .matches()); 9572 } 9573 9574 @Test fetchConnectedGa4PropertyExceptionTest()9575 public void fetchConnectedGa4PropertyExceptionTest() throws Exception { 9576 ApiException exception = 9577 ApiExceptionFactory.createException( 9578 new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); 9579 mockService.addException(exception); 9580 9581 try { 9582 FetchConnectedGa4PropertyRequest request = 9583 FetchConnectedGa4PropertyRequest.newBuilder() 9584 .setProperty(PropertyName.of("[PROPERTY]").toString()) 9585 .build(); 9586 client.fetchConnectedGa4Property(request); 9587 Assert.fail("No exception raised"); 9588 } catch (InvalidArgumentException e) { 9589 // Expected exception. 9590 } 9591 } 9592 } 9593