Search in sources :

Example 81 with SingletonAssembler

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

the class TransferMoneyTest method setup.

@BeforeClass
public static void setup() throws Exception {
    assembler = new SingletonAssembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.entities(CheckingAccountRolemap.class, SavingsAccountRolemap.class, CreditorRolemap.class);
            new EntityTestAssembler().assemble(module);
        }
    };
    bootstrapData(assembler);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) AssemblyException(org.qi4j.bootstrap.AssemblyException) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) SavingsAccountRolemap(org.qi4j.dci.moneytransfer.rolemap.SavingsAccountRolemap) CheckingAccountRolemap(org.qi4j.dci.moneytransfer.rolemap.CheckingAccountRolemap) CreditorRolemap(org.qi4j.dci.moneytransfer.rolemap.CreditorRolemap) BeforeClass(org.junit.BeforeClass)

Example 82 with SingletonAssembler

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

the class TransferMoneyTest2 method setup.

@BeforeClass
public static void setup() throws Exception {
    SingletonAssembler assembler = new SingletonAssembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.entities(CheckingAccountEntity.class, SavingsAccountEntity.class, CreditorEntity.class);
            new EntityTestAssembler().assemble(module);
            module.transients(TransferMoneyContext2.class);
            module.objects(PayBillsContext2.class);
        }
    };
    module = assembler.module();
    bootstrapData();
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) BeforeClass(org.junit.BeforeClass)

Example 83 with SingletonAssembler

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

the class SequencingConcernTest method failingBooking.

/**
     * Tests that when shipping service fails to make the booking generator is not called and booking failure code is
     * returned.
     */
@Test
@Ignore("Expectations need to be figured out.")
public void failingBooking() 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 sequence = createMock(HasSequence.class);
    expect(shippingService.makeBooking(cargo, voyage)).andReturn(-1000);
    expect(voyage.bookedCargoSize().get()).andReturn(0.0).atLeastOnce();
    expect(cargo.size().get()).andReturn(0.0).atLeastOnce();
    expect(sequence.sequence().get()).andReturn(0).atLeastOnce();
    replay(shippingService, cargo, voyage);
    ShippingServiceTestComposite underTest = assembler.module().newTransient(ShippingServiceTestComposite.class);
    underTest.useMock(shippingService).forClass(ShippingService.class);
    assertThat("Booking result", underTest.makeBooking(cargo, voyage), is(equalTo(-1000)));
    verify(shippingService, cargo, voyage);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 84 with SingletonAssembler

use of org.qi4j.bootstrap.SingletonAssembler 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().newTransient(HelloWorldComposite.class);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Before(org.junit.Before)

Example 85 with SingletonAssembler

use of org.qi4j.bootstrap.SingletonAssembler 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)

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