TopicConstantServiceClient implements BackgroundResource { public final TopicConstant getTopicConstant(TopicConstantName resourceName) { GetTopicConstantRequest request = GetTopicConstantRequest.newBuilder() .setResourceName(resourceName == null ? null : resourceName.toString()) .build(); return getTopicConstant(request); } protected  TopicConstantServiceClient(TopicConstantServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  TopicConstantServiceClient(TopicConstantServiceStub stub); static final TopicConstantServiceClient create(); static final TopicConstantServiceClient create(TopicConstantServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final TopicConstantServiceClient create(TopicConstantServiceStub stub); final TopicConstantServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") TopicConstantServiceStub getStub(); final TopicConstant getTopicConstant(TopicConstantName resourceName); final TopicConstant getTopicConstant(String resourceName); final TopicConstant getTopicConstant(GetTopicConstantRequest request); final UnaryCallable<GetTopicConstantRequest, TopicConstant> getTopicConstantCallable(); @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 getTopicConstantTest() { com.google.ads.googleads.v5.services.TopicConstantName resourceName2 = com.google.ads.googleads.v5.services.TopicConstantName.of("[TOPIC_CONSTANT]"); long id = 3355L; com.google.ads.googleads.v5.services.TopicConstantName topicConstantParent = com.google.ads.googleads.v5.services.TopicConstantName.of("[TOPIC_CONSTANT]"); TopicConstant expectedResponse = TopicConstant.newBuilder() .setResourceName(resourceName2.toString()) .setId(id) .setTopicConstantParent(topicConstantParent.toString()) .build(); mockTopicConstantService.addResponse(expectedResponse); TopicConstantName resourceName = TopicConstantName.of("[TOPIC_CONSTANT]"); TopicConstant actualResponse = client.getTopicConstant(resourceName); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockTopicConstantService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetTopicConstantRequest actualRequest = (GetTopicConstantRequest) actualRequests.get(0); Assert.assertEquals(resourceName, TopicConstantName.parse(actualRequest.getResourceName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void getTopicConstantExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockTopicConstantService.addException(exception); try { TopicConstantName resourceName = TopicConstantName.of("[TOPIC_CONSTANT]"); client.getTopicConstant(resourceName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }