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();
}
}
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();
}
}
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);
}
Aggregations