Search in sources :

Example 26 with ModuleAssembly

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"));
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Test(org.junit.Test)

Example 27 with ModuleAssembly

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);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) LayerAssembly(org.qi4j.bootstrap.LayerAssembly)

Example 28 with ModuleAssembly

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());
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) AssemblyException(org.qi4j.bootstrap.AssemblyException) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Module(org.qi4j.api.structure.Module) Test(org.junit.Test)

Example 29 with ModuleAssembly

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());
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) AssemblyException(org.qi4j.bootstrap.AssemblyException) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Module(org.qi4j.api.structure.Module) Test(org.junit.Test)

Example 30 with ModuleAssembly

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());
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) AssemblyException(org.qi4j.bootstrap.AssemblyException) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Module(org.qi4j.api.structure.Module) Test(org.junit.Test)

Aggregations

ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)191 SingletonAssembler (org.qi4j.bootstrap.SingletonAssembler)87 Test (org.junit.Test)82 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)59 AssemblyException (org.qi4j.bootstrap.AssemblyException)27 Application (org.qi4j.api.structure.Application)26 OrgJsonValueSerializationAssembler (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)24 Assembler (org.qi4j.bootstrap.Assembler)23 Module (org.qi4j.api.structure.Module)19 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)15 Before (org.junit.Before)12 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)12 Energy4Java (org.qi4j.bootstrap.Energy4Java)12 DataSourceAssembler (org.qi4j.library.sql.assembly.DataSourceAssembler)11 DBCPDataSourceServiceAssembler (org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler)9 IOException (java.io.IOException)8 ApplicationAssemblerAdapter (org.qi4j.bootstrap.ApplicationAssemblerAdapter)8 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)8 File (java.io.File)7 OrgJsonValueSerializationService (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationService)7