GMetricProvider implements Provider<GMetric> { @Override public GMetric get() { try { return new GMetric( configuration.getGroup(), configuration.getPort(), configuration.getUDPAddressingMode(), configuration.getTtl(), configuration.isGanglia31x(), configuration.getUUID(), configuration.getSpoof()); } catch (IOException e) { throw new UncheckedIOException(e); } } @Inject  GMetricProvider(MetricsGangliaReporterConfiguration configuration); @Override GMetric get();  }
@Test public void getReturnsGMetricUsingUnicast() throws Exception { final MetricsGangliaReporterConfiguration configuration = new MetricsGangliaReporterConfiguration() { @Override public GMetric.UDPAddressingMode getUDPAddressingMode() { return GMetric.UDPAddressingMode.UNICAST; } }; final GMetricProvider provider = new GMetricProvider(configuration); final GMetric metric = provider.get(); assertNotNull(metric); }
@Test public void getReturnsGMetricUsingMulticast() throws Exception { final MetricsGangliaReporterConfiguration configuration = new MetricsGangliaReporterConfiguration() { @Override public GMetric.UDPAddressingMode getUDPAddressingMode() { return GMetric.UDPAddressingMode.MULTICAST; } }; final GMetricProvider provider = new GMetricProvider(configuration); final GMetric metric = provider.get(); assertNotNull(metric); }