DistanceViewServiceClient implements BackgroundResource { public final DistanceView getDistanceView(DistanceViewName resourceName) { GetDistanceViewRequest request = GetDistanceViewRequest.newBuilder() .setResourceName(resourceName == null ? null : resourceName.toString()) .build(); return getDistanceView(request); } protected  DistanceViewServiceClient(DistanceViewServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  DistanceViewServiceClient(DistanceViewServiceStub stub); static final DistanceViewServiceClient create(); static final DistanceViewServiceClient create(DistanceViewServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final DistanceViewServiceClient create(DistanceViewServiceStub stub); final DistanceViewServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") DistanceViewServiceStub getStub(); final DistanceView getDistanceView(DistanceViewName resourceName); final DistanceView getDistanceView(String resourceName); final DistanceView getDistanceView(GetDistanceViewRequest request); final UnaryCallable<GetDistanceViewRequest, DistanceView> getDistanceViewCallable(); @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 getDistanceViewTest() { com.google.ads.googleads.v5.services.DistanceViewName resourceName2 = com.google.ads.googleads.v5.services.DistanceViewName.of("[CUSTOMER]", "[DISTANCE_VIEW]"); boolean metricSystem = true; DistanceView expectedResponse = DistanceView.newBuilder() .setResourceName(resourceName2.toString()) .setMetricSystem(metricSystem) .build(); mockDistanceViewService.addResponse(expectedResponse); DistanceViewName resourceName = DistanceViewName.of("[CUSTOMER]", "[DISTANCE_VIEW]"); DistanceView actualResponse = client.getDistanceView(resourceName); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockDistanceViewService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetDistanceViewRequest actualRequest = (GetDistanceViewRequest) actualRequests.get(0); Assert.assertEquals(resourceName, DistanceViewName.parse(actualRequest.getResourceName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void getDistanceViewExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockDistanceViewService.addException(exception); try { DistanceViewName resourceName = DistanceViewName.of("[CUSTOMER]", "[DISTANCE_VIEW]"); client.getDistanceView(resourceName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }