@Test public void testCreateDatabaseProxy() { try { Class.forName("com.mongodb.ReadPreference"); } catch (final ClassNotFoundException e) { Logger.getRootLogger().info(e.toString()); return; } final MongoDatabase database = createNiceMock(MongoDatabase.class); final MongoCollection<Document> collection = createNiceMock(MongoCollection.class); final CodecRegistry codecRegistry = createNiceMock(CodecRegistry.class); expect(database.withCodecRegistry(codecRegistry)).andReturn(database).anyTimes(); expect(database.getCollection("collection")).andReturn(collection).anyTimes(); expect(database.getName()).andReturn("db").anyTimes(); expect(collection.withCodecRegistry(codecRegistry)).andReturn(collection).anyTimes(); replay(database); replay(collection); replay(codecRegistry); final MongoDatabase databaseProxy = MongoWrapper.createDatabaseProxy(database); assertNotNull("createDatabaseProxy", databaseProxy); assertNotNull("databaseProxy", databaseProxy.withCodecRegistry(codecRegistry)); assertNotNull("getCollection", databaseProxy.getCollection("collection")); assertEquals("getName", "db", databaseProxy.getName()); assertNotNull("collectionProxy", databaseProxy.getCollection("collection").withCodecRegistry(codecRegistry)); databaseProxy.getCollection("collection").getCodecRegistry(); databaseProxy.getCollection("collection").find(); verify(database); verify(collection); verify(codecRegistry); }
public static MongoDatabase createDatabaseProxy(final MongoDatabase database) { if (DISABLED) { return database; } SERVICES_COUNTER.setDisplayed(!COUNTER_HIDDEN); SERVICES_COUNTER.setUsed(true); return JdbcWrapper.createProxy(database, new MongoDatabaseHandler(database)); }
MongoWrapper { public static MongoDatabase createDatabaseProxy(final MongoDatabase database) { if (DISABLED) { return database; } SERVICES_COUNTER.setDisplayed(!COUNTER_HIDDEN); SERVICES_COUNTER.setUsed(true); return JdbcWrapper.createProxy(database, new MongoDatabaseHandler(database)); } }
MongoWrapper { public static MongoDatabase createDatabaseProxy(final MongoDatabase database) { if (DISABLED) { return database; } SERVICES_COUNTER.setDisplayed(!COUNTER_HIDDEN); SERVICES_COUNTER.setUsed(true); return JdbcWrapper.createProxy(database, new MongoDatabaseHandler(database)); } private  MongoWrapper(); }
MongoWrapper { public static MongoDatabase createDatabaseProxy(final MongoDatabase database) { if (DISABLED) { return database; } SERVICES_COUNTER.setDisplayed(!COUNTER_HIDDEN); SERVICES_COUNTER.setUsed(true); return JdbcWrapper.createProxy(database, new MongoDatabaseHandler(database)); } private  MongoWrapper(); static MongoDatabase createDatabaseProxy(final MongoDatabase database); }
MongoWrapper { public static MongoDatabase createDatabaseProxy(final MongoDatabase database) { if (DISABLED) { return database; } SERVICES_COUNTER.setDisplayed(!COUNTER_HIDDEN); SERVICES_COUNTER.setUsed(true); return JdbcWrapper.createProxy(database, new MongoDatabaseHandler(database)); } private  MongoWrapper(); static MongoDatabase createDatabaseProxy(final MongoDatabase database);  }