UserInterestServiceClient implements BackgroundResource { public final UserInterest getUserInterest(UserInterestName resourceName) { GetUserInterestRequest request = GetUserInterestRequest.newBuilder() .setResourceName(resourceName == null ? null : resourceName.toString()) .build(); return getUserInterest(request); } protected  UserInterestServiceClient(UserInterestServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  UserInterestServiceClient(UserInterestServiceStub stub); static final UserInterestServiceClient create(); static final UserInterestServiceClient create(UserInterestServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final UserInterestServiceClient create(UserInterestServiceStub stub); final UserInterestServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") UserInterestServiceStub getStub(); final UserInterest getUserInterest(UserInterestName resourceName); final UserInterest getUserInterest(String resourceName); final UserInterest getUserInterest(GetUserInterestRequest request); final UnaryCallable<GetUserInterestRequest, UserInterest> getUserInterestCallable(); @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 getUserInterestTest() { com.google.ads.googleads.v5.services.UserInterestName resourceName2 = com.google.ads.googleads.v5.services.UserInterestName.of("[CUSTOMER]", "[USER_INTEREST]"); UserInterest expectedResponse = UserInterest.newBuilder().setResourceName(resourceName2.toString()).build(); mockUserInterestService.addResponse(expectedResponse); UserInterestName resourceName = UserInterestName.of("[CUSTOMER]", "[USER_INTEREST]"); UserInterest actualResponse = client.getUserInterest(resourceName); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockUserInterestService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetUserInterestRequest actualRequest = (GetUserInterestRequest) actualRequests.get(0); Assert.assertEquals(resourceName, UserInterestName.parse(actualRequest.getResourceName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void getUserInterestExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockUserInterestService.addException(exception); try { UserInterestName resourceName = UserInterestName.of("[CUSTOMER]", "[USER_INTEREST]"); client.getUserInterest(resourceName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }