Skip to content

Commit b7deb07

Browse files
author
michele
committed
getDocumentsWithCustomShardingKey
1 parent 49d0def commit b7deb07

File tree

1 file changed

+39
-21
lines changed

1 file changed

+39
-21
lines changed

β€Žsrc/test/java/com/arangodb/ArangoCollectionTest.java

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,26 @@
2020

2121
package com.arangodb;
2222

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;
4124
import com.arangodb.entity.*;
4225
import com.arangodb.model.*;
26+
import com.arangodb.model.DocumentImportOptions.OnDuplicate;
27+
import com.arangodb.velocypack.VPackSlice;
4328
import org.junit.After;
29+
import org.junit.Ignore;
4430
import org.junit.Test;
4531
import org.junit.runner.RunWith;
4632
import org.junit.runners.Parameterized;
4733

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;
5143

5244
/**
5345
* @author Mark Vollmary
@@ -309,6 +301,32 @@ public void getDocuments() {
309301
}
310302
}
311303

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+
312330
@Test
313331
public void getDocumentsDirtyRead() {
314332
final Collection<BaseDocument> values = new ArrayList<>();

0 commit comments

Comments
 (0)