This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch sandbox/camel-3.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit a42e973b98921cd0fb25811f4d29f5ae38885e7c Author: Andrea Cosentino <[email protected]> AuthorDate: Tue Nov 20 14:38:30 2018 +0100 CAMEL-12774 - Error during type conversion from type: java.lang.String to the required type: org.elasticsearch.action.update.UpdateRequest - Take 2 --- .../converter/ElasticsearchActionRequestConverter.java | 2 +- .../elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java index 1347219..6572c96 100644 --- a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java +++ b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java @@ -61,7 +61,7 @@ public final class ElasticsearchActionRequestConverter { } else if (document instanceof Map) { updateRequest.doc((Map<String, Object>) document); } else if (document instanceof String) { - updateRequest.doc(XContentFactory.xContent((String) document), (String) document); + updateRequest.doc((String) document, XContentFactory.xContentType((String) document)); } else if (document instanceof XContentBuilder) { updateRequest.doc((XContentBuilder) document); } else { diff --git a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java index 96e994f..161e629 100644 --- a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java +++ b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java @@ -49,6 +49,7 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB GetResponse response = template.requestBody("direct:get", indexId, GetResponse.class); assertNotNull("response should not be null", response); assertNotNull("response source should not be null", response.getSource()); + System.err.println(response.getSource()); } @Test @@ -303,12 +304,15 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB String indexId = template.requestBody("direct:index", map, String.class); assertNotNull("indexId should be set", indexId); - String body = "{\"id\" : 1}"; + String body = "{\"teststringupdate-key\" : \"teststringupdate-updated\"}"; Map<String, Object> headers = new HashMap<>(); headers.put(ElasticsearchConstants.PARAM_INDEX_ID, indexId); indexId = template.requestBodyAndHeaders("direct:update", body, headers, String.class); assertNotNull("indexId should be set", indexId); + + GetResponse response = template.requestBody("direct:get", indexId, GetResponse.class); + assertEquals("teststringupdate-updated", response.getSource().get("teststringupdate-key")); } @Override
