@SuppressWarnings ("unchecked")
@Test
public void prepareShouldNotRewriteLongToDoubles() throws IOException {

    // Construct a new Jest client according to configuration via factory
    JestHttpClient clientWithMockedHttpClient = (JestHttpClient) new JestClientFactory().getObject();
    // Construct mock Sort
    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)
            // multiple index or types can be added.
            .addIndex("twitter")
            .addType("tweet")
            .addSort(mockSort)
            .build();
    // Create HttpUriRequest
    HttpUriRequest request = clientWithMockedHttpClient.prepareRequest(search, null);
    // Extract Payload
    HttpEntity entity = ((HttpPost) request).getEntity();
    String payload = EntityUtils.toString(entity, Charset.defaultCharset());
    // Verify payload does not have a double
    assertFalse(payload.contains("1234.0"));
    assertTrue(payload.contains("1234"));
    // Verify payload does not use scientific notation
    assertFalse(payload.contains("5.678E20"));
    assertTrue(payload.contains("567800000000000000000"));
}