Search in sources :

Example 1 with ObjectId

use of org.mongojack.ObjectId in project graylog2-server by Graylog2.

the class ESMongoDateTimeDeserializerTest method deserializeMongoDateTime.

@Test
@MongoDBFixtures("DateTime.json")
public void deserializeMongoDateTime() throws Exception {
    final DBCollection date_collection = mongodb.mongoConnection().getDatabase().getCollection("date_collection");
    final JacksonDBCollection<DTO, ObjectId> db = JacksonDBCollection.wrap(date_collection, DTO.class, ObjectId.class, objectMapper, null);
    final DTO value = db.findOne();
    assertThat(value.dateTime).isEqualTo(new DateTime(2019, 1, 13, 14, 0, DateTimeZone.UTC));
}
Also used : DBCollection(com.mongodb.DBCollection) JacksonDBCollection(org.mongojack.JacksonDBCollection) ObjectId(org.mongojack.ObjectId) DateTime(org.joda.time.DateTime) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Aggregations

DBCollection (com.mongodb.DBCollection)1 MongoDBFixtures (org.graylog.testing.mongodb.MongoDBFixtures)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1 JacksonDBCollection (org.mongojack.JacksonDBCollection)1 ObjectId (org.mongojack.ObjectId)1