Search in sources :

Example 16 with Application

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

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

Example 18 with Application

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

the class Qi95IssueTest method canCreateAndQueryWithInMemoryRdfWithJdbm.

@Test
public void canCreateAndQueryWithInMemoryRdfWithJdbm() throws Exception {
    Application application = createApplication(inMemoryRdf, jdbmStore, domain);
    try {
        application.activate();
        Module domain = application.findModule("Domain", "Domain");
        UnitOfWorkFactory unitOfWorkFactory = domain;
        createABunchOfStuffAndDoQueries(unitOfWorkFactory, domain);
    } finally {
        application.passivate();
    }
}
Also used : UnitOfWorkFactory(org.qi4j.api.unitofwork.UnitOfWorkFactory) Module(org.qi4j.api.structure.Module) Application(org.qi4j.api.structure.Application) Test(org.junit.Test)

Example 19 with Application

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

the class Qi95IssueTest method createApplication.

private Application createApplication(final ModuleAssemblyBuilder queryServiceModuleBuilder, final ModuleAssemblyBuilder entityStoreModuleBuilder, final LayerAssemblyBuilder domainLayerBuilder) throws AssemblyException {
    Energy4Java qi4j = new Energy4Java();
    Application application = qi4j.newApplication(new ApplicationAssembler() {

        @Override
        public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
            ApplicationAssembly applicationAssembly = applicationFactory.newApplicationAssembly();
            LayerAssembly configLayer = applicationAssembly.layer("Config");
            configModule.buildModuleAssembly(configLayer, "Configuration");
            LayerAssembly infrastructureLayer = applicationAssembly.layer("Infrastructure");
            infrastructureLayer.uses(configLayer);
            queryServiceModuleBuilder.buildModuleAssembly(infrastructureLayer, "Query Service");
            entityStoreModuleBuilder.buildModuleAssembly(infrastructureLayer, "Entity Store");
            LayerAssembly domainLayer = domainLayerBuilder.buildLayerAssembly(applicationAssembly);
            domainLayer.uses(infrastructureLayer);
            return applicationAssembly;
        }
    });
    return application;
}
Also used : Application(org.qi4j.api.structure.Application)

Example 20 with Application

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

the class Qi95IssueTest method canCreateAndQueryWithNativeRdfWithInMemoryStore.

@Test
public void canCreateAndQueryWithNativeRdfWithInMemoryStore() throws Exception {
    Application application = createApplication(nativeRdf, inMemoryStore, domain);
    try {
        application.activate();
        Module domain = application.findModule("Domain", "Domain");
        UnitOfWorkFactory unitOfWorkFactory = domain;
        createABunchOfStuffAndDoQueries(unitOfWorkFactory, domain);
    } finally {
        application.passivate();
    }
}
Also used : UnitOfWorkFactory(org.qi4j.api.unitofwork.UnitOfWorkFactory) 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