From 0f71b8a453c5fe006a026b168a6f428c81ee3688 Mon Sep 17 00:00:00 2001 From: Yoann Abbes Date: Fri, 28 Feb 2020 16:45:33 +0100 Subject: [PATCH 1/9] document:mDelete --- .ci/doc/templates/print-result-array.tpl.java | 29 ++++++ .ci/doc/templates/print-result.tpl.java | 2 +- doc/3/controllers/document/m-delete/index.md | 47 ++++++++++ .../document/m-delete/snippets/m-delete.java | 14 +++ .../m-delete/snippets/m-delete.test.yml | 14 +++ .../API/Controllers/DocumentController.java | 67 ++++++++++++++ src/main/java/io/kuzzle/sdk/Kuzzle.java | 11 ++- .../DocumentTest/DocumentTest.java | 88 +++++++++++++++++++ 8 files changed, 270 insertions(+), 2 deletions(-) create mode 100644 .ci/doc/templates/print-result-array.tpl.java create mode 100644 doc/3/controllers/document/m-delete/index.md create mode 100644 doc/3/controllers/document/m-delete/snippets/m-delete.java create mode 100644 doc/3/controllers/document/m-delete/snippets/m-delete.test.yml create mode 100644 src/main/java/io/kuzzle/sdk/API/Controllers/DocumentController.java create mode 100644 src/test/java/io/kuzzle/test/API/Controllers/DocumentTest/DocumentTest.java diff --git a/.ci/doc/templates/print-result-array.tpl.java b/.ci/doc/templates/print-result-array.tpl.java new file mode 100644 index 00000000..9c751d0b --- /dev/null +++ b/.ci/doc/templates/print-result-array.tpl.java @@ -0,0 +1,29 @@ +import io.kuzzle.sdk.Kuzzle; +import io.kuzzle.sdk.Protocol.WebSocket; +import io.kuzzle.sdk.Options.Protocol.WebSocketOptions; +import io.kuzzle.sdk.Options.KuzzleOptions; +import io.kuzzle.sdk.CoreClasses.Responses.Response; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.ArrayList; + +public class SnippetTest { + private static Kuzzle kuzzle; + + public static void main(String[] argv) { + try { + kuzzle = new Kuzzle(new WebSocket("kuzzle")); + kuzzle.connect(); + [snippet-code] + for (Object o : result.get("successes")) { + System.out.println(o); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (kuzzle != null) { + kuzzle.disconnect(); + } + } + } +} \ No newline at end of file diff --git a/.ci/doc/templates/print-result.tpl.java b/.ci/doc/templates/print-result.tpl.java index 1e7b1e39..04280871 100644 --- a/.ci/doc/templates/print-result.tpl.java +++ b/.ci/doc/templates/print-result.tpl.java @@ -8,8 +8,8 @@ import java.util.ArrayList; public class SnippetTest { - private static Kuzzle kuzzle; + private static Kuzzle kuzzle; public static void main(String[] argv) { try { kuzzle = new Kuzzle(new WebSocket("kuzzle")); diff --git a/doc/3/controllers/document/m-delete/index.md b/doc/3/controllers/document/m-delete/index.md new file mode 100644 index 00000000..3838503f --- /dev/null +++ b/doc/3/controllers/document/m-delete/index.md @@ -0,0 +1,47 @@ +--- +code: true +type: page +title: mDelete +description: Deletes multiple documents +--- + +# mDelete + +Delete multiple documents. + +--- + +## Arguments + +```java +public CompletableFuture>> mDelete( + final String index, + final String collection, + final ArrayList ids) +throws NotConnectedException, InternalException + +``` + +| Arguments | Type | Description | +| ------------------ | ------------------------------------------------------- | --------------------------------- | +| `index` |
String
| Index name | +| `collection` |
String
| Collection name | +| `ids` |
ArrayList
| Document IDs | +--- + +## Return + +A `ConcurrentHashMap>` which has a `successes` and `errors` `ArrayList`: +The `successes` array contains the successfully deleted document IDs. + +Each deletion error is an object of the errors array with the following properties: + +| Property | Type | Description | +|------------- |--------------------------------------------- |--------------------------------- | +| `_id` |
String
| Document ID | +| `reason` |
ConcurrentHashMap
| Human readable reason | +| `status` |
Integer
| HTTP status code | + +## Usage + +<<< ./snippets/m-delete.java diff --git a/doc/3/controllers/document/m-delete/snippets/m-delete.java b/doc/3/controllers/document/m-delete/snippets/m-delete.java new file mode 100644 index 00000000..513b6071 --- /dev/null +++ b/doc/3/controllers/document/m-delete/snippets/m-delete.java @@ -0,0 +1,14 @@ + final ArrayList ids = new ArrayList<>(); + ids.add("some-id"); + ids.add("some-id2"); + + ConcurrentHashMap> result = kuzzle.getDocumentController().mDelete("nyc-open-data", "yellow-taxi", ids) + .get(); +/* + result = + { + successes=[some-id, some-id2], + errors=[] + } + +*/ \ No newline at end of file diff --git a/doc/3/controllers/document/m-delete/snippets/m-delete.test.yml b/doc/3/controllers/document/m-delete/snippets/m-delete.test.yml new file mode 100644 index 00000000..3e66fff2 --- /dev/null +++ b/doc/3/controllers/document/m-delete/snippets/m-delete.test.yml @@ -0,0 +1,14 @@ +name: document#mGet +description: Get multiple documents +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + curl -XPOST -d '{"name":"John"}' -H "Content-Type: application/json" kuzzle:7512/nyc-open-data/yellow-taxi/some-id/_create + curl -XPOST -d '{"color":"purple"}' -H "Content-Type: application/json" kuzzle:7512/nyc-open-data/yellow-taxi/some-id2/_create + after: +template: print-result-array +expected: + - "some-id" + - "some-id2" \ No newline at end of file diff --git a/src/main/java/io/kuzzle/sdk/API/Controllers/DocumentController.java b/src/main/java/io/kuzzle/sdk/API/Controllers/DocumentController.java new file mode 100644 index 00000000..9f8b58d2 --- /dev/null +++ b/src/main/java/io/kuzzle/sdk/API/Controllers/DocumentController.java @@ -0,0 +1,67 @@ +package io.kuzzle.sdk.API.Controllers; + +import io.kuzzle.sdk.CoreClasses.Maps.KuzzleMap; +import io.kuzzle.sdk.Exceptions.InternalException; +import io.kuzzle.sdk.Exceptions.NotConnectedException; +import io.kuzzle.sdk.Kuzzle; + +import java.util.ArrayList; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; + +public class DocumentController extends BaseController { + public DocumentController(final Kuzzle kuzzle) { + super(kuzzle); + } + + /** + * Deletes multiple documents. + * + * @param index + * @param collection + * @param ids + * @param waitForRefresh + * @return a CompletableFuture + * @throws NotConnectedException + * @throws InternalException + */ + public CompletableFuture>> mDelete( + final String index, + final String collection, + final ArrayList ids, + final Boolean waitForRefresh) throws NotConnectedException, InternalException { + + + final KuzzleMap query = new KuzzleMap(); + query + .put("index", index) + .put("collection", collection) + .put("controller", "document") + .put("action", "mDelete") + .put("waitForRefresh", waitForRefresh) + .put("body", new KuzzleMap().put("ids", ids)); + + return kuzzle + .query(query) + .thenApplyAsync( + (response) -> (ConcurrentHashMap>) response.result); + } + + /** + * Deletes multiple documents. + * + * @param index + * @param collection + * @param ids + * @return a CompletableFuture + * @throws NotConnectedException + * @throws InternalException + */ + public CompletableFuture>> mDelete( + final String index, + final String collection, + final ArrayList ids) throws NotConnectedException, InternalException { + + return mDelete(index, collection, ids, null); + } +} diff --git a/src/main/java/io/kuzzle/sdk/Kuzzle.java b/src/main/java/io/kuzzle/sdk/Kuzzle.java index 062a2b4c..de964120 100644 --- a/src/main/java/io/kuzzle/sdk/Kuzzle.java +++ b/src/main/java/io/kuzzle/sdk/Kuzzle.java @@ -1,10 +1,11 @@ package io.kuzzle.sdk; +import io.kuzzle.sdk.API.Controllers.AuthController; +import io.kuzzle.sdk.API.Controllers.DocumentController; import io.kuzzle.sdk.API.Controllers.IndexController; import io.kuzzle.sdk.API.Controllers.RealtimeController; import io.kuzzle.sdk.CoreClasses.Json.JsonSerializer; import io.kuzzle.sdk.CoreClasses.Maps.KuzzleMap; -import io.kuzzle.sdk.API.Controllers.AuthController; import io.kuzzle.sdk.CoreClasses.Task; import io.kuzzle.sdk.Exceptions.*; import io.kuzzle.sdk.Options.KuzzleOptions; @@ -77,6 +78,14 @@ public AuthController getAuthController() { return new AuthController(this); } + /** + * @return The DocumentController + */ + public DocumentController getDocumentController() { + return new DocumentController(this); + + } + /** * @return The IndexController */ diff --git a/src/test/java/io/kuzzle/test/API/Controllers/DocumentTest/DocumentTest.java b/src/test/java/io/kuzzle/test/API/Controllers/DocumentTest/DocumentTest.java new file mode 100644 index 00000000..beea3aca --- /dev/null +++ b/src/test/java/io/kuzzle/test/API/Controllers/DocumentTest/DocumentTest.java @@ -0,0 +1,88 @@ +package io.kuzzle.test.API.Controllers.DocumentTest; + +import io.kuzzle.sdk.CoreClasses.Maps.KuzzleMap; +import io.kuzzle.sdk.Exceptions.InternalException; +import io.kuzzle.sdk.Exceptions.NotConnectedException; +import io.kuzzle.sdk.Kuzzle; +import io.kuzzle.sdk.Protocol.AbstractProtocol; +import io.kuzzle.sdk.Protocol.ProtocolState; +import io.kuzzle.sdk.Protocol.WebSocket; + +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; +import org.mockito.stubbing.Answer; + +import java.util.ArrayList; +import java.util.concurrent.ConcurrentHashMap; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.*; + +public class DocumentTest { + + private AbstractProtocol networkProtocol = Mockito.mock(WebSocket.class); + + @Test + public void mDeleteDocumentTestA() throws NotConnectedException, InternalException { + + Kuzzle kuzzleMock = spy(new Kuzzle(networkProtocol)); + String index = "nyc-open-data"; + String collection = "yellow-taxi"; + + final ArrayList ids = new ArrayList<>(); + ids.add("some-id1"); + ids.add("some-id2"); + ArgumentCaptor arg = ArgumentCaptor.forClass(KuzzleMap.class); + + kuzzleMock.getDocumentController().mDelete(index, collection, ids); + Mockito.verify(kuzzleMock, Mockito.times(1)).query(arg.capture()); + + assertEquals((arg.getValue()).getString("controller"), "document"); + assertEquals((arg.getValue()).getString("action"), "mDelete"); + assertEquals((arg.getValue()).getString("index"), "nyc-open-data"); + assertEquals((arg.getValue()).getBoolean("waitForRefresh"), null); + assertEquals(((ArrayList)(((KuzzleMap)(arg.getValue()).get("body"))).get("ids")).get(0), "some-id1"); + assertEquals(((ArrayList)(((KuzzleMap)(arg.getValue()).get("body"))).get("ids")).get(1), "some-id2"); + } + + @Test + public void mDeleteDocumentTestB() throws NotConnectedException, InternalException { + + Kuzzle kuzzleMock = spy(new Kuzzle(networkProtocol)); + String index = "nyc-open-data"; + String collection = "yellow-taxi"; + + final ArrayList ids = new ArrayList<>(); + ids.add("some-id1"); + ids.add("some-id2"); + ArgumentCaptor arg = ArgumentCaptor.forClass(KuzzleMap.class); + + kuzzleMock.getDocumentController().mDelete(index, collection, ids, false); + Mockito.verify(kuzzleMock, Mockito.times(1)).query(arg.capture()); + + assertEquals((arg.getValue()).getString("controller"), "document"); + assertEquals((arg.getValue()).getString("action"), "mDelete"); + assertEquals((arg.getValue()).getString("index"), "nyc-open-data"); + assertEquals((arg.getValue()).getBoolean("waitForRefresh"), false); + assertEquals(((ArrayList)(((KuzzleMap)(arg.getValue()).get("body"))).get("ids")).get(0), "some-id1"); + assertEquals(((ArrayList)(((KuzzleMap)(arg.getValue()).get("body"))).get("ids")).get(1), "some-id2"); + } + + @Test(expected = NotConnectedException.class) + public void mDeleteDocumentShouldThrowWhenNotConnected() throws NotConnectedException, InternalException { + AbstractProtocol fakeNetworkProtocol = Mockito.mock(WebSocket.class); + Mockito.when(fakeNetworkProtocol.getState()).thenAnswer((Answer) invocation -> ProtocolState.CLOSE); + + Kuzzle kuzzleMock = spy(new Kuzzle(fakeNetworkProtocol)); + String index = "nyc-open-data"; + String collection = "yellow-taxi"; + + final ArrayList ids = new ArrayList<>(); + ids.add("some-id1"); + ids.add("some-id2"); + + kuzzleMock.getDocumentController().mDelete(index, collection, ids); + } + +} From 51931348fca348adfe6515c55f95daf643a6e0e3 Mon Sep 17 00:00:00 2001 From: Yoann Abbes Date: Fri, 28 Feb 2020 16:49:07 +0100 Subject: [PATCH 2/9] nit --- .ci/doc/templates/print-result.tpl.java | 2 +- .../controllers/document/m-delete/snippets/m-delete.test.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.ci/doc/templates/print-result.tpl.java b/.ci/doc/templates/print-result.tpl.java index 04280871..1e7b1e39 100644 --- a/.ci/doc/templates/print-result.tpl.java +++ b/.ci/doc/templates/print-result.tpl.java @@ -8,8 +8,8 @@ import java.util.ArrayList; public class SnippetTest { - private static Kuzzle kuzzle; + public static void main(String[] argv) { try { kuzzle = new Kuzzle(new WebSocket("kuzzle")); diff --git a/doc/3/controllers/document/m-delete/snippets/m-delete.test.yml b/doc/3/controllers/document/m-delete/snippets/m-delete.test.yml index 3e66fff2..a7dd0966 100644 --- a/doc/3/controllers/document/m-delete/snippets/m-delete.test.yml +++ b/doc/3/controllers/document/m-delete/snippets/m-delete.test.yml @@ -1,5 +1,5 @@ -name: document#mGet -description: Get multiple documents +name: document#mDelete +description: Delete multiple documents hooks: before: | curl -XDELETE kuzzle:7512/nyc-open-data From 86f94122750644f22fd5dbd1e4a73d018a945fc2 Mon Sep 17 00:00:00 2001 From: Yoann-Abbes <44844010+Yoann-Abbes@users.noreply.github.com> Date: Mon, 2 Mar 2020 10:46:49 +0100 Subject: [PATCH 3/9] Update doc/3/controllers/document/m-delete/index.md Co-Authored-By: Adrien Maret --- doc/3/controllers/document/m-delete/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/3/controllers/document/m-delete/index.md b/doc/3/controllers/document/m-delete/index.md index 3838503f..4d903339 100644 --- a/doc/3/controllers/document/m-delete/index.md +++ b/doc/3/controllers/document/m-delete/index.md @@ -7,7 +7,7 @@ description: Deletes multiple documents # mDelete -Delete multiple documents. +Deletes multiple documents. --- From 5c6809670caafeb20d901129647226bb08264075 Mon Sep 17 00:00:00 2001 From: Yoann-Abbes <44844010+Yoann-Abbes@users.noreply.github.com> Date: Mon, 2 Mar 2020 10:46:56 +0100 Subject: [PATCH 4/9] Update doc/3/controllers/document/m-delete/index.md Co-Authored-By: Adrien Maret --- doc/3/controllers/document/m-delete/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/3/controllers/document/m-delete/index.md b/doc/3/controllers/document/m-delete/index.md index 4d903339..7875de51 100644 --- a/doc/3/controllers/document/m-delete/index.md +++ b/doc/3/controllers/document/m-delete/index.md @@ -39,7 +39,7 @@ Each deletion error is an object of the errors array with the following properti | Property | Type | Description | |------------- |--------------------------------------------- |--------------------------------- | | `_id` |
String
| Document ID | -| `reason` |
ConcurrentHashMap
| Human readable reason | +| `reason` |
String
| Human readable reason | | `status` |
Integer
| HTTP status code | ## Usage From 98a3008799f2640032b02069a93061583ccc2318 Mon Sep 17 00:00:00 2001 From: Yoann-Abbes <44844010+Yoann-Abbes@users.noreply.github.com> Date: Mon, 2 Mar 2020 10:47:48 +0100 Subject: [PATCH 5/9] Update doc/3/controllers/document/m-delete/index.md Co-Authored-By: Adrien Maret --- doc/3/controllers/document/m-delete/index.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/3/controllers/document/m-delete/index.md b/doc/3/controllers/document/m-delete/index.md index 7875de51..0263c038 100644 --- a/doc/3/controllers/document/m-delete/index.md +++ b/doc/3/controllers/document/m-delete/index.md @@ -40,7 +40,6 @@ Each deletion error is an object of the errors array with the following properti |------------- |--------------------------------------------- |--------------------------------- | | `_id` |
String
| Document ID | | `reason` |
String
| Human readable reason | -| `status` |
Integer
| HTTP status code | ## Usage From 2c09c2383aaa64956962712d5541bbc65c2b75b5 Mon Sep 17 00:00:00 2001 From: Yoann Date: Mon, 2 Mar 2020 15:43:46 +0100 Subject: [PATCH 6/9] conflict [ci skip] --- .../API/Controllers/DocumentController.java | 90 ++++++------- .../DocumentTest/DocumentTest.java | 122 +++++++++--------- 2 files changed, 106 insertions(+), 106 deletions(-) diff --git a/src/main/java/io/kuzzle/sdk/API/Controllers/DocumentController.java b/src/main/java/io/kuzzle/sdk/API/Controllers/DocumentController.java index 9f8b58d2..22f14427 100644 --- a/src/main/java/io/kuzzle/sdk/API/Controllers/DocumentController.java +++ b/src/main/java/io/kuzzle/sdk/API/Controllers/DocumentController.java @@ -14,54 +14,54 @@ public DocumentController(final Kuzzle kuzzle) { super(kuzzle); } - /** - * Deletes multiple documents. - * - * @param index - * @param collection - * @param ids - * @param waitForRefresh - * @return a CompletableFuture - * @throws NotConnectedException - * @throws InternalException - */ - public CompletableFuture>> mDelete( - final String index, - final String collection, - final ArrayList ids, - final Boolean waitForRefresh) throws NotConnectedException, InternalException { + // /** + // * Deletes multiple documents. + // * + // * @param index + // * @param collection + // * @param ids + // * @param waitForRefresh + // * @return a CompletableFuture + // * @throws NotConnectedException + // * @throws InternalException + // */ + // public CompletableFuture>> mDelete( + // final String index, + // final String collection, + // final ArrayList ids, + // final Boolean waitForRefresh) throws NotConnectedException, InternalException { - final KuzzleMap query = new KuzzleMap(); - query - .put("index", index) - .put("collection", collection) - .put("controller", "document") - .put("action", "mDelete") - .put("waitForRefresh", waitForRefresh) - .put("body", new KuzzleMap().put("ids", ids)); + // final KuzzleMap query = new KuzzleMap(); + // query + // .put("index", index) + // .put("collection", collection) + // .put("controller", "document") + // .put("action", "mDelete") + // .put("waitForRefresh", waitForRefresh) + // .put("body", new KuzzleMap().put("ids", ids)); - return kuzzle - .query(query) - .thenApplyAsync( - (response) -> (ConcurrentHashMap>) response.result); - } + // return kuzzle + // .query(query) + // .thenApplyAsync( + // (response) -> (ConcurrentHashMap>) response.result); + // } - /** - * Deletes multiple documents. - * - * @param index - * @param collection - * @param ids - * @return a CompletableFuture - * @throws NotConnectedException - * @throws InternalException - */ - public CompletableFuture>> mDelete( - final String index, - final String collection, - final ArrayList ids) throws NotConnectedException, InternalException { + // /** + // * Deletes multiple documents. + // * + // * @param index + // * @param collection + // * @param ids + // * @return a CompletableFuture + // * @throws NotConnectedException + // * @throws InternalException + // */ + // public CompletableFuture>> mDelete( + // final String index, + // final String collection, + // final ArrayList ids) throws NotConnectedException, InternalException { - return mDelete(index, collection, ids, null); - } + // return mDelete(index, collection, ids, null); + // } } diff --git a/src/test/java/io/kuzzle/test/API/Controllers/DocumentTest/DocumentTest.java b/src/test/java/io/kuzzle/test/API/Controllers/DocumentTest/DocumentTest.java index beea3aca..3ad76a18 100644 --- a/src/test/java/io/kuzzle/test/API/Controllers/DocumentTest/DocumentTest.java +++ b/src/test/java/io/kuzzle/test/API/Controllers/DocumentTest/DocumentTest.java @@ -23,66 +23,66 @@ public class DocumentTest { private AbstractProtocol networkProtocol = Mockito.mock(WebSocket.class); - @Test - public void mDeleteDocumentTestA() throws NotConnectedException, InternalException { - - Kuzzle kuzzleMock = spy(new Kuzzle(networkProtocol)); - String index = "nyc-open-data"; - String collection = "yellow-taxi"; - - final ArrayList ids = new ArrayList<>(); - ids.add("some-id1"); - ids.add("some-id2"); - ArgumentCaptor arg = ArgumentCaptor.forClass(KuzzleMap.class); - - kuzzleMock.getDocumentController().mDelete(index, collection, ids); - Mockito.verify(kuzzleMock, Mockito.times(1)).query(arg.capture()); - - assertEquals((arg.getValue()).getString("controller"), "document"); - assertEquals((arg.getValue()).getString("action"), "mDelete"); - assertEquals((arg.getValue()).getString("index"), "nyc-open-data"); - assertEquals((arg.getValue()).getBoolean("waitForRefresh"), null); - assertEquals(((ArrayList)(((KuzzleMap)(arg.getValue()).get("body"))).get("ids")).get(0), "some-id1"); - assertEquals(((ArrayList)(((KuzzleMap)(arg.getValue()).get("body"))).get("ids")).get(1), "some-id2"); - } - - @Test - public void mDeleteDocumentTestB() throws NotConnectedException, InternalException { - - Kuzzle kuzzleMock = spy(new Kuzzle(networkProtocol)); - String index = "nyc-open-data"; - String collection = "yellow-taxi"; - - final ArrayList ids = new ArrayList<>(); - ids.add("some-id1"); - ids.add("some-id2"); - ArgumentCaptor arg = ArgumentCaptor.forClass(KuzzleMap.class); - - kuzzleMock.getDocumentController().mDelete(index, collection, ids, false); - Mockito.verify(kuzzleMock, Mockito.times(1)).query(arg.capture()); - - assertEquals((arg.getValue()).getString("controller"), "document"); - assertEquals((arg.getValue()).getString("action"), "mDelete"); - assertEquals((arg.getValue()).getString("index"), "nyc-open-data"); - assertEquals((arg.getValue()).getBoolean("waitForRefresh"), false); - assertEquals(((ArrayList)(((KuzzleMap)(arg.getValue()).get("body"))).get("ids")).get(0), "some-id1"); - assertEquals(((ArrayList)(((KuzzleMap)(arg.getValue()).get("body"))).get("ids")).get(1), "some-id2"); - } - - @Test(expected = NotConnectedException.class) - public void mDeleteDocumentShouldThrowWhenNotConnected() throws NotConnectedException, InternalException { - AbstractProtocol fakeNetworkProtocol = Mockito.mock(WebSocket.class); - Mockito.when(fakeNetworkProtocol.getState()).thenAnswer((Answer) invocation -> ProtocolState.CLOSE); - - Kuzzle kuzzleMock = spy(new Kuzzle(fakeNetworkProtocol)); - String index = "nyc-open-data"; - String collection = "yellow-taxi"; - - final ArrayList ids = new ArrayList<>(); - ids.add("some-id1"); - ids.add("some-id2"); - - kuzzleMock.getDocumentController().mDelete(index, collection, ids); - } + // @Test + // public void mDeleteDocumentTestA() throws NotConnectedException, InternalException { + + // Kuzzle kuzzleMock = spy(new Kuzzle(networkProtocol)); + // String index = "nyc-open-data"; + // String collection = "yellow-taxi"; + + // final ArrayList ids = new ArrayList<>(); + // ids.add("some-id1"); + // ids.add("some-id2"); + // ArgumentCaptor arg = ArgumentCaptor.forClass(KuzzleMap.class); + + // kuzzleMock.getDocumentController().mDelete(index, collection, ids); + // Mockito.verify(kuzzleMock, Mockito.times(1)).query(arg.capture()); + + // assertEquals((arg.getValue()).getString("controller"), "document"); + // assertEquals((arg.getValue()).getString("action"), "mDelete"); + // assertEquals((arg.getValue()).getString("index"), "nyc-open-data"); + // assertEquals((arg.getValue()).getBoolean("waitForRefresh"), null); + // assertEquals(((ArrayList)(((KuzzleMap)(arg.getValue()).get("body"))).get("ids")).get(0), "some-id1"); + // assertEquals(((ArrayList)(((KuzzleMap)(arg.getValue()).get("body"))).get("ids")).get(1), "some-id2"); + // } + + // @Test + // public void mDeleteDocumentTestB() throws NotConnectedException, InternalException { + + // Kuzzle kuzzleMock = spy(new Kuzzle(networkProtocol)); + // String index = "nyc-open-data"; + // String collection = "yellow-taxi"; + + // final ArrayList ids = new ArrayList<>(); + // ids.add("some-id1"); + // ids.add("some-id2"); + // ArgumentCaptor arg = ArgumentCaptor.forClass(KuzzleMap.class); + + // kuzzleMock.getDocumentController().mDelete(index, collection, ids, false); + // Mockito.verify(kuzzleMock, Mockito.times(1)).query(arg.capture()); + + // assertEquals((arg.getValue()).getString("controller"), "document"); + // assertEquals((arg.getValue()).getString("action"), "mDelete"); + // assertEquals((arg.getValue()).getString("index"), "nyc-open-data"); + // assertEquals((arg.getValue()).getBoolean("waitForRefresh"), false); + // assertEquals(((ArrayList)(((KuzzleMap)(arg.getValue()).get("body"))).get("ids")).get(0), "some-id1"); + // assertEquals(((ArrayList)(((KuzzleMap)(arg.getValue()).get("body"))).get("ids")).get(1), "some-id2"); + // } + + // @Test(expected = NotConnectedException.class) + // public void mDeleteDocumentShouldThrowWhenNotConnected() throws NotConnectedException, InternalException { + // AbstractProtocol fakeNetworkProtocol = Mockito.mock(WebSocket.class); + // Mockito.when(fakeNetworkProtocol.getState()).thenAnswer((Answer) invocation -> ProtocolState.CLOSE); + + // Kuzzle kuzzleMock = spy(new Kuzzle(fakeNetworkProtocol)); + // String index = "nyc-open-data"; + // String collection = "yellow-taxi"; + + // final ArrayList ids = new ArrayList<>(); + // ids.add("some-id1"); + // ids.add("some-id2"); + + // kuzzleMock.getDocumentController().mDelete(index, collection, ids); + // } } From ed18a047605ec59d9547f8dca7bfb5f22f181229 Mon Sep 17 00:00:00 2001 From: Yoann Date: Mon, 2 Mar 2020 15:46:53 +0100 Subject: [PATCH 7/9] doc --- doc/3/controllers/document/replace/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/3/controllers/document/replace/index.md b/doc/3/controllers/document/replace/index.md index 43dde4e7..fc3bb906 100644 --- a/doc/3/controllers/document/replace/index.md +++ b/doc/3/controllers/document/replace/index.md @@ -35,7 +35,7 @@ throws NotConnectedException, InternalException | `index` |
String
| Index | | `collection` |
String
| Collection | | `id` |
String
| Document ID | -| `document` |
ConcurrentHashMap
| Updated ocument content | +| `document` |
ConcurrentHashMap
| New content of the document to update | | `waitForRefresh` |
Boolean
| If set to `true`, Kuzzle will wait for the persistence layer to finish indexing| --- From fbbc19b867ee2754163f23bf7e281c7833dc5226 Mon Sep 17 00:00:00 2001 From: Yoann Abbes Date: Wed, 4 Mar 2020 16:29:42 +0100 Subject: [PATCH 8/9] netify --- doc/3/controllers/document/m-delete/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/3/controllers/document/m-delete/index.md b/doc/3/controllers/document/m-delete/index.md index 3838503f..39b7839c 100644 --- a/doc/3/controllers/document/m-delete/index.md +++ b/doc/3/controllers/document/m-delete/index.md @@ -44,4 +44,4 @@ Each deletion error is an object of the errors array with the following properti ## Usage -<<< ./snippets/m-delete.java +<<< ./snippets/m-delete.java \ No newline at end of file From f07d412ae671f98b3e381dc228a666f78dbff38c Mon Sep 17 00:00:00 2001 From: Yoann Abbes Date: Wed, 4 Mar 2020 16:30:51 +0100 Subject: [PATCH 9/9] doc --- doc/3/controllers/document/m-delete/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/3/controllers/document/m-delete/index.md b/doc/3/controllers/document/m-delete/index.md index 85efe766..d7de90bd 100644 --- a/doc/3/controllers/document/m-delete/index.md +++ b/doc/3/controllers/document/m-delete/index.md @@ -39,7 +39,7 @@ Each deletion error is an object of the errors array with the following properti | Property | Type | Description | |------------- |--------------------------------------------- |--------------------------------- | | `_id` |
String
| Document ID | -| `reason` |
String
| Human readable reason | +| `reason` |
String
| Human readable reason | ## Usage