mreutegg commented on code in PR #858:
URL: https://github.com/apache/jackrabbit-oak/pull/858#discussion_r1132315205
##########
oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreTest.java:
##########
@@ -241,6 +243,80 @@ public void queryWithLimit() throws Exception {
store.dispose();
}
+ @Test
+ public void queryWithProjection() {
+ DocumentStore docStore = openDocumentStore();
+ DocumentNodeStore store = new DocumentMK.Builder()
+ .setDocumentStore(docStore).setAsyncDelay(0).getNodeStore();
+ Revision rev = Revision.newRevision(0);
+ List<UpdateOp> inserts = new ArrayList<UpdateOp>();
+ for (int i = 0; i < 10; i++) {
+ DocumentNodeState n = new DocumentNodeState(store,
Path.fromString("/node-" + i),
+ new RevisionVector(rev));
+ inserts.add(n.asOperation(rev));
+ }
+ docStore.create(Collection.NODES, inserts);
+ List<NodeDocument> docs = docStore.query(Collection.NODES,
+ Utils.getKeyLowerLimit(Path.ROOT),
Utils.getKeyUpperLimit(Path.ROOT), null, 0,
+ 20, newArrayList(MODIFIED_IN_SECS));
+ // since _id is mandatory, so data size should be 2
+ docs.forEach(d -> assertEquals(2 , d.data.size()));
+ assertEquals(10, docs.size());
+ store.dispose();
+ }
+
+ @Test
+ public void queryWithEmptyProjection() {
+ DocumentStore docStore = openDocumentStore();
+ DocumentNodeStore store = new DocumentMK.Builder()
+ .setDocumentStore(docStore).setAsyncDelay(0).getNodeStore();
+ Revision rev = Revision.newRevision(0);
+ List<UpdateOp> inserts = new ArrayList<UpdateOp>();
+ for (int i = 0; i < 10; i++) {
+ DocumentNodeState n = new DocumentNodeState(store,
Path.fromString("/node-" + i),
+ new RevisionVector(rev));
+ inserts.add(n.asOperation(rev));
+ }
+ docStore.create(Collection.NODES, inserts);
+ List<NodeDocument> docs = docStore.query(Collection.NODES,
+ Utils.getKeyLowerLimit(Path.ROOT),
Utils.getKeyUpperLimit(Path.ROOT), null, 0,
+ 20, newArrayList());
+ if (MONGO_DB) {
+ // we have _modCount as additional field in case we use
MongoDocumentStore
+ docs.forEach(d -> assertEquals(4 , d.data.size()));
+ } else {
+ docs.forEach(d -> assertEquals(3 , d.data.size()));
+ }
+ assertEquals(10, docs.size());
+ store.dispose();
+ }
+
+ @Test
+ public void queryWithNullProjection() {
+ DocumentStore docStore = openDocumentStore();
+ DocumentNodeStore store = new DocumentMK.Builder()
+ .setDocumentStore(docStore).setAsyncDelay(0).getNodeStore();
+ Revision rev = Revision.newRevision(0);
+ List<UpdateOp> inserts = new ArrayList<UpdateOp>();
+ for (int i = 0; i < 10; i++) {
+ DocumentNodeState n = new DocumentNodeState(store,
Path.fromString("/node-" + i),
+ new RevisionVector(rev));
+ inserts.add(n.asOperation(rev));
+ }
+ docStore.create(Collection.NODES, inserts);
+ List<NodeDocument> docs = docStore.query(Collection.NODES,
+ Utils.getKeyLowerLimit(Path.ROOT),
Utils.getKeyUpperLimit(Path.ROOT), null, 0,
+ 20, null);
+ if (MONGO_DB) {
+ // we have _modCount as additional field in case we use
MongoDocumentStore
+ docs.forEach(d -> assertEquals(4 , d.data.size()));
+ } else {
+ docs.forEach(d -> assertEquals(3 , d.data.size()));
+ }
+ assertEquals(10, docs.size());
+ store.dispose();
+ }
+
Review Comment:
Confusingly MongoDocumentStoreTest does not use MongoDB as a DocumentStore
by default.
I would rather move these tests to MongoDocumentStoreIT:
https://github.com/rishabhdaim/jackrabbit-oak/pull/2
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]