@Test public void testMongoDatabaseQuery() throws JsonException { LocalQuery lq = new LocalQuery(); lq.requireTouchedByStage("test"); lq.requireNotTouchedByStage("test2"); lq.requireContentFieldExists("exists"); MongoQuery q = new MongoQuery(lq.toJson()); Document d = mdc.getDocumentReader().getDocument(q); if (d != null) { fail("Expected no document to be returned"); } lq = new LocalQuery(); if (mdc.getDocumentReader().getDocument(new MongoQuery(lq.toJson())) == null) { fail("Expected to find a document"); } }
@Test public void testRequireNotTouchedByStage() throws JsonException { LocalQuery q = new LocalQuery(); q.requireNotTouchedByStage("xyz"); List<DatabaseDocument<MongoType>> ds = mdc.getDocumentReader().getDocuments(new MongoQuery(q.toJson()), 3); if (ds.size() != 3) { fail("Received incorrect number of documents.."); } Document d = mdc.getDocumentWriter().getAndTag(new MongoQuery(), "xyz"); if (d == null) { fail("Should have gotten a document back..."); } mdc.getDocumentWriter().markTouched(d.getID(), "xyz"); ds = mdc.getDocumentReader().getDocuments(new MongoQuery(q.toJson()), 3); if (ds.size() != 2) { fail("Received incorrect number of documents.."); } }