AbstractAction implements Action<T> { protected String buildURI(ElasticsearchVersion elasticsearchVersion) { StringBuilder sb = new StringBuilder(); try { if (StringUtils.isNotBlank(indexName)) { sb.append(URLEncoder.encode(indexName, CHARSET)); String commandExtension = getURLCommandExtension(elasticsearchVersion); if (StringUtils.isNotBlank(commandExtension)) { sb.append("/").append(URLEncoder.encode(commandExtension, CHARSET)); } if (StringUtils.isNotBlank(typeName)) { sb.append("/").append(URLEncoder.encode(typeName, CHARSET)); } } } catch (UnsupportedEncodingException e) { log.error("Error occurred while adding index/type to uri", e); } return sb.toString(); } AbstractAction(); @SuppressWarnings("unchecked")  AbstractAction(Builder builder); static String getIdFromSource(Object source); Collection<Object> getParameter(String parameter); Object getHeader(String header); @Override Map<String, Object> getHeaders(); @Override String getURI(ElasticsearchVersion elasticsearchVersion); @Override String getData(Gson gson); @Override String getPathToResult(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); abstract String getRestMethodName(); static String CHARSET; }
@Test public void buildRestUrlWithValidParameters() { String expected = "twitter/tweet/1"; final Delete build = new Delete.Builder("1").index("twitter").type("tweet").build(); String actual = build.buildURI(ElasticsearchVersion.UNKNOWN); assertEquals(expected, actual); }