}
@SuppressWarnings("unchecked")
@Test
public final void testPublishingUsingDifferentExposers() {
StatExposerTestingService service =
injector.getInstance(StatExposerTestingService.class);
service.call();
service.call();
Stats stats = injector.getInstance(Stats.class);
ImmutableMap<StatDescriptor, Object> snapshot = stats.snapshot();
assertEquals(snapshot.size(), 8, "Snapshot has unexpected size: " + snapshot);
AtomicInteger atomicIntegerCallCount = service.getCallCount();
String stringCallCount = String.valueOf(atomicIntegerCallCount);
StatDescriptor callsDefaultExposerDescriptor = getByName(
StatExposerTestingService.CALLS_WITH_DEFAULT_EXPOSER, snapshot);
String callsDefaultExposerValue =
(String) snapshot.get(callsDefaultExposerDescriptor);
assertEquals(stringCallCount, callsDefaultExposerValue);
StatDescriptor callsIdentityExposerDescriptor = getByName(
StatExposerTestingService.CALLS_WITH_IDENTITY_EXPOSER, snapshot);
AtomicInteger callsIdentityExposerValue =
(AtomicInteger) snapshot.get(callsIdentityExposerDescriptor);
assertEquals(atomicIntegerCallCount.get(), callsIdentityExposerValue.get());
StatDescriptor callsInferenceExposerDescriptor = getByName(
StatExposerTestingService.CALLS_WITH_INFERENCE_EXPOSER, snapshot);
String callsInferenceExposerValue =
(String) snapshot.get(callsInferenceExposerDescriptor);
assertEquals(stringCallCount, callsInferenceExposerValue);
StatDescriptor callsToStringExposerDescriptor = getByName(
StatExposerTestingService.CALLS_WITH_TO_STRING_EXPOSER, snapshot);
String callsToStringExposerValue =
(String) snapshot.get(callsToStringExposerDescriptor);
assertEquals(stringCallCount, callsToStringExposerValue);
List<Integer> callsList = service.getCallsList();
String callsListAsString = String.valueOf(callsList);
StatDescriptor listDefaultExposerDescriptor = getByName(
StatExposerTestingService.LIST_WITH_DEFAULT_EXPOSER, snapshot);
List<Integer> listDefaultExposerValue =