ElasticResponse { public int getNumHits() { final int numHits; if (results != null) { numHits = results.getHits().size(); } else { numHits = 0; } return numHits; }  ElasticResults getResults(); Map<String,ElasticAggregation> getAggregations(); String getScrollId(); @JsonIgnore List<ElasticHit> getHits(); int getNumHits(); long getTotalNumHits(); float getMaxScore(); @Override String toString();  }
@Test public void getNumHits() throws IOException { ElasticResponse response = mapper.readValue("{\"hits\":{\"hits\":[{},{},{}]}}", ElasticResponse.class); assertEquals(3, response.getNumHits()); }