Package org.springframework.data.mongodb.core.mapping

Examples of org.springframework.data.mongodb.core.mapping.PersonPojoStringId


    converter.read(Person.class, dbObject);
  }

  @Test
  public void convertsObjectIdStringsToObjectIdCorrectly() {
    PersonPojoStringId p1 = new PersonPojoStringId("1234567890", "Text-1");
    DBObject dbo1 = new BasicDBObject();

    converter.write(p1, dbo1);
    assertThat(dbo1.get("_id"), is(instanceOf(String.class)));

    PersonPojoStringId p2 = new PersonPojoStringId(new ObjectId().toString(), "Text-1");
    DBObject dbo2 = new BasicDBObject();

    converter.write(p2, dbo2);
    assertThat(dbo2.get("_id"), is(instanceOf(ObjectId.class)));
  }
View Full Code Here


    assertEquals(0, afterSaveListener.seenEvents.size());

    assertEquals(0, simpleMappingEventListener.onBeforeSaveEvents.size());
    assertEquals(0, simpleMappingEventListener.onAfterSaveEvents.size());

    PersonPojoStringId p = new PersonPojoStringId("1", "Text");
    template.insert(p);

    assertEquals(1, personBeforeSaveListener.seenEvents.size());
    assertEquals(1, afterSaveListener.seenEvents.size());

    assertEquals(1, simpleMappingEventListener.onBeforeSaveEvents.size());
    assertEquals(1, simpleMappingEventListener.onAfterSaveEvents.size());

    Assert.assertTrue(personBeforeSaveListener.seenEvents.get(0) instanceof BeforeSaveEvent<?>);
    Assert.assertTrue(afterSaveListener.seenEvents.get(0) instanceof AfterSaveEvent<?>);

    BeforeSaveEvent<PersonPojoStringId> beforeSaveEvent = (BeforeSaveEvent<PersonPojoStringId>) personBeforeSaveListener.seenEvents
        .get(0);
    PersonPojoStringId p2 = beforeSaveEvent.getSource();
    DBObject dbo = beforeSaveEvent.getDBObject();

    comparePersonAndDbo(p, p2, dbo);

    AfterSaveEvent<Object> afterSaveEvent = (AfterSaveEvent<Object>) afterSaveListener.seenEvents.get(0);
View Full Code Here

TOP

Related Classes of org.springframework.data.mongodb.core.mapping.PersonPojoStringId

Copyright © 2018 www.massapicom. 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.