SearchScroll extends AbstractAction<SearchResult> { @Override public String getRestMethodName() { return this.restMethodName; } protected  SearchScroll(Builder builder); @Override SearchResult createNewElasticSearchResult(String responseBody, int statusCode, String reasonPhrase, Gson gson); @Override String getRestMethodName(); @Override String getPathToResult(); static final String SCROLL_ID; }
@Test public void methodIsGetIfScrollIdIsShort() { String scrollId = Strings.padStart("scrollId", SearchScroll.MAX_SCROLL_ID_LENGTH, 'x'); SearchScroll searchScroll = new SearchScroll.Builder(scrollId, "1m").build(); String uri = searchScroll.getURI(ElasticsearchVersion.UNKNOWN); assertEquals("GET", searchScroll.getRestMethodName()); assertNull(searchScroll.getData(new Gson())); assertTrue(uri.length() < 2000); assertTrue(uri.contains(scrollId)); }
@Test public void methodIsPostIfScrollIdIsLong() { String scrollId = Strings.padStart("scrollId", 2000, 'x'); JsonObject expectedResults = new JsonObject(); expectedResults.addProperty("scroll_id", scrollId); SearchScroll searchScroll = new SearchScroll.Builder(scrollId, "1m").build(); String uri = searchScroll.getURI(ElasticsearchVersion.UNKNOWN); assertEquals("POST", searchScroll.getRestMethodName()); assertEquals(expectedResults.toString(), searchScroll.getData(new Gson())); assertTrue(uri.length() < 2000); assertFalse(uri.contains(scrollId)); }