CustomerServiceClient implements BackgroundResource { public final Customer getCustomer(CustomerName resourceName) { GetCustomerRequest request = GetCustomerRequest.newBuilder() .setResourceName(resourceName == null ? null : resourceName.toString()) .build(); return getCustomer(request); } protected  CustomerServiceClient(CustomerServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  CustomerServiceClient(CustomerServiceStub stub); static final CustomerServiceClient create(); static final CustomerServiceClient create(CustomerServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final CustomerServiceClient create(CustomerServiceStub stub); final CustomerServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") CustomerServiceStub getStub(); final Customer getCustomer(CustomerName resourceName); final Customer getCustomer(String resourceName); final Customer getCustomer(GetCustomerRequest request); final UnaryCallable<GetCustomerRequest, Customer> getCustomerCallable(); final MutateCustomerResponse mutateCustomer(
      String customerId, CustomerOperation operation); final MutateCustomerResponse mutateCustomer(MutateCustomerRequest request); final UnaryCallable<MutateCustomerRequest, MutateCustomerResponse> mutateCustomerCallable(); final ListAccessibleCustomersResponse listAccessibleCustomers(
      ListAccessibleCustomersRequest request); final UnaryCallable<ListAccessibleCustomersRequest, ListAccessibleCustomersResponse> listAccessibleCustomersCallable(); final CreateCustomerClientResponse createCustomerClient(
      String customerId, Customer customerClient); final CreateCustomerClientResponse createCustomerClient(
      CreateCustomerClientRequest request); final UnaryCallable<CreateCustomerClientRequest, CreateCustomerClientResponse> createCustomerClientCallable(); @Override final void close(); @Override void shutdown(); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override void shutdownNow(); @Override boolean awaitTermination(long duration, TimeUnit unit);  }
@Test @SuppressWarnings("all") public void getCustomerTest() { com.google.ads.googleads.v5.services.CustomerName resourceName2 = com.google.ads.googleads.v5.services.CustomerName.of("[CUSTOMER]"); long id = 3355L; String descriptiveName = "descriptiveName-2128097762"; String currencyCode = "currencyCode1108728155"; String timeZone = "timeZone36848094"; String trackingUrlTemplate = "trackingUrlTemplate-1611329070"; String finalUrlSuffix = "finalUrlSuffix-1825164662"; boolean autoTaggingEnabled = false; boolean hasPartnersBadge = true; boolean manager = false; boolean testAccount = true; double optimizationScore = -1.69982841E8; Customer expectedResponse = Customer.newBuilder() .setResourceName(resourceName2.toString()) .setId(id) .setDescriptiveName(descriptiveName) .setCurrencyCode(currencyCode) .setTimeZone(timeZone) .setTrackingUrlTemplate(trackingUrlTemplate) .setFinalUrlSuffix(finalUrlSuffix) .setAutoTaggingEnabled(autoTaggingEnabled) .setHasPartnersBadge(hasPartnersBadge) .setManager(manager) .setTestAccount(testAccount) .setOptimizationScore(optimizationScore) .build(); mockCustomerService.addResponse(expectedResponse); CustomerName resourceName = CustomerName.of("[CUSTOMER]"); Customer actualResponse = client.getCustomer(resourceName); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockCustomerService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetCustomerRequest actualRequest = (GetCustomerRequest) actualRequests.get(0); Assert.assertEquals(resourceName, CustomerName.parse(actualRequest.getResourceName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void getCustomerExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockCustomerService.addException(exception); try { CustomerName resourceName = CustomerName.of("[CUSTOMER]"); client.getCustomer(resourceName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }