|
20 | 20 |
|
21 | 21 | package com.arangodb;
|
22 | 22 |
|
23 |
| -import static org.hamcrest.CoreMatchers.notNullValue; |
24 |
| -import static org.hamcrest.Matchers.anyOf; |
25 |
| -import static org.hamcrest.Matchers.containsString; |
26 |
| -import static org.hamcrest.Matchers.empty; |
27 |
| -import static org.hamcrest.Matchers.hasItem; |
28 |
| -import static org.hamcrest.Matchers.hasItems; |
29 |
| -import static org.hamcrest.Matchers.instanceOf; |
30 |
| -import static org.hamcrest.Matchers.is; |
31 |
| -import static org.hamcrest.Matchers.isOneOf; |
32 |
| -import static org.hamcrest.Matchers.not; |
33 |
| -import static org.hamcrest.Matchers.nullValue; |
34 |
| -import static org.hamcrest.Matchers.startsWith; |
35 |
| -import static org.junit.Assert.assertThat; |
36 |
| -import static org.junit.Assert.fail; |
37 |
| -import static org.junit.Assume.assumeTrue; |
38 |
| - |
39 |
| -import java.util.*; |
40 |
| - |
| 23 | +import com.arangodb.ArangoDB.Builder; |
41 | 24 | import com.arangodb.entity.*;
|
42 | 25 | import com.arangodb.model.*;
|
| 26 | +import com.arangodb.model.DocumentImportOptions.OnDuplicate; |
| 27 | +import com.arangodb.velocypack.VPackSlice; |
43 | 28 | import org.junit.After;
|
| 29 | +import org.junit.Ignore; |
44 | 30 | import org.junit.Test;
|
45 | 31 | import org.junit.runner.RunWith;
|
46 | 32 | import org.junit.runners.Parameterized;
|
47 | 33 |
|
48 |
| -import com.arangodb.ArangoDB.Builder; |
49 |
| -import com.arangodb.model.DocumentImportOptions.OnDuplicate; |
50 |
| -import com.arangodb.velocypack.VPackSlice; |
| 34 | +import java.util.*; |
| 35 | +import java.util.stream.Collectors; |
| 36 | +import java.util.stream.IntStream; |
| 37 | + |
| 38 | +import static org.hamcrest.CoreMatchers.notNullValue; |
| 39 | +import static org.hamcrest.Matchers.*; |
| 40 | +import static org.junit.Assert.assertThat; |
| 41 | +import static org.junit.Assert.fail; |
| 42 | +import static org.junit.Assume.assumeTrue; |
51 | 43 |
|
52 | 44 | /**
|
53 | 45 | * @author Mark Vollmary
|
@@ -309,6 +301,32 @@ public void getDocuments() {
|
309 | 301 | }
|
310 | 302 | }
|
311 | 303 |
|
| 304 | + @Test |
| 305 | + @Ignore |
| 306 | + public void getDocumentsWithCustomShardingKey() { |
| 307 | + ArangoCollection collection = db.collection("customShardingKeyCollection"); |
| 308 | + if (collection.exists()) |
| 309 | + collection.drop(); |
| 310 | + |
| 311 | + collection.create(new CollectionCreateOptions() |
| 312 | + .shardKeys("customField") |
| 313 | + .numberOfShards(10) |
| 314 | + ); |
| 315 | + |
| 316 | + List<BaseDocument> values = IntStream.range(0, 10) |
| 317 | + .mapToObj(String::valueOf).map(key -> new BaseDocument()) |
| 318 | + .peek(it -> it.addAttribute("customField", UUID.randomUUID().toString())) |
| 319 | + .collect(Collectors.toList()); |
| 320 | + |
| 321 | + MultiDocumentEntity<DocumentCreateEntity<BaseDocument>> inserted = collection.insertDocuments(values); |
| 322 | + List<String> insertedKeys = inserted.getDocuments().stream().map(DocumentEntity::getKey).collect(Collectors.toList()); |
| 323 | + |
| 324 | + final Collection<BaseDocument> documents = collection |
| 325 | + .getDocuments(insertedKeys, BaseDocument.class).getDocuments(); |
| 326 | + |
| 327 | + assertThat(documents.size(), is(10)); |
| 328 | + } |
| 329 | + |
312 | 330 | @Test
|
313 | 331 | public void getDocumentsDirtyRead() {
|
314 | 332 | final Collection<BaseDocument> values = new ArrayList<>();
|
|
0 commit comments