use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class ObjectConcernTest method testConcernOnObject.
@Test
public void testConcernOnObject() throws ActivationException, AssemblyException {
SingletonAssembler assembler = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.objects(TestObject.class);
}
};
TestObject object = assembler.module().newObject(TestObject.class);
object.doStuff();
}
use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class ServiceSelectorImporterTest method givenManyServicesAndSelectFirstWhenInjectServiceThenDontGetSelf.
@Test
public void givenManyServicesAndSelectFirstWhenInjectServiceThenDontGetSelf() throws ActivationException, AssemblyException {
SingletonAssembler assembler = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.objects(ServiceConsumer.class);
module.importedServices(TestService.class).importedBy(SERVICE_SELECTOR).setMetaInfo(ServiceQualifier.withId("TestServiceComposite2_1"));
ModuleAssembly module2 = module.layer().module("Other module");
module2.addServices(TestServiceComposite2.class, TestServiceComposite2.class).visibleIn(Visibility.layer);
}
};
TestService service = assembler.module().newObject(ServiceConsumer.class).getService();
assertThat("service is specified one", service.test(), equalTo("mixin2"));
}
use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class ServiceSelectorImporterTest method givenManyServicesWhenInjectServiceThenGetFirstOne.
@Test
public void givenManyServicesWhenInjectServiceThenGetFirstOne() throws ActivationException, AssemblyException {
SingletonAssembler assembler = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.objects(ServiceConsumer.class);
module.services(TestServiceComposite1.class, TestServiceComposite2.class);
}
};
TestService service = assembler.module().newObject(ServiceConsumer.class).getService();
assertThat("service is first one", service.test(), equalTo("mixin1"));
}
use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class TypeToCompositeLookupTest method values.
@Test
public void values() throws ActivationException, AssemblyException {
Module module = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.values(SomeOtherFoo.class);
}
}.module();
assertEquals(CATHEDRAL, module.newValueBuilder(SomeOtherFoo.class).newInstance().bar());
assertEquals(CATHEDRAL, module.newValueBuilder(BasicFoo.class).newInstance().bar());
assertEquals(CATHEDRAL, module.newValueBuilder(Foo.class).newInstance().bar());
}
use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class TypeToCompositeLookupTest method objects.
@Test
public void objects() throws ActivationException, AssemblyException {
Module module = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.objects(SomeOtherFooImpl.class);
}
}.module();
assertEquals(CATHEDRAL, module.newObject(SomeOtherFooImpl.class).bar());
assertEquals(CATHEDRAL, module.newObject(BasicFooImpl.class).bar());
assertEquals(CATHEDRAL, module.newObject(Foo.class).bar());
}
Aggregations