use of org.qi4j.bootstrap.ModuleAssembly 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.ModuleAssembly in project qi4j-sdk by Qi4j.
the class AbstractQi4jTest method defineApplication.
@Override
protected void defineApplication(ApplicationAssembly applicationAssembly) throws AssemblyException {
LayerAssembly layer = applicationAssembly.layer("Layer 1");
ModuleAssembly module = layer.module("Module 1");
module.objects(AbstractQi4jTest.this.getClass());
assemble(module);
}
use of org.qi4j.bootstrap.ModuleAssembly 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.ModuleAssembly 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());
}
use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.
the class TypeToCompositeLookupTest method services.
@Test
public void services() throws ActivationException, AssemblyException {
Module module = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.services(SomeOtherFoo.class);
}
}.module();
assertEquals(CATHEDRAL, module.findService(SomeOtherFoo.class).get().bar());
assertEquals(CATHEDRAL, module.findService(BasicFoo.class).get().bar());
assertEquals(CATHEDRAL, module.findService(Foo.class).get().bar());
}
Aggregations