@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 testRequireTouchedByStage() throws JsonException { LocalQuery q = new LocalQuery(); q.requireTouchedByStage("xyz"); List<DatabaseDocument<MongoType>> ds = mdc.getDocumentReader().getDocuments(new MongoQuery(q.toJson()), 3); if (ds.size() != 0) { fail("Got documents, shouldn't have."); } 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() != 1) { fail("Received incorrect number of documents.."); } }