Search in sources :

Example 46 with SingletonAssembler

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

the class ImportedServiceActivationTest method testNewInstanceImportedServiceActivators.

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

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.importedServices(TestedService.class).withActivators(TestedActivator.class).setMetaInfo(new TestedServiceInstance()).importOnStartup();
        }
    };
    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)

Example 47 with SingletonAssembler

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

the class LayerActivationTest method testLayersActivators.

@Test
public void testLayersActivators() throws Exception {
    SingletonAssembler assembly = new SingletonAssembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.layer().withActivators(TestedActivator.class);
        }
    };
    // Activate
    Application application = assembly.application();
    // Assert activated
    Assert.assertEquals("Activation Level", 2, activationLevel);
    // Passivate
    application.passivate();
    // Assert passivated
    Assert.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)

Example 48 with SingletonAssembler

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

the class ModuleActivationTest method testModulesActivators.

@Test
public void testModulesActivators() throws Exception {
    SingletonAssembler assembly = new SingletonAssembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.withActivators(TestedActivator.class);
        }
    };
    // Activate
    Application application = assembly.application();
    // Assert activated
    Assert.assertEquals("Activation Level", 2, activationLevel);
    // Passivate
    application.passivate();
    // Assert passivated
    Assert.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)

Example 49 with SingletonAssembler

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

the class ServiceActivationTest method testServicesActivators.

@Test
public void testServicesActivators() throws Exception {
    SingletonAssembler assembly = new SingletonAssembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.addServices(TestedServiceComposite.class).withActivators(TestedActivator.class).instantiateOnStartup();
            module.addServices(TestedServiceComposite2.class).withActivators(TestedActivator.class).instantiateOnStartup();
        }
    };
    // Activate
    Application application = assembly.application();
    // Assert activated
    Assert.assertEquals("Activation Level", 4, activationLevel);
    // Passivate
    application.passivate();
    // Assert passivated
    Assert.assertEquals("Passivation Level", 4, passivationLevel);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Application(org.qi4j.api.structure.Application) Test(org.junit.Test)

Example 50 with SingletonAssembler

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

the class CompositeModelResolverTest method testWhenDependentMixinsThenOrderMixins.

@Test
public void testWhenDependentMixinsThenOrderMixins() throws Exception {
    Module module = new SingletonAssembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.transients(TestComposite1.class);
        }
    }.module();
    Assert.assertEquals("ok", module.newTransient(TestComposite1.class).testB());
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) AssemblyException(org.qi4j.bootstrap.AssemblyException) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Module(org.qi4j.api.structure.Module) Test(org.junit.Test)

Aggregations

ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)87 SingletonAssembler (org.qi4j.bootstrap.SingletonAssembler)87 Test (org.junit.Test)65 Module (org.qi4j.api.structure.Module)15 AssemblyException (org.qi4j.bootstrap.AssemblyException)14 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)13 Before (org.junit.Before)11 Application (org.qi4j.api.structure.Application)10 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)5 AmbiguousTypeException (org.qi4j.api.composite.AmbiguousTypeException)4 ServiceReference (org.qi4j.api.service.ServiceReference)4 ArrayList (java.util.ArrayList)3 TransientBuilderFactory (org.qi4j.api.composite.TransientBuilderFactory)3 ObjectFactory (org.qi4j.api.object.ObjectFactory)3 ValueBuilder (org.qi4j.api.value.ValueBuilder)3 UnitOfWorkDomainEventsValue (org.qi4j.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue)3 File (java.io.File)2 BeforeClass (org.junit.BeforeClass)2 Ignore (org.junit.Ignore)2 ServiceDeclaration (org.qi4j.bootstrap.ServiceDeclaration)2