Search in sources :

Example 36 with AssemblyException

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

the class AbstractEntityStorePerformanceTest method whenReadEntityWithComplexTypeThenRecordIterationsPerSecond.

@Test
public void whenReadEntityWithComplexTypeThenRecordIterationsPerSecond() throws Exception {
    try {
        Assembler assembler = new Assembler() {

            @Override
            public void assemble(ModuleAssembly module) throws AssemblyException {
                module.entities(ComplexProduct.class);
            }
        };
        createQi4jRuntime(assembler);
        {
            int bulk = 0;
            UnitOfWork uow = module.newUnitOfWork(newUsecase("readEntityWithComplexType PREPARE " + bulk));
            for (int i = 0; i < ITERATIONS; i++) {
                ComplexProduct product = uow.newEntity(ComplexProduct.class, "product" + i);
                product.name().set("Product " + i);
                if (i % 1000 == 0) {
                    uow.complete();
                    bulk++;
                    uow = module.newUnitOfWork(newUsecase("readEntityWithComplexType PREPARE " + bulk));
                }
            }
            uow.complete();
        }
        profile(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                Report report = new Report(storeName);
                int bulk = 0;
                UnitOfWork uow = module.newUnitOfWork(newUsecase("readEntityWithComplexType " + bulk));
                Random rnd = new Random();
                report.start("readEntityWithComplexType");
                String id = rnd.nextInt(ITERATIONS) + "";
                for (int i = 0; i < ITERATIONS; i++) {
                    ComplexProduct product = uow.get(ComplexProduct.class, "product" + id);
                    String name = product.name().get();
                    if (i % 100 == 0) {
                        uow.discard();
                        bulk++;
                        uow = module.newUnitOfWork(newUsecase("readEntityWithComplexType " + bulk));
                    }
                }
                uow.complete();
                report.stop(ITERATIONS);
                writeReport(report);
                return null;
            }
        });
    } finally {
        cleanUp();
    }
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Random(java.util.Random) Assembler(org.qi4j.bootstrap.Assembler) IOException(java.io.IOException) AssemblyException(org.qi4j.bootstrap.AssemblyException) Test(org.junit.Test)

Example 37 with AssemblyException

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

the class AbstractEntityStorePerformanceTest method whenCreateEntityWithComplexTypeThenRecordIterationsPerSecond.

@Test
public void whenCreateEntityWithComplexTypeThenRecordIterationsPerSecond() throws Exception {
    try {
        Assembler assembler = new Assembler() {

            @Override
            public void assemble(ModuleAssembly module) throws AssemblyException {
                module.entities(ComplexProduct.class);
            }
        };
        createQi4jRuntime(assembler);
        profile(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                Report report = new Report(storeName);
                report.start("createEntityWithComplexType");
                for (int i = 0; i < ITERATIONS; i++) {
                    try (UnitOfWork uow = module.newUnitOfWork(newUsecase("createEntityWithComplexType " + i))) {
                        ComplexProduct product = uow.newEntity(ComplexProduct.class);
                        String id = product.identity().get();
                        uow.complete();
                    }
                }
                report.stop(ITERATIONS);
                writeReport(report);
                return null;
            }
        });
    } finally {
        cleanUp();
    }
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Assembler(org.qi4j.bootstrap.Assembler) IOException(java.io.IOException) AssemblyException(org.qi4j.bootstrap.AssemblyException) Test(org.junit.Test)

Example 38 with AssemblyException

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

Aggregations

AssemblyException (org.qi4j.bootstrap.AssemblyException)38 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)27 Test (org.junit.Test)23 Module (org.qi4j.api.structure.Module)14 SingletonAssembler (org.qi4j.bootstrap.SingletonAssembler)14 IOException (java.io.IOException)10 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)10 ApplicationAssembler (org.qi4j.bootstrap.ApplicationAssembler)10 Assembler (org.qi4j.bootstrap.Assembler)10 ApplicationAssemblyFactory (org.qi4j.bootstrap.ApplicationAssemblyFactory)9 Application (org.qi4j.api.structure.Application)8 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)8 Energy4Java (org.qi4j.bootstrap.Energy4Java)8 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)5 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)5 AmbiguousTypeException (org.qi4j.api.composite.AmbiguousTypeException)4 ApplicationDescriptor (org.qi4j.api.structure.ApplicationDescriptor)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 JettyConfiguration (org.qi4j.library.http.JettyConfiguration)2