### Question:
EsFilterResult implements FilterResult { @Override public String getNextToken() { final int currentFrom = queryNode.has("from") ? queryNode.get("from").asInt() : 0; final int size = queryNode.get("size").asInt(); final int nextFrom = currentFrom + size; if (getTotal() > nextFrom) { return "" + nextFrom; } return null; } EsFilterResult(JsonNode queryNode, JsonNode resultNode);  EsFilterResult(JsonNode queryNode, JsonNode resultNode, String idField); @Override List<String> getUriList(); @Override String getNextToken(); @Override String getPrevToken(); @Override int getTotal(); void findFacets(Facet facet, ObjectNode data); @Override List<Facet> getFacets(); final String idField; }### Answer:
@Test public void getNextTokenReturnsATokenWhenTheSizePlusTheCurrentFromAreLessThanTheTotal() { final ObjectNode queryNode = jsnO("from", jsn(0), "size", jsn(10)); final ObjectNode resultNode = jsnO("hits", jsnO("total", jsn(20))); final EsFilterResult instance = new EsFilterResult(queryNode, resultNode); final String nextToken = instance.getNextToken(); assertThat(nextToken, is(notNullValue())); }
@Test public void getNextTokenReturnsNoTokenWhenTheSizePlusTheCurrentFromAreMoreThanTheTotal() { final ObjectNode queryNode = jsnO("from", jsn(15), "size", jsn(10)); final ObjectNode resultNode = jsnO("hits", jsnO("total", jsn(20))); final EsFilterResult instance = new EsFilterResult(queryNode, resultNode); final String nextToken = instance.getNextToken(); assertThat(nextToken, is(nullValue())); }
@Test public void getNextTokenReturnsNoTokenWhenTheSizePlusTheCurrentFromAreEqualToTheTotal() { final ObjectNode queryNode = jsnO("from", jsn(10), "size", jsn(10)); final ObjectNode resultNode = jsnO("hits", jsnO("total", jsn(20))); final EsFilterResult instance = new EsFilterResult(queryNode, resultNode); final String nextToken = instance.getNextToken(); assertThat(nextToken, is(nullValue())); }