@Test
public void sourceFilteringByQueryTest() {

    String query = "{\"sort\":[],\"_source\":{\"exclude\":[\"excludeFieldName\"],\"include\":[\"includeFieldName\"]}}";
    Action search = new Search.Builder(query).build();
    JsonParser parser = new JsonParser();
    JsonElement parsed = parser.parse(search.getData(new Gson()).toString());
    JsonObject obj = parsed.getAsJsonObject();
    JsonObject source = obj.getAsJsonObject("_source");
    JsonArray includePattern = source.getAsJsonArray("include");
    assertEquals(1, includePattern.size());
    assertEquals("includeFieldName", includePattern.get(0).getAsString());
    JsonArray excludePattern = source.getAsJsonArray("exclude");
    assertEquals(1, excludePattern.size());
    assertEquals("excludeFieldName", excludePattern.get(0).getAsString());
}