LibratoReporterProvider implements Provider<LibratoReporter> { @Override public LibratoReporter get() { final Duration timeout = configuration.getTimeout(); final ReporterBuilder builder = LibratoReporter.builder(metricRegistry, configuration.getUsername(), configuration.getToken()) .setName(configuration.getName()) .setPrefix(configuration.getPrefix()) .setPrefixDelimiter(configuration.getPrefixDelimiter()) .setTimeout(timeout.getQuantity(), timeout.getUnit()) .setDeleteIdleStats(configuration.isDeleteIdleStats()) .setOmitComplexGauges(configuration.isOmitComplexGauges()) .setDurationUnit(configuration.getUnitDurations()) .setRateUnit(configuration.getUnitRates()) .setFilter(new RegexMetricFilter(configuration.getIncludeMetrics())) .setEnableLegacy(configuration.isEnableLegacy()) .setEnableTagging(configuration.isEnableTagging()); if (configuration.isEnableTagging()) { configuration.getTags().forEach(builder::addTag); } if (configuration.getSource() != null) { builder.setSource(configuration.getSource()); } if (configuration.getSourceRegex() != null) { builder.setSourceRegex(configuration.getSourceRegex().pattern()); } return builder.build(); } @Inject  LibratoReporterProvider(MetricsLibratoReporterConfiguration configuration, MetricRegistry metricRegistry); @Override LibratoReporter get();  }
@Test public void get() throws Exception { final MetricsLibratoReporterConfiguration configuration = new MetricsLibratoReporterConfiguration() { @Override public String getUsername() { return "username"; } @Override public String getToken() { return "token"; } }; final LibratoReporterProvider provider = new LibratoReporterProvider(configuration, new MetricRegistry()); final LibratoReporter reporter = provider.get(); assertNotNull(reporter); }