You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/05/16 08:48:32 UTC

[james-project] 17/23: JAMES-2719 Migrate ES backend tests to ES6 syntax

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

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit eed7a8bd8d45ba8245feac5de406c9fa67b5660e
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Wed May 15 15:51:07 2019 +0700

    JAMES-2719 Migrate ES backend tests to ES6 syntax
---
 .../james/backends/es/v6/DockerElasticSearch.java  |  17 +-
 .../backends/es/v6/DockerElasticSearchRule.java    |   5 -
 .../backends/es/v6/ElasticSearchIndexerTest.java   |  96 +++++-----
 .../backends/es/v6/IndexCreationFactoryTest.java   |   4 +-
 .../backends/es/v6/NodeMappingFactoryTest.java     |  35 ++--
 .../backends/es/v6/search/ScrollIterableTest.java  | 205 ---------------------
 .../es/v6/utils/TestingClientProvider.java         |  37 ----
 7 files changed, 77 insertions(+), 322 deletions(-)

diff --git a/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/DockerElasticSearch.java b/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/DockerElasticSearch.java
index 6e159f7..413e7ef 100644
--- a/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/DockerElasticSearch.java
+++ b/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/DockerElasticSearch.java
@@ -57,13 +57,14 @@ public class DockerElasticSearch {
     }
 
     private static final int ES_HTTP_PORT = 9200;
-    private static final int ES_TCP_PORT = 9300;
 
     private final DockerGenericContainer eSContainer;
 
     public DockerElasticSearch() {
-        this.eSContainer = new DockerGenericContainer(Images.ELASTICSEARCH_2)
-            .withExposedPorts(ES_HTTP_PORT, ES_TCP_PORT)
+        this.eSContainer = new DockerGenericContainer(Images.ELASTICSEARCH_6)
+            .withEnv("discovery.type", "single-node")
+            .withAffinityToContainer()
+            .withExposedPorts(ES_HTTP_PORT)
             .waitingFor(new HostPortWaitStrategy().withRateLimiter(RateLimiters.TWENTIES_PER_SECOND));
     }
 
@@ -81,18 +82,10 @@ public class DockerElasticSearch {
         return eSContainer.getMappedPort(ES_HTTP_PORT);
     }
 
-    public int getTcpPort() {
-        return eSContainer.getMappedPort(ES_TCP_PORT);
-    }
-
     public String getIp() {
         return eSContainer.getHostIp();
     }
 
-    public Host getTcpHost() {
-        return Host.from(getIp(), getTcpPort());
-    }
-
     public Host getHttpHost() {
         return Host.from(getIp(), getHttpPort());
     }
@@ -117,7 +110,7 @@ public class DockerElasticSearch {
 
     public ClientProvider clientProvider() {
         Optional<String> noClusterName = Optional.empty();
-        return ClientProviderImpl.fromHosts(ImmutableList.of(getTcpHost()), noClusterName);
+        return ClientProviderImpl.fromHosts(ImmutableList.of(getHttpHost()), noClusterName);
     }
 
     private ElasticSearchAPI esAPI() {
diff --git a/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/DockerElasticSearchRule.java b/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/DockerElasticSearchRule.java
index c5b19e5..e945e31 100644
--- a/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/DockerElasticSearchRule.java
+++ b/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/DockerElasticSearchRule.java
@@ -19,7 +19,6 @@
 
 package org.apache.james.backends.es.v6;
 
-import org.apache.james.util.Host;
 import org.junit.rules.ExternalResource;
 
 public class DockerElasticSearchRule extends ExternalResource {
@@ -43,8 +42,4 @@ public class DockerElasticSearchRule extends ExternalResource {
     public void awaitForElasticSearch() {
         dockerElasticSearch.awaitForElasticSearch();
     }
-
-    public Host getTcpHost() {
-        return dockerElasticSearch.getTcpHost();
-    }
 }
diff --git a/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/ElasticSearchIndexerTest.java b/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/ElasticSearchIndexerTest.java
index 4346958..fc2219e 100644
--- a/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/ElasticSearchIndexerTest.java
+++ b/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/ElasticSearchIndexerTest.java
@@ -26,9 +26,12 @@ import static org.elasticsearch.index.query.QueryBuilders.termQuery;
 import java.util.concurrent.Executors;
 
 import org.apache.james.util.concurrent.NamedThreadFactory;
+import org.elasticsearch.action.search.SearchRequest;
 import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.client.Client;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestHighLevelClient;
 import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.search.builder.SearchSourceBuilder;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -57,23 +60,24 @@ public class ElasticSearchIndexerTest {
             ALIAS_NAME, TYPE_NAME, MINIMUM_BATCH_SIZE);
     }
 
-    private Client getESClient() {
+    private RestHighLevelClient getESClient() {
         return elasticSearch.clientProvider().get();
     }
 
     @Test
-    public void indexMessageShouldWork() {
+    public void indexMessageShouldWork() throws Exception {
         String messageId = "1";
         String content = "{\"message\": \"trying out Elasticsearch\"}";
         
         testee.index(messageId, content);
         elasticSearch.awaitForElasticSearch();
         
-        try (Client client = getESClient()) {
-            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
-                    .setTypes(TYPE_NAME.getValue())
-                    .setQuery(QueryBuilders.matchQuery("message", "trying"))
-                    .get();
+        try (RestHighLevelClient client = getESClient()) {
+            SearchResponse searchResponse = client.search(
+                new SearchRequest(INDEX_NAME.getValue())
+                    .types(TYPE_NAME.getValue())
+                    .source(new SearchSourceBuilder().query(QueryBuilders.matchQuery("message", "trying"))),
+                RequestOptions.DEFAULT);
             assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
         }
     }
@@ -85,7 +89,7 @@ public class ElasticSearchIndexerTest {
     }
     
     @Test
-    public void updateMessages() {
+    public void updateMessages() throws Exception {
         String messageId = "1";
         String content = "{\"message\": \"trying out Elasticsearch\",\"field\":\"Should be unchanged\"}";
 
@@ -95,19 +99,21 @@ public class ElasticSearchIndexerTest {
         testee.update(ImmutableList.of(new UpdatedRepresentation(messageId, "{\"message\": \"mastering out Elasticsearch\"}")));
         elasticSearch.awaitForElasticSearch();
 
-        try (Client client = getESClient()) {
-            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
-                .setTypes(TYPE_NAME.getValue())
-                .setQuery(QueryBuilders.matchQuery("message", "mastering"))
-                .get();
+        try (RestHighLevelClient client = getESClient()) {
+            SearchResponse searchResponse = client.search(
+                new SearchRequest(INDEX_NAME.getValue())
+                    .types(TYPE_NAME.getValue())
+                    .source(new SearchSourceBuilder().query(QueryBuilders.matchQuery("message", "mastering"))),
+                RequestOptions.DEFAULT);
             assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
         }
 
-        try (Client client = getESClient()) {
-            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
-                .setTypes(TYPE_NAME.getValue())
-                .setQuery(QueryBuilders.matchQuery("field", "unchanged"))
-                .get();
+        try (RestHighLevelClient client = getESClient()) {
+            SearchResponse searchResponse = client.search(
+                new SearchRequest(INDEX_NAME.getValue())
+                    .types(TYPE_NAME.getValue())
+                    .source(new SearchSourceBuilder().query(QueryBuilders.matchQuery("field", "unchanged"))),
+                RequestOptions.DEFAULT);
             assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
         }
     }
@@ -147,11 +153,12 @@ public class ElasticSearchIndexerTest {
         testee.deleteAllMatchingQuery(termQuery("property", "1")).get();
         elasticSearch.awaitForElasticSearch();
         
-        try (Client client = getESClient()) {
-            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
-                    .setTypes(TYPE_NAME.getValue())
-                    .setQuery(QueryBuilders.matchAllQuery())
-                    .get();
+        try (RestHighLevelClient client = getESClient()) {
+            SearchResponse searchResponse = client.search(
+                new SearchRequest(INDEX_NAME.getValue())
+                    .types(TYPE_NAME.getValue())
+                    .source(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery())),
+                RequestOptions.DEFAULT);
             assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(0);
         }
     }
@@ -177,17 +184,18 @@ public class ElasticSearchIndexerTest {
         testee.deleteAllMatchingQuery(termQuery("property", "1")).get();
         elasticSearch.awaitForElasticSearch();
         
-        try (Client client = getESClient()) {
-            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
-                    .setTypes(TYPE_NAME.getValue())
-                    .setQuery(QueryBuilders.matchAllQuery())
-                    .get();
+        try (RestHighLevelClient client = getESClient()) {
+            SearchResponse searchResponse = client.search(
+                new SearchRequest(INDEX_NAME.getValue())
+                    .types(TYPE_NAME.getValue())
+                    .source(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery())),
+                RequestOptions.DEFAULT);
             assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
         }
     }
     
     @Test
-    public void deleteMessage() {
+    public void deleteMessage() throws Exception {
         String messageId = "1:2";
         String content = "{\"message\": \"trying out Elasticsearch\"}";
 
@@ -197,17 +205,18 @@ public class ElasticSearchIndexerTest {
         testee.delete(ImmutableList.of(messageId));
         elasticSearch.awaitForElasticSearch();
         
-        try (Client client = getESClient()) {
-            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
-                    .setTypes(TYPE_NAME.getValue())
-                    .setQuery(QueryBuilders.matchAllQuery())
-                    .get();
+        try (RestHighLevelClient client = getESClient()) {
+            SearchResponse searchResponse = client.search(
+                new SearchRequest(INDEX_NAME.getValue())
+                    .types(TYPE_NAME.getValue())
+                    .source(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery())),
+                RequestOptions.DEFAULT);
             assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(0);
         }
     }
 
     @Test
-    public void deleteShouldWorkWhenMultipleMessages() {
+    public void deleteShouldWorkWhenMultipleMessages() throws Exception {
         String messageId = "1:1";
         String content = "{\"message\": \"trying out Elasticsearch\", \"mailboxId\":\"1\"}";
 
@@ -227,22 +236,23 @@ public class ElasticSearchIndexerTest {
         testee.delete(ImmutableList.of(messageId, messageId3));
         elasticSearch.awaitForElasticSearch();
 
-        try (Client client = getESClient()) {
-            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
-                .setTypes(TYPE_NAME.getValue())
-                .setQuery(QueryBuilders.matchAllQuery())
-                .get();
+        try (RestHighLevelClient client = getESClient()) {
+            SearchResponse searchResponse = client.search(
+                new SearchRequest(INDEX_NAME.getValue())
+                    .types(TYPE_NAME.getValue())
+                    .source(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery())),
+                RequestOptions.DEFAULT);
             assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
         }
     }
     
     @Test
-    public void updateMessagesShouldNotThrowWhenEmptyList() {
+    public void updateMessagesShouldNotThrowWhenEmptyList() throws Exception {
         testee.update(ImmutableList.of());
     }
     
     @Test
-    public void deleteMessagesShouldNotThrowWhenEmptyList() {
+    public void deleteMessagesShouldNotThrowWhenEmptyList() throws Exception {
         testee.delete(ImmutableList.of());
     }
 }
diff --git a/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/IndexCreationFactoryTest.java b/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/IndexCreationFactoryTest.java
index a5417eb..4f1efd3 100644
--- a/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/IndexCreationFactoryTest.java
+++ b/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/IndexCreationFactoryTest.java
@@ -26,8 +26,8 @@ import org.junit.Rule;
 import org.junit.Test;
 
 public class IndexCreationFactoryTest {
-    public static final IndexName INDEX_NAME = new IndexName("index");
-    public static final ReadAliasName ALIAS_NAME = new ReadAliasName("alias");
+    private static final IndexName INDEX_NAME = new IndexName("index");
+    private static final ReadAliasName ALIAS_NAME = new ReadAliasName("alias");
 
     @Rule
     public DockerElasticSearchRule elasticSearch = new DockerElasticSearchRule();
diff --git a/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/NodeMappingFactoryTest.java b/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/NodeMappingFactoryTest.java
index bcbefef..95207ff 100644
--- a/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/NodeMappingFactoryTest.java
+++ b/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/NodeMappingFactoryTest.java
@@ -19,18 +19,20 @@
 
 package org.apache.james.backends.es.v6;
 
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
 
+import org.elasticsearch.ElasticsearchStatusException;
 import org.elasticsearch.common.xcontent.XContentBuilder;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
 public class NodeMappingFactoryTest {
-    public static final String MESSAGE = "message";
-    public static final IndexName INDEX_NAME = new IndexName("index");
-    public static final ReadAliasName ALIAS_NAME = new ReadAliasName("alias");
-    public static final TypeName TYPE_NAME = new TypeName("type");
+    private static final String MESSAGE = "message";
+    private static final IndexName INDEX_NAME = new IndexName("index");
+    private static final ReadAliasName ALIAS_NAME = new ReadAliasName("alias");
+    private static final TypeName TYPE_NAME = new TypeName("type");
 
     @Rule
     public DockerElasticSearchRule elasticSearch = new DockerElasticSearchRule();
@@ -58,7 +60,7 @@ public class NodeMappingFactoryTest {
     }
 
     @Test
-    public void applyMappingShouldNotThrowWhenIndexerChanges() throws Exception {
+    public void applyMappingShouldThrowWhenTryingIndexerChanges() throws Exception {
         NodeMappingFactory.applyMapping(clientProvider.get(),
             INDEX_NAME,
             TYPE_NAME,
@@ -66,20 +68,19 @@ public class NodeMappingFactoryTest {
 
         elasticSearch.awaitForElasticSearch();
 
-        NodeMappingFactory.applyMapping(clientProvider.get(),
+        assertThatThrownBy(() ->NodeMappingFactory.applyMapping(clientProvider.get(),
             INDEX_NAME,
             TYPE_NAME,
-            getOtherMappingsSources());
+            getOtherMappingsSources()))
+        .isInstanceOf(ElasticsearchStatusException.class);
     }
 
     private XContentBuilder getMappingsSources() throws Exception {
         return jsonBuilder()
             .startObject()
-                .startObject(TYPE_NAME.getValue())
-                    .startObject(NodeMappingFactory.PROPERTIES)
-                        .startObject(MESSAGE)
-                            .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
-                        .endObject()
+                .startObject(NodeMappingFactory.PROPERTIES)
+                    .startObject(MESSAGE)
+                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.TEXT)
                     .endObject()
                 .endObject()
             .endObject();
@@ -88,12 +89,10 @@ public class NodeMappingFactoryTest {
     private XContentBuilder getOtherMappingsSources() throws Exception {
         return jsonBuilder()
             .startObject()
-                .startObject(TYPE_NAME.getValue())
-                    .startObject(NodeMappingFactory.PROPERTIES)
-                        .startObject(MESSAGE)
-                            .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
-                            .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
-                        .endObject()
+                .startObject(NodeMappingFactory.PROPERTIES)
+                    .startObject(MESSAGE)
+                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.TEXT)
+                        .field(NodeMappingFactory.INDEX, false)
                     .endObject()
                 .endObject()
             .endObject();
diff --git a/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/search/ScrollIterableTest.java b/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/search/ScrollIterableTest.java
deleted file mode 100644
index 4810975..0000000
--- a/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/search/ScrollIterableTest.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.backends.es.v6.search;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.awaitility.Awaitility.await;
-import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import org.apache.james.backends.es.v6.ClientProvider;
-import org.apache.james.backends.es.v6.DockerElasticSearchRule;
-import org.apache.james.backends.es.v6.ElasticSearchConfiguration;
-import org.apache.james.backends.es.v6.IndexCreationFactory;
-import org.apache.james.backends.es.v6.IndexName;
-import org.apache.james.backends.es.v6.NodeMappingFactory;
-import org.apache.james.backends.es.v6.ReadAliasName;
-import org.apache.james.backends.es.v6.TypeName;
-import org.awaitility.Duration;
-import org.awaitility.core.ConditionFactory;
-import org.elasticsearch.action.search.SearchRequestBuilder;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.search.SearchHit;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class ScrollIterableTest {
-
-    private static final TimeValue TIMEOUT = new TimeValue(6000);
-    private static final int SIZE = 2;
-    private static final String MESSAGE = "message";
-    private static final IndexName INDEX_NAME = new IndexName("index");
-    private static final ReadAliasName ALIAS_NAME = new ReadAliasName("alias");
-    private static final TypeName TYPE_NAME = new TypeName("messages");
-
-    private static final ConditionFactory WAIT_CONDITION = await().timeout(Duration.FIVE_SECONDS);
-
-    @Rule
-    public DockerElasticSearchRule elasticSearch = new DockerElasticSearchRule();
-    private ClientProvider clientProvider;
-
-    @Before
-    public void setUp() throws Exception {
-        clientProvider = elasticSearch.clientProvider();
-        new IndexCreationFactory(ElasticSearchConfiguration.DEFAULT_CONFIGURATION)
-            .useIndex(INDEX_NAME)
-            .addAlias(ALIAS_NAME)
-            .createIndexAndAliases(clientProvider.get());
-        elasticSearch.awaitForElasticSearch();
-        NodeMappingFactory.applyMapping(clientProvider.get(), INDEX_NAME, TYPE_NAME, getMappingsSources());
-    }
-
-    private XContentBuilder getMappingsSources() throws IOException {
-        return jsonBuilder()
-            .startObject()
-                .startObject(TYPE_NAME.getValue())
-                    .startObject(NodeMappingFactory.PROPERTIES)
-                        .startObject(MESSAGE)
-                            .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
-                        .endObject()
-                    .endObject()
-                .endObject()
-            .endObject();
-    }
-
-    @Test
-    public void scrollIterableShouldWorkWhenEmpty() {
-        try (Client client = clientProvider.get()) {
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME.getValue())
-                .setTypes(TYPE_NAME.getValue())
-                .setScroll(TIMEOUT)
-                .setQuery(matchAllQuery())
-                .setSize(SIZE);
-
-            assertThat(new ScrollIterable(client, searchRequestBuilder))
-                .isEmpty();
-        }
-    }
-
-    @Test
-    public void scrollIterableShouldWorkWhenOneElement() {
-        try (Client client = clientProvider.get()) {
-            String id = "1";
-            client.prepareIndex(INDEX_NAME.getValue(), TYPE_NAME.getValue(), id)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            elasticSearch.awaitForElasticSearch();
-            WAIT_CONDITION.untilAsserted(() -> hasIdsInIndex(client, id));
-
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME.getValue())
-                .setTypes(TYPE_NAME.getValue())
-                .setScroll(TIMEOUT)
-                .setQuery(matchAllQuery())
-                .setSize(SIZE);
-
-            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder)))
-                .containsOnly(id);
-        }
-    }
-
-    @Test
-    public void scrollIterableShouldWorkWhenSizeElement() {
-        try (Client client = clientProvider.get()) {
-            String id1 = "1";
-            client.prepareIndex(INDEX_NAME.getValue(), TYPE_NAME.getValue(), id1)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            String id2 = "2";
-            client.prepareIndex(INDEX_NAME.getValue(), TYPE_NAME.getValue(), id2)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            elasticSearch.awaitForElasticSearch();
-            WAIT_CONDITION.untilAsserted(() -> hasIdsInIndex(client, id1, id2));
-
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME.getValue())
-                .setTypes(TYPE_NAME.getValue())
-                .setScroll(TIMEOUT)
-                .setQuery(matchAllQuery())
-                .setSize(SIZE);
-
-            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder)))
-                .containsOnly(id1, id2);
-        }
-    }
-
-    @Test
-    public void scrollIterableShouldWorkWhenMoreThanSizeElement() {
-        try (Client client = clientProvider.get()) {
-            String id1 = "1";
-            client.prepareIndex(INDEX_NAME.getValue(), TYPE_NAME.getValue(), id1)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            String id2 = "2";
-            client.prepareIndex(INDEX_NAME.getValue(), TYPE_NAME.getValue(), id2)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            String id3 = "3";
-            client.prepareIndex(INDEX_NAME.getValue(), TYPE_NAME.getValue(), id3)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            elasticSearch.awaitForElasticSearch();
-            WAIT_CONDITION.untilAsserted(() -> hasIdsInIndex(client, id1, id2, id3));
-
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME.getValue())
-                .setTypes(TYPE_NAME.getValue())
-                .setScroll(TIMEOUT)
-                .setQuery(matchAllQuery())
-                .setSize(SIZE);
-
-            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder)))
-                .containsOnly(id1, id2, id3);
-        }
-    }
-
-    private List<String> convertToIdList(ScrollIterable scrollIterable) {
-        return scrollIterable.stream()
-            .flatMap(searchResponse -> Arrays.stream(searchResponse.getHits().getHits()))
-            .map(SearchHit::getId)
-            .collect(Collectors.toList());
-    }
-
-    private void hasIdsInIndex(Client client, String... ids) {
-        SearchHit[] hits = client.prepareSearch(INDEX_NAME.getValue())
-            .setQuery(QueryBuilders.idsQuery(TYPE_NAME.getValue()).addIds(ids))
-            .execute()
-            .actionGet()
-            .getHits()
-            .hits();
-
-        assertThat(hits)
-            .extracting(SearchHit::getId)
-            .contains(ids);
-    }
-}
diff --git a/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/utils/TestingClientProvider.java b/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/utils/TestingClientProvider.java
deleted file mode 100644
index 967b80e..0000000
--- a/backends-common/elasticsearch-v6/src/test/java/org/apache/james/backends/es/v6/utils/TestingClientProvider.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.backends.es.v6.utils;
-
-import org.apache.james.backends.es.v6.ClientProvider;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.node.Node;
-
-public class TestingClientProvider implements ClientProvider {
-
-    private final Node node;
-
-    public TestingClientProvider(Node node) {
-        this.node = node;
-    }
-    
-    @Override
-    public Client get() {
-        return node.client();
-    }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org