Mappers { public static <T> T getMapper(Class<T> clazz) { try { List<ClassLoader> classLoaders = collectClassLoaders( clazz.getClassLoader() ); return getMapper( clazz, classLoaders ); } catch ( ClassNotFoundException | NoSuchMethodException e ) { throw new RuntimeException( e ); } } private  Mappers(); static T getMapper(Class<T> clazz); static Class<? extends T> getMapperClass(Class<T> clazz);  }
@Test public void shouldReturnImplementationInstance() { Foo mapper = Mappers.getMapper( Foo.class ); assertThat( mapper ).isNotNull(); }
@Test public void findsNestedMapperImpl() { assertThat( Mappers.getMapper( SomeClass.Foo.class ) ).isNotNull(); assertThat( Mappers.getMapper( SomeClass.NestedClass.Foo.class ) ).isNotNull(); }
@Test public void shouldReturnPackagePrivateImplementationInstance() { assertThat( Mappers.getMapper( PackagePrivateMapper.class ) ).isNotNull(); }