@Test
  public void whenCreateClassToInstanceMap_thenCreated() {
    final ClassToInstanceMap<Number> numbers = MutableClassToInstanceMap.create();
    numbers.putInstance(Integer.class, 1);
    numbers.putInstance(Double.class, 1.5);

    assertEquals(1, numbers.get(Integer.class));
    assertEquals(1.5, numbers.get(Double.class));
  }
  @Test
  public void putAndGetInstance() {
    // given
    ClassToInstanceMap<Exception> map = MutableClassToInstanceMap.create();

    // when
    map.putInstance(RuntimeException.class, new RuntimeException());
    map.putInstance(NullPointerException.class, new NullPointerException());

    // then
    assertThat(map.getInstance(RuntimeException.class), is(RuntimeException.class));
    assertThat(map.getInstance(NullPointerException.class), is(NullPointerException.class));
  }
 @SuppressWarnings("unchecked")
 @Override
 public boolean processClass(final Class candidate) throws Exception {
   if (DnsResolver.class.isAssignableFrom(candidate)
       && !Modifier.isAbstract(candidate.getModifiers())) {
     try {
       final DnsResolver resolver = (DnsResolver) candidate.newInstance();
       resolvers.putInstance(candidate, resolver);
       return true;
     } catch (final Exception ex) {
       LOG.error(
           "Failed to create instance of DnsResolver: "
               + candidate
               + " because of: "
               + ex.getMessage());
     }
   }
   return false;
 }