Search in sources :

Example 6 with Energy4Java

use of org.qi4j.bootstrap.Energy4Java 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 7 with Energy4Java

use of org.qi4j.bootstrap.Energy4Java 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 8 with Energy4Java

use of org.qi4j.bootstrap.Energy4Java 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)

Example 9 with Energy4Java

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

the class StructureTest method createApplicationUsingApplicationAssembly.

@Test
public void createApplicationUsingApplicationAssembly() throws AssemblyException {
    Energy4Java boot = new Energy4Java();
    boot.newApplication(new ApplicationAssembler() {

        public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
            ApplicationAssembly applicationAssembly = applicationFactory.newApplicationAssembly();
            // Application Layer
            LayerAssembly applicationLayer = applicationAssembly.layer("Application");
            ModuleAssembly applicationModule = applicationLayer.module("Application");
            new DomainApplicationAssembler().assemble(applicationModule);
            // View Layer
            LayerAssembly viewLayer = applicationAssembly.layer("View");
            ModuleAssembly viewModule = viewLayer.module("View");
            new ViewAssembler().assemble(viewModule);
            viewLayer.uses(applicationLayer);
            return applicationAssembly;
        }
    });
}
Also used : ApplicationAssemblyFactory(org.qi4j.bootstrap.ApplicationAssemblyFactory) AssemblyException(org.qi4j.bootstrap.AssemblyException) ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) ApplicationAssembler(org.qi4j.bootstrap.ApplicationAssembler) ApplicationAssembly(org.qi4j.bootstrap.ApplicationAssembly) Energy4Java(org.qi4j.bootstrap.Energy4Java) LayerAssembly(org.qi4j.bootstrap.LayerAssembly) Test(org.junit.Test)

Example 10 with Energy4Java

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

the class MixinVisibilityTest method testMultipleMixinsInLayerWillFailDiffModule.

@Test(expected = AmbiguousTypeException.class)
public void testMultipleMixinsInLayerWillFailDiffModule() 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.objects(ObjectA.class);
        }
    } }, { // Module 2
    new Assembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.setName("Module B");
            module.transients(B1Composite.class).visibleIn(Visibility.layer);
        }
    } }, { // Module 3
    new Assembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.setName("Module C");
            module.transients(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)

Aggregations

Energy4Java (org.qi4j.bootstrap.Energy4Java)39 Assembler (org.qi4j.bootstrap.Assembler)19 Application (org.qi4j.api.structure.Application)18 ApplicationAssemblerAdapter (org.qi4j.bootstrap.ApplicationAssemblerAdapter)17 Test (org.junit.Test)15 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)12 ApplicationAssembler (org.qi4j.bootstrap.ApplicationAssembler)11 ApplicationDescriptor (org.qi4j.api.structure.ApplicationDescriptor)8 AssemblyException (org.qi4j.bootstrap.AssemblyException)8 Before (org.junit.Before)7 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)7 ApplicationAssemblyFactory (org.qi4j.bootstrap.ApplicationAssemblyFactory)7 Module (org.qi4j.api.structure.Module)6 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)6 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)4 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)3 Envisage (org.qi4j.envisage.Envisage)3 UnitOfWorkCompletionException (org.qi4j.api.unitofwork.UnitOfWorkCompletionException)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1