JestHttpClient extends AbstractJestClient { protected <T extends JestResult> HttpUriRequest prepareRequest(final Action<T> clientRequest, final RequestConfig requestConfig) { String elasticSearchRestUrl = getRequestURL(getNextServer(), clientRequest.getURI(elasticsearchVersion)); HttpUriRequest request = constructHttpMethod(clientRequest.getRestMethodName(), elasticSearchRestUrl, clientRequest.getData(gson), requestConfig); log.debug("Request method={} url={}", clientRequest.getRestMethodName(), elasticSearchRestUrl); for (Entry<String, Object> header : clientRequest.getHeaders().entrySet()) { request.addHeader(header.getKey(), header.getValue().toString()); } return request; }  @Override T execute(Action<T> clientRequest); T execute(Action<T> clientRequest, RequestConfig requestConfig); @Override void executeAsync(final Action<T> clientRequest, final JestResultHandler<? super T> resultHandler); void executeAsync(final Action<T> clientRequest, final JestResultHandler<? super T> resultHandler, final RequestConfig requestConfig); @Override void shutdownClient(); @Override void close(); CloseableHttpClient getHttpClient(); void setHttpClient(CloseableHttpClient httpClient); CloseableHttpAsyncClient getAsyncClient(); void setAsyncClient(CloseableHttpAsyncClient asyncClient); Gson getGson(); void setGson(Gson gson); HttpClientContext getHttpClientContextTemplate(); void setHttpClientContextTemplate(HttpClientContext httpClientContext); void setElasticsearchVersion(ElasticsearchVersion elasticsearchVersion);  }
@SuppressWarnings ("unchecked") @Test public void prepareShouldNotRewriteLongToDoubles() throws IOException { JestHttpClient clientWithMockedHttpClient = (JestHttpClient) new JestClientFactory().getObject(); Sort mockSort = mock(Sort.class); String query = "{\n" + " \"query\": {\n" + " \"bool\" : {\n" + " \"should\" : [\n" + " { \"term\" : { \"id\" : 1234 } },\n" + " { \"term\" : { \"id\" : 567800000000000000000 } }\n" + " ]\n" + " }\n" + " }\n" + "}"; Search search = new Search.Builder(query) .addIndex("twitter") .addType("tweet") .addSort(mockSort) .build(); HttpUriRequest request = clientWithMockedHttpClient.prepareRequest(search, null); HttpEntity entity = ((HttpPost) request).getEntity(); String payload = EntityUtils.toString(entity, Charset.defaultCharset()); assertFalse(payload.contains("1234.0")); assertTrue(payload.contains("1234")); assertFalse(payload.contains("5.678E20")); assertTrue(payload.contains("567800000000000000000")); }