});
}
@Test
public final void testPublishingStatsInDummyService() {
DummyService service = injector.getInstance(DummyService.class);
service.call();
service.call();
service.call();
Stats stats = injector.getInstance(Stats.class);
ImmutableMap<StatDescriptor, Object> snapshot = stats.snapshot();
assertEquals(snapshot.size(), 2);
// Here we check the value of the field, NUMBER_OF_CALLS
StatDescriptor numberOfCallsDescriptor =
getByName(DummyService.NUMBER_OF_CALLS, snapshot);
String numberOfCallsValue = (String) snapshot.get(numberOfCallsDescriptor);
assertEquals(String.valueOf(service.getCalls()), numberOfCallsValue);
// Here we check the value of the method, CALL_LATENCY_NS
StatDescriptor callLatencyNsDescriptor =
getByName(DummyService.CALL_LATENCY_NS, snapshot);
String callLatencyValue = (String) snapshot.get(callLatencyNsDescriptor);
assertEquals(service.getCallLatencyMs().toString(), callLatencyValue);
}