KeywordPlanIdeaServiceClient implements BackgroundResource { public final GenerateKeywordIdeasPagedResponse generateKeywordIdeas( GenerateKeywordIdeasRequest request) { return generateKeywordIdeasPagedCallable().call(request); } protected  KeywordPlanIdeaServiceClient(KeywordPlanIdeaServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  KeywordPlanIdeaServiceClient(KeywordPlanIdeaServiceStub stub); static final KeywordPlanIdeaServiceClient create(); static final KeywordPlanIdeaServiceClient create(KeywordPlanIdeaServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final KeywordPlanIdeaServiceClient create(KeywordPlanIdeaServiceStub stub); final KeywordPlanIdeaServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") KeywordPlanIdeaServiceStub getStub(); final GenerateKeywordIdeasPagedResponse generateKeywordIdeas(
      GenerateKeywordIdeasRequest request); final UnaryCallable<GenerateKeywordIdeasRequest, GenerateKeywordIdeasPagedResponse> generateKeywordIdeasPagedCallable(); final UnaryCallable<GenerateKeywordIdeasRequest, GenerateKeywordIdeaResponse> generateKeywordIdeasCallable(); @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 generateKeywordIdeasTest() { String nextPageToken = ""; long totalSize = 705419236L; GenerateKeywordIdeaResult resultsElement = GenerateKeywordIdeaResult.newBuilder().build(); List<GenerateKeywordIdeaResult> results = Arrays.asList(resultsElement); GenerateKeywordIdeaResponse expectedResponse = GenerateKeywordIdeaResponse.newBuilder() .setNextPageToken(nextPageToken) .setTotalSize(totalSize) .addAllResults(results) .build(); mockKeywordPlanIdeaService.addResponse(expectedResponse); StringValue language = StringValue.newBuilder().build(); GenerateKeywordIdeasRequest request = GenerateKeywordIdeasRequest.newBuilder().setLanguage(language).build(); GenerateKeywordIdeasPagedResponse pagedListResponse = client.generateKeywordIdeas(request); List<GenerateKeywordIdeaResult> resources = Lists.newArrayList(pagedListResponse.iterateAll()); Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getResultsList().get(0), resources.get(0)); List<AbstractMessage> actualRequests = mockKeywordPlanIdeaService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GenerateKeywordIdeasRequest actualRequest = (GenerateKeywordIdeasRequest) actualRequests.get(0); Assert.assertEquals(language, actualRequest.getLanguage()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void generateKeywordIdeasExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockKeywordPlanIdeaService.addException(exception); try { StringValue language = StringValue.newBuilder().build(); GenerateKeywordIdeasRequest request = GenerateKeywordIdeasRequest.newBuilder().setLanguage(language).build(); client.generateKeywordIdeas(request); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }