final GuiceProvidedModuleHandler guiceProvidedModuleHandler = new GuiceProvidedModuleHandler();
final GuiceModuleHandler guiceModuleHandler = new GuiceModuleHandler();
final GuiceInjectableClassHandler<Inject> guiceInjectableClassHandler = new GuiceInjectableClassHandler<Inject>();
final GuiceInjectableClassHandler<javax.inject.Inject> jsr330InjectableClassHandler = new GuiceInjectableClassHandler<javax.inject.Inject>();
final MockHandler mockHandler = new MockHandler();
final MockFrameworkHandler mockFrameworkHandler = new MockFrameworkHandler();
// Visit class and super-classes
new ClassVisitor()
.registerHandler( GuiceProvidedModules.class, guiceProvidedModuleHandler )
.registerHandler( GuiceModules.class, guiceModuleHandler )
.registerHandler( Mock.class, mockHandler )
.registerHandler( MockFramework.class, mockFrameworkHandler )
.registerHandler( Inject.class, guiceInjectableClassHandler )
.registerHandler( javax.inject.Inject.class, jsr330InjectableClassHandler )
.visit( clazz );
// Retrieve mock framework
if ( mockFrameworkHandler.getMockType() != null )
{
this.mockFramework = mockFrameworkHandler.getMockType();
}
// retrieve the modules founded
allModules.addAll( guiceProvidedModuleHandler.getModules() );
allModules.addAll( guiceModuleHandler.getModules() );
MockEngine engine = MockEngineFactory.getMockEngine( this.mockFramework );
this.mocked.putAll( mockHandler.getMockedObject( engine ) );
if ( !this.mocked.isEmpty() )
{
// Replace all real module binding with Mocked moduled.
Module m = Modules.override( allModules ).with( new GuiceMockModule( this.mocked ) );
allModules.clear();