From 74686b7e63cfd31166e6745fa6a81de3082d29a1 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 16 May 2016 12:12:14 +0200 Subject: [PATCH] EsTester verifies that putDocuments() does not fail --- .../src/test/java/org/sonar/server/es/EsTester.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/EsTester.java b/server/sonar-server/src/test/java/org/sonar/server/es/EsTester.java index 6d706d1d775..7c089e869ec 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/es/EsTester.java +++ b/server/sonar-server/src/test/java/org/sonar/server/es/EsTester.java @@ -35,6 +35,7 @@ import org.apache.commons.lang.math.RandomUtils; import org.apache.commons.lang.reflect.ConstructorUtils; import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; import org.elasticsearch.action.bulk.BulkRequestBuilder; +import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -145,7 +146,8 @@ public class EsTester extends ExternalResource { } bulk.add(new IndexRequest(index, type).source(IOUtils.toString(new FileInputStream(file)))); } - bulk.get(); + BulkResponse response = bulk.get(); + assertThat(response.hasFailures()).as(response.buildFailureMessage()).isFalse(); } public void putDocuments(String index, String type, BaseDoc... docs) throws Exception { @@ -153,7 +155,8 @@ public class EsTester extends ExternalResource { for (BaseDoc doc : docs) { bulk.add(new IndexRequest(index, type).source(doc.getFields())); } - bulk.get(); + BulkResponse response = bulk.get(); + assertThat(response.hasFailures()).as(response.buildFailureMessage()).isFalse(); } public void putDocuments(String index, String type, Map... docs) throws Exception { @@ -161,7 +164,8 @@ public class EsTester extends ExternalResource { for (Map doc : docs) { bulk.add(new IndexRequest(index, type).source(doc)); } - bulk.get(); + BulkResponse response = bulk.get(); + assertThat(response.hasFailures()).as(response.buildFailureMessage()).isFalse(); } public long countDocuments(String indexName, String typeName) { -- 2.39.5