|
27 | 27 | import static org.hamcrest.Matchers.hasItem; |
28 | 28 | import static org.hamcrest.Matchers.instanceOf; |
29 | 29 | import static org.hamcrest.Matchers.is; |
| 30 | +import static org.hamcrest.Matchers.isOneOf; |
30 | 31 | import static org.hamcrest.Matchers.not; |
31 | 32 | import static org.hamcrest.Matchers.nullValue; |
32 | 33 | import static org.hamcrest.Matchers.startsWith; |
33 | 34 | import static org.junit.Assert.assertThat; |
34 | 35 | import static org.junit.Assert.fail; |
35 | 36 |
|
36 | 37 | import java.util.ArrayList; |
| 38 | +import java.util.Arrays; |
37 | 39 | import java.util.Collection; |
| 40 | +import java.util.Collections; |
38 | 41 | import java.util.HashMap; |
39 | 42 | import java.util.Map; |
40 | 43 | import java.util.concurrent.CompletableFuture; |
@@ -254,6 +257,41 @@ public void getDocumentWrongKey() throws InterruptedException, ExecutionExceptio |
254 | 257 | db.collection(COLLECTION_NAME).getDocument("no/no", BaseDocument.class).get(); |
255 | 258 | } |
256 | 259 |
|
| 260 | + @Test |
| 261 | + public void getDocuments() throws InterruptedException, ExecutionException { |
| 262 | + final Collection<BaseDocument> values = new ArrayList<>(); |
| 263 | + values.add(new BaseDocument("1")); |
| 264 | + values.add(new BaseDocument("2")); |
| 265 | + values.add(new BaseDocument("3")); |
| 266 | + db.collection(COLLECTION_NAME).insertDocuments(values).get(); |
| 267 | + final MultiDocumentEntity<BaseDocument> documents = db.collection(COLLECTION_NAME) |
| 268 | + .getDocuments(Arrays.asList("1", "2", "3"), BaseDocument.class).get(); |
| 269 | + assertThat(documents, is(notNullValue())); |
| 270 | + assertThat(documents.getDocuments().size(), is(3)); |
| 271 | + for (final BaseDocument document : documents.getDocuments()) { |
| 272 | + assertThat(document.getId(), |
| 273 | + isOneOf(COLLECTION_NAME + "/" + "1", COLLECTION_NAME + "/" + "2", COLLECTION_NAME + "/" + "3")); |
| 274 | + } |
| 275 | + } |
| 276 | + |
| 277 | + @Test |
| 278 | + public void getDocumentsNotFound() throws InterruptedException, ExecutionException { |
| 279 | + final MultiDocumentEntity<BaseDocument> readResult = db.collection(COLLECTION_NAME) |
| 280 | + .getDocuments(Collections.singleton("no"), BaseDocument.class).get(); |
| 281 | + assertThat(readResult, is(notNullValue())); |
| 282 | + assertThat(readResult.getDocuments().size(), is(0)); |
| 283 | + assertThat(readResult.getErrors().size(), is(1)); |
| 284 | + } |
| 285 | + |
| 286 | + @Test |
| 287 | + public void getDocumentsWrongKey() throws InterruptedException, ExecutionException { |
| 288 | + final MultiDocumentEntity<BaseDocument> readResult = db.collection(COLLECTION_NAME) |
| 289 | + .getDocuments(Collections.singleton("no/no"), BaseDocument.class).get(); |
| 290 | + assertThat(readResult, is(notNullValue())); |
| 291 | + assertThat(readResult.getDocuments().size(), is(0)); |
| 292 | + assertThat(readResult.getErrors().size(), is(1)); |
| 293 | + } |
| 294 | + |
257 | 295 | @Test |
258 | 296 | public void updateDocument() throws ArangoDBException, InterruptedException, ExecutionException { |
259 | 297 | final BaseDocument doc = new BaseDocument(); |
@@ -2059,4 +2097,19 @@ public void revokeAccessUserNotFound() throws InterruptedException, ExecutionExc |
2059 | 2097 | db.collection(COLLECTION_NAME).grantAccess("user1", Permissions.NONE).get(); |
2060 | 2098 | } |
2061 | 2099 |
|
| 2100 | + @Test |
| 2101 | + public void resetAccess() throws InterruptedException, ExecutionException { |
| 2102 | + try { |
| 2103 | + arangoDB.createUser("user1", "1234", null).get(); |
| 2104 | + db.collection(COLLECTION_NAME).resetAccess("user1").get(); |
| 2105 | + } finally { |
| 2106 | + arangoDB.deleteUser("user1").get(); |
| 2107 | + } |
| 2108 | + } |
| 2109 | + |
| 2110 | + @Test(expected = ExecutionException.class) |
| 2111 | + public void resetAccessUserNotFound() throws InterruptedException, ExecutionException { |
| 2112 | + db.collection(COLLECTION_NAME).resetAccess("user1").get(); |
| 2113 | + } |
| 2114 | + |
2062 | 2115 | } |
0 commit comments