コード例 #1
0
  /** @see DATAMONGO-468 */
  @Test
  public void rendersUpdateOfDbRefPropertyWithDomainObjectCorrectly() {

    Entity entity = new Entity();
    entity.id = "5";

    Update update = new Update().set("dbRefProperty", entity);
    DBObject mappedObject =
        mapper.getMappedObject(
            update.getUpdateObject(),
            context.getPersistentEntity(DocumentWithDBRefCollection.class));

    DBObject setClause = getAsDBObject(mappedObject, "$set");
    assertThat(setClause.get("dbRefProperty"), is((Object) new DBRef(null, "entity", entity.id)));
  }
コード例 #2
0
  /** @see DATAMONGO-404 */
  @Test
  public void createsDbRefForEntityOnPulls() {

    Entity entity = new Entity();
    entity.id = "5";

    Update update = new Update().pull("dbRefAnnotatedList", entity);
    DBObject mappedObject =
        mapper.getMappedObject(
            update.getUpdateObject(),
            context.getPersistentEntity(DocumentWithDBRefCollection.class));

    DBObject pullClause = getAsDBObject(mappedObject, "$pull");
    assertThat(
        pullClause.get("dbRefAnnotatedList"), is((Object) new DBRef(null, "entity", entity.id)));
  }