MongoDBReporterProvider implements Provider<MongoDBReporter> { @Override public MongoDBReporter get() { final MongoClientURI mongoClientURI = configuration.getUri(); final MongoCredential credentials = mongoClientURI.getCredentials(); return MongoDBReporter.forRegistry(metricRegistry) .serverAddresses(extractServerAddresses(mongoClientURI)) .mongoCredentials(credentials == null ? new MongoCredential[0] : new MongoCredential[]{credentials}) .mongoClientOptions(mongoClientURI.getOptions()) .withDatabaseName(mongoClientURI.getDatabase()) .additionalFields(configuration.getAdditionalFields()) .convertDurationsTo(configuration.getUnitDurations()) .convertRatesTo(configuration.getUnitRates()) .filter(new RegexMetricFilter(configuration.getIncludeMetrics())) .build(); } @Inject  MongoDBReporterProvider(MetricsMongoDbReporterConfiguration configuration,
                                   MetricRegistry metricRegistry); @Override MongoDBReporter get();  }
@Test public void get() throws Exception { final MetricsMongoDbReporterConfiguration configuration = new MetricsMongoDbReporterConfiguration() { @Override public MongoClientURI getUri() { return new MongoClientURI("mongodb: } }; final MongoDBReporterProvider provider = new MongoDBReporterProvider(configuration, new MetricRegistry()); final MongoDBReporter reporter = provider.get(); assertNotNull(reporter); }