RosieViewProxyGenerator { T generate(Object view) { final Class[] viewClasses = getViewInterfaceClasses(view); ClassLoader classLoader = viewClasses[0].getClassLoader(); return (T) Proxy.newProxyInstance(classLoader, viewClasses, EMPTY_HANDLER); }    }
@Test public void shouldGenerateAClassImplementingBothInterfacesExtendingFromRosieView() { A a = generator.generate(anyClassExtendingInterfaces); B b = generator.generate(anyClassExtendingInterfaces); assertTrue(a instanceof A); assertTrue(a instanceof B); assertTrue(b instanceof A); assertTrue(b instanceof B); }
@Test public void shouldNotGenerateTheClassUsingTheInstancesNotExtendingFromRosieView() { A a = generator.generate(anyClassExtendingInterfaces); assertFalse(a instanceof NotARosieView); }