You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/04/04 13:42:20 UTC

[camel] branch camel-2.21.x updated (76d64a8 -> 1726041)

This is an automated email from the ASF dual-hosted git repository.

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


    from 76d64a8  Add XML schema references for release 2.20.3
     new b7ab8f5  CAMEL-12419 - camel-elasticsearch-rest, return the complete bulk index item response to the exchange body
     new 1726041  CAMEL-12419 - Fixed CS

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../component/elasticsearch/ElasticsearchProducer.java      | 11 ++---------
 .../component/elasticsearch/ElasticsearchBulkTest.java      | 13 ++++++-------
 2 files changed, 8 insertions(+), 16 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
acosentino@apache.org.

[camel] 02/02: CAMEL-12419 - Fixed CS

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1726041e8d54968db5b63465560f6e4659f4e908
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Apr 4 15:39:41 2018 +0200

    CAMEL-12419 - Fixed CS
---
 .../apache/camel/component/elasticsearch/ElasticsearchBulkTest.java    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBulkTest.java b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBulkTest.java
index 6d3e112..780c30a 100644
--- a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBulkTest.java
+++ b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBulkTest.java
@@ -24,9 +24,10 @@ import org.apache.camel.builder.RouteBuilder;
 import org.elasticsearch.action.bulk.BulkItemResponse;
 import org.elasticsearch.action.bulk.BulkRequest;
 import org.elasticsearch.action.index.IndexRequest;
+import org.junit.Test;
+
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import org.junit.Test;
 
 public class ElasticsearchBulkTest extends ElasticsearchBaseTest {
 

-- 
To stop receiving notification emails like this one, please contact
acosentino@apache.org.

[camel] 01/02: CAMEL-12419 - camel-elasticsearch-rest, return the complete bulk index item response to the exchange body

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b7ab8f553a71269318c844840b12ba0d09234704
Author: lboutros@jouve.com <lb...@jouve.com>
AuthorDate: Wed Apr 4 15:04:35 2018 +0200

    CAMEL-12419 - camel-elasticsearch-rest, return the complete bulk index item response to the exchange body
---
 .../component/elasticsearch/ElasticsearchProducer.java   | 11 ++---------
 .../component/elasticsearch/ElasticsearchBulkTest.java   | 16 +++++++---------
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java
index 349a63a..8a224bd 100644
--- a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java
+++ b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java
@@ -18,11 +18,8 @@ package org.apache.camel.component.elasticsearch;
 
 import java.lang.reflect.InvocationTargetException;
 import java.net.UnknownHostException;
-import java.util.Arrays;
 import java.util.Collections;
-import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
@@ -36,7 +33,6 @@ import org.apache.http.client.CredentialsProvider;
 import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.elasticsearch.ElasticsearchStatusException;
 import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
-import org.elasticsearch.action.bulk.BulkItemResponse;
 import org.elasticsearch.action.bulk.BulkRequest;
 import org.elasticsearch.action.delete.DeleteRequest;
 import org.elasticsearch.action.get.GetRequest;
@@ -171,10 +167,7 @@ public class ElasticsearchProducer extends DefaultProducer {
             message.setBody(restHighLevelClient.bulk(bulkRequest).getItems());
         } else if (operation == ElasticsearchOperation.BulkIndex) {
             BulkRequest bulkRequest = ElasticsearchActionRequestConverter.toBulkRequest(message.getBody(), exchange);
-            List<String> indexedIds = Arrays.stream(restHighLevelClient.bulk(bulkRequest).getItems())
-                .map(BulkItemResponse::getId)
-                .collect(Collectors.toList());
-            message.setBody(indexedIds);
+            message.setBody(restHighLevelClient.bulk(bulkRequest).getItems());
         } else if (operation == ElasticsearchOperation.Delete) {
             DeleteRequest deleteRequest = ElasticsearchActionRequestConverter.toDeleteRequest(message.getBody(), exchange);
             message.setBody(restHighLevelClient.delete(deleteRequest).getResult());
@@ -303,4 +296,4 @@ public class ElasticsearchProducer extends DefaultProducer {
             super(restClient, (client) -> { }, Collections.emptyList());
         }
     }
-}
\ No newline at end of file
+}
diff --git a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBulkTest.java b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBulkTest.java
index 75a2a8a..6d3e112 100644
--- a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBulkTest.java
+++ b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBulkTest.java
@@ -20,22 +20,19 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-
 import org.apache.camel.builder.RouteBuilder;
 import org.elasticsearch.action.bulk.BulkItemResponse;
 import org.elasticsearch.action.bulk.BulkRequest;
 import org.elasticsearch.action.index.IndexRequest;
-import org.junit.Test;
-
 import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.hasItem;
 import static org.hamcrest.CoreMatchers.notNullValue;
+import org.junit.Test;
 
 public class ElasticsearchBulkTest extends ElasticsearchBaseTest {
 
     @Test
     public void testBulkIndex() throws Exception {
-        List<Map<String, String>> documents = new ArrayList<Map<String, String>>();
+        List<Map<String, String>> documents = new ArrayList<>();
         Map<String, String> document1 = createIndexedData("1");
         Map<String, String> document2 = createIndexedData("2");
 
@@ -76,12 +73,13 @@ public class ElasticsearchBulkTest extends ElasticsearchBaseTest {
 
         // when
         @SuppressWarnings("unchecked")
-        List<String> indexedDocumentIds = template.requestBody("direct:bulk_index", request, List.class);
+        BulkItemResponse[] response = template.requestBody("direct:bulk_index", request, BulkItemResponse[].class);
 
         // then
-        assertThat(indexedDocumentIds, notNullValue());
-        assertThat(indexedDocumentIds.size(), equalTo(1));
-        assertThat(indexedDocumentIds, hasItem(prefix + "baz"));
+        assertThat(response, notNullValue());
+        assertThat(response.length, equalTo(1));
+        assertThat(response[0].isFailed(), equalTo(false));
+        assertThat(response[0].getId(), equalTo(prefix + "baz"));
     }
 
     @Test

-- 
To stop receiving notification emails like this one, please contact
acosentino@apache.org.