Search in sources :

Example 96 with ModuleAssembly

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

the class ConstructorInjectionOfThisTest method givenConcernWithThisInConstructorWhenCreatingModelExpectException.

@Test
public void givenConcernWithThisInConstructorWhenCreatingModelExpectException() throws ActivationException, AssemblyException {
    SingletonAssembler singletonAssembler = new SingletonAssembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.values(Does.class).withConcerns(DoesConcern.class);
        }
    };
    Module module = singletonAssembler.application().findModule("Layer 1", "Module 1");
    Does does = module.newValue(Does.class);
    does.doSomething();
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Module(org.qi4j.api.structure.Module) Test(org.junit.Test)

Example 97 with ModuleAssembly

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

the class ConstructorInjectionOfThisTest method givenSideEffectWithThisInConstructorWhenCreatingModelExpectException.

@Test
public void givenSideEffectWithThisInConstructorWhenCreatingModelExpectException() throws ActivationException, AssemblyException {
    SingletonAssembler singletonAssembler = new SingletonAssembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.values(Does.class).withSideEffects(DoesSideEffect.class);
        }
    };
    Module module = singletonAssembler.application().findModule("Layer 1", "Module 1");
    Does does = module.newValue(Does.class);
    does.doSomething();
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Module(org.qi4j.api.structure.Module) Test(org.junit.Test)

Example 98 with ModuleAssembly

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

the class ServiceInjectionTest method testInjectionServiceBetweenLayers.

@Test
public void testInjectionServiceBetweenLayers() throws ActivationException, AssemblyException {
    SingletonAssembler assembly = new SingletonAssembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.services(MyServiceComposite.class).identifiedBy("Foo").setMetaInfo(new ServiceName("Foo"));
            module.services(StringService.class, LongService.class);
            LayerAssembly layerAssembly = module.layer();
            module.objects(ServiceUser.class);
            ApplicationAssembly applicationAssembly = layerAssembly.application();
            LayerAssembly layer2Assembly = applicationAssembly.layer("Other layer");
            layerAssembly.uses(layer2Assembly);
            ModuleAssembly module2 = layer2Assembly.module("Other module");
            ServiceDeclaration service2Decl = module2.services(MyServiceComposite2.class);
            service2Decl.identifiedBy("Bar").setMetaInfo(new ServiceName("Bar")).visibleIn(application);
        }
    };
    testInjection(assembly);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) ServiceDeclaration(org.qi4j.bootstrap.ServiceDeclaration) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) ApplicationAssembly(org.qi4j.bootstrap.ApplicationAssembly) LayerAssembly(org.qi4j.bootstrap.LayerAssembly) Test(org.junit.Test)

Example 99 with ModuleAssembly

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

the class ServiceInjectionTest method testInjectionServiceBetweenModules.

@Test
public void testInjectionServiceBetweenModules() throws ActivationException, AssemblyException {
    SingletonAssembler assembly = new SingletonAssembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.services(MyServiceComposite.class).identifiedBy("Foo").setMetaInfo(new ServiceName("Foo"));
            module.services(StringService.class, LongService.class);
            module.objects(ServiceUser.class);
            ModuleAssembly module2 = module.layer().module("Other module");
            ServiceDeclaration service2Decl = module2.services(MyServiceComposite.class);
            service2Decl.identifiedBy("Bar").setMetaInfo(new ServiceName("Bar")).visibleIn(layer);
            ServiceDeclaration service3Decl = module2.services(MyServiceComposite2.class);
            service3Decl.identifiedBy("Boo").setMetaInfo(new ServiceName("Boo"));
        }
    };
    testInjection(assembly);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) ServiceDeclaration(org.qi4j.bootstrap.ServiceDeclaration) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Test(org.junit.Test)

Example 100 with ModuleAssembly

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

the class ImportedServiceActivationTest method testNewObjectImportedServiceActivators.

@Test
public void testNewObjectImportedServiceActivators() throws Exception {
    SingletonAssembler assembler = new SingletonAssembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.importedServices(TestedService.class).importedBy(ImportedServiceDeclaration.NEW_OBJECT).withActivators(TestedActivator.class).importOnStartup();
            module.objects(TestedServiceInstance.class);
        }
    };
    Application application = assembler.application();
    assertEquals("Activation Level", 2, activationLevel);
    application.passivate();
    assertEquals("Passivation Level", 2, passivationLevel);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Application(org.qi4j.api.structure.Application) 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