camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [camel] branch camel-2.22.x updated: CAMEL-12774 - Camel-elasticsearch-rest: Error during type conversion from type: java.lang.String to the required type: org.elasticsearch.action.update.UpdateRequest
Date Wed, 05 Sep 2018 06:14:02 GMT
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-2.22.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.22.x by this push:
     new a474340  CAMEL-12774 - Camel-elasticsearch-rest: Error during type conversion from
type: java.lang.String to the required type: org.elasticsearch.action.update.UpdateRequest
a474340 is described below

commit a47434000734e384ecee746c7d1e30a3b0c1290f
Author: Andrea Cosentino <ancosen@gmail.com>
AuthorDate: Wed Sep 5 08:00:30 2018 +0200

    CAMEL-12774 - Camel-elasticsearch-rest: Error during type conversion from type: java.lang.String
to the required type: org.elasticsearch.action.update.UpdateRequest
---
 .../converter/ElasticsearchActionRequestConverter.java     |  2 +-
 .../ElasticsearchGetSearchDeleteExistsUpdateTest.java      | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

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 5dfce04..aea664e 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
@@ -59,7 +59,7 @@ public final class ElasticsearchActionRequestConverter {
         } else if (document instanceof Map) {
             updateRequest.doc((Map<String, Object>) document);
         } else if (document instanceof String) {
-            updateRequest.doc((String) document);
+            updateRequest.doc((String) document, XContentFactory.xContent((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 c97064d..be4d98b 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
@@ -270,6 +270,20 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB
         // then
         assertThat(response, notNullValue());
     }
+    
+    @Test
+    public void testStringUpdate() throws Exception {
+        Map<String, String> map = createIndexedData();
+        String indexId = template.requestBody("direct:index", map, String.class);
+        assertNotNull("indexId should be set", indexId);
+
+        String body = "{\"id\" : 1}";
+
+        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);
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {


Mime
View raw message