GuiceProbeProvider { @SuppressWarnings("unchecked") public <T extends GuiceProbe> T getProbe(Class<T> clazz) { Preconditions.checkNotNull(clazz); return Optional.ofNullable(registry.get(clazz)) .map(probe -> (T) probe) .orElseThrow(() -> new RuntimeException("No probe registered for class: " + clazz)); } @SuppressWarnings("unchecked") @Inject  GuiceProbeProvider(Set<GuiceProbe> guiceProbes); @SuppressWarnings("unchecked") T getProbe(Class<T> clazz);  }
@Test public void getProveShouldThrowExcpetionWhenNull() { expectedException.expect(NullPointerException.class); guiceProbeProvider.getProbe(null); }
@Test public void getProbeShouldThrowRuntimeExceptionWhenEmpty() { expectedException.expect(RuntimeException.class); guiceProbeProvider.getProbe(GuiceProbe2.class); }
@Test public void getProbeShouldReturnRightProbe() { assertThat(guiceProbeProvider.getProbe(GuiceProbe1.class)).isEqualTo(guiceProbe1); }