public class ServiceIdSelectorTest
{
@Test
public void givenManyServicesWhenInjectServiceThenGetSelectedOne()
{
SingletonAssembler assembler = new SingletonAssembler()
{
public void assemble( ModuleAssembly module )
throws AssemblyException
{
module.objects( ServiceConsumer.class );
module.services( TestServiceComposite1.class,
TestServiceComposite2.class );
}
};
ObjectFactory obf = assembler.module();
ServiceConsumer consumer = obf.newObject( ServiceConsumer.class, TestServiceComposite2.class.getSimpleName() );
TestService service = consumer.getService();
assertThat( "service is selected one", service.test(), equalTo( "mixin2" ) );
}