• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.cloud.channel.v1;
18 
19 import static com.google.cloud.channel.v1.CloudChannelServiceClient.ListChannelPartnerLinksPagedResponse;
20 import static com.google.cloud.channel.v1.CloudChannelServiceClient.ListChannelPartnerRepricingConfigsPagedResponse;
21 import static com.google.cloud.channel.v1.CloudChannelServiceClient.ListCustomerRepricingConfigsPagedResponse;
22 import static com.google.cloud.channel.v1.CloudChannelServiceClient.ListCustomersPagedResponse;
23 import static com.google.cloud.channel.v1.CloudChannelServiceClient.ListEntitlementChangesPagedResponse;
24 import static com.google.cloud.channel.v1.CloudChannelServiceClient.ListEntitlementsPagedResponse;
25 import static com.google.cloud.channel.v1.CloudChannelServiceClient.ListOffersPagedResponse;
26 import static com.google.cloud.channel.v1.CloudChannelServiceClient.ListProductsPagedResponse;
27 import static com.google.cloud.channel.v1.CloudChannelServiceClient.ListPurchasableOffersPagedResponse;
28 import static com.google.cloud.channel.v1.CloudChannelServiceClient.ListPurchasableSkusPagedResponse;
29 import static com.google.cloud.channel.v1.CloudChannelServiceClient.ListSkusPagedResponse;
30 import static com.google.cloud.channel.v1.CloudChannelServiceClient.ListSubscribersPagedResponse;
31 import static com.google.cloud.channel.v1.CloudChannelServiceClient.ListTransferableOffersPagedResponse;
32 import static com.google.cloud.channel.v1.CloudChannelServiceClient.ListTransferableSkusPagedResponse;
33 
34 import com.google.api.gax.core.NoCredentialsProvider;
35 import com.google.api.gax.grpc.GaxGrpcProperties;
36 import com.google.api.gax.grpc.testing.LocalChannelProvider;
37 import com.google.api.gax.grpc.testing.MockGrpcService;
38 import com.google.api.gax.grpc.testing.MockServiceHelper;
39 import com.google.api.gax.rpc.ApiClientHeaderProvider;
40 import com.google.api.gax.rpc.InvalidArgumentException;
41 import com.google.api.gax.rpc.StatusCode;
42 import com.google.common.collect.Lists;
43 import com.google.longrunning.Operation;
44 import com.google.protobuf.AbstractMessage;
45 import com.google.protobuf.Any;
46 import com.google.protobuf.Empty;
47 import com.google.protobuf.FieldMask;
48 import com.google.protobuf.Timestamp;
49 import com.google.type.PostalAddress;
50 import io.grpc.StatusRuntimeException;
51 import java.io.IOException;
52 import java.util.ArrayList;
53 import java.util.Arrays;
54 import java.util.List;
55 import java.util.UUID;
56 import java.util.concurrent.ExecutionException;
57 import javax.annotation.Generated;
58 import org.junit.After;
59 import org.junit.AfterClass;
60 import org.junit.Assert;
61 import org.junit.Before;
62 import org.junit.BeforeClass;
63 import org.junit.Test;
64 
65 @Generated("by gapic-generator-java")
66 public class CloudChannelServiceClientTest {
67   private static MockCloudChannelService mockCloudChannelService;
68   private static MockServiceHelper mockServiceHelper;
69   private LocalChannelProvider channelProvider;
70   private CloudChannelServiceClient client;
71 
72   @BeforeClass
startStaticServer()73   public static void startStaticServer() {
74     mockCloudChannelService = new MockCloudChannelService();
75     mockServiceHelper =
76         new MockServiceHelper(
77             UUID.randomUUID().toString(), Arrays.<MockGrpcService>asList(mockCloudChannelService));
78     mockServiceHelper.start();
79   }
80 
81   @AfterClass
stopServer()82   public static void stopServer() {
83     mockServiceHelper.stop();
84   }
85 
86   @Before
setUp()87   public void setUp() throws IOException {
88     mockServiceHelper.reset();
89     channelProvider = mockServiceHelper.createChannelProvider();
90     CloudChannelServiceSettings settings =
91         CloudChannelServiceSettings.newBuilder()
92             .setTransportChannelProvider(channelProvider)
93             .setCredentialsProvider(NoCredentialsProvider.create())
94             .build();
95     client = CloudChannelServiceClient.create(settings);
96   }
97 
98   @After
tearDown()99   public void tearDown() throws Exception {
100     client.close();
101   }
102 
103   @Test
listCustomersTest()104   public void listCustomersTest() throws Exception {
105     Customer responsesElement = Customer.newBuilder().build();
106     ListCustomersResponse expectedResponse =
107         ListCustomersResponse.newBuilder()
108             .setNextPageToken("")
109             .addAllCustomers(Arrays.asList(responsesElement))
110             .build();
111     mockCloudChannelService.addResponse(expectedResponse);
112 
113     ListCustomersRequest request =
114         ListCustomersRequest.newBuilder()
115             .setParent("parent-995424086")
116             .setPageSize(883849137)
117             .setPageToken("pageToken873572522")
118             .setFilter("filter-1274492040")
119             .build();
120 
121     ListCustomersPagedResponse pagedListResponse = client.listCustomers(request);
122 
123     List<Customer> resources = Lists.newArrayList(pagedListResponse.iterateAll());
124 
125     Assert.assertEquals(1, resources.size());
126     Assert.assertEquals(expectedResponse.getCustomersList().get(0), resources.get(0));
127 
128     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
129     Assert.assertEquals(1, actualRequests.size());
130     ListCustomersRequest actualRequest = ((ListCustomersRequest) actualRequests.get(0));
131 
132     Assert.assertEquals(request.getParent(), actualRequest.getParent());
133     Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
134     Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
135     Assert.assertEquals(request.getFilter(), actualRequest.getFilter());
136     Assert.assertTrue(
137         channelProvider.isHeaderSent(
138             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
139             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
140   }
141 
142   @Test
listCustomersExceptionTest()143   public void listCustomersExceptionTest() throws Exception {
144     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
145     mockCloudChannelService.addException(exception);
146 
147     try {
148       ListCustomersRequest request =
149           ListCustomersRequest.newBuilder()
150               .setParent("parent-995424086")
151               .setPageSize(883849137)
152               .setPageToken("pageToken873572522")
153               .setFilter("filter-1274492040")
154               .build();
155       client.listCustomers(request);
156       Assert.fail("No exception raised");
157     } catch (InvalidArgumentException e) {
158       // Expected exception.
159     }
160   }
161 
162   @Test
getCustomerTest()163   public void getCustomerTest() throws Exception {
164     Customer expectedResponse =
165         Customer.newBuilder()
166             .setName(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
167             .setOrgDisplayName("orgDisplayName127031529")
168             .setOrgPostalAddress(PostalAddress.newBuilder().build())
169             .setPrimaryContactInfo(ContactInfo.newBuilder().build())
170             .setAlternateEmail("alternateEmail-232564926")
171             .setDomain("domain-1326197564")
172             .setCreateTime(Timestamp.newBuilder().build())
173             .setUpdateTime(Timestamp.newBuilder().build())
174             .setCloudIdentityId("cloudIdentityId941784718")
175             .setLanguageCode("languageCode-2092349083")
176             .setCloudIdentityInfo(CloudIdentityInfo.newBuilder().build())
177             .setChannelPartnerId("channelPartnerId-170366400")
178             .setCorrelationId("correlationId-764983747")
179             .build();
180     mockCloudChannelService.addResponse(expectedResponse);
181 
182     CustomerName name = CustomerName.of("[ACCOUNT]", "[CUSTOMER]");
183 
184     Customer actualResponse = client.getCustomer(name);
185     Assert.assertEquals(expectedResponse, actualResponse);
186 
187     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
188     Assert.assertEquals(1, actualRequests.size());
189     GetCustomerRequest actualRequest = ((GetCustomerRequest) actualRequests.get(0));
190 
191     Assert.assertEquals(name.toString(), actualRequest.getName());
192     Assert.assertTrue(
193         channelProvider.isHeaderSent(
194             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
195             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
196   }
197 
198   @Test
getCustomerExceptionTest()199   public void getCustomerExceptionTest() throws Exception {
200     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
201     mockCloudChannelService.addException(exception);
202 
203     try {
204       CustomerName name = CustomerName.of("[ACCOUNT]", "[CUSTOMER]");
205       client.getCustomer(name);
206       Assert.fail("No exception raised");
207     } catch (InvalidArgumentException e) {
208       // Expected exception.
209     }
210   }
211 
212   @Test
getCustomerTest2()213   public void getCustomerTest2() throws Exception {
214     Customer expectedResponse =
215         Customer.newBuilder()
216             .setName(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
217             .setOrgDisplayName("orgDisplayName127031529")
218             .setOrgPostalAddress(PostalAddress.newBuilder().build())
219             .setPrimaryContactInfo(ContactInfo.newBuilder().build())
220             .setAlternateEmail("alternateEmail-232564926")
221             .setDomain("domain-1326197564")
222             .setCreateTime(Timestamp.newBuilder().build())
223             .setUpdateTime(Timestamp.newBuilder().build())
224             .setCloudIdentityId("cloudIdentityId941784718")
225             .setLanguageCode("languageCode-2092349083")
226             .setCloudIdentityInfo(CloudIdentityInfo.newBuilder().build())
227             .setChannelPartnerId("channelPartnerId-170366400")
228             .setCorrelationId("correlationId-764983747")
229             .build();
230     mockCloudChannelService.addResponse(expectedResponse);
231 
232     String name = "name3373707";
233 
234     Customer actualResponse = client.getCustomer(name);
235     Assert.assertEquals(expectedResponse, actualResponse);
236 
237     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
238     Assert.assertEquals(1, actualRequests.size());
239     GetCustomerRequest actualRequest = ((GetCustomerRequest) actualRequests.get(0));
240 
241     Assert.assertEquals(name, actualRequest.getName());
242     Assert.assertTrue(
243         channelProvider.isHeaderSent(
244             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
245             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
246   }
247 
248   @Test
getCustomerExceptionTest2()249   public void getCustomerExceptionTest2() throws Exception {
250     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
251     mockCloudChannelService.addException(exception);
252 
253     try {
254       String name = "name3373707";
255       client.getCustomer(name);
256       Assert.fail("No exception raised");
257     } catch (InvalidArgumentException e) {
258       // Expected exception.
259     }
260   }
261 
262   @Test
checkCloudIdentityAccountsExistTest()263   public void checkCloudIdentityAccountsExistTest() throws Exception {
264     CheckCloudIdentityAccountsExistResponse expectedResponse =
265         CheckCloudIdentityAccountsExistResponse.newBuilder()
266             .addAllCloudIdentityAccounts(new ArrayList<CloudIdentityCustomerAccount>())
267             .build();
268     mockCloudChannelService.addResponse(expectedResponse);
269 
270     CheckCloudIdentityAccountsExistRequest request =
271         CheckCloudIdentityAccountsExistRequest.newBuilder()
272             .setParent("parent-995424086")
273             .setDomain("domain-1326197564")
274             .build();
275 
276     CheckCloudIdentityAccountsExistResponse actualResponse =
277         client.checkCloudIdentityAccountsExist(request);
278     Assert.assertEquals(expectedResponse, actualResponse);
279 
280     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
281     Assert.assertEquals(1, actualRequests.size());
282     CheckCloudIdentityAccountsExistRequest actualRequest =
283         ((CheckCloudIdentityAccountsExistRequest) actualRequests.get(0));
284 
285     Assert.assertEquals(request.getParent(), actualRequest.getParent());
286     Assert.assertEquals(request.getDomain(), actualRequest.getDomain());
287     Assert.assertTrue(
288         channelProvider.isHeaderSent(
289             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
290             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
291   }
292 
293   @Test
checkCloudIdentityAccountsExistExceptionTest()294   public void checkCloudIdentityAccountsExistExceptionTest() throws Exception {
295     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
296     mockCloudChannelService.addException(exception);
297 
298     try {
299       CheckCloudIdentityAccountsExistRequest request =
300           CheckCloudIdentityAccountsExistRequest.newBuilder()
301               .setParent("parent-995424086")
302               .setDomain("domain-1326197564")
303               .build();
304       client.checkCloudIdentityAccountsExist(request);
305       Assert.fail("No exception raised");
306     } catch (InvalidArgumentException e) {
307       // Expected exception.
308     }
309   }
310 
311   @Test
createCustomerTest()312   public void createCustomerTest() throws Exception {
313     Customer expectedResponse =
314         Customer.newBuilder()
315             .setName(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
316             .setOrgDisplayName("orgDisplayName127031529")
317             .setOrgPostalAddress(PostalAddress.newBuilder().build())
318             .setPrimaryContactInfo(ContactInfo.newBuilder().build())
319             .setAlternateEmail("alternateEmail-232564926")
320             .setDomain("domain-1326197564")
321             .setCreateTime(Timestamp.newBuilder().build())
322             .setUpdateTime(Timestamp.newBuilder().build())
323             .setCloudIdentityId("cloudIdentityId941784718")
324             .setLanguageCode("languageCode-2092349083")
325             .setCloudIdentityInfo(CloudIdentityInfo.newBuilder().build())
326             .setChannelPartnerId("channelPartnerId-170366400")
327             .setCorrelationId("correlationId-764983747")
328             .build();
329     mockCloudChannelService.addResponse(expectedResponse);
330 
331     CreateCustomerRequest request =
332         CreateCustomerRequest.newBuilder()
333             .setParent("parent-995424086")
334             .setCustomer(Customer.newBuilder().build())
335             .build();
336 
337     Customer actualResponse = client.createCustomer(request);
338     Assert.assertEquals(expectedResponse, actualResponse);
339 
340     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
341     Assert.assertEquals(1, actualRequests.size());
342     CreateCustomerRequest actualRequest = ((CreateCustomerRequest) actualRequests.get(0));
343 
344     Assert.assertEquals(request.getParent(), actualRequest.getParent());
345     Assert.assertEquals(request.getCustomer(), actualRequest.getCustomer());
346     Assert.assertTrue(
347         channelProvider.isHeaderSent(
348             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
349             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
350   }
351 
352   @Test
createCustomerExceptionTest()353   public void createCustomerExceptionTest() throws Exception {
354     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
355     mockCloudChannelService.addException(exception);
356 
357     try {
358       CreateCustomerRequest request =
359           CreateCustomerRequest.newBuilder()
360               .setParent("parent-995424086")
361               .setCustomer(Customer.newBuilder().build())
362               .build();
363       client.createCustomer(request);
364       Assert.fail("No exception raised");
365     } catch (InvalidArgumentException e) {
366       // Expected exception.
367     }
368   }
369 
370   @Test
updateCustomerTest()371   public void updateCustomerTest() throws Exception {
372     Customer expectedResponse =
373         Customer.newBuilder()
374             .setName(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
375             .setOrgDisplayName("orgDisplayName127031529")
376             .setOrgPostalAddress(PostalAddress.newBuilder().build())
377             .setPrimaryContactInfo(ContactInfo.newBuilder().build())
378             .setAlternateEmail("alternateEmail-232564926")
379             .setDomain("domain-1326197564")
380             .setCreateTime(Timestamp.newBuilder().build())
381             .setUpdateTime(Timestamp.newBuilder().build())
382             .setCloudIdentityId("cloudIdentityId941784718")
383             .setLanguageCode("languageCode-2092349083")
384             .setCloudIdentityInfo(CloudIdentityInfo.newBuilder().build())
385             .setChannelPartnerId("channelPartnerId-170366400")
386             .setCorrelationId("correlationId-764983747")
387             .build();
388     mockCloudChannelService.addResponse(expectedResponse);
389 
390     UpdateCustomerRequest request =
391         UpdateCustomerRequest.newBuilder()
392             .setCustomer(Customer.newBuilder().build())
393             .setUpdateMask(FieldMask.newBuilder().build())
394             .build();
395 
396     Customer actualResponse = client.updateCustomer(request);
397     Assert.assertEquals(expectedResponse, actualResponse);
398 
399     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
400     Assert.assertEquals(1, actualRequests.size());
401     UpdateCustomerRequest actualRequest = ((UpdateCustomerRequest) actualRequests.get(0));
402 
403     Assert.assertEquals(request.getCustomer(), actualRequest.getCustomer());
404     Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask());
405     Assert.assertTrue(
406         channelProvider.isHeaderSent(
407             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
408             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
409   }
410 
411   @Test
updateCustomerExceptionTest()412   public void updateCustomerExceptionTest() throws Exception {
413     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
414     mockCloudChannelService.addException(exception);
415 
416     try {
417       UpdateCustomerRequest request =
418           UpdateCustomerRequest.newBuilder()
419               .setCustomer(Customer.newBuilder().build())
420               .setUpdateMask(FieldMask.newBuilder().build())
421               .build();
422       client.updateCustomer(request);
423       Assert.fail("No exception raised");
424     } catch (InvalidArgumentException e) {
425       // Expected exception.
426     }
427   }
428 
429   @Test
deleteCustomerTest()430   public void deleteCustomerTest() throws Exception {
431     Empty expectedResponse = Empty.newBuilder().build();
432     mockCloudChannelService.addResponse(expectedResponse);
433 
434     CustomerName name = CustomerName.of("[ACCOUNT]", "[CUSTOMER]");
435 
436     client.deleteCustomer(name);
437 
438     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
439     Assert.assertEquals(1, actualRequests.size());
440     DeleteCustomerRequest actualRequest = ((DeleteCustomerRequest) actualRequests.get(0));
441 
442     Assert.assertEquals(name.toString(), actualRequest.getName());
443     Assert.assertTrue(
444         channelProvider.isHeaderSent(
445             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
446             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
447   }
448 
449   @Test
deleteCustomerExceptionTest()450   public void deleteCustomerExceptionTest() throws Exception {
451     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
452     mockCloudChannelService.addException(exception);
453 
454     try {
455       CustomerName name = CustomerName.of("[ACCOUNT]", "[CUSTOMER]");
456       client.deleteCustomer(name);
457       Assert.fail("No exception raised");
458     } catch (InvalidArgumentException e) {
459       // Expected exception.
460     }
461   }
462 
463   @Test
deleteCustomerTest2()464   public void deleteCustomerTest2() throws Exception {
465     Empty expectedResponse = Empty.newBuilder().build();
466     mockCloudChannelService.addResponse(expectedResponse);
467 
468     String name = "name3373707";
469 
470     client.deleteCustomer(name);
471 
472     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
473     Assert.assertEquals(1, actualRequests.size());
474     DeleteCustomerRequest actualRequest = ((DeleteCustomerRequest) actualRequests.get(0));
475 
476     Assert.assertEquals(name, actualRequest.getName());
477     Assert.assertTrue(
478         channelProvider.isHeaderSent(
479             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
480             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
481   }
482 
483   @Test
deleteCustomerExceptionTest2()484   public void deleteCustomerExceptionTest2() throws Exception {
485     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
486     mockCloudChannelService.addException(exception);
487 
488     try {
489       String name = "name3373707";
490       client.deleteCustomer(name);
491       Assert.fail("No exception raised");
492     } catch (InvalidArgumentException e) {
493       // Expected exception.
494     }
495   }
496 
497   @Test
importCustomerTest()498   public void importCustomerTest() throws Exception {
499     Customer expectedResponse =
500         Customer.newBuilder()
501             .setName(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
502             .setOrgDisplayName("orgDisplayName127031529")
503             .setOrgPostalAddress(PostalAddress.newBuilder().build())
504             .setPrimaryContactInfo(ContactInfo.newBuilder().build())
505             .setAlternateEmail("alternateEmail-232564926")
506             .setDomain("domain-1326197564")
507             .setCreateTime(Timestamp.newBuilder().build())
508             .setUpdateTime(Timestamp.newBuilder().build())
509             .setCloudIdentityId("cloudIdentityId941784718")
510             .setLanguageCode("languageCode-2092349083")
511             .setCloudIdentityInfo(CloudIdentityInfo.newBuilder().build())
512             .setChannelPartnerId("channelPartnerId-170366400")
513             .setCorrelationId("correlationId-764983747")
514             .build();
515     mockCloudChannelService.addResponse(expectedResponse);
516 
517     ImportCustomerRequest request =
518         ImportCustomerRequest.newBuilder()
519             .setParent("parent-995424086")
520             .setAuthToken("authToken1450587441")
521             .setOverwriteIfExists(true)
522             .setChannelPartnerId("channelPartnerId-170366400")
523             .setCustomer(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
524             .build();
525 
526     Customer actualResponse = client.importCustomer(request);
527     Assert.assertEquals(expectedResponse, actualResponse);
528 
529     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
530     Assert.assertEquals(1, actualRequests.size());
531     ImportCustomerRequest actualRequest = ((ImportCustomerRequest) actualRequests.get(0));
532 
533     Assert.assertEquals(request.getDomain(), actualRequest.getDomain());
534     Assert.assertEquals(request.getCloudIdentityId(), actualRequest.getCloudIdentityId());
535     Assert.assertEquals(request.getParent(), actualRequest.getParent());
536     Assert.assertEquals(request.getAuthToken(), actualRequest.getAuthToken());
537     Assert.assertEquals(request.getOverwriteIfExists(), actualRequest.getOverwriteIfExists());
538     Assert.assertEquals(request.getChannelPartnerId(), actualRequest.getChannelPartnerId());
539     Assert.assertEquals(request.getCustomer(), actualRequest.getCustomer());
540     Assert.assertTrue(
541         channelProvider.isHeaderSent(
542             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
543             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
544   }
545 
546   @Test
importCustomerExceptionTest()547   public void importCustomerExceptionTest() throws Exception {
548     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
549     mockCloudChannelService.addException(exception);
550 
551     try {
552       ImportCustomerRequest request =
553           ImportCustomerRequest.newBuilder()
554               .setParent("parent-995424086")
555               .setAuthToken("authToken1450587441")
556               .setOverwriteIfExists(true)
557               .setChannelPartnerId("channelPartnerId-170366400")
558               .setCustomer(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
559               .build();
560       client.importCustomer(request);
561       Assert.fail("No exception raised");
562     } catch (InvalidArgumentException e) {
563       // Expected exception.
564     }
565   }
566 
567   @Test
provisionCloudIdentityTest()568   public void provisionCloudIdentityTest() throws Exception {
569     Customer expectedResponse =
570         Customer.newBuilder()
571             .setName(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
572             .setOrgDisplayName("orgDisplayName127031529")
573             .setOrgPostalAddress(PostalAddress.newBuilder().build())
574             .setPrimaryContactInfo(ContactInfo.newBuilder().build())
575             .setAlternateEmail("alternateEmail-232564926")
576             .setDomain("domain-1326197564")
577             .setCreateTime(Timestamp.newBuilder().build())
578             .setUpdateTime(Timestamp.newBuilder().build())
579             .setCloudIdentityId("cloudIdentityId941784718")
580             .setLanguageCode("languageCode-2092349083")
581             .setCloudIdentityInfo(CloudIdentityInfo.newBuilder().build())
582             .setChannelPartnerId("channelPartnerId-170366400")
583             .setCorrelationId("correlationId-764983747")
584             .build();
585     Operation resultOperation =
586         Operation.newBuilder()
587             .setName("provisionCloudIdentityTest")
588             .setDone(true)
589             .setResponse(Any.pack(expectedResponse))
590             .build();
591     mockCloudChannelService.addResponse(resultOperation);
592 
593     ProvisionCloudIdentityRequest request =
594         ProvisionCloudIdentityRequest.newBuilder()
595             .setCustomer(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
596             .setCloudIdentityInfo(CloudIdentityInfo.newBuilder().build())
597             .setUser(AdminUser.newBuilder().build())
598             .setValidateOnly(true)
599             .build();
600 
601     Customer actualResponse = client.provisionCloudIdentityAsync(request).get();
602     Assert.assertEquals(expectedResponse, actualResponse);
603 
604     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
605     Assert.assertEquals(1, actualRequests.size());
606     ProvisionCloudIdentityRequest actualRequest =
607         ((ProvisionCloudIdentityRequest) actualRequests.get(0));
608 
609     Assert.assertEquals(request.getCustomer(), actualRequest.getCustomer());
610     Assert.assertEquals(request.getCloudIdentityInfo(), actualRequest.getCloudIdentityInfo());
611     Assert.assertEquals(request.getUser(), actualRequest.getUser());
612     Assert.assertEquals(request.getValidateOnly(), actualRequest.getValidateOnly());
613     Assert.assertTrue(
614         channelProvider.isHeaderSent(
615             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
616             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
617   }
618 
619   @Test
provisionCloudIdentityExceptionTest()620   public void provisionCloudIdentityExceptionTest() throws Exception {
621     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
622     mockCloudChannelService.addException(exception);
623 
624     try {
625       ProvisionCloudIdentityRequest request =
626           ProvisionCloudIdentityRequest.newBuilder()
627               .setCustomer(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
628               .setCloudIdentityInfo(CloudIdentityInfo.newBuilder().build())
629               .setUser(AdminUser.newBuilder().build())
630               .setValidateOnly(true)
631               .build();
632       client.provisionCloudIdentityAsync(request).get();
633       Assert.fail("No exception raised");
634     } catch (ExecutionException e) {
635       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
636       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
637       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
638     }
639   }
640 
641   @Test
listEntitlementsTest()642   public void listEntitlementsTest() throws Exception {
643     Entitlement responsesElement = Entitlement.newBuilder().build();
644     ListEntitlementsResponse expectedResponse =
645         ListEntitlementsResponse.newBuilder()
646             .setNextPageToken("")
647             .addAllEntitlements(Arrays.asList(responsesElement))
648             .build();
649     mockCloudChannelService.addResponse(expectedResponse);
650 
651     ListEntitlementsRequest request =
652         ListEntitlementsRequest.newBuilder()
653             .setParent(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
654             .setPageSize(883849137)
655             .setPageToken("pageToken873572522")
656             .build();
657 
658     ListEntitlementsPagedResponse pagedListResponse = client.listEntitlements(request);
659 
660     List<Entitlement> resources = Lists.newArrayList(pagedListResponse.iterateAll());
661 
662     Assert.assertEquals(1, resources.size());
663     Assert.assertEquals(expectedResponse.getEntitlementsList().get(0), resources.get(0));
664 
665     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
666     Assert.assertEquals(1, actualRequests.size());
667     ListEntitlementsRequest actualRequest = ((ListEntitlementsRequest) actualRequests.get(0));
668 
669     Assert.assertEquals(request.getParent(), actualRequest.getParent());
670     Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
671     Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
672     Assert.assertTrue(
673         channelProvider.isHeaderSent(
674             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
675             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
676   }
677 
678   @Test
listEntitlementsExceptionTest()679   public void listEntitlementsExceptionTest() throws Exception {
680     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
681     mockCloudChannelService.addException(exception);
682 
683     try {
684       ListEntitlementsRequest request =
685           ListEntitlementsRequest.newBuilder()
686               .setParent(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
687               .setPageSize(883849137)
688               .setPageToken("pageToken873572522")
689               .build();
690       client.listEntitlements(request);
691       Assert.fail("No exception raised");
692     } catch (InvalidArgumentException e) {
693       // Expected exception.
694     }
695   }
696 
697   @Test
listTransferableSkusTest()698   public void listTransferableSkusTest() throws Exception {
699     TransferableSku responsesElement = TransferableSku.newBuilder().build();
700     ListTransferableSkusResponse expectedResponse =
701         ListTransferableSkusResponse.newBuilder()
702             .setNextPageToken("")
703             .addAllTransferableSkus(Arrays.asList(responsesElement))
704             .build();
705     mockCloudChannelService.addResponse(expectedResponse);
706 
707     ListTransferableSkusRequest request =
708         ListTransferableSkusRequest.newBuilder()
709             .setParent("parent-995424086")
710             .setPageSize(883849137)
711             .setPageToken("pageToken873572522")
712             .setAuthToken("authToken1450587441")
713             .setLanguageCode("languageCode-2092349083")
714             .build();
715 
716     ListTransferableSkusPagedResponse pagedListResponse = client.listTransferableSkus(request);
717 
718     List<TransferableSku> resources = Lists.newArrayList(pagedListResponse.iterateAll());
719 
720     Assert.assertEquals(1, resources.size());
721     Assert.assertEquals(expectedResponse.getTransferableSkusList().get(0), resources.get(0));
722 
723     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
724     Assert.assertEquals(1, actualRequests.size());
725     ListTransferableSkusRequest actualRequest =
726         ((ListTransferableSkusRequest) actualRequests.get(0));
727 
728     Assert.assertEquals(request.getCloudIdentityId(), actualRequest.getCloudIdentityId());
729     Assert.assertEquals(request.getCustomerName(), actualRequest.getCustomerName());
730     Assert.assertEquals(request.getParent(), actualRequest.getParent());
731     Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
732     Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
733     Assert.assertEquals(request.getAuthToken(), actualRequest.getAuthToken());
734     Assert.assertEquals(request.getLanguageCode(), actualRequest.getLanguageCode());
735     Assert.assertTrue(
736         channelProvider.isHeaderSent(
737             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
738             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
739   }
740 
741   @Test
listTransferableSkusExceptionTest()742   public void listTransferableSkusExceptionTest() throws Exception {
743     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
744     mockCloudChannelService.addException(exception);
745 
746     try {
747       ListTransferableSkusRequest request =
748           ListTransferableSkusRequest.newBuilder()
749               .setParent("parent-995424086")
750               .setPageSize(883849137)
751               .setPageToken("pageToken873572522")
752               .setAuthToken("authToken1450587441")
753               .setLanguageCode("languageCode-2092349083")
754               .build();
755       client.listTransferableSkus(request);
756       Assert.fail("No exception raised");
757     } catch (InvalidArgumentException e) {
758       // Expected exception.
759     }
760   }
761 
762   @Test
listTransferableOffersTest()763   public void listTransferableOffersTest() throws Exception {
764     TransferableOffer responsesElement = TransferableOffer.newBuilder().build();
765     ListTransferableOffersResponse expectedResponse =
766         ListTransferableOffersResponse.newBuilder()
767             .setNextPageToken("")
768             .addAllTransferableOffers(Arrays.asList(responsesElement))
769             .build();
770     mockCloudChannelService.addResponse(expectedResponse);
771 
772     ListTransferableOffersRequest request =
773         ListTransferableOffersRequest.newBuilder()
774             .setParent("parent-995424086")
775             .setPageSize(883849137)
776             .setPageToken("pageToken873572522")
777             .setSku("sku113949")
778             .setLanguageCode("languageCode-2092349083")
779             .build();
780 
781     ListTransferableOffersPagedResponse pagedListResponse = client.listTransferableOffers(request);
782 
783     List<TransferableOffer> resources = Lists.newArrayList(pagedListResponse.iterateAll());
784 
785     Assert.assertEquals(1, resources.size());
786     Assert.assertEquals(expectedResponse.getTransferableOffersList().get(0), resources.get(0));
787 
788     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
789     Assert.assertEquals(1, actualRequests.size());
790     ListTransferableOffersRequest actualRequest =
791         ((ListTransferableOffersRequest) actualRequests.get(0));
792 
793     Assert.assertEquals(request.getCloudIdentityId(), actualRequest.getCloudIdentityId());
794     Assert.assertEquals(request.getCustomerName(), actualRequest.getCustomerName());
795     Assert.assertEquals(request.getParent(), actualRequest.getParent());
796     Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
797     Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
798     Assert.assertEquals(request.getSku(), actualRequest.getSku());
799     Assert.assertEquals(request.getLanguageCode(), actualRequest.getLanguageCode());
800     Assert.assertTrue(
801         channelProvider.isHeaderSent(
802             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
803             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
804   }
805 
806   @Test
listTransferableOffersExceptionTest()807   public void listTransferableOffersExceptionTest() throws Exception {
808     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
809     mockCloudChannelService.addException(exception);
810 
811     try {
812       ListTransferableOffersRequest request =
813           ListTransferableOffersRequest.newBuilder()
814               .setParent("parent-995424086")
815               .setPageSize(883849137)
816               .setPageToken("pageToken873572522")
817               .setSku("sku113949")
818               .setLanguageCode("languageCode-2092349083")
819               .build();
820       client.listTransferableOffers(request);
821       Assert.fail("No exception raised");
822     } catch (InvalidArgumentException e) {
823       // Expected exception.
824     }
825   }
826 
827   @Test
getEntitlementTest()828   public void getEntitlementTest() throws Exception {
829     Entitlement expectedResponse =
830         Entitlement.newBuilder()
831             .setName(EntitlementName.of("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]").toString())
832             .setCreateTime(Timestamp.newBuilder().build())
833             .setUpdateTime(Timestamp.newBuilder().build())
834             .setOffer(OfferName.of("[ACCOUNT]", "[OFFER]").toString())
835             .setCommitmentSettings(CommitmentSettings.newBuilder().build())
836             .setProvisionedService(ProvisionedService.newBuilder().build())
837             .addAllSuspensionReasons(new ArrayList<Entitlement.SuspensionReason>())
838             .setPurchaseOrderId("purchaseOrderId2029917384")
839             .setTrialSettings(TrialSettings.newBuilder().build())
840             .setAssociationInfo(AssociationInfo.newBuilder().build())
841             .addAllParameters(new ArrayList<Parameter>())
842             .setBillingAccount("billingAccount708726578")
843             .build();
844     mockCloudChannelService.addResponse(expectedResponse);
845 
846     GetEntitlementRequest request =
847         GetEntitlementRequest.newBuilder()
848             .setName(EntitlementName.of("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]").toString())
849             .build();
850 
851     Entitlement actualResponse = client.getEntitlement(request);
852     Assert.assertEquals(expectedResponse, actualResponse);
853 
854     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
855     Assert.assertEquals(1, actualRequests.size());
856     GetEntitlementRequest actualRequest = ((GetEntitlementRequest) actualRequests.get(0));
857 
858     Assert.assertEquals(request.getName(), actualRequest.getName());
859     Assert.assertTrue(
860         channelProvider.isHeaderSent(
861             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
862             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
863   }
864 
865   @Test
getEntitlementExceptionTest()866   public void getEntitlementExceptionTest() throws Exception {
867     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
868     mockCloudChannelService.addException(exception);
869 
870     try {
871       GetEntitlementRequest request =
872           GetEntitlementRequest.newBuilder()
873               .setName(EntitlementName.of("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]").toString())
874               .build();
875       client.getEntitlement(request);
876       Assert.fail("No exception raised");
877     } catch (InvalidArgumentException e) {
878       // Expected exception.
879     }
880   }
881 
882   @Test
createEntitlementTest()883   public void createEntitlementTest() throws Exception {
884     Entitlement expectedResponse =
885         Entitlement.newBuilder()
886             .setName(EntitlementName.of("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]").toString())
887             .setCreateTime(Timestamp.newBuilder().build())
888             .setUpdateTime(Timestamp.newBuilder().build())
889             .setOffer(OfferName.of("[ACCOUNT]", "[OFFER]").toString())
890             .setCommitmentSettings(CommitmentSettings.newBuilder().build())
891             .setProvisionedService(ProvisionedService.newBuilder().build())
892             .addAllSuspensionReasons(new ArrayList<Entitlement.SuspensionReason>())
893             .setPurchaseOrderId("purchaseOrderId2029917384")
894             .setTrialSettings(TrialSettings.newBuilder().build())
895             .setAssociationInfo(AssociationInfo.newBuilder().build())
896             .addAllParameters(new ArrayList<Parameter>())
897             .setBillingAccount("billingAccount708726578")
898             .build();
899     Operation resultOperation =
900         Operation.newBuilder()
901             .setName("createEntitlementTest")
902             .setDone(true)
903             .setResponse(Any.pack(expectedResponse))
904             .build();
905     mockCloudChannelService.addResponse(resultOperation);
906 
907     CreateEntitlementRequest request =
908         CreateEntitlementRequest.newBuilder()
909             .setParent(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
910             .setEntitlement(Entitlement.newBuilder().build())
911             .setRequestId("requestId693933066")
912             .build();
913 
914     Entitlement actualResponse = client.createEntitlementAsync(request).get();
915     Assert.assertEquals(expectedResponse, actualResponse);
916 
917     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
918     Assert.assertEquals(1, actualRequests.size());
919     CreateEntitlementRequest actualRequest = ((CreateEntitlementRequest) actualRequests.get(0));
920 
921     Assert.assertEquals(request.getParent(), actualRequest.getParent());
922     Assert.assertEquals(request.getEntitlement(), actualRequest.getEntitlement());
923     Assert.assertEquals(request.getRequestId(), actualRequest.getRequestId());
924     Assert.assertTrue(
925         channelProvider.isHeaderSent(
926             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
927             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
928   }
929 
930   @Test
createEntitlementExceptionTest()931   public void createEntitlementExceptionTest() throws Exception {
932     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
933     mockCloudChannelService.addException(exception);
934 
935     try {
936       CreateEntitlementRequest request =
937           CreateEntitlementRequest.newBuilder()
938               .setParent(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
939               .setEntitlement(Entitlement.newBuilder().build())
940               .setRequestId("requestId693933066")
941               .build();
942       client.createEntitlementAsync(request).get();
943       Assert.fail("No exception raised");
944     } catch (ExecutionException e) {
945       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
946       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
947       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
948     }
949   }
950 
951   @Test
changeParametersTest()952   public void changeParametersTest() throws Exception {
953     Entitlement expectedResponse =
954         Entitlement.newBuilder()
955             .setName(EntitlementName.of("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]").toString())
956             .setCreateTime(Timestamp.newBuilder().build())
957             .setUpdateTime(Timestamp.newBuilder().build())
958             .setOffer(OfferName.of("[ACCOUNT]", "[OFFER]").toString())
959             .setCommitmentSettings(CommitmentSettings.newBuilder().build())
960             .setProvisionedService(ProvisionedService.newBuilder().build())
961             .addAllSuspensionReasons(new ArrayList<Entitlement.SuspensionReason>())
962             .setPurchaseOrderId("purchaseOrderId2029917384")
963             .setTrialSettings(TrialSettings.newBuilder().build())
964             .setAssociationInfo(AssociationInfo.newBuilder().build())
965             .addAllParameters(new ArrayList<Parameter>())
966             .setBillingAccount("billingAccount708726578")
967             .build();
968     Operation resultOperation =
969         Operation.newBuilder()
970             .setName("changeParametersTest")
971             .setDone(true)
972             .setResponse(Any.pack(expectedResponse))
973             .build();
974     mockCloudChannelService.addResponse(resultOperation);
975 
976     ChangeParametersRequest request =
977         ChangeParametersRequest.newBuilder()
978             .setName("name3373707")
979             .addAllParameters(new ArrayList<Parameter>())
980             .setRequestId("requestId693933066")
981             .setPurchaseOrderId("purchaseOrderId2029917384")
982             .build();
983 
984     Entitlement actualResponse = client.changeParametersAsync(request).get();
985     Assert.assertEquals(expectedResponse, actualResponse);
986 
987     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
988     Assert.assertEquals(1, actualRequests.size());
989     ChangeParametersRequest actualRequest = ((ChangeParametersRequest) actualRequests.get(0));
990 
991     Assert.assertEquals(request.getName(), actualRequest.getName());
992     Assert.assertEquals(request.getParametersList(), actualRequest.getParametersList());
993     Assert.assertEquals(request.getRequestId(), actualRequest.getRequestId());
994     Assert.assertEquals(request.getPurchaseOrderId(), actualRequest.getPurchaseOrderId());
995     Assert.assertTrue(
996         channelProvider.isHeaderSent(
997             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
998             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
999   }
1000 
1001   @Test
changeParametersExceptionTest()1002   public void changeParametersExceptionTest() throws Exception {
1003     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1004     mockCloudChannelService.addException(exception);
1005 
1006     try {
1007       ChangeParametersRequest request =
1008           ChangeParametersRequest.newBuilder()
1009               .setName("name3373707")
1010               .addAllParameters(new ArrayList<Parameter>())
1011               .setRequestId("requestId693933066")
1012               .setPurchaseOrderId("purchaseOrderId2029917384")
1013               .build();
1014       client.changeParametersAsync(request).get();
1015       Assert.fail("No exception raised");
1016     } catch (ExecutionException e) {
1017       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
1018       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
1019       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
1020     }
1021   }
1022 
1023   @Test
changeRenewalSettingsTest()1024   public void changeRenewalSettingsTest() throws Exception {
1025     Entitlement expectedResponse =
1026         Entitlement.newBuilder()
1027             .setName(EntitlementName.of("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]").toString())
1028             .setCreateTime(Timestamp.newBuilder().build())
1029             .setUpdateTime(Timestamp.newBuilder().build())
1030             .setOffer(OfferName.of("[ACCOUNT]", "[OFFER]").toString())
1031             .setCommitmentSettings(CommitmentSettings.newBuilder().build())
1032             .setProvisionedService(ProvisionedService.newBuilder().build())
1033             .addAllSuspensionReasons(new ArrayList<Entitlement.SuspensionReason>())
1034             .setPurchaseOrderId("purchaseOrderId2029917384")
1035             .setTrialSettings(TrialSettings.newBuilder().build())
1036             .setAssociationInfo(AssociationInfo.newBuilder().build())
1037             .addAllParameters(new ArrayList<Parameter>())
1038             .setBillingAccount("billingAccount708726578")
1039             .build();
1040     Operation resultOperation =
1041         Operation.newBuilder()
1042             .setName("changeRenewalSettingsTest")
1043             .setDone(true)
1044             .setResponse(Any.pack(expectedResponse))
1045             .build();
1046     mockCloudChannelService.addResponse(resultOperation);
1047 
1048     ChangeRenewalSettingsRequest request =
1049         ChangeRenewalSettingsRequest.newBuilder()
1050             .setName("name3373707")
1051             .setRenewalSettings(RenewalSettings.newBuilder().build())
1052             .setRequestId("requestId693933066")
1053             .build();
1054 
1055     Entitlement actualResponse = client.changeRenewalSettingsAsync(request).get();
1056     Assert.assertEquals(expectedResponse, actualResponse);
1057 
1058     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1059     Assert.assertEquals(1, actualRequests.size());
1060     ChangeRenewalSettingsRequest actualRequest =
1061         ((ChangeRenewalSettingsRequest) actualRequests.get(0));
1062 
1063     Assert.assertEquals(request.getName(), actualRequest.getName());
1064     Assert.assertEquals(request.getRenewalSettings(), actualRequest.getRenewalSettings());
1065     Assert.assertEquals(request.getRequestId(), actualRequest.getRequestId());
1066     Assert.assertTrue(
1067         channelProvider.isHeaderSent(
1068             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1069             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1070   }
1071 
1072   @Test
changeRenewalSettingsExceptionTest()1073   public void changeRenewalSettingsExceptionTest() throws Exception {
1074     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1075     mockCloudChannelService.addException(exception);
1076 
1077     try {
1078       ChangeRenewalSettingsRequest request =
1079           ChangeRenewalSettingsRequest.newBuilder()
1080               .setName("name3373707")
1081               .setRenewalSettings(RenewalSettings.newBuilder().build())
1082               .setRequestId("requestId693933066")
1083               .build();
1084       client.changeRenewalSettingsAsync(request).get();
1085       Assert.fail("No exception raised");
1086     } catch (ExecutionException e) {
1087       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
1088       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
1089       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
1090     }
1091   }
1092 
1093   @Test
changeOfferTest()1094   public void changeOfferTest() throws Exception {
1095     Entitlement expectedResponse =
1096         Entitlement.newBuilder()
1097             .setName(EntitlementName.of("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]").toString())
1098             .setCreateTime(Timestamp.newBuilder().build())
1099             .setUpdateTime(Timestamp.newBuilder().build())
1100             .setOffer(OfferName.of("[ACCOUNT]", "[OFFER]").toString())
1101             .setCommitmentSettings(CommitmentSettings.newBuilder().build())
1102             .setProvisionedService(ProvisionedService.newBuilder().build())
1103             .addAllSuspensionReasons(new ArrayList<Entitlement.SuspensionReason>())
1104             .setPurchaseOrderId("purchaseOrderId2029917384")
1105             .setTrialSettings(TrialSettings.newBuilder().build())
1106             .setAssociationInfo(AssociationInfo.newBuilder().build())
1107             .addAllParameters(new ArrayList<Parameter>())
1108             .setBillingAccount("billingAccount708726578")
1109             .build();
1110     Operation resultOperation =
1111         Operation.newBuilder()
1112             .setName("changeOfferTest")
1113             .setDone(true)
1114             .setResponse(Any.pack(expectedResponse))
1115             .build();
1116     mockCloudChannelService.addResponse(resultOperation);
1117 
1118     ChangeOfferRequest request =
1119         ChangeOfferRequest.newBuilder()
1120             .setName("name3373707")
1121             .setOffer(OfferName.of("[ACCOUNT]", "[OFFER]").toString())
1122             .addAllParameters(new ArrayList<Parameter>())
1123             .setPurchaseOrderId("purchaseOrderId2029917384")
1124             .setRequestId("requestId693933066")
1125             .build();
1126 
1127     Entitlement actualResponse = client.changeOfferAsync(request).get();
1128     Assert.assertEquals(expectedResponse, actualResponse);
1129 
1130     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1131     Assert.assertEquals(1, actualRequests.size());
1132     ChangeOfferRequest actualRequest = ((ChangeOfferRequest) actualRequests.get(0));
1133 
1134     Assert.assertEquals(request.getName(), actualRequest.getName());
1135     Assert.assertEquals(request.getOffer(), actualRequest.getOffer());
1136     Assert.assertEquals(request.getParametersList(), actualRequest.getParametersList());
1137     Assert.assertEquals(request.getPurchaseOrderId(), actualRequest.getPurchaseOrderId());
1138     Assert.assertEquals(request.getRequestId(), actualRequest.getRequestId());
1139     Assert.assertTrue(
1140         channelProvider.isHeaderSent(
1141             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1142             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1143   }
1144 
1145   @Test
changeOfferExceptionTest()1146   public void changeOfferExceptionTest() throws Exception {
1147     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1148     mockCloudChannelService.addException(exception);
1149 
1150     try {
1151       ChangeOfferRequest request =
1152           ChangeOfferRequest.newBuilder()
1153               .setName("name3373707")
1154               .setOffer(OfferName.of("[ACCOUNT]", "[OFFER]").toString())
1155               .addAllParameters(new ArrayList<Parameter>())
1156               .setPurchaseOrderId("purchaseOrderId2029917384")
1157               .setRequestId("requestId693933066")
1158               .build();
1159       client.changeOfferAsync(request).get();
1160       Assert.fail("No exception raised");
1161     } catch (ExecutionException e) {
1162       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
1163       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
1164       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
1165     }
1166   }
1167 
1168   @Test
startPaidServiceTest()1169   public void startPaidServiceTest() throws Exception {
1170     Entitlement expectedResponse =
1171         Entitlement.newBuilder()
1172             .setName(EntitlementName.of("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]").toString())
1173             .setCreateTime(Timestamp.newBuilder().build())
1174             .setUpdateTime(Timestamp.newBuilder().build())
1175             .setOffer(OfferName.of("[ACCOUNT]", "[OFFER]").toString())
1176             .setCommitmentSettings(CommitmentSettings.newBuilder().build())
1177             .setProvisionedService(ProvisionedService.newBuilder().build())
1178             .addAllSuspensionReasons(new ArrayList<Entitlement.SuspensionReason>())
1179             .setPurchaseOrderId("purchaseOrderId2029917384")
1180             .setTrialSettings(TrialSettings.newBuilder().build())
1181             .setAssociationInfo(AssociationInfo.newBuilder().build())
1182             .addAllParameters(new ArrayList<Parameter>())
1183             .setBillingAccount("billingAccount708726578")
1184             .build();
1185     Operation resultOperation =
1186         Operation.newBuilder()
1187             .setName("startPaidServiceTest")
1188             .setDone(true)
1189             .setResponse(Any.pack(expectedResponse))
1190             .build();
1191     mockCloudChannelService.addResponse(resultOperation);
1192 
1193     StartPaidServiceRequest request =
1194         StartPaidServiceRequest.newBuilder()
1195             .setName("name3373707")
1196             .setRequestId("requestId693933066")
1197             .build();
1198 
1199     Entitlement actualResponse = client.startPaidServiceAsync(request).get();
1200     Assert.assertEquals(expectedResponse, actualResponse);
1201 
1202     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1203     Assert.assertEquals(1, actualRequests.size());
1204     StartPaidServiceRequest actualRequest = ((StartPaidServiceRequest) actualRequests.get(0));
1205 
1206     Assert.assertEquals(request.getName(), actualRequest.getName());
1207     Assert.assertEquals(request.getRequestId(), actualRequest.getRequestId());
1208     Assert.assertTrue(
1209         channelProvider.isHeaderSent(
1210             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1211             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1212   }
1213 
1214   @Test
startPaidServiceExceptionTest()1215   public void startPaidServiceExceptionTest() throws Exception {
1216     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1217     mockCloudChannelService.addException(exception);
1218 
1219     try {
1220       StartPaidServiceRequest request =
1221           StartPaidServiceRequest.newBuilder()
1222               .setName("name3373707")
1223               .setRequestId("requestId693933066")
1224               .build();
1225       client.startPaidServiceAsync(request).get();
1226       Assert.fail("No exception raised");
1227     } catch (ExecutionException e) {
1228       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
1229       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
1230       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
1231     }
1232   }
1233 
1234   @Test
suspendEntitlementTest()1235   public void suspendEntitlementTest() throws Exception {
1236     Entitlement expectedResponse =
1237         Entitlement.newBuilder()
1238             .setName(EntitlementName.of("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]").toString())
1239             .setCreateTime(Timestamp.newBuilder().build())
1240             .setUpdateTime(Timestamp.newBuilder().build())
1241             .setOffer(OfferName.of("[ACCOUNT]", "[OFFER]").toString())
1242             .setCommitmentSettings(CommitmentSettings.newBuilder().build())
1243             .setProvisionedService(ProvisionedService.newBuilder().build())
1244             .addAllSuspensionReasons(new ArrayList<Entitlement.SuspensionReason>())
1245             .setPurchaseOrderId("purchaseOrderId2029917384")
1246             .setTrialSettings(TrialSettings.newBuilder().build())
1247             .setAssociationInfo(AssociationInfo.newBuilder().build())
1248             .addAllParameters(new ArrayList<Parameter>())
1249             .setBillingAccount("billingAccount708726578")
1250             .build();
1251     Operation resultOperation =
1252         Operation.newBuilder()
1253             .setName("suspendEntitlementTest")
1254             .setDone(true)
1255             .setResponse(Any.pack(expectedResponse))
1256             .build();
1257     mockCloudChannelService.addResponse(resultOperation);
1258 
1259     SuspendEntitlementRequest request =
1260         SuspendEntitlementRequest.newBuilder()
1261             .setName("name3373707")
1262             .setRequestId("requestId693933066")
1263             .build();
1264 
1265     Entitlement actualResponse = client.suspendEntitlementAsync(request).get();
1266     Assert.assertEquals(expectedResponse, actualResponse);
1267 
1268     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1269     Assert.assertEquals(1, actualRequests.size());
1270     SuspendEntitlementRequest actualRequest = ((SuspendEntitlementRequest) actualRequests.get(0));
1271 
1272     Assert.assertEquals(request.getName(), actualRequest.getName());
1273     Assert.assertEquals(request.getRequestId(), actualRequest.getRequestId());
1274     Assert.assertTrue(
1275         channelProvider.isHeaderSent(
1276             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1277             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1278   }
1279 
1280   @Test
suspendEntitlementExceptionTest()1281   public void suspendEntitlementExceptionTest() throws Exception {
1282     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1283     mockCloudChannelService.addException(exception);
1284 
1285     try {
1286       SuspendEntitlementRequest request =
1287           SuspendEntitlementRequest.newBuilder()
1288               .setName("name3373707")
1289               .setRequestId("requestId693933066")
1290               .build();
1291       client.suspendEntitlementAsync(request).get();
1292       Assert.fail("No exception raised");
1293     } catch (ExecutionException e) {
1294       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
1295       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
1296       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
1297     }
1298   }
1299 
1300   @Test
cancelEntitlementTest()1301   public void cancelEntitlementTest() throws Exception {
1302     Empty expectedResponse = Empty.newBuilder().build();
1303     Operation resultOperation =
1304         Operation.newBuilder()
1305             .setName("cancelEntitlementTest")
1306             .setDone(true)
1307             .setResponse(Any.pack(expectedResponse))
1308             .build();
1309     mockCloudChannelService.addResponse(resultOperation);
1310 
1311     CancelEntitlementRequest request =
1312         CancelEntitlementRequest.newBuilder()
1313             .setName("name3373707")
1314             .setRequestId("requestId693933066")
1315             .build();
1316 
1317     client.cancelEntitlementAsync(request).get();
1318 
1319     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1320     Assert.assertEquals(1, actualRequests.size());
1321     CancelEntitlementRequest actualRequest = ((CancelEntitlementRequest) actualRequests.get(0));
1322 
1323     Assert.assertEquals(request.getName(), actualRequest.getName());
1324     Assert.assertEquals(request.getRequestId(), actualRequest.getRequestId());
1325     Assert.assertTrue(
1326         channelProvider.isHeaderSent(
1327             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1328             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1329   }
1330 
1331   @Test
cancelEntitlementExceptionTest()1332   public void cancelEntitlementExceptionTest() throws Exception {
1333     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1334     mockCloudChannelService.addException(exception);
1335 
1336     try {
1337       CancelEntitlementRequest request =
1338           CancelEntitlementRequest.newBuilder()
1339               .setName("name3373707")
1340               .setRequestId("requestId693933066")
1341               .build();
1342       client.cancelEntitlementAsync(request).get();
1343       Assert.fail("No exception raised");
1344     } catch (ExecutionException e) {
1345       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
1346       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
1347       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
1348     }
1349   }
1350 
1351   @Test
activateEntitlementTest()1352   public void activateEntitlementTest() throws Exception {
1353     Entitlement expectedResponse =
1354         Entitlement.newBuilder()
1355             .setName(EntitlementName.of("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]").toString())
1356             .setCreateTime(Timestamp.newBuilder().build())
1357             .setUpdateTime(Timestamp.newBuilder().build())
1358             .setOffer(OfferName.of("[ACCOUNT]", "[OFFER]").toString())
1359             .setCommitmentSettings(CommitmentSettings.newBuilder().build())
1360             .setProvisionedService(ProvisionedService.newBuilder().build())
1361             .addAllSuspensionReasons(new ArrayList<Entitlement.SuspensionReason>())
1362             .setPurchaseOrderId("purchaseOrderId2029917384")
1363             .setTrialSettings(TrialSettings.newBuilder().build())
1364             .setAssociationInfo(AssociationInfo.newBuilder().build())
1365             .addAllParameters(new ArrayList<Parameter>())
1366             .setBillingAccount("billingAccount708726578")
1367             .build();
1368     Operation resultOperation =
1369         Operation.newBuilder()
1370             .setName("activateEntitlementTest")
1371             .setDone(true)
1372             .setResponse(Any.pack(expectedResponse))
1373             .build();
1374     mockCloudChannelService.addResponse(resultOperation);
1375 
1376     ActivateEntitlementRequest request =
1377         ActivateEntitlementRequest.newBuilder()
1378             .setName("name3373707")
1379             .setRequestId("requestId693933066")
1380             .build();
1381 
1382     Entitlement actualResponse = client.activateEntitlementAsync(request).get();
1383     Assert.assertEquals(expectedResponse, actualResponse);
1384 
1385     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1386     Assert.assertEquals(1, actualRequests.size());
1387     ActivateEntitlementRequest actualRequest = ((ActivateEntitlementRequest) actualRequests.get(0));
1388 
1389     Assert.assertEquals(request.getName(), actualRequest.getName());
1390     Assert.assertEquals(request.getRequestId(), actualRequest.getRequestId());
1391     Assert.assertTrue(
1392         channelProvider.isHeaderSent(
1393             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1394             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1395   }
1396 
1397   @Test
activateEntitlementExceptionTest()1398   public void activateEntitlementExceptionTest() throws Exception {
1399     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1400     mockCloudChannelService.addException(exception);
1401 
1402     try {
1403       ActivateEntitlementRequest request =
1404           ActivateEntitlementRequest.newBuilder()
1405               .setName("name3373707")
1406               .setRequestId("requestId693933066")
1407               .build();
1408       client.activateEntitlementAsync(request).get();
1409       Assert.fail("No exception raised");
1410     } catch (ExecutionException e) {
1411       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
1412       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
1413       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
1414     }
1415   }
1416 
1417   @Test
transferEntitlementsTest()1418   public void transferEntitlementsTest() throws Exception {
1419     TransferEntitlementsResponse expectedResponse =
1420         TransferEntitlementsResponse.newBuilder()
1421             .addAllEntitlements(new ArrayList<Entitlement>())
1422             .build();
1423     Operation resultOperation =
1424         Operation.newBuilder()
1425             .setName("transferEntitlementsTest")
1426             .setDone(true)
1427             .setResponse(Any.pack(expectedResponse))
1428             .build();
1429     mockCloudChannelService.addResponse(resultOperation);
1430 
1431     TransferEntitlementsRequest request =
1432         TransferEntitlementsRequest.newBuilder()
1433             .setParent("parent-995424086")
1434             .addAllEntitlements(new ArrayList<Entitlement>())
1435             .setAuthToken("authToken1450587441")
1436             .setRequestId("requestId693933066")
1437             .build();
1438 
1439     TransferEntitlementsResponse actualResponse = client.transferEntitlementsAsync(request).get();
1440     Assert.assertEquals(expectedResponse, actualResponse);
1441 
1442     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1443     Assert.assertEquals(1, actualRequests.size());
1444     TransferEntitlementsRequest actualRequest =
1445         ((TransferEntitlementsRequest) actualRequests.get(0));
1446 
1447     Assert.assertEquals(request.getParent(), actualRequest.getParent());
1448     Assert.assertEquals(request.getEntitlementsList(), actualRequest.getEntitlementsList());
1449     Assert.assertEquals(request.getAuthToken(), actualRequest.getAuthToken());
1450     Assert.assertEquals(request.getRequestId(), actualRequest.getRequestId());
1451     Assert.assertTrue(
1452         channelProvider.isHeaderSent(
1453             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1454             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1455   }
1456 
1457   @Test
transferEntitlementsExceptionTest()1458   public void transferEntitlementsExceptionTest() throws Exception {
1459     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1460     mockCloudChannelService.addException(exception);
1461 
1462     try {
1463       TransferEntitlementsRequest request =
1464           TransferEntitlementsRequest.newBuilder()
1465               .setParent("parent-995424086")
1466               .addAllEntitlements(new ArrayList<Entitlement>())
1467               .setAuthToken("authToken1450587441")
1468               .setRequestId("requestId693933066")
1469               .build();
1470       client.transferEntitlementsAsync(request).get();
1471       Assert.fail("No exception raised");
1472     } catch (ExecutionException e) {
1473       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
1474       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
1475       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
1476     }
1477   }
1478 
1479   @Test
transferEntitlementsToGoogleTest()1480   public void transferEntitlementsToGoogleTest() throws Exception {
1481     Empty expectedResponse = Empty.newBuilder().build();
1482     Operation resultOperation =
1483         Operation.newBuilder()
1484             .setName("transferEntitlementsToGoogleTest")
1485             .setDone(true)
1486             .setResponse(Any.pack(expectedResponse))
1487             .build();
1488     mockCloudChannelService.addResponse(resultOperation);
1489 
1490     TransferEntitlementsToGoogleRequest request =
1491         TransferEntitlementsToGoogleRequest.newBuilder()
1492             .setParent("parent-995424086")
1493             .addAllEntitlements(new ArrayList<Entitlement>())
1494             .setRequestId("requestId693933066")
1495             .build();
1496 
1497     client.transferEntitlementsToGoogleAsync(request).get();
1498 
1499     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1500     Assert.assertEquals(1, actualRequests.size());
1501     TransferEntitlementsToGoogleRequest actualRequest =
1502         ((TransferEntitlementsToGoogleRequest) actualRequests.get(0));
1503 
1504     Assert.assertEquals(request.getParent(), actualRequest.getParent());
1505     Assert.assertEquals(request.getEntitlementsList(), actualRequest.getEntitlementsList());
1506     Assert.assertEquals(request.getRequestId(), actualRequest.getRequestId());
1507     Assert.assertTrue(
1508         channelProvider.isHeaderSent(
1509             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1510             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1511   }
1512 
1513   @Test
transferEntitlementsToGoogleExceptionTest()1514   public void transferEntitlementsToGoogleExceptionTest() throws Exception {
1515     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1516     mockCloudChannelService.addException(exception);
1517 
1518     try {
1519       TransferEntitlementsToGoogleRequest request =
1520           TransferEntitlementsToGoogleRequest.newBuilder()
1521               .setParent("parent-995424086")
1522               .addAllEntitlements(new ArrayList<Entitlement>())
1523               .setRequestId("requestId693933066")
1524               .build();
1525       client.transferEntitlementsToGoogleAsync(request).get();
1526       Assert.fail("No exception raised");
1527     } catch (ExecutionException e) {
1528       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
1529       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
1530       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
1531     }
1532   }
1533 
1534   @Test
listChannelPartnerLinksTest()1535   public void listChannelPartnerLinksTest() throws Exception {
1536     ChannelPartnerLink responsesElement = ChannelPartnerLink.newBuilder().build();
1537     ListChannelPartnerLinksResponse expectedResponse =
1538         ListChannelPartnerLinksResponse.newBuilder()
1539             .setNextPageToken("")
1540             .addAllChannelPartnerLinks(Arrays.asList(responsesElement))
1541             .build();
1542     mockCloudChannelService.addResponse(expectedResponse);
1543 
1544     ListChannelPartnerLinksRequest request =
1545         ListChannelPartnerLinksRequest.newBuilder()
1546             .setParent("parent-995424086")
1547             .setPageSize(883849137)
1548             .setPageToken("pageToken873572522")
1549             .setView(ChannelPartnerLinkView.forNumber(0))
1550             .build();
1551 
1552     ListChannelPartnerLinksPagedResponse pagedListResponse =
1553         client.listChannelPartnerLinks(request);
1554 
1555     List<ChannelPartnerLink> resources = Lists.newArrayList(pagedListResponse.iterateAll());
1556 
1557     Assert.assertEquals(1, resources.size());
1558     Assert.assertEquals(expectedResponse.getChannelPartnerLinksList().get(0), resources.get(0));
1559 
1560     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1561     Assert.assertEquals(1, actualRequests.size());
1562     ListChannelPartnerLinksRequest actualRequest =
1563         ((ListChannelPartnerLinksRequest) actualRequests.get(0));
1564 
1565     Assert.assertEquals(request.getParent(), actualRequest.getParent());
1566     Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
1567     Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
1568     Assert.assertEquals(request.getView(), actualRequest.getView());
1569     Assert.assertTrue(
1570         channelProvider.isHeaderSent(
1571             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1572             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1573   }
1574 
1575   @Test
listChannelPartnerLinksExceptionTest()1576   public void listChannelPartnerLinksExceptionTest() throws Exception {
1577     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1578     mockCloudChannelService.addException(exception);
1579 
1580     try {
1581       ListChannelPartnerLinksRequest request =
1582           ListChannelPartnerLinksRequest.newBuilder()
1583               .setParent("parent-995424086")
1584               .setPageSize(883849137)
1585               .setPageToken("pageToken873572522")
1586               .setView(ChannelPartnerLinkView.forNumber(0))
1587               .build();
1588       client.listChannelPartnerLinks(request);
1589       Assert.fail("No exception raised");
1590     } catch (InvalidArgumentException e) {
1591       // Expected exception.
1592     }
1593   }
1594 
1595   @Test
getChannelPartnerLinkTest()1596   public void getChannelPartnerLinkTest() throws Exception {
1597     ChannelPartnerLink expectedResponse =
1598         ChannelPartnerLink.newBuilder()
1599             .setName(ChannelPartnerLinkName.of("[ACCOUNT]", "[CHANNEL_PARTNER_LINK]").toString())
1600             .setResellerCloudIdentityId("resellerCloudIdentityId478410940")
1601             .setLinkState(ChannelPartnerLinkState.forNumber(0))
1602             .setInviteLinkUri("inviteLinkUri-1908670519")
1603             .setCreateTime(Timestamp.newBuilder().build())
1604             .setUpdateTime(Timestamp.newBuilder().build())
1605             .setPublicId("publicId1293600100")
1606             .setChannelPartnerCloudIdentityInfo(CloudIdentityInfo.newBuilder().build())
1607             .build();
1608     mockCloudChannelService.addResponse(expectedResponse);
1609 
1610     GetChannelPartnerLinkRequest request =
1611         GetChannelPartnerLinkRequest.newBuilder()
1612             .setName("name3373707")
1613             .setView(ChannelPartnerLinkView.forNumber(0))
1614             .build();
1615 
1616     ChannelPartnerLink actualResponse = client.getChannelPartnerLink(request);
1617     Assert.assertEquals(expectedResponse, actualResponse);
1618 
1619     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1620     Assert.assertEquals(1, actualRequests.size());
1621     GetChannelPartnerLinkRequest actualRequest =
1622         ((GetChannelPartnerLinkRequest) actualRequests.get(0));
1623 
1624     Assert.assertEquals(request.getName(), actualRequest.getName());
1625     Assert.assertEquals(request.getView(), actualRequest.getView());
1626     Assert.assertTrue(
1627         channelProvider.isHeaderSent(
1628             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1629             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1630   }
1631 
1632   @Test
getChannelPartnerLinkExceptionTest()1633   public void getChannelPartnerLinkExceptionTest() throws Exception {
1634     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1635     mockCloudChannelService.addException(exception);
1636 
1637     try {
1638       GetChannelPartnerLinkRequest request =
1639           GetChannelPartnerLinkRequest.newBuilder()
1640               .setName("name3373707")
1641               .setView(ChannelPartnerLinkView.forNumber(0))
1642               .build();
1643       client.getChannelPartnerLink(request);
1644       Assert.fail("No exception raised");
1645     } catch (InvalidArgumentException e) {
1646       // Expected exception.
1647     }
1648   }
1649 
1650   @Test
createChannelPartnerLinkTest()1651   public void createChannelPartnerLinkTest() throws Exception {
1652     ChannelPartnerLink expectedResponse =
1653         ChannelPartnerLink.newBuilder()
1654             .setName(ChannelPartnerLinkName.of("[ACCOUNT]", "[CHANNEL_PARTNER_LINK]").toString())
1655             .setResellerCloudIdentityId("resellerCloudIdentityId478410940")
1656             .setLinkState(ChannelPartnerLinkState.forNumber(0))
1657             .setInviteLinkUri("inviteLinkUri-1908670519")
1658             .setCreateTime(Timestamp.newBuilder().build())
1659             .setUpdateTime(Timestamp.newBuilder().build())
1660             .setPublicId("publicId1293600100")
1661             .setChannelPartnerCloudIdentityInfo(CloudIdentityInfo.newBuilder().build())
1662             .build();
1663     mockCloudChannelService.addResponse(expectedResponse);
1664 
1665     CreateChannelPartnerLinkRequest request =
1666         CreateChannelPartnerLinkRequest.newBuilder()
1667             .setParent("parent-995424086")
1668             .setChannelPartnerLink(ChannelPartnerLink.newBuilder().build())
1669             .build();
1670 
1671     ChannelPartnerLink actualResponse = client.createChannelPartnerLink(request);
1672     Assert.assertEquals(expectedResponse, actualResponse);
1673 
1674     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1675     Assert.assertEquals(1, actualRequests.size());
1676     CreateChannelPartnerLinkRequest actualRequest =
1677         ((CreateChannelPartnerLinkRequest) actualRequests.get(0));
1678 
1679     Assert.assertEquals(request.getParent(), actualRequest.getParent());
1680     Assert.assertEquals(request.getChannelPartnerLink(), actualRequest.getChannelPartnerLink());
1681     Assert.assertTrue(
1682         channelProvider.isHeaderSent(
1683             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1684             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1685   }
1686 
1687   @Test
createChannelPartnerLinkExceptionTest()1688   public void createChannelPartnerLinkExceptionTest() throws Exception {
1689     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1690     mockCloudChannelService.addException(exception);
1691 
1692     try {
1693       CreateChannelPartnerLinkRequest request =
1694           CreateChannelPartnerLinkRequest.newBuilder()
1695               .setParent("parent-995424086")
1696               .setChannelPartnerLink(ChannelPartnerLink.newBuilder().build())
1697               .build();
1698       client.createChannelPartnerLink(request);
1699       Assert.fail("No exception raised");
1700     } catch (InvalidArgumentException e) {
1701       // Expected exception.
1702     }
1703   }
1704 
1705   @Test
updateChannelPartnerLinkTest()1706   public void updateChannelPartnerLinkTest() throws Exception {
1707     ChannelPartnerLink expectedResponse =
1708         ChannelPartnerLink.newBuilder()
1709             .setName(ChannelPartnerLinkName.of("[ACCOUNT]", "[CHANNEL_PARTNER_LINK]").toString())
1710             .setResellerCloudIdentityId("resellerCloudIdentityId478410940")
1711             .setLinkState(ChannelPartnerLinkState.forNumber(0))
1712             .setInviteLinkUri("inviteLinkUri-1908670519")
1713             .setCreateTime(Timestamp.newBuilder().build())
1714             .setUpdateTime(Timestamp.newBuilder().build())
1715             .setPublicId("publicId1293600100")
1716             .setChannelPartnerCloudIdentityInfo(CloudIdentityInfo.newBuilder().build())
1717             .build();
1718     mockCloudChannelService.addResponse(expectedResponse);
1719 
1720     UpdateChannelPartnerLinkRequest request =
1721         UpdateChannelPartnerLinkRequest.newBuilder()
1722             .setName("name3373707")
1723             .setChannelPartnerLink(ChannelPartnerLink.newBuilder().build())
1724             .setUpdateMask(FieldMask.newBuilder().build())
1725             .build();
1726 
1727     ChannelPartnerLink actualResponse = client.updateChannelPartnerLink(request);
1728     Assert.assertEquals(expectedResponse, actualResponse);
1729 
1730     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1731     Assert.assertEquals(1, actualRequests.size());
1732     UpdateChannelPartnerLinkRequest actualRequest =
1733         ((UpdateChannelPartnerLinkRequest) actualRequests.get(0));
1734 
1735     Assert.assertEquals(request.getName(), actualRequest.getName());
1736     Assert.assertEquals(request.getChannelPartnerLink(), actualRequest.getChannelPartnerLink());
1737     Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask());
1738     Assert.assertTrue(
1739         channelProvider.isHeaderSent(
1740             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1741             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1742   }
1743 
1744   @Test
updateChannelPartnerLinkExceptionTest()1745   public void updateChannelPartnerLinkExceptionTest() throws Exception {
1746     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1747     mockCloudChannelService.addException(exception);
1748 
1749     try {
1750       UpdateChannelPartnerLinkRequest request =
1751           UpdateChannelPartnerLinkRequest.newBuilder()
1752               .setName("name3373707")
1753               .setChannelPartnerLink(ChannelPartnerLink.newBuilder().build())
1754               .setUpdateMask(FieldMask.newBuilder().build())
1755               .build();
1756       client.updateChannelPartnerLink(request);
1757       Assert.fail("No exception raised");
1758     } catch (InvalidArgumentException e) {
1759       // Expected exception.
1760     }
1761   }
1762 
1763   @Test
getCustomerRepricingConfigTest()1764   public void getCustomerRepricingConfigTest() throws Exception {
1765     CustomerRepricingConfig expectedResponse =
1766         CustomerRepricingConfig.newBuilder()
1767             .setName(
1768                 CustomerRepricingConfigName.of(
1769                         "[ACCOUNT]", "[CUSTOMER]", "[CUSTOMER_REPRICING_CONFIG]")
1770                     .toString())
1771             .setRepricingConfig(RepricingConfig.newBuilder().build())
1772             .setUpdateTime(Timestamp.newBuilder().build())
1773             .build();
1774     mockCloudChannelService.addResponse(expectedResponse);
1775 
1776     CustomerRepricingConfigName name =
1777         CustomerRepricingConfigName.of("[ACCOUNT]", "[CUSTOMER]", "[CUSTOMER_REPRICING_CONFIG]");
1778 
1779     CustomerRepricingConfig actualResponse = client.getCustomerRepricingConfig(name);
1780     Assert.assertEquals(expectedResponse, actualResponse);
1781 
1782     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1783     Assert.assertEquals(1, actualRequests.size());
1784     GetCustomerRepricingConfigRequest actualRequest =
1785         ((GetCustomerRepricingConfigRequest) actualRequests.get(0));
1786 
1787     Assert.assertEquals(name.toString(), actualRequest.getName());
1788     Assert.assertTrue(
1789         channelProvider.isHeaderSent(
1790             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1791             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1792   }
1793 
1794   @Test
getCustomerRepricingConfigExceptionTest()1795   public void getCustomerRepricingConfigExceptionTest() throws Exception {
1796     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1797     mockCloudChannelService.addException(exception);
1798 
1799     try {
1800       CustomerRepricingConfigName name =
1801           CustomerRepricingConfigName.of("[ACCOUNT]", "[CUSTOMER]", "[CUSTOMER_REPRICING_CONFIG]");
1802       client.getCustomerRepricingConfig(name);
1803       Assert.fail("No exception raised");
1804     } catch (InvalidArgumentException e) {
1805       // Expected exception.
1806     }
1807   }
1808 
1809   @Test
getCustomerRepricingConfigTest2()1810   public void getCustomerRepricingConfigTest2() throws Exception {
1811     CustomerRepricingConfig expectedResponse =
1812         CustomerRepricingConfig.newBuilder()
1813             .setName(
1814                 CustomerRepricingConfigName.of(
1815                         "[ACCOUNT]", "[CUSTOMER]", "[CUSTOMER_REPRICING_CONFIG]")
1816                     .toString())
1817             .setRepricingConfig(RepricingConfig.newBuilder().build())
1818             .setUpdateTime(Timestamp.newBuilder().build())
1819             .build();
1820     mockCloudChannelService.addResponse(expectedResponse);
1821 
1822     String name = "name3373707";
1823 
1824     CustomerRepricingConfig actualResponse = client.getCustomerRepricingConfig(name);
1825     Assert.assertEquals(expectedResponse, actualResponse);
1826 
1827     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1828     Assert.assertEquals(1, actualRequests.size());
1829     GetCustomerRepricingConfigRequest actualRequest =
1830         ((GetCustomerRepricingConfigRequest) actualRequests.get(0));
1831 
1832     Assert.assertEquals(name, actualRequest.getName());
1833     Assert.assertTrue(
1834         channelProvider.isHeaderSent(
1835             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1836             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1837   }
1838 
1839   @Test
getCustomerRepricingConfigExceptionTest2()1840   public void getCustomerRepricingConfigExceptionTest2() throws Exception {
1841     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1842     mockCloudChannelService.addException(exception);
1843 
1844     try {
1845       String name = "name3373707";
1846       client.getCustomerRepricingConfig(name);
1847       Assert.fail("No exception raised");
1848     } catch (InvalidArgumentException e) {
1849       // Expected exception.
1850     }
1851   }
1852 
1853   @Test
listCustomerRepricingConfigsTest()1854   public void listCustomerRepricingConfigsTest() throws Exception {
1855     CustomerRepricingConfig responsesElement = CustomerRepricingConfig.newBuilder().build();
1856     ListCustomerRepricingConfigsResponse expectedResponse =
1857         ListCustomerRepricingConfigsResponse.newBuilder()
1858             .setNextPageToken("")
1859             .addAllCustomerRepricingConfigs(Arrays.asList(responsesElement))
1860             .build();
1861     mockCloudChannelService.addResponse(expectedResponse);
1862 
1863     CustomerName parent = CustomerName.of("[ACCOUNT]", "[CUSTOMER]");
1864 
1865     ListCustomerRepricingConfigsPagedResponse pagedListResponse =
1866         client.listCustomerRepricingConfigs(parent);
1867 
1868     List<CustomerRepricingConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
1869 
1870     Assert.assertEquals(1, resources.size());
1871     Assert.assertEquals(
1872         expectedResponse.getCustomerRepricingConfigsList().get(0), resources.get(0));
1873 
1874     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1875     Assert.assertEquals(1, actualRequests.size());
1876     ListCustomerRepricingConfigsRequest actualRequest =
1877         ((ListCustomerRepricingConfigsRequest) actualRequests.get(0));
1878 
1879     Assert.assertEquals(parent.toString(), actualRequest.getParent());
1880     Assert.assertTrue(
1881         channelProvider.isHeaderSent(
1882             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1883             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1884   }
1885 
1886   @Test
listCustomerRepricingConfigsExceptionTest()1887   public void listCustomerRepricingConfigsExceptionTest() throws Exception {
1888     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1889     mockCloudChannelService.addException(exception);
1890 
1891     try {
1892       CustomerName parent = CustomerName.of("[ACCOUNT]", "[CUSTOMER]");
1893       client.listCustomerRepricingConfigs(parent);
1894       Assert.fail("No exception raised");
1895     } catch (InvalidArgumentException e) {
1896       // Expected exception.
1897     }
1898   }
1899 
1900   @Test
listCustomerRepricingConfigsTest2()1901   public void listCustomerRepricingConfigsTest2() throws Exception {
1902     CustomerRepricingConfig responsesElement = CustomerRepricingConfig.newBuilder().build();
1903     ListCustomerRepricingConfigsResponse expectedResponse =
1904         ListCustomerRepricingConfigsResponse.newBuilder()
1905             .setNextPageToken("")
1906             .addAllCustomerRepricingConfigs(Arrays.asList(responsesElement))
1907             .build();
1908     mockCloudChannelService.addResponse(expectedResponse);
1909 
1910     String parent = "parent-995424086";
1911 
1912     ListCustomerRepricingConfigsPagedResponse pagedListResponse =
1913         client.listCustomerRepricingConfigs(parent);
1914 
1915     List<CustomerRepricingConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
1916 
1917     Assert.assertEquals(1, resources.size());
1918     Assert.assertEquals(
1919         expectedResponse.getCustomerRepricingConfigsList().get(0), resources.get(0));
1920 
1921     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1922     Assert.assertEquals(1, actualRequests.size());
1923     ListCustomerRepricingConfigsRequest actualRequest =
1924         ((ListCustomerRepricingConfigsRequest) actualRequests.get(0));
1925 
1926     Assert.assertEquals(parent, actualRequest.getParent());
1927     Assert.assertTrue(
1928         channelProvider.isHeaderSent(
1929             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1930             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1931   }
1932 
1933   @Test
listCustomerRepricingConfigsExceptionTest2()1934   public void listCustomerRepricingConfigsExceptionTest2() throws Exception {
1935     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1936     mockCloudChannelService.addException(exception);
1937 
1938     try {
1939       String parent = "parent-995424086";
1940       client.listCustomerRepricingConfigs(parent);
1941       Assert.fail("No exception raised");
1942     } catch (InvalidArgumentException e) {
1943       // Expected exception.
1944     }
1945   }
1946 
1947   @Test
createCustomerRepricingConfigTest()1948   public void createCustomerRepricingConfigTest() throws Exception {
1949     CustomerRepricingConfig expectedResponse =
1950         CustomerRepricingConfig.newBuilder()
1951             .setName(
1952                 CustomerRepricingConfigName.of(
1953                         "[ACCOUNT]", "[CUSTOMER]", "[CUSTOMER_REPRICING_CONFIG]")
1954                     .toString())
1955             .setRepricingConfig(RepricingConfig.newBuilder().build())
1956             .setUpdateTime(Timestamp.newBuilder().build())
1957             .build();
1958     mockCloudChannelService.addResponse(expectedResponse);
1959 
1960     CustomerName parent = CustomerName.of("[ACCOUNT]", "[CUSTOMER]");
1961     CustomerRepricingConfig customerRepricingConfig = CustomerRepricingConfig.newBuilder().build();
1962 
1963     CustomerRepricingConfig actualResponse =
1964         client.createCustomerRepricingConfig(parent, customerRepricingConfig);
1965     Assert.assertEquals(expectedResponse, actualResponse);
1966 
1967     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
1968     Assert.assertEquals(1, actualRequests.size());
1969     CreateCustomerRepricingConfigRequest actualRequest =
1970         ((CreateCustomerRepricingConfigRequest) actualRequests.get(0));
1971 
1972     Assert.assertEquals(parent.toString(), actualRequest.getParent());
1973     Assert.assertEquals(customerRepricingConfig, actualRequest.getCustomerRepricingConfig());
1974     Assert.assertTrue(
1975         channelProvider.isHeaderSent(
1976             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1977             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1978   }
1979 
1980   @Test
createCustomerRepricingConfigExceptionTest()1981   public void createCustomerRepricingConfigExceptionTest() throws Exception {
1982     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1983     mockCloudChannelService.addException(exception);
1984 
1985     try {
1986       CustomerName parent = CustomerName.of("[ACCOUNT]", "[CUSTOMER]");
1987       CustomerRepricingConfig customerRepricingConfig =
1988           CustomerRepricingConfig.newBuilder().build();
1989       client.createCustomerRepricingConfig(parent, customerRepricingConfig);
1990       Assert.fail("No exception raised");
1991     } catch (InvalidArgumentException e) {
1992       // Expected exception.
1993     }
1994   }
1995 
1996   @Test
createCustomerRepricingConfigTest2()1997   public void createCustomerRepricingConfigTest2() throws Exception {
1998     CustomerRepricingConfig expectedResponse =
1999         CustomerRepricingConfig.newBuilder()
2000             .setName(
2001                 CustomerRepricingConfigName.of(
2002                         "[ACCOUNT]", "[CUSTOMER]", "[CUSTOMER_REPRICING_CONFIG]")
2003                     .toString())
2004             .setRepricingConfig(RepricingConfig.newBuilder().build())
2005             .setUpdateTime(Timestamp.newBuilder().build())
2006             .build();
2007     mockCloudChannelService.addResponse(expectedResponse);
2008 
2009     String parent = "parent-995424086";
2010     CustomerRepricingConfig customerRepricingConfig = CustomerRepricingConfig.newBuilder().build();
2011 
2012     CustomerRepricingConfig actualResponse =
2013         client.createCustomerRepricingConfig(parent, customerRepricingConfig);
2014     Assert.assertEquals(expectedResponse, actualResponse);
2015 
2016     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2017     Assert.assertEquals(1, actualRequests.size());
2018     CreateCustomerRepricingConfigRequest actualRequest =
2019         ((CreateCustomerRepricingConfigRequest) actualRequests.get(0));
2020 
2021     Assert.assertEquals(parent, actualRequest.getParent());
2022     Assert.assertEquals(customerRepricingConfig, actualRequest.getCustomerRepricingConfig());
2023     Assert.assertTrue(
2024         channelProvider.isHeaderSent(
2025             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2026             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2027   }
2028 
2029   @Test
createCustomerRepricingConfigExceptionTest2()2030   public void createCustomerRepricingConfigExceptionTest2() throws Exception {
2031     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2032     mockCloudChannelService.addException(exception);
2033 
2034     try {
2035       String parent = "parent-995424086";
2036       CustomerRepricingConfig customerRepricingConfig =
2037           CustomerRepricingConfig.newBuilder().build();
2038       client.createCustomerRepricingConfig(parent, customerRepricingConfig);
2039       Assert.fail("No exception raised");
2040     } catch (InvalidArgumentException e) {
2041       // Expected exception.
2042     }
2043   }
2044 
2045   @Test
updateCustomerRepricingConfigTest()2046   public void updateCustomerRepricingConfigTest() throws Exception {
2047     CustomerRepricingConfig expectedResponse =
2048         CustomerRepricingConfig.newBuilder()
2049             .setName(
2050                 CustomerRepricingConfigName.of(
2051                         "[ACCOUNT]", "[CUSTOMER]", "[CUSTOMER_REPRICING_CONFIG]")
2052                     .toString())
2053             .setRepricingConfig(RepricingConfig.newBuilder().build())
2054             .setUpdateTime(Timestamp.newBuilder().build())
2055             .build();
2056     mockCloudChannelService.addResponse(expectedResponse);
2057 
2058     CustomerRepricingConfig customerRepricingConfig = CustomerRepricingConfig.newBuilder().build();
2059 
2060     CustomerRepricingConfig actualResponse =
2061         client.updateCustomerRepricingConfig(customerRepricingConfig);
2062     Assert.assertEquals(expectedResponse, actualResponse);
2063 
2064     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2065     Assert.assertEquals(1, actualRequests.size());
2066     UpdateCustomerRepricingConfigRequest actualRequest =
2067         ((UpdateCustomerRepricingConfigRequest) actualRequests.get(0));
2068 
2069     Assert.assertEquals(customerRepricingConfig, actualRequest.getCustomerRepricingConfig());
2070     Assert.assertTrue(
2071         channelProvider.isHeaderSent(
2072             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2073             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2074   }
2075 
2076   @Test
updateCustomerRepricingConfigExceptionTest()2077   public void updateCustomerRepricingConfigExceptionTest() throws Exception {
2078     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2079     mockCloudChannelService.addException(exception);
2080 
2081     try {
2082       CustomerRepricingConfig customerRepricingConfig =
2083           CustomerRepricingConfig.newBuilder().build();
2084       client.updateCustomerRepricingConfig(customerRepricingConfig);
2085       Assert.fail("No exception raised");
2086     } catch (InvalidArgumentException e) {
2087       // Expected exception.
2088     }
2089   }
2090 
2091   @Test
deleteCustomerRepricingConfigTest()2092   public void deleteCustomerRepricingConfigTest() throws Exception {
2093     Empty expectedResponse = Empty.newBuilder().build();
2094     mockCloudChannelService.addResponse(expectedResponse);
2095 
2096     CustomerRepricingConfigName name =
2097         CustomerRepricingConfigName.of("[ACCOUNT]", "[CUSTOMER]", "[CUSTOMER_REPRICING_CONFIG]");
2098 
2099     client.deleteCustomerRepricingConfig(name);
2100 
2101     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2102     Assert.assertEquals(1, actualRequests.size());
2103     DeleteCustomerRepricingConfigRequest actualRequest =
2104         ((DeleteCustomerRepricingConfigRequest) actualRequests.get(0));
2105 
2106     Assert.assertEquals(name.toString(), actualRequest.getName());
2107     Assert.assertTrue(
2108         channelProvider.isHeaderSent(
2109             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2110             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2111   }
2112 
2113   @Test
deleteCustomerRepricingConfigExceptionTest()2114   public void deleteCustomerRepricingConfigExceptionTest() throws Exception {
2115     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2116     mockCloudChannelService.addException(exception);
2117 
2118     try {
2119       CustomerRepricingConfigName name =
2120           CustomerRepricingConfigName.of("[ACCOUNT]", "[CUSTOMER]", "[CUSTOMER_REPRICING_CONFIG]");
2121       client.deleteCustomerRepricingConfig(name);
2122       Assert.fail("No exception raised");
2123     } catch (InvalidArgumentException e) {
2124       // Expected exception.
2125     }
2126   }
2127 
2128   @Test
deleteCustomerRepricingConfigTest2()2129   public void deleteCustomerRepricingConfigTest2() throws Exception {
2130     Empty expectedResponse = Empty.newBuilder().build();
2131     mockCloudChannelService.addResponse(expectedResponse);
2132 
2133     String name = "name3373707";
2134 
2135     client.deleteCustomerRepricingConfig(name);
2136 
2137     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2138     Assert.assertEquals(1, actualRequests.size());
2139     DeleteCustomerRepricingConfigRequest actualRequest =
2140         ((DeleteCustomerRepricingConfigRequest) actualRequests.get(0));
2141 
2142     Assert.assertEquals(name, actualRequest.getName());
2143     Assert.assertTrue(
2144         channelProvider.isHeaderSent(
2145             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2146             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2147   }
2148 
2149   @Test
deleteCustomerRepricingConfigExceptionTest2()2150   public void deleteCustomerRepricingConfigExceptionTest2() throws Exception {
2151     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2152     mockCloudChannelService.addException(exception);
2153 
2154     try {
2155       String name = "name3373707";
2156       client.deleteCustomerRepricingConfig(name);
2157       Assert.fail("No exception raised");
2158     } catch (InvalidArgumentException e) {
2159       // Expected exception.
2160     }
2161   }
2162 
2163   @Test
getChannelPartnerRepricingConfigTest()2164   public void getChannelPartnerRepricingConfigTest() throws Exception {
2165     ChannelPartnerRepricingConfig expectedResponse =
2166         ChannelPartnerRepricingConfig.newBuilder()
2167             .setName(
2168                 ChannelPartnerRepricingConfigName.of(
2169                         "[ACCOUNT]", "[CHANNEL_PARTNER]", "[CHANNEL_PARTNER_REPRICING_CONFIG]")
2170                     .toString())
2171             .setRepricingConfig(RepricingConfig.newBuilder().build())
2172             .setUpdateTime(Timestamp.newBuilder().build())
2173             .build();
2174     mockCloudChannelService.addResponse(expectedResponse);
2175 
2176     ChannelPartnerRepricingConfigName name =
2177         ChannelPartnerRepricingConfigName.of(
2178             "[ACCOUNT]", "[CHANNEL_PARTNER]", "[CHANNEL_PARTNER_REPRICING_CONFIG]");
2179 
2180     ChannelPartnerRepricingConfig actualResponse = client.getChannelPartnerRepricingConfig(name);
2181     Assert.assertEquals(expectedResponse, actualResponse);
2182 
2183     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2184     Assert.assertEquals(1, actualRequests.size());
2185     GetChannelPartnerRepricingConfigRequest actualRequest =
2186         ((GetChannelPartnerRepricingConfigRequest) actualRequests.get(0));
2187 
2188     Assert.assertEquals(name.toString(), actualRequest.getName());
2189     Assert.assertTrue(
2190         channelProvider.isHeaderSent(
2191             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2192             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2193   }
2194 
2195   @Test
getChannelPartnerRepricingConfigExceptionTest()2196   public void getChannelPartnerRepricingConfigExceptionTest() throws Exception {
2197     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2198     mockCloudChannelService.addException(exception);
2199 
2200     try {
2201       ChannelPartnerRepricingConfigName name =
2202           ChannelPartnerRepricingConfigName.of(
2203               "[ACCOUNT]", "[CHANNEL_PARTNER]", "[CHANNEL_PARTNER_REPRICING_CONFIG]");
2204       client.getChannelPartnerRepricingConfig(name);
2205       Assert.fail("No exception raised");
2206     } catch (InvalidArgumentException e) {
2207       // Expected exception.
2208     }
2209   }
2210 
2211   @Test
getChannelPartnerRepricingConfigTest2()2212   public void getChannelPartnerRepricingConfigTest2() throws Exception {
2213     ChannelPartnerRepricingConfig expectedResponse =
2214         ChannelPartnerRepricingConfig.newBuilder()
2215             .setName(
2216                 ChannelPartnerRepricingConfigName.of(
2217                         "[ACCOUNT]", "[CHANNEL_PARTNER]", "[CHANNEL_PARTNER_REPRICING_CONFIG]")
2218                     .toString())
2219             .setRepricingConfig(RepricingConfig.newBuilder().build())
2220             .setUpdateTime(Timestamp.newBuilder().build())
2221             .build();
2222     mockCloudChannelService.addResponse(expectedResponse);
2223 
2224     String name = "name3373707";
2225 
2226     ChannelPartnerRepricingConfig actualResponse = client.getChannelPartnerRepricingConfig(name);
2227     Assert.assertEquals(expectedResponse, actualResponse);
2228 
2229     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2230     Assert.assertEquals(1, actualRequests.size());
2231     GetChannelPartnerRepricingConfigRequest actualRequest =
2232         ((GetChannelPartnerRepricingConfigRequest) actualRequests.get(0));
2233 
2234     Assert.assertEquals(name, actualRequest.getName());
2235     Assert.assertTrue(
2236         channelProvider.isHeaderSent(
2237             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2238             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2239   }
2240 
2241   @Test
getChannelPartnerRepricingConfigExceptionTest2()2242   public void getChannelPartnerRepricingConfigExceptionTest2() throws Exception {
2243     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2244     mockCloudChannelService.addException(exception);
2245 
2246     try {
2247       String name = "name3373707";
2248       client.getChannelPartnerRepricingConfig(name);
2249       Assert.fail("No exception raised");
2250     } catch (InvalidArgumentException e) {
2251       // Expected exception.
2252     }
2253   }
2254 
2255   @Test
listChannelPartnerRepricingConfigsTest()2256   public void listChannelPartnerRepricingConfigsTest() throws Exception {
2257     ChannelPartnerRepricingConfig responsesElement =
2258         ChannelPartnerRepricingConfig.newBuilder().build();
2259     ListChannelPartnerRepricingConfigsResponse expectedResponse =
2260         ListChannelPartnerRepricingConfigsResponse.newBuilder()
2261             .setNextPageToken("")
2262             .addAllChannelPartnerRepricingConfigs(Arrays.asList(responsesElement))
2263             .build();
2264     mockCloudChannelService.addResponse(expectedResponse);
2265 
2266     ChannelPartnerLinkName parent =
2267         ChannelPartnerLinkName.of("[ACCOUNT]", "[CHANNEL_PARTNER_LINK]");
2268 
2269     ListChannelPartnerRepricingConfigsPagedResponse pagedListResponse =
2270         client.listChannelPartnerRepricingConfigs(parent);
2271 
2272     List<ChannelPartnerRepricingConfig> resources =
2273         Lists.newArrayList(pagedListResponse.iterateAll());
2274 
2275     Assert.assertEquals(1, resources.size());
2276     Assert.assertEquals(
2277         expectedResponse.getChannelPartnerRepricingConfigsList().get(0), resources.get(0));
2278 
2279     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2280     Assert.assertEquals(1, actualRequests.size());
2281     ListChannelPartnerRepricingConfigsRequest actualRequest =
2282         ((ListChannelPartnerRepricingConfigsRequest) actualRequests.get(0));
2283 
2284     Assert.assertEquals(parent.toString(), actualRequest.getParent());
2285     Assert.assertTrue(
2286         channelProvider.isHeaderSent(
2287             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2288             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2289   }
2290 
2291   @Test
listChannelPartnerRepricingConfigsExceptionTest()2292   public void listChannelPartnerRepricingConfigsExceptionTest() throws Exception {
2293     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2294     mockCloudChannelService.addException(exception);
2295 
2296     try {
2297       ChannelPartnerLinkName parent =
2298           ChannelPartnerLinkName.of("[ACCOUNT]", "[CHANNEL_PARTNER_LINK]");
2299       client.listChannelPartnerRepricingConfigs(parent);
2300       Assert.fail("No exception raised");
2301     } catch (InvalidArgumentException e) {
2302       // Expected exception.
2303     }
2304   }
2305 
2306   @Test
listChannelPartnerRepricingConfigsTest2()2307   public void listChannelPartnerRepricingConfigsTest2() throws Exception {
2308     ChannelPartnerRepricingConfig responsesElement =
2309         ChannelPartnerRepricingConfig.newBuilder().build();
2310     ListChannelPartnerRepricingConfigsResponse expectedResponse =
2311         ListChannelPartnerRepricingConfigsResponse.newBuilder()
2312             .setNextPageToken("")
2313             .addAllChannelPartnerRepricingConfigs(Arrays.asList(responsesElement))
2314             .build();
2315     mockCloudChannelService.addResponse(expectedResponse);
2316 
2317     String parent = "parent-995424086";
2318 
2319     ListChannelPartnerRepricingConfigsPagedResponse pagedListResponse =
2320         client.listChannelPartnerRepricingConfigs(parent);
2321 
2322     List<ChannelPartnerRepricingConfig> resources =
2323         Lists.newArrayList(pagedListResponse.iterateAll());
2324 
2325     Assert.assertEquals(1, resources.size());
2326     Assert.assertEquals(
2327         expectedResponse.getChannelPartnerRepricingConfigsList().get(0), resources.get(0));
2328 
2329     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2330     Assert.assertEquals(1, actualRequests.size());
2331     ListChannelPartnerRepricingConfigsRequest actualRequest =
2332         ((ListChannelPartnerRepricingConfigsRequest) actualRequests.get(0));
2333 
2334     Assert.assertEquals(parent, actualRequest.getParent());
2335     Assert.assertTrue(
2336         channelProvider.isHeaderSent(
2337             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2338             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2339   }
2340 
2341   @Test
listChannelPartnerRepricingConfigsExceptionTest2()2342   public void listChannelPartnerRepricingConfigsExceptionTest2() throws Exception {
2343     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2344     mockCloudChannelService.addException(exception);
2345 
2346     try {
2347       String parent = "parent-995424086";
2348       client.listChannelPartnerRepricingConfigs(parent);
2349       Assert.fail("No exception raised");
2350     } catch (InvalidArgumentException e) {
2351       // Expected exception.
2352     }
2353   }
2354 
2355   @Test
createChannelPartnerRepricingConfigTest()2356   public void createChannelPartnerRepricingConfigTest() throws Exception {
2357     ChannelPartnerRepricingConfig expectedResponse =
2358         ChannelPartnerRepricingConfig.newBuilder()
2359             .setName(
2360                 ChannelPartnerRepricingConfigName.of(
2361                         "[ACCOUNT]", "[CHANNEL_PARTNER]", "[CHANNEL_PARTNER_REPRICING_CONFIG]")
2362                     .toString())
2363             .setRepricingConfig(RepricingConfig.newBuilder().build())
2364             .setUpdateTime(Timestamp.newBuilder().build())
2365             .build();
2366     mockCloudChannelService.addResponse(expectedResponse);
2367 
2368     ChannelPartnerLinkName parent =
2369         ChannelPartnerLinkName.of("[ACCOUNT]", "[CHANNEL_PARTNER_LINK]");
2370     ChannelPartnerRepricingConfig channelPartnerRepricingConfig =
2371         ChannelPartnerRepricingConfig.newBuilder().build();
2372 
2373     ChannelPartnerRepricingConfig actualResponse =
2374         client.createChannelPartnerRepricingConfig(parent, channelPartnerRepricingConfig);
2375     Assert.assertEquals(expectedResponse, actualResponse);
2376 
2377     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2378     Assert.assertEquals(1, actualRequests.size());
2379     CreateChannelPartnerRepricingConfigRequest actualRequest =
2380         ((CreateChannelPartnerRepricingConfigRequest) actualRequests.get(0));
2381 
2382     Assert.assertEquals(parent.toString(), actualRequest.getParent());
2383     Assert.assertEquals(
2384         channelPartnerRepricingConfig, actualRequest.getChannelPartnerRepricingConfig());
2385     Assert.assertTrue(
2386         channelProvider.isHeaderSent(
2387             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2388             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2389   }
2390 
2391   @Test
createChannelPartnerRepricingConfigExceptionTest()2392   public void createChannelPartnerRepricingConfigExceptionTest() throws Exception {
2393     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2394     mockCloudChannelService.addException(exception);
2395 
2396     try {
2397       ChannelPartnerLinkName parent =
2398           ChannelPartnerLinkName.of("[ACCOUNT]", "[CHANNEL_PARTNER_LINK]");
2399       ChannelPartnerRepricingConfig channelPartnerRepricingConfig =
2400           ChannelPartnerRepricingConfig.newBuilder().build();
2401       client.createChannelPartnerRepricingConfig(parent, channelPartnerRepricingConfig);
2402       Assert.fail("No exception raised");
2403     } catch (InvalidArgumentException e) {
2404       // Expected exception.
2405     }
2406   }
2407 
2408   @Test
createChannelPartnerRepricingConfigTest2()2409   public void createChannelPartnerRepricingConfigTest2() throws Exception {
2410     ChannelPartnerRepricingConfig expectedResponse =
2411         ChannelPartnerRepricingConfig.newBuilder()
2412             .setName(
2413                 ChannelPartnerRepricingConfigName.of(
2414                         "[ACCOUNT]", "[CHANNEL_PARTNER]", "[CHANNEL_PARTNER_REPRICING_CONFIG]")
2415                     .toString())
2416             .setRepricingConfig(RepricingConfig.newBuilder().build())
2417             .setUpdateTime(Timestamp.newBuilder().build())
2418             .build();
2419     mockCloudChannelService.addResponse(expectedResponse);
2420 
2421     String parent = "parent-995424086";
2422     ChannelPartnerRepricingConfig channelPartnerRepricingConfig =
2423         ChannelPartnerRepricingConfig.newBuilder().build();
2424 
2425     ChannelPartnerRepricingConfig actualResponse =
2426         client.createChannelPartnerRepricingConfig(parent, channelPartnerRepricingConfig);
2427     Assert.assertEquals(expectedResponse, actualResponse);
2428 
2429     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2430     Assert.assertEquals(1, actualRequests.size());
2431     CreateChannelPartnerRepricingConfigRequest actualRequest =
2432         ((CreateChannelPartnerRepricingConfigRequest) actualRequests.get(0));
2433 
2434     Assert.assertEquals(parent, actualRequest.getParent());
2435     Assert.assertEquals(
2436         channelPartnerRepricingConfig, actualRequest.getChannelPartnerRepricingConfig());
2437     Assert.assertTrue(
2438         channelProvider.isHeaderSent(
2439             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2440             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2441   }
2442 
2443   @Test
createChannelPartnerRepricingConfigExceptionTest2()2444   public void createChannelPartnerRepricingConfigExceptionTest2() throws Exception {
2445     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2446     mockCloudChannelService.addException(exception);
2447 
2448     try {
2449       String parent = "parent-995424086";
2450       ChannelPartnerRepricingConfig channelPartnerRepricingConfig =
2451           ChannelPartnerRepricingConfig.newBuilder().build();
2452       client.createChannelPartnerRepricingConfig(parent, channelPartnerRepricingConfig);
2453       Assert.fail("No exception raised");
2454     } catch (InvalidArgumentException e) {
2455       // Expected exception.
2456     }
2457   }
2458 
2459   @Test
updateChannelPartnerRepricingConfigTest()2460   public void updateChannelPartnerRepricingConfigTest() throws Exception {
2461     ChannelPartnerRepricingConfig expectedResponse =
2462         ChannelPartnerRepricingConfig.newBuilder()
2463             .setName(
2464                 ChannelPartnerRepricingConfigName.of(
2465                         "[ACCOUNT]", "[CHANNEL_PARTNER]", "[CHANNEL_PARTNER_REPRICING_CONFIG]")
2466                     .toString())
2467             .setRepricingConfig(RepricingConfig.newBuilder().build())
2468             .setUpdateTime(Timestamp.newBuilder().build())
2469             .build();
2470     mockCloudChannelService.addResponse(expectedResponse);
2471 
2472     ChannelPartnerRepricingConfig channelPartnerRepricingConfig =
2473         ChannelPartnerRepricingConfig.newBuilder().build();
2474 
2475     ChannelPartnerRepricingConfig actualResponse =
2476         client.updateChannelPartnerRepricingConfig(channelPartnerRepricingConfig);
2477     Assert.assertEquals(expectedResponse, actualResponse);
2478 
2479     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2480     Assert.assertEquals(1, actualRequests.size());
2481     UpdateChannelPartnerRepricingConfigRequest actualRequest =
2482         ((UpdateChannelPartnerRepricingConfigRequest) actualRequests.get(0));
2483 
2484     Assert.assertEquals(
2485         channelPartnerRepricingConfig, actualRequest.getChannelPartnerRepricingConfig());
2486     Assert.assertTrue(
2487         channelProvider.isHeaderSent(
2488             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2489             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2490   }
2491 
2492   @Test
updateChannelPartnerRepricingConfigExceptionTest()2493   public void updateChannelPartnerRepricingConfigExceptionTest() throws Exception {
2494     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2495     mockCloudChannelService.addException(exception);
2496 
2497     try {
2498       ChannelPartnerRepricingConfig channelPartnerRepricingConfig =
2499           ChannelPartnerRepricingConfig.newBuilder().build();
2500       client.updateChannelPartnerRepricingConfig(channelPartnerRepricingConfig);
2501       Assert.fail("No exception raised");
2502     } catch (InvalidArgumentException e) {
2503       // Expected exception.
2504     }
2505   }
2506 
2507   @Test
deleteChannelPartnerRepricingConfigTest()2508   public void deleteChannelPartnerRepricingConfigTest() throws Exception {
2509     Empty expectedResponse = Empty.newBuilder().build();
2510     mockCloudChannelService.addResponse(expectedResponse);
2511 
2512     ChannelPartnerRepricingConfigName name =
2513         ChannelPartnerRepricingConfigName.of(
2514             "[ACCOUNT]", "[CHANNEL_PARTNER]", "[CHANNEL_PARTNER_REPRICING_CONFIG]");
2515 
2516     client.deleteChannelPartnerRepricingConfig(name);
2517 
2518     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2519     Assert.assertEquals(1, actualRequests.size());
2520     DeleteChannelPartnerRepricingConfigRequest actualRequest =
2521         ((DeleteChannelPartnerRepricingConfigRequest) actualRequests.get(0));
2522 
2523     Assert.assertEquals(name.toString(), actualRequest.getName());
2524     Assert.assertTrue(
2525         channelProvider.isHeaderSent(
2526             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2527             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2528   }
2529 
2530   @Test
deleteChannelPartnerRepricingConfigExceptionTest()2531   public void deleteChannelPartnerRepricingConfigExceptionTest() throws Exception {
2532     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2533     mockCloudChannelService.addException(exception);
2534 
2535     try {
2536       ChannelPartnerRepricingConfigName name =
2537           ChannelPartnerRepricingConfigName.of(
2538               "[ACCOUNT]", "[CHANNEL_PARTNER]", "[CHANNEL_PARTNER_REPRICING_CONFIG]");
2539       client.deleteChannelPartnerRepricingConfig(name);
2540       Assert.fail("No exception raised");
2541     } catch (InvalidArgumentException e) {
2542       // Expected exception.
2543     }
2544   }
2545 
2546   @Test
deleteChannelPartnerRepricingConfigTest2()2547   public void deleteChannelPartnerRepricingConfigTest2() throws Exception {
2548     Empty expectedResponse = Empty.newBuilder().build();
2549     mockCloudChannelService.addResponse(expectedResponse);
2550 
2551     String name = "name3373707";
2552 
2553     client.deleteChannelPartnerRepricingConfig(name);
2554 
2555     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2556     Assert.assertEquals(1, actualRequests.size());
2557     DeleteChannelPartnerRepricingConfigRequest actualRequest =
2558         ((DeleteChannelPartnerRepricingConfigRequest) actualRequests.get(0));
2559 
2560     Assert.assertEquals(name, actualRequest.getName());
2561     Assert.assertTrue(
2562         channelProvider.isHeaderSent(
2563             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2564             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2565   }
2566 
2567   @Test
deleteChannelPartnerRepricingConfigExceptionTest2()2568   public void deleteChannelPartnerRepricingConfigExceptionTest2() throws Exception {
2569     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2570     mockCloudChannelService.addException(exception);
2571 
2572     try {
2573       String name = "name3373707";
2574       client.deleteChannelPartnerRepricingConfig(name);
2575       Assert.fail("No exception raised");
2576     } catch (InvalidArgumentException e) {
2577       // Expected exception.
2578     }
2579   }
2580 
2581   @Test
lookupOfferTest()2582   public void lookupOfferTest() throws Exception {
2583     Offer expectedResponse =
2584         Offer.newBuilder()
2585             .setName(OfferName.of("[ACCOUNT]", "[OFFER]").toString())
2586             .setMarketingInfo(MarketingInfo.newBuilder().build())
2587             .setSku(Sku.newBuilder().build())
2588             .setPlan(Plan.newBuilder().build())
2589             .setConstraints(Constraints.newBuilder().build())
2590             .addAllPriceByResources(new ArrayList<PriceByResource>())
2591             .setStartTime(Timestamp.newBuilder().build())
2592             .setEndTime(Timestamp.newBuilder().build())
2593             .addAllParameterDefinitions(new ArrayList<ParameterDefinition>())
2594             .setDealCode("dealCode509806713")
2595             .build();
2596     mockCloudChannelService.addResponse(expectedResponse);
2597 
2598     LookupOfferRequest request =
2599         LookupOfferRequest.newBuilder()
2600             .setEntitlement(
2601                 EntitlementName.of("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]").toString())
2602             .build();
2603 
2604     Offer actualResponse = client.lookupOffer(request);
2605     Assert.assertEquals(expectedResponse, actualResponse);
2606 
2607     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2608     Assert.assertEquals(1, actualRequests.size());
2609     LookupOfferRequest actualRequest = ((LookupOfferRequest) actualRequests.get(0));
2610 
2611     Assert.assertEquals(request.getEntitlement(), actualRequest.getEntitlement());
2612     Assert.assertTrue(
2613         channelProvider.isHeaderSent(
2614             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2615             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2616   }
2617 
2618   @Test
lookupOfferExceptionTest()2619   public void lookupOfferExceptionTest() throws Exception {
2620     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2621     mockCloudChannelService.addException(exception);
2622 
2623     try {
2624       LookupOfferRequest request =
2625           LookupOfferRequest.newBuilder()
2626               .setEntitlement(
2627                   EntitlementName.of("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]").toString())
2628               .build();
2629       client.lookupOffer(request);
2630       Assert.fail("No exception raised");
2631     } catch (InvalidArgumentException e) {
2632       // Expected exception.
2633     }
2634   }
2635 
2636   @Test
listProductsTest()2637   public void listProductsTest() throws Exception {
2638     Product responsesElement = Product.newBuilder().build();
2639     ListProductsResponse expectedResponse =
2640         ListProductsResponse.newBuilder()
2641             .setNextPageToken("")
2642             .addAllProducts(Arrays.asList(responsesElement))
2643             .build();
2644     mockCloudChannelService.addResponse(expectedResponse);
2645 
2646     ListProductsRequest request =
2647         ListProductsRequest.newBuilder()
2648             .setAccount("account-1177318867")
2649             .setPageSize(883849137)
2650             .setPageToken("pageToken873572522")
2651             .setLanguageCode("languageCode-2092349083")
2652             .build();
2653 
2654     ListProductsPagedResponse pagedListResponse = client.listProducts(request);
2655 
2656     List<Product> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2657 
2658     Assert.assertEquals(1, resources.size());
2659     Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0));
2660 
2661     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2662     Assert.assertEquals(1, actualRequests.size());
2663     ListProductsRequest actualRequest = ((ListProductsRequest) actualRequests.get(0));
2664 
2665     Assert.assertEquals(request.getAccount(), actualRequest.getAccount());
2666     Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
2667     Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
2668     Assert.assertEquals(request.getLanguageCode(), actualRequest.getLanguageCode());
2669     Assert.assertTrue(
2670         channelProvider.isHeaderSent(
2671             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2672             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2673   }
2674 
2675   @Test
listProductsExceptionTest()2676   public void listProductsExceptionTest() throws Exception {
2677     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2678     mockCloudChannelService.addException(exception);
2679 
2680     try {
2681       ListProductsRequest request =
2682           ListProductsRequest.newBuilder()
2683               .setAccount("account-1177318867")
2684               .setPageSize(883849137)
2685               .setPageToken("pageToken873572522")
2686               .setLanguageCode("languageCode-2092349083")
2687               .build();
2688       client.listProducts(request);
2689       Assert.fail("No exception raised");
2690     } catch (InvalidArgumentException e) {
2691       // Expected exception.
2692     }
2693   }
2694 
2695   @Test
listSkusTest()2696   public void listSkusTest() throws Exception {
2697     Sku responsesElement = Sku.newBuilder().build();
2698     ListSkusResponse expectedResponse =
2699         ListSkusResponse.newBuilder()
2700             .setNextPageToken("")
2701             .addAllSkus(Arrays.asList(responsesElement))
2702             .build();
2703     mockCloudChannelService.addResponse(expectedResponse);
2704 
2705     ListSkusRequest request =
2706         ListSkusRequest.newBuilder()
2707             .setParent(ProductName.of("[PRODUCT]").toString())
2708             .setAccount("account-1177318867")
2709             .setPageSize(883849137)
2710             .setPageToken("pageToken873572522")
2711             .setLanguageCode("languageCode-2092349083")
2712             .build();
2713 
2714     ListSkusPagedResponse pagedListResponse = client.listSkus(request);
2715 
2716     List<Sku> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2717 
2718     Assert.assertEquals(1, resources.size());
2719     Assert.assertEquals(expectedResponse.getSkusList().get(0), resources.get(0));
2720 
2721     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2722     Assert.assertEquals(1, actualRequests.size());
2723     ListSkusRequest actualRequest = ((ListSkusRequest) actualRequests.get(0));
2724 
2725     Assert.assertEquals(request.getParent(), actualRequest.getParent());
2726     Assert.assertEquals(request.getAccount(), actualRequest.getAccount());
2727     Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
2728     Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
2729     Assert.assertEquals(request.getLanguageCode(), actualRequest.getLanguageCode());
2730     Assert.assertTrue(
2731         channelProvider.isHeaderSent(
2732             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2733             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2734   }
2735 
2736   @Test
listSkusExceptionTest()2737   public void listSkusExceptionTest() throws Exception {
2738     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2739     mockCloudChannelService.addException(exception);
2740 
2741     try {
2742       ListSkusRequest request =
2743           ListSkusRequest.newBuilder()
2744               .setParent(ProductName.of("[PRODUCT]").toString())
2745               .setAccount("account-1177318867")
2746               .setPageSize(883849137)
2747               .setPageToken("pageToken873572522")
2748               .setLanguageCode("languageCode-2092349083")
2749               .build();
2750       client.listSkus(request);
2751       Assert.fail("No exception raised");
2752     } catch (InvalidArgumentException e) {
2753       // Expected exception.
2754     }
2755   }
2756 
2757   @Test
listOffersTest()2758   public void listOffersTest() throws Exception {
2759     Offer responsesElement = Offer.newBuilder().build();
2760     ListOffersResponse expectedResponse =
2761         ListOffersResponse.newBuilder()
2762             .setNextPageToken("")
2763             .addAllOffers(Arrays.asList(responsesElement))
2764             .build();
2765     mockCloudChannelService.addResponse(expectedResponse);
2766 
2767     ListOffersRequest request =
2768         ListOffersRequest.newBuilder()
2769             .setParent("parent-995424086")
2770             .setPageSize(883849137)
2771             .setPageToken("pageToken873572522")
2772             .setFilter("filter-1274492040")
2773             .setLanguageCode("languageCode-2092349083")
2774             .setShowFutureOffers(true)
2775             .build();
2776 
2777     ListOffersPagedResponse pagedListResponse = client.listOffers(request);
2778 
2779     List<Offer> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2780 
2781     Assert.assertEquals(1, resources.size());
2782     Assert.assertEquals(expectedResponse.getOffersList().get(0), resources.get(0));
2783 
2784     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2785     Assert.assertEquals(1, actualRequests.size());
2786     ListOffersRequest actualRequest = ((ListOffersRequest) actualRequests.get(0));
2787 
2788     Assert.assertEquals(request.getParent(), actualRequest.getParent());
2789     Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
2790     Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
2791     Assert.assertEquals(request.getFilter(), actualRequest.getFilter());
2792     Assert.assertEquals(request.getLanguageCode(), actualRequest.getLanguageCode());
2793     Assert.assertEquals(request.getShowFutureOffers(), actualRequest.getShowFutureOffers());
2794     Assert.assertTrue(
2795         channelProvider.isHeaderSent(
2796             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2797             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2798   }
2799 
2800   @Test
listOffersExceptionTest()2801   public void listOffersExceptionTest() throws Exception {
2802     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2803     mockCloudChannelService.addException(exception);
2804 
2805     try {
2806       ListOffersRequest request =
2807           ListOffersRequest.newBuilder()
2808               .setParent("parent-995424086")
2809               .setPageSize(883849137)
2810               .setPageToken("pageToken873572522")
2811               .setFilter("filter-1274492040")
2812               .setLanguageCode("languageCode-2092349083")
2813               .setShowFutureOffers(true)
2814               .build();
2815       client.listOffers(request);
2816       Assert.fail("No exception raised");
2817     } catch (InvalidArgumentException e) {
2818       // Expected exception.
2819     }
2820   }
2821 
2822   @Test
listPurchasableSkusTest()2823   public void listPurchasableSkusTest() throws Exception {
2824     PurchasableSku responsesElement = PurchasableSku.newBuilder().build();
2825     ListPurchasableSkusResponse expectedResponse =
2826         ListPurchasableSkusResponse.newBuilder()
2827             .setNextPageToken("")
2828             .addAllPurchasableSkus(Arrays.asList(responsesElement))
2829             .build();
2830     mockCloudChannelService.addResponse(expectedResponse);
2831 
2832     ListPurchasableSkusRequest request =
2833         ListPurchasableSkusRequest.newBuilder()
2834             .setCustomer(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
2835             .setPageSize(883849137)
2836             .setPageToken("pageToken873572522")
2837             .setLanguageCode("languageCode-2092349083")
2838             .build();
2839 
2840     ListPurchasableSkusPagedResponse pagedListResponse = client.listPurchasableSkus(request);
2841 
2842     List<PurchasableSku> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2843 
2844     Assert.assertEquals(1, resources.size());
2845     Assert.assertEquals(expectedResponse.getPurchasableSkusList().get(0), resources.get(0));
2846 
2847     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2848     Assert.assertEquals(1, actualRequests.size());
2849     ListPurchasableSkusRequest actualRequest = ((ListPurchasableSkusRequest) actualRequests.get(0));
2850 
2851     Assert.assertEquals(
2852         request.getCreateEntitlementPurchase(), actualRequest.getCreateEntitlementPurchase());
2853     Assert.assertEquals(request.getChangeOfferPurchase(), actualRequest.getChangeOfferPurchase());
2854     Assert.assertEquals(request.getCustomer(), actualRequest.getCustomer());
2855     Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
2856     Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
2857     Assert.assertEquals(request.getLanguageCode(), actualRequest.getLanguageCode());
2858     Assert.assertTrue(
2859         channelProvider.isHeaderSent(
2860             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2861             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2862   }
2863 
2864   @Test
listPurchasableSkusExceptionTest()2865   public void listPurchasableSkusExceptionTest() throws Exception {
2866     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2867     mockCloudChannelService.addException(exception);
2868 
2869     try {
2870       ListPurchasableSkusRequest request =
2871           ListPurchasableSkusRequest.newBuilder()
2872               .setCustomer(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
2873               .setPageSize(883849137)
2874               .setPageToken("pageToken873572522")
2875               .setLanguageCode("languageCode-2092349083")
2876               .build();
2877       client.listPurchasableSkus(request);
2878       Assert.fail("No exception raised");
2879     } catch (InvalidArgumentException e) {
2880       // Expected exception.
2881     }
2882   }
2883 
2884   @Test
listPurchasableOffersTest()2885   public void listPurchasableOffersTest() throws Exception {
2886     PurchasableOffer responsesElement = PurchasableOffer.newBuilder().build();
2887     ListPurchasableOffersResponse expectedResponse =
2888         ListPurchasableOffersResponse.newBuilder()
2889             .setNextPageToken("")
2890             .addAllPurchasableOffers(Arrays.asList(responsesElement))
2891             .build();
2892     mockCloudChannelService.addResponse(expectedResponse);
2893 
2894     ListPurchasableOffersRequest request =
2895         ListPurchasableOffersRequest.newBuilder()
2896             .setCustomer(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
2897             .setPageSize(883849137)
2898             .setPageToken("pageToken873572522")
2899             .setLanguageCode("languageCode-2092349083")
2900             .build();
2901 
2902     ListPurchasableOffersPagedResponse pagedListResponse = client.listPurchasableOffers(request);
2903 
2904     List<PurchasableOffer> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2905 
2906     Assert.assertEquals(1, resources.size());
2907     Assert.assertEquals(expectedResponse.getPurchasableOffersList().get(0), resources.get(0));
2908 
2909     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2910     Assert.assertEquals(1, actualRequests.size());
2911     ListPurchasableOffersRequest actualRequest =
2912         ((ListPurchasableOffersRequest) actualRequests.get(0));
2913 
2914     Assert.assertEquals(
2915         request.getCreateEntitlementPurchase(), actualRequest.getCreateEntitlementPurchase());
2916     Assert.assertEquals(request.getChangeOfferPurchase(), actualRequest.getChangeOfferPurchase());
2917     Assert.assertEquals(request.getCustomer(), actualRequest.getCustomer());
2918     Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
2919     Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
2920     Assert.assertEquals(request.getLanguageCode(), actualRequest.getLanguageCode());
2921     Assert.assertTrue(
2922         channelProvider.isHeaderSent(
2923             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2924             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2925   }
2926 
2927   @Test
listPurchasableOffersExceptionTest()2928   public void listPurchasableOffersExceptionTest() throws Exception {
2929     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2930     mockCloudChannelService.addException(exception);
2931 
2932     try {
2933       ListPurchasableOffersRequest request =
2934           ListPurchasableOffersRequest.newBuilder()
2935               .setCustomer(CustomerName.of("[ACCOUNT]", "[CUSTOMER]").toString())
2936               .setPageSize(883849137)
2937               .setPageToken("pageToken873572522")
2938               .setLanguageCode("languageCode-2092349083")
2939               .build();
2940       client.listPurchasableOffers(request);
2941       Assert.fail("No exception raised");
2942     } catch (InvalidArgumentException e) {
2943       // Expected exception.
2944     }
2945   }
2946 
2947   @Test
registerSubscriberTest()2948   public void registerSubscriberTest() throws Exception {
2949     RegisterSubscriberResponse expectedResponse =
2950         RegisterSubscriberResponse.newBuilder().setTopic("topic110546223").build();
2951     mockCloudChannelService.addResponse(expectedResponse);
2952 
2953     RegisterSubscriberRequest request =
2954         RegisterSubscriberRequest.newBuilder()
2955             .setAccount("account-1177318867")
2956             .setServiceAccount("serviceAccount1079137720")
2957             .build();
2958 
2959     RegisterSubscriberResponse actualResponse = client.registerSubscriber(request);
2960     Assert.assertEquals(expectedResponse, actualResponse);
2961 
2962     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
2963     Assert.assertEquals(1, actualRequests.size());
2964     RegisterSubscriberRequest actualRequest = ((RegisterSubscriberRequest) actualRequests.get(0));
2965 
2966     Assert.assertEquals(request.getAccount(), actualRequest.getAccount());
2967     Assert.assertEquals(request.getServiceAccount(), actualRequest.getServiceAccount());
2968     Assert.assertTrue(
2969         channelProvider.isHeaderSent(
2970             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2971             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2972   }
2973 
2974   @Test
registerSubscriberExceptionTest()2975   public void registerSubscriberExceptionTest() throws Exception {
2976     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2977     mockCloudChannelService.addException(exception);
2978 
2979     try {
2980       RegisterSubscriberRequest request =
2981           RegisterSubscriberRequest.newBuilder()
2982               .setAccount("account-1177318867")
2983               .setServiceAccount("serviceAccount1079137720")
2984               .build();
2985       client.registerSubscriber(request);
2986       Assert.fail("No exception raised");
2987     } catch (InvalidArgumentException e) {
2988       // Expected exception.
2989     }
2990   }
2991 
2992   @Test
unregisterSubscriberTest()2993   public void unregisterSubscriberTest() throws Exception {
2994     UnregisterSubscriberResponse expectedResponse =
2995         UnregisterSubscriberResponse.newBuilder().setTopic("topic110546223").build();
2996     mockCloudChannelService.addResponse(expectedResponse);
2997 
2998     UnregisterSubscriberRequest request =
2999         UnregisterSubscriberRequest.newBuilder()
3000             .setAccount("account-1177318867")
3001             .setServiceAccount("serviceAccount1079137720")
3002             .build();
3003 
3004     UnregisterSubscriberResponse actualResponse = client.unregisterSubscriber(request);
3005     Assert.assertEquals(expectedResponse, actualResponse);
3006 
3007     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
3008     Assert.assertEquals(1, actualRequests.size());
3009     UnregisterSubscriberRequest actualRequest =
3010         ((UnregisterSubscriberRequest) actualRequests.get(0));
3011 
3012     Assert.assertEquals(request.getAccount(), actualRequest.getAccount());
3013     Assert.assertEquals(request.getServiceAccount(), actualRequest.getServiceAccount());
3014     Assert.assertTrue(
3015         channelProvider.isHeaderSent(
3016             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3017             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3018   }
3019 
3020   @Test
unregisterSubscriberExceptionTest()3021   public void unregisterSubscriberExceptionTest() throws Exception {
3022     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3023     mockCloudChannelService.addException(exception);
3024 
3025     try {
3026       UnregisterSubscriberRequest request =
3027           UnregisterSubscriberRequest.newBuilder()
3028               .setAccount("account-1177318867")
3029               .setServiceAccount("serviceAccount1079137720")
3030               .build();
3031       client.unregisterSubscriber(request);
3032       Assert.fail("No exception raised");
3033     } catch (InvalidArgumentException e) {
3034       // Expected exception.
3035     }
3036   }
3037 
3038   @Test
listSubscribersTest()3039   public void listSubscribersTest() throws Exception {
3040     String responsesElement = "responsesElement-318365110";
3041     ListSubscribersResponse expectedResponse =
3042         ListSubscribersResponse.newBuilder()
3043             .setNextPageToken("")
3044             .addAllServiceAccounts(Arrays.asList(responsesElement))
3045             .build();
3046     mockCloudChannelService.addResponse(expectedResponse);
3047 
3048     ListSubscribersRequest request =
3049         ListSubscribersRequest.newBuilder()
3050             .setAccount("account-1177318867")
3051             .setPageSize(883849137)
3052             .setPageToken("pageToken873572522")
3053             .build();
3054 
3055     ListSubscribersPagedResponse pagedListResponse = client.listSubscribers(request);
3056 
3057     List<String> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3058 
3059     Assert.assertEquals(1, resources.size());
3060     Assert.assertEquals(expectedResponse.getServiceAccountsList().get(0), resources.get(0));
3061 
3062     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
3063     Assert.assertEquals(1, actualRequests.size());
3064     ListSubscribersRequest actualRequest = ((ListSubscribersRequest) actualRequests.get(0));
3065 
3066     Assert.assertEquals(request.getAccount(), actualRequest.getAccount());
3067     Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
3068     Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
3069     Assert.assertTrue(
3070         channelProvider.isHeaderSent(
3071             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3072             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3073   }
3074 
3075   @Test
listSubscribersExceptionTest()3076   public void listSubscribersExceptionTest() throws Exception {
3077     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3078     mockCloudChannelService.addException(exception);
3079 
3080     try {
3081       ListSubscribersRequest request =
3082           ListSubscribersRequest.newBuilder()
3083               .setAccount("account-1177318867")
3084               .setPageSize(883849137)
3085               .setPageToken("pageToken873572522")
3086               .build();
3087       client.listSubscribers(request);
3088       Assert.fail("No exception raised");
3089     } catch (InvalidArgumentException e) {
3090       // Expected exception.
3091     }
3092   }
3093 
3094   @Test
listEntitlementChangesTest()3095   public void listEntitlementChangesTest() throws Exception {
3096     EntitlementChange responsesElement = EntitlementChange.newBuilder().build();
3097     ListEntitlementChangesResponse expectedResponse =
3098         ListEntitlementChangesResponse.newBuilder()
3099             .setNextPageToken("")
3100             .addAllEntitlementChanges(Arrays.asList(responsesElement))
3101             .build();
3102     mockCloudChannelService.addResponse(expectedResponse);
3103 
3104     EntitlementName parent = EntitlementName.of("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]");
3105 
3106     ListEntitlementChangesPagedResponse pagedListResponse = client.listEntitlementChanges(parent);
3107 
3108     List<EntitlementChange> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3109 
3110     Assert.assertEquals(1, resources.size());
3111     Assert.assertEquals(expectedResponse.getEntitlementChangesList().get(0), resources.get(0));
3112 
3113     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
3114     Assert.assertEquals(1, actualRequests.size());
3115     ListEntitlementChangesRequest actualRequest =
3116         ((ListEntitlementChangesRequest) actualRequests.get(0));
3117 
3118     Assert.assertEquals(parent.toString(), actualRequest.getParent());
3119     Assert.assertTrue(
3120         channelProvider.isHeaderSent(
3121             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3122             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3123   }
3124 
3125   @Test
listEntitlementChangesExceptionTest()3126   public void listEntitlementChangesExceptionTest() throws Exception {
3127     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3128     mockCloudChannelService.addException(exception);
3129 
3130     try {
3131       EntitlementName parent = EntitlementName.of("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]");
3132       client.listEntitlementChanges(parent);
3133       Assert.fail("No exception raised");
3134     } catch (InvalidArgumentException e) {
3135       // Expected exception.
3136     }
3137   }
3138 
3139   @Test
listEntitlementChangesTest2()3140   public void listEntitlementChangesTest2() throws Exception {
3141     EntitlementChange responsesElement = EntitlementChange.newBuilder().build();
3142     ListEntitlementChangesResponse expectedResponse =
3143         ListEntitlementChangesResponse.newBuilder()
3144             .setNextPageToken("")
3145             .addAllEntitlementChanges(Arrays.asList(responsesElement))
3146             .build();
3147     mockCloudChannelService.addResponse(expectedResponse);
3148 
3149     String parent = "parent-995424086";
3150 
3151     ListEntitlementChangesPagedResponse pagedListResponse = client.listEntitlementChanges(parent);
3152 
3153     List<EntitlementChange> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3154 
3155     Assert.assertEquals(1, resources.size());
3156     Assert.assertEquals(expectedResponse.getEntitlementChangesList().get(0), resources.get(0));
3157 
3158     List<AbstractMessage> actualRequests = mockCloudChannelService.getRequests();
3159     Assert.assertEquals(1, actualRequests.size());
3160     ListEntitlementChangesRequest actualRequest =
3161         ((ListEntitlementChangesRequest) actualRequests.get(0));
3162 
3163     Assert.assertEquals(parent, actualRequest.getParent());
3164     Assert.assertTrue(
3165         channelProvider.isHeaderSent(
3166             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3167             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3168   }
3169 
3170   @Test
listEntitlementChangesExceptionTest2()3171   public void listEntitlementChangesExceptionTest2() throws Exception {
3172     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3173     mockCloudChannelService.addException(exception);
3174 
3175     try {
3176       String parent = "parent-995424086";
3177       client.listEntitlementChanges(parent);
3178       Assert.fail("No exception raised");
3179     } catch (InvalidArgumentException e) {
3180       // Expected exception.
3181     }
3182   }
3183 }
3184