Search in sources :

Example 1 with Assembler

use of org.qi4j.bootstrap.Assembler in project qi4j-sdk by Qi4j.

the class MixinVisibilityTest method testMixinInLowerLayerIsVisible.

@Test
public void testMixinInLowerLayerIsVisible() throws Exception {
    Energy4Java boot = new Energy4Java();
    Assembler[][][] assemblers = new Assembler[][][] { { // Layer 1
    { new Assembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.setName("Module A");
            module.objects(ObjectA.class);
        }
    } } }, { // Layer 2
    { new Assembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.setName("Module B");
            module.transients(B1Composite.class).visibleIn(Visibility.application);
        }
    } } } };
    Application app = boot.newApplication(new ApplicationAssemblerAdapter(assemblers) {
    });
    app.activate();
    ObjectA object = app.findModule("Layer 1", "Module A").newObject(ObjectA.class);
    assertEquals("ok", object.test1());
    assertEquals("abc", object.test2());
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) Energy4Java(org.qi4j.bootstrap.Energy4Java) Assembler(org.qi4j.bootstrap.Assembler) Application(org.qi4j.api.structure.Application) ApplicationAssemblerAdapter(org.qi4j.bootstrap.ApplicationAssemblerAdapter) Test(org.junit.Test)

Example 2 with Assembler

use of org.qi4j.bootstrap.Assembler in project qi4j-sdk by Qi4j.

the class MixinVisibilityTest method testMultipleMixinsInLayerWillFailSameModule.

@Test(expected = AmbiguousTypeException.class)
public void testMultipleMixinsInLayerWillFailSameModule() throws Exception {
    Energy4Java boot = new Energy4Java();
    Assembler[][][] assemblers = new Assembler[][][] { { // Layer
    { new Assembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.setName("Module A");
            module.objects(ObjectA.class);
        }
    } }, { new Assembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.setName("Module B");
            module.transients(B1Composite.class, B2Composite.class).visibleIn(Visibility.layer);
        }
    } } } };
    Application app = boot.newApplication(new ApplicationAssemblerAdapter(assemblers) {
    });
    app.activate();
    ObjectA object = app.findModule("Layer 1", "Module A").newObject(ObjectA.class);
    assertEquals("ok", object.test1());
    assertEquals("abc", object.test2());
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) Energy4Java(org.qi4j.bootstrap.Energy4Java) Assembler(org.qi4j.bootstrap.Assembler) Application(org.qi4j.api.structure.Application) ApplicationAssemblerAdapter(org.qi4j.bootstrap.ApplicationAssemblerAdapter) Test(org.junit.Test)

Example 3 with Assembler

use of org.qi4j.bootstrap.Assembler in project qi4j-sdk by Qi4j.

the class MixinVisibilityTest method testMixinInModuleIsVisible.

@Test
public void testMixinInModuleIsVisible() throws Exception {
    Energy4Java boot = new Energy4Java();
    Assembler[][][] assemblers = new Assembler[][][] { { // Layer
    { // Module 1
    new Assembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.setName("Module A");
            module.transients(B1Composite.class);
            module.objects(ObjectA.class);
        }
    } } } };
    Application app = boot.newApplication(new ApplicationAssemblerAdapter(assemblers) {
    });
    app.activate();
    ObjectA object = app.findModule("Layer 1", "Module A").newObject(ObjectA.class);
    assertEquals("ok", object.test1());
    assertEquals("abc", object.test2());
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) Energy4Java(org.qi4j.bootstrap.Energy4Java) Assembler(org.qi4j.bootstrap.Assembler) Application(org.qi4j.api.structure.Application) ApplicationAssemblerAdapter(org.qi4j.bootstrap.ApplicationAssemblerAdapter) Test(org.junit.Test)

Example 4 with Assembler

use of org.qi4j.bootstrap.Assembler in project qi4j-sdk by Qi4j.

the class PrivateCompositeVisibilityTest method testPrivateCompositeVisibility.

@Test(expected = NoSuchTransientException.class)
public void testPrivateCompositeVisibility() throws Exception {
    Energy4Java boot = new Energy4Java();
    Assembler[][][] assemblers = new Assembler[][][] { { // Layer
    { new AssemblerA() }, { new AssemblerB() } } };
    Application app = boot.newApplication(new ApplicationAssemblerAdapter(assemblers) {
    });
    app.activate();
    ObjectA object = app.findModule("Layer 1", "Module A").newObject(ObjectA.class);
    object.test();
}
Also used : Energy4Java(org.qi4j.bootstrap.Energy4Java) Assembler(org.qi4j.bootstrap.Assembler) Application(org.qi4j.api.structure.Application) ApplicationAssemblerAdapter(org.qi4j.bootstrap.ApplicationAssemblerAdapter) Test(org.junit.Test)

Example 5 with Assembler

use of org.qi4j.bootstrap.Assembler in project qi4j-sdk by Qi4j.

the class StructureTest method createApplicationUsingArrayOfAssemblers.

@Test
public void createApplicationUsingArrayOfAssemblers() throws AssemblyException {
    Energy4Java boot = new Energy4Java();
    Assembler[][][] assemblers = new Assembler[][][] { { // User Interface layer
    { new ViewAssembler() } }, { // Application layer
    { new DomainApplicationAssembler() } }, { // Domain layer
    { new DomainModelAssembler() } }, { // Infrastructure layer
    { new InfrastructureAssembler() } } };
    boot.newApplication(new ApplicationAssemblerAdapter(assemblers) {
    });
}
Also used : Energy4Java(org.qi4j.bootstrap.Energy4Java) ApplicationAssembler(org.qi4j.bootstrap.ApplicationAssembler) Assembler(org.qi4j.bootstrap.Assembler) ApplicationAssemblerAdapter(org.qi4j.bootstrap.ApplicationAssemblerAdapter) Test(org.junit.Test)

Aggregations

Assembler (org.qi4j.bootstrap.Assembler)34 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)23 Energy4Java (org.qi4j.bootstrap.Energy4Java)19 Test (org.junit.Test)17 ApplicationAssemblerAdapter (org.qi4j.bootstrap.ApplicationAssemblerAdapter)17 Application (org.qi4j.api.structure.Application)13 AssemblyException (org.qi4j.bootstrap.AssemblyException)10 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)9 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)8 IOException (java.io.IOException)6 Before (org.junit.Before)6 Module (org.qi4j.api.structure.Module)5 ApplicationAssembler (org.qi4j.bootstrap.ApplicationAssembler)4 OrgJsonValueSerializationAssembler (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)4 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)3 ApplicationAssemblyFactory (org.qi4j.bootstrap.ApplicationAssemblyFactory)3 DataSourceAssembler (org.qi4j.library.sql.assembly.DataSourceAssembler)3 DBCPDataSourceServiceAssembler (org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler)3 PostgreSQLEntityStoreAssembler (org.qi4j.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler)2 Connection (java.sql.Connection)1