context.addModule( new ModuleOne() );
context.addModule( new ModuleTwo() );
context.addModule( new ModuleThree() );
context.bootstrap();
AcrossContextBeanRegistry registry = AcrossContextUtils.getBeanRegistry( context );
List<GenericBean> beans = registry.getBeansOfType( GenericBean.class, true );
assertEquals( 6, beans.size() );
ResolvableType listType = ResolvableType.forClassWithGenerics( List.class, Integer.class );
ResolvableType type = ResolvableType.forClassWithGenerics( GenericBean.class,
ResolvableType.forClass( Long.class ),
listType
);
beans = registry.getBeansOfType( type, true );
assertEquals( 3, beans.size() );
assertEquals( "longWithIntegerList", beans.get( 0 ).getName() );
assertEquals( "longWithIntegerList", beans.get( 1 ).getName() );
assertEquals( "longWithIntegerList", beans.get( 2 ).getName() );
listType = ResolvableType.forClassWithGenerics( List.class, Date.class );
type = ResolvableType.forClassWithGenerics( GenericBean.class,
ResolvableType.forClass( String.class ),
listType
);
beans = registry.getBeansOfType( type, true );
assertEquals( 3, beans.size() );
assertEquals( "stringWithDateList", beans.get( 0 ).getName() );
assertEquals( "stringWithDateList", beans.get( 1 ).getName() );
assertEquals( "stringWithDateList", beans.get( 2 ).getName() );
}