HttpRequestRunnable implements Runnable { HttpRequest createHttpRequest() throws IOException { GenericData tokenRequest = new GenericData(); HttpRequestFormatter<RequestT> requestFormatter = getApiMethodDescriptor().getRequestFormatter(); HttpRequestFactory requestFactory; Credentials credentials = getHttpJsonCallOptions().getCredentials(); if (credentials != null) { requestFactory = getHttpTransport().createRequestFactory(new HttpCredentialsAdapter(credentials)); } else { requestFactory = getHttpTransport().createRequestFactory(); } String requestBody = requestFormatter.getRequestBody(getRequest()); HttpContent jsonHttpContent; if (!Strings.isNullOrEmpty(requestBody)) { getJsonFactory().createJsonParser(requestBody).parse(tokenRequest); jsonHttpContent = new JsonHttpContent(getJsonFactory(), tokenRequest) .setMediaType((new HttpMediaType("application/json"))); } else { jsonHttpContent = new EmptyContent(); } GenericUrl url = new GenericUrl(getEndpoint() + requestFormatter.getPath(getRequest())); Map<String, List<String>> queryParams = requestFormatter.getQueryParamNames(getRequest()); for (Entry<String, List<String>> queryParam : queryParams.entrySet()) { if (queryParam.getValue() != null) { url.set(queryParam.getKey(), queryParam.getValue()); } } HttpRequest httpRequest = requestFactory.buildRequest(getApiMethodDescriptor().getHttpMethod(), url, jsonHttpContent); for (HttpJsonHeaderEnhancer enhancer : getHeaderEnhancers()) { enhancer.enhance(httpRequest.getHeaders()); } httpRequest.setParser(new JsonObjectParser(getJsonFactory())); return httpRequest; }  @Override void run();  }
@Test public void testRequestUrl() throws IOException { HttpRequest httpRequest = httpRequestRunnable.createHttpRequest(); Truth.assertThat(httpRequest.getContent()).isInstanceOf(EmptyContent.class); String expectedUrl = ENDPOINT + "name/feline" + "?food=bird&food=mouse&size=small"; Truth.assertThat(httpRequest.getUrl().toString()).isEqualTo(expectedUrl); }