Ejemplo n.º 1
0
 @Test
 public void testRequireID() {
   Document d = mdc.getDocumentReader().getDocument(new MongoQuery());
   MongoQuery mdq = new MongoQuery();
   mdq.requireID(d.getID());
   if (null == mdc.getDocumentReader().getDocument(mdq)) {
     fail("Did not find a document with expected ID");
   }
   if (!mdc.getDocumentReader().getDocument(mdq).isEqual(d)) {
     fail("Found wrong document! " + d.getID());
   }
 }
Ejemplo n.º 2
0
  @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..");
    }
  }
Ejemplo n.º 3
0
  @Test
  public void testFromJSON() throws JsonException {
    LocalQuery q = new LocalQuery();
    MongoQuery mdq = new MongoQuery();
    mdq.fromJson(q.toJson());
    if (mdq.toDBObject().keySet().size() != 0) {
      fail("Expected query to be empty");
    }

    q.requireContentFieldExists("name");
    mdq.fromJson(q.toJson());
    if (mdq.toDBObject().keySet().size() != 1) {
      fail("Expected query to have one value");
    }
    List<DatabaseDocument<MongoType>> list = mdc.getDocumentReader().getDocuments(mdq, 142);
    if (list.size() != 2) {
      fail("Expected to find two documents");
    }
    for (Document d : list) {
      if (!d.hasContentField("name")) {
        fail("Fetched document is missing content field name");
      }
    }
  }