From bf8241eec5478c7dd6bf1ac3b5f33d8724056626 Mon Sep 17 00:00:00 2001 From: David Pilato Date: Mon, 20 Feb 2017 10:33:19 +0100 Subject: [PATCH] Remove createSampleDocument method and use the sync'ed index method --- .../java/org/elasticsearch/client/CrudIT.java | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java index b1c1ba8a66f..1aa05c43017 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java @@ -60,7 +60,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { { // Testing deletion String docId = "id"; - createSampleDocument(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar"))); + highLevelClient().index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar"))); DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId); if (randomBoolean()) { deleteRequest.version(1L); @@ -74,7 +74,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { { // Testing version conflict String docId = "version_conflict"; - createSampleDocument(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar"))); + highLevelClient().index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar"))); DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).version(2); ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync)); @@ -87,7 +87,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { { // Testing version type String docId = "version_type"; - createSampleDocument(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")) + highLevelClient().index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")) .versionType(VersionType.EXTERNAL).version(12)); DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).versionType(VersionType.EXTERNAL).version(13); DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); @@ -99,7 +99,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { { // Testing version type with a wrong version String docId = "wrong_version"; - createSampleDocument(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")) + highLevelClient().index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")) .versionType(VersionType.EXTERNAL).version(12)); ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> { DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).versionType(VersionType.EXTERNAL).version(10); @@ -113,7 +113,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { { // Testing routing String docId = "routing"; - createSampleDocument(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")).routing("foo")); + highLevelClient().index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")).routing("foo")); DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).routing("foo"); DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); @@ -344,14 +344,4 @@ public class CrudIT extends ESRestHighLevelClientTestCase { "version conflict, document already exists (current version [1])]", exception.getMessage()); } } - - /** - * Index a document - * @param request index request - * @throws IOException if something goes wrong while executing the index request - */ - private void createSampleDocument(IndexRequest request) throws IOException { - IndexResponse indexResponse = execute(request, highLevelClient()::index, highLevelClient()::indexAsync); - assertEquals(RestStatus.CREATED, indexResponse.status()); - } }