Search in sources :

Example 11 with Application

use of org.qi4j.api.structure.Application 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 12 with Application

use of org.qi4j.api.structure.Application 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 13 with Application

use of org.qi4j.api.structure.Application in project qi4j-sdk by Qi4j.

the class ModuleTest method givenFixture1WhenGetModuleForCompositeThenCorrectModuleIsReturned.

@Test
public void givenFixture1WhenGetModuleForCompositeThenCorrectModuleIsReturned() throws AssemblyException {
    Application app = givenFixture1();
    Module module = app.findModule("Layer 1", "Module 1").newTransient(TestComposite1.class).getModule();
    assertThat("module for composite is correct", module, equalTo(module));
}
Also used : Module(org.qi4j.api.structure.Module) Application(org.qi4j.api.structure.Application) Test(org.junit.Test)

Example 14 with Application

use of org.qi4j.api.structure.Application in project qi4j-sdk by Qi4j.

the class ModuleTest method givenFixture1WhenFindFromAnotherModuleThenCompositeTypeIsReturned.

@Test
public void givenFixture1WhenFindFromAnotherModuleThenCompositeTypeIsReturned() throws ClassNotFoundException, AssemblyException {
    Application app = givenFixture1();
    Module module = app.findModule("Layer 1", "Module 1").newTransient(TestComposite1.class).getModule();
    module.classLoader().loadClass(TestComposite2.class.getName());
}
Also used : Module(org.qi4j.api.structure.Module) Application(org.qi4j.api.structure.Application) Test(org.junit.Test)

Example 15 with Application

use of org.qi4j.api.structure.Application in project qi4j-sdk by Qi4j.

the class ModuleTest method givenFixture1WhenGetNameThenConfiguredNameIsReturned.

@Test
public void givenFixture1WhenGetNameThenConfiguredNameIsReturned() throws AssemblyException {
    Application app = givenFixture1();
    Module module = app.findModule("Layer 1", "Module 1").newTransient(TestComposite1.class).getModule();
    assertThat("module name is correct", module.name(), equalTo("Module 1"));
}
Also used : Module(org.qi4j.api.structure.Module) Application(org.qi4j.api.structure.Application) Test(org.junit.Test)

Aggregations

Application (org.qi4j.api.structure.Application)50 Test (org.junit.Test)32 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)26 Module (org.qi4j.api.structure.Module)18 Energy4Java (org.qi4j.bootstrap.Energy4Java)18 Assembler (org.qi4j.bootstrap.Assembler)13 ApplicationAssemblerAdapter (org.qi4j.bootstrap.ApplicationAssemblerAdapter)10 SingletonAssembler (org.qi4j.bootstrap.SingletonAssembler)10 AssemblyException (org.qi4j.bootstrap.AssemblyException)8 Function (org.qi4j.functional.Function)7 ApplicationAssembler (org.qi4j.bootstrap.ApplicationAssembler)6 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)6 UnitOfWorkFactory (org.qi4j.api.unitofwork.UnitOfWorkFactory)5 ApplicationAssemblyFactory (org.qi4j.bootstrap.ApplicationAssemblyFactory)5 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)4 MemoryEntityStoreService (org.qi4j.entitystore.memory.MemoryEntityStoreService)4 UuidIdentityGeneratorService (org.qi4j.spi.uuid.UuidIdentityGeneratorService)4 OrgJsonValueSerializationService (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationService)4 ArrayList (java.util.ArrayList)3 ApplicationDescriptor (org.qi4j.api.structure.ApplicationDescriptor)3