Examples of BasicDBObjectBuilder


Examples of com.mongodb.BasicDBObjectBuilder

   * @see DATAMONGO-1050
   */
  @Test
  public void readShouldUseExplicitFieldnameForIdPropertyWhenAnnotated() {

    DBObject source = new BasicDBObjectBuilder().add("_id", "rootId")
        .add("nested", new BasicDBObject("id", "nestedId")).get();

    RootForClassWithExplicitlyRenamedIdField sink = converter.read(RootForClassWithExplicitlyRenamedIdField.class,
        source);

View Full Code Here

Examples of com.mongodb.BasicDBObjectBuilder

   * @see DATAMONGO-1050
   */
  @Test
  public void namedIdFieldShouldExtractValueFromUnderscoreIdField() {

    DBObject dbo = new BasicDBObjectBuilder().add("_id", "A").add("id", "B").get();

    ClassWithNamedIdField withNamedIdField = converter.read(ClassWithNamedIdField.class, dbo);

    assertThat(withNamedIdField.id, is("A"));
  }
View Full Code Here

Examples of com.mongodb.BasicDBObjectBuilder

   * @see DATAMONGO-1050
   */
  @Test
  public void explicitlyRenamedIfFieldShouldExtractValueFromIdField() {

    DBObject dbo = new BasicDBObjectBuilder().add("_id", "A").add("id", "B").get();

    ClassWithExplicitlyRenamedField withExplicitlyRenamedField = converter.read(ClassWithExplicitlyRenamedField.class,
        dbo);

    assertThat(withExplicitlyRenamedField.id, is("B"));
View Full Code Here

Examples of com.mongodb.BasicDBObjectBuilder

   * @see DATAMONGO-1050
   */
  @Test
  public void annotatedIdFieldShouldExtractValueFromUnderscoreIdField() {

    DBObject dbo = new BasicDBObjectBuilder().add("_id", "A").add("id", "B").get();

    ClassWithAnnotatedIdField withAnnotatedIdField = converter.read(ClassWithAnnotatedIdField.class, dbo);

    assertThat(withAnnotatedIdField.key, is("A"));
  }
View Full Code Here

Examples of com.mongodb.BasicDBObjectBuilder

  @Test
  public void getUpdateObjectShouldReturnCurrentDateCorrectlyForSingleFieldWhenUsingDate() {

    Update update = new Update().currentDate("foo");
    assertThat(update.getUpdateObject(),
        equalTo(new BasicDBObjectBuilder().add("$currentDate", new BasicDBObject("foo", true)).get()));
  }
View Full Code Here

Examples of com.mongodb.BasicDBObjectBuilder

  @Test
  public void getUpdateObjectShouldReturnCurrentDateCorrectlyForMultipleFieldsWhenUsingDate() {

    Update update = new Update().currentDate("foo").currentDate("bar");
    assertThat(update.getUpdateObject(),
        equalTo(new BasicDBObjectBuilder().add("$currentDate", new BasicDBObject("foo", true).append("bar", true))
            .get()));
  }
View Full Code Here

Examples of com.mongodb.BasicDBObjectBuilder

  public void getUpdateObjectShouldReturnCurrentDateCorrectlyForSingleFieldWhenUsingTimestamp() {

    Update update = new Update().currentTimestamp("foo");
    assertThat(
        update.getUpdateObject(),
        equalTo(new BasicDBObjectBuilder().add("$currentDate",
            new BasicDBObject("foo", new BasicDBObject("$type", "timestamp"))).get()));
  }
View Full Code Here

Examples of com.mongodb.BasicDBObjectBuilder

  public void getUpdateObjectShouldReturnCurrentDateCorrectlyForMultipleFieldsWhenUsingTimestamp() {

    Update update = new Update().currentTimestamp("foo").currentTimestamp("bar");
    assertThat(
        update.getUpdateObject(),
        equalTo(new BasicDBObjectBuilder().add(
            "$currentDate",
            new BasicDBObject("foo", new BasicDBObject("$type", "timestamp")).append("bar", new BasicDBObject("$type",
                "timestamp"))).get()));
  }
View Full Code Here

Examples of com.mongodb.BasicDBObjectBuilder

  public void getUpdateObjectShouldReturnCurrentDateCorrectlyWhenUsingMixedDateAndTimestamp() {

    Update update = new Update().currentDate("foo").currentTimestamp("bar");
    assertThat(
        update.getUpdateObject(),
        equalTo(new BasicDBObjectBuilder().add("$currentDate",
            new BasicDBObject("foo", true).append("bar", new BasicDBObject("$type", "timestamp"))).get()));
  }
View Full Code Here

Examples of com.mongodb.BasicDBObjectBuilder

  @Test
  public void customizedFieldNameShouldBeMappedCorrectlyWhenApplyingSort() {

    Query query = query(where("field").is("bar")).with(new Sort(Direction.DESC, "field"));
    DBObject dbo = mapper.getMappedObject(query.getSortObject(), context.getPersistentEntity(CustomizedField.class));
    assertThat(dbo, equalTo(new BasicDBObjectBuilder().add("foo", -1).get()));
  }
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.