Search in sources :

Example 1 with PojoCodecProvider

use of org.bson.codecs.pojo.PojoCodecProvider in project mongo-java-driver by mongodb.

the class AbstractUuidRepresentationTest method setUp.

@Before
public void setUp() {
    PojoCodecProvider pojoCodecProvider = PojoCodecProvider.builder().automatic(true).build();
    CodecRegistry codecRegistry = fromRegistries(getDefaultCodecRegistry(), fromProviders(pojoCodecProvider));
    createMongoClient(uuidRepresentation, codecRegistry);
    MongoDatabase database = getDatabase(getDefaultDatabaseName());
    documentCollection = database.getCollection(getClass().getName());
    dbObjectCollection = documentCollection.withDocumentClass(DBObject.class);
    uuidIdPojoCollection = documentCollection.withDocumentClass(UuidIdPojo.class);
    bsonDocumentCollection = getMongoClient().getDatabase(getDefaultDatabaseName()).getCollection(getClass().getName()).withDocumentClass(BsonDocument.class);
    bsonDocumentCollection.drop();
}
Also used : BsonDocument(org.bson.BsonDocument) PojoCodecProvider(org.bson.codecs.pojo.PojoCodecProvider) CodecRegistry(org.bson.codecs.configuration.CodecRegistry) MongoClientSettings.getDefaultCodecRegistry(com.mongodb.MongoClientSettings.getDefaultCodecRegistry) DBObject(com.mongodb.DBObject) BasicDBObject(com.mongodb.BasicDBObject) Before(org.junit.Before)

Aggregations

BasicDBObject (com.mongodb.BasicDBObject)1 DBObject (com.mongodb.DBObject)1 MongoClientSettings.getDefaultCodecRegistry (com.mongodb.MongoClientSettings.getDefaultCodecRegistry)1 BsonDocument (org.bson.BsonDocument)1 CodecRegistry (org.bson.codecs.configuration.CodecRegistry)1 PojoCodecProvider (org.bson.codecs.pojo.PojoCodecProvider)1 Before (org.junit.Before)1