Package com.mongodb

Examples of com.mongodb.DBObject.containsField()


    Query query = query(where("field.field").is(new CustomizedField()));
    DBObject result = mapper
        .getMappedObject(query.getQueryObject(), context.getPersistentEntity(CustomizedField.class));

    assertThat(result.containsField("foo.foo"), is(true));
    assertThat(result.keySet().size(), is(1));
  }

  @Test
  public void returnsOriginalKeyIfNoPropertyReference() {
View Full Code Here


    Query query = query(where("bar").is(new CustomizedField()));
    DBObject result = mapper
        .getMappedObject(query.getQueryObject(), context.getPersistentEntity(CustomizedField.class));

    assertThat(result.containsField("bar"), is(true));
    assertThat(result.keySet().size(), is(1));
  }

  @Test
  public void convertsAssociationCorrectly() {
View Full Code Here

    String id = new ObjectId().toString();
    Query query = query(where("id").is(id));

    DBObject object = mapper.getMappedObject(query.getQueryObject(), null);

    assertThat(object.containsField("id"), is(true));
    assertThat(object.get("id"), is((Object) id));
    assertThat(object.containsField("_id"), is(false));
  }

  /**
 
View Full Code Here

    DBObject object = mapper.getMappedObject(query.getQueryObject(), null);

    assertThat(object.containsField("id"), is(true));
    assertThat(object.get("id"), is((Object) id));
    assertThat(object.containsField("_id"), is(false));
  }

  /**
   * @see DATAMONGO-677
   */
 
View Full Code Here

    DBObject dbObject = new BasicDBObject();
    dbObject.put("mapWithDBRef", mapDbObject);

    DBObject mapped = mapper.getMappedObject(dbObject, context.getPersistentEntity(WithMapDBRef.class));

    assertThat(mapped.containsField("mapWithDBRef"), is(true));
    assertThat(mapped.get("mapWithDBRef"), instanceOf(BasicDBObject.class));
    assertThat(((BasicDBObject) mapped.get("mapWithDBRef")).containsField("test"), is(true));
    assertThat(((BasicDBObject) mapped.get("mapWithDBRef")).get("test"), instanceOf(com.mongodb.DBRef.class));
  }
View Full Code Here

  public void convertsUnderscoreIdValueWithoutMetadata() {

    DBObject dbObject = new BasicDBObject().append("_id", new ObjectId().toString());

    DBObject mapped = mapper.getMappedObject(dbObject, null);
    assertThat(mapped.containsField("_id"), is(true));
    assertThat(mapped.get("_id"), is(instanceOf(ObjectId.class)));
  }

  /**
   * @see DATAMONGO-705
View Full Code Here

    BasicMongoPersistentEntity<?> entity = context.getPersistentEntity(WithDBRef.class);
    DBObject mappedObject = mapper.getMappedObject(query.getQueryObject(), entity);

    DBObject reference = getAsDBObject(mappedObject, "reference");
    assertThat(reference.containsField("$exists"), is(true));
    assertThat(reference.get("$exists"), is((Object) false));
  }

  /**
   * @see DATAMONGO-706
View Full Code Here

    ObjectId id = new ObjectId();

    DBObject query = new BasicDBObject("reference.id", new com.mongodb.DBRef(null, "reference", id.toString()));
    DBObject result = mapper.getMappedObject(query, context.getPersistentEntity(WithDBRef.class));

    assertThat(result.containsField("reference"), is(true));
    com.mongodb.DBRef reference = getTypedValue(result, "reference", com.mongodb.DBRef.class);
    assertThat(reference.getId(), is(instanceOf(ObjectId.class)));
  }

  /**
 
View Full Code Here

  private void assertMapReduceResults(GroupByResults<XObject> results) {

    DBObject dboRawResults = results.getRawResults();

    assertThat(dboRawResults.containsField("serverUsed"), is(true));
    assertThat(dboRawResults.get("serverUsed").toString(), endsWith("127.0.0.1:27017"));

    int numResults = 0;
    for (XObject xObject : results) {
      if (xObject.getX() == 1) {
View Full Code Here

      dbo.put("cond", queryMapper.getMappedObject(criteria.getCriteriaObject(), null));
    }
    // If initial document was a JavaScript string, potentially loaded by Spring's Resource abstraction, load it and
    // convert to DBObject

    if (dbo.containsField("initial")) {
      Object initialObj = dbo.get("initial");
      if (initialObj instanceof String) {
        String initialAsString = replaceWithResourceIfNecessary((String) initialObj);
        dbo.put("initial", JSON.parse(initialAsString));
      }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.