Search in sources :

Example 81 with ModuleAssembly

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

the class VisitableDetailTest method visit.

@Test
public void visit() throws AssemblyException, ActivationException {
    ApplicationDescriptor application = new Energy4Java().newApplicationModel(new ApplicationAssembler() {

        @Override
        public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
            ApplicationAssembly app = applicationFactory.newApplicationAssembly();
            app.setName("UnderTestApp");
            app.withActivators(ApplicationActivator.class);
            LayerAssembly layer = app.layer("LayerName");
            layer.withActivators(LayerActivator.class);
            ModuleAssembly module = layer.module("ModuleName");
            module.withActivators(ModuleActivator.class);
            return app;
        }
    });
    ApplicationDetailDescriptor detail = createApplicationDetailDescriptor(application);
    Visitor visitor = new Visitor();
    detail.accept(visitor);
    assertThat(visitor.events, equalTo(Arrays.asList(// Application
    "visitEnter( UnderTestApp )", "visit( " + ApplicationActivator.class.getName() + " )", // Layer
    "visitEnter( LayerName )", "visit( " + LayerActivator.class.getName() + " )", // Module
    "visitEnter( ModuleName )", "visit( " + ModuleActivator.class.getName() + " )", // Leaving Structure
    "visitLeave( ModuleName )", "visitLeave( LayerName )", "visitLeave( UnderTestApp )")));
}
Also used : ApplicationAssemblyFactory(org.qi4j.bootstrap.ApplicationAssemblyFactory) ApplicationDetailDescriptorBuilder.createApplicationDetailDescriptor(org.qi4j.tools.model.descriptor.ApplicationDetailDescriptorBuilder.createApplicationDetailDescriptor) ApplicationDetailDescriptor(org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor) HierarchicalVisitor(org.qi4j.functional.HierarchicalVisitor) ApplicationAssembly(org.qi4j.bootstrap.ApplicationAssembly) ApplicationDescriptor(org.qi4j.api.structure.ApplicationDescriptor) LayerAssembly(org.qi4j.bootstrap.LayerAssembly) AssemblyException(org.qi4j.bootstrap.AssemblyException) ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) ApplicationAssembler(org.qi4j.bootstrap.ApplicationAssembler) Energy4Java(org.qi4j.bootstrap.Energy4Java) Test(org.junit.Test)

Example 82 with ModuleAssembly

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

the class SequencingConcernTest method successfulBooking.

/**
     * Tests that when shipping service succeeds to make the booking generator gets called and generated value is
     * returned.
     */
@Test
@Ignore("Expectations need to be figured out.")
public void successfulBooking() throws ActivationException, AssemblyException {
    SingletonAssembler assembler = new SingletonAssembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.transients(ShippingServiceTestComposite.class);
        }
    };
    ShippingService shippingService = createMock(ShippingService.class);
    Cargo cargo = createMock(Cargo.class);
    Voyage voyage = createMock(Voyage.class);
    HasSequence generator = createMock(HasSequence.class);
    Property<Integer> sequence = createMock(Property.class);
    expect(shippingService.makeBooking(cargo, voyage)).andReturn(100);
    expect(generator.sequence()).andReturn(sequence).anyTimes();
    expect(sequence.get()).andReturn(1000);
    replay(shippingService, cargo, voyage, generator, sequence);
    ShippingServiceTestComposite underTest = assembler.module().newTransient(ShippingServiceTestComposite.class);
    underTest.useMock(shippingService).forClass(ShippingService.class);
    underTest.useMock(generator).forClass(HasSequence.class);
    assertThat("Booking result", underTest.makeBooking(cargo, voyage), is(equalTo(1000)));
    verify(shippingService, cargo, voyage, generator, sequence);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 83 with ModuleAssembly

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

the class HelloWorldTest method setUp.

@Before
public void setUp() throws Exception {
    SingletonAssembler assembly = new SingletonAssembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.transients(HelloWorldComposite.class);
        }
    };
    helloWorld = assembly.module().newTransientBuilder(HelloWorldComposite.class).newInstance();
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Before(org.junit.Before)

Example 84 with ModuleAssembly

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

the class SchoolAssembler method createInfrastructureLayer.

private LayerAssembly createInfrastructureLayer(ApplicationAssembly appAssembly) throws AssemblyException {
    LayerAssembly layerInfrastructure = appAssembly.layer("Infrastructure");
    ModuleAssembly moduleMail = layerInfrastructure.module("Mail");
    new MailServiceAssembler().assemble(moduleMail);
    ModuleAssembly modulePersistence = layerInfrastructure.module("Persistence");
    new PersistenceAssembler().assemble(modulePersistence);
    return layerInfrastructure;
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) MailServiceAssembler(org.qi4j.envisage.school.infrastructure.mail.assembly.MailServiceAssembler) PersistenceAssembler(org.qi4j.envisage.school.infrastructure.persistence.PersistenceAssembler) LayerAssembly(org.qi4j.bootstrap.LayerAssembly)

Example 85 with ModuleAssembly

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

the class SchoolAssembler method createDomainLayer.

private LayerAssembly createDomainLayer(ApplicationAssembly appAssembly) throws AssemblyException {
    LayerAssembly layerDomain = appAssembly.layer("domain");
    ModuleAssembly modulePerson = layerDomain.module("person");
    new PersonModelAssembler().assemble(modulePerson);
    ModuleAssembly moduleSchool = layerDomain.module("school");
    new SchoolModelAssembler().assemble(moduleSchool);
    return layerDomain;
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SchoolModelAssembler(org.qi4j.envisage.school.domain.school.assembly.SchoolModelAssembler) LayerAssembly(org.qi4j.bootstrap.LayerAssembly) PersonModelAssembler(org.qi4j.envisage.school.domain.person.assembly.PersonModelAssembler)

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