use of org.qi4j.bootstrap.Assembler in project qi4j-sdk by Qi4j.
the class MixinVisibilityTest method testMixinInLayerIsNotVisible.
@Test(expected = NoSuchTransientException.class)
public void testMixinInLayerIsNotVisible() throws Exception {
Energy4Java boot = new Energy4Java();
Assembler[][][] assemblers = new Assembler[][][] { { // Layer
{ new Assembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.setName("Module A");
module.objects(ObjectA.class);
}
} }, { new Assembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.setName("Module B");
module.transients(B1Composite.class);
}
} } } };
Application app = boot.newApplication(new ApplicationAssemblerAdapter(assemblers) {
});
app.activate();
ObjectA object = app.findModule("Layer 1", "Module A").newObject(ObjectA.class);
assertEquals("ok", object.test1());
assertEquals("abc", object.test2());
}
use of org.qi4j.bootstrap.Assembler in project qi4j-sdk by Qi4j.
the class MixinVisibilityTest method testMixinInLowerLayerIsNotVisible.
// @Test( expected= MixinTypeNotAvailableException.class )
public void testMixinInLowerLayerIsNotVisible() throws Exception {
Energy4Java boot = new Energy4Java();
Assembler[][][] assemblers = new Assembler[][][] { { // Layer 1
{ new Assembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.setName("Module A");
module.objects(ObjectA.class);
}
} } }, { // Layer 2
{ new Assembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.setName("Module B");
module.transients(B1Composite.class).visibleIn(Visibility.layer);
}
} } } };
Application app = boot.newApplication(new ApplicationAssemblerAdapter(assemblers) {
});
app.activate();
ObjectA object = app.findModule("Layer 1", "Module ").newObject(ObjectA.class);
assertEquals("ok", object.test1());
assertEquals("abc", object.test2());
}
use of org.qi4j.bootstrap.Assembler in project qi4j-sdk by Qi4j.
the class AbstractQi4jScenarioTest method newApplication.
protected static ApplicationDescriptor newApplication() throws AssemblyException {
final Assembler asm = assembler;
ApplicationAssembler assembler = new ApplicationAssembler() {
@Override
public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
return applicationFactory.newApplicationAssembly(asm);
}
};
try {
return qi4j.newApplicationModel(assembler);
} catch (AssemblyException e) {
assemblyException(e);
return null;
}
}
use of org.qi4j.bootstrap.Assembler in project qi4j-sdk by Qi4j.
the class AbstractEntityStorePerformanceTest method whenCreateEntityWithComplexTypeInBatchThenRecordIterationsPerSecond.
@Test
public void whenCreateEntityWithComplexTypeInBatchThenRecordIterationsPerSecond() 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("createEntityInBulkWithComplexType");
int bulk = 0;
UnitOfWork uow = module.newUnitOfWork(newUsecase("createEntityInBulkWithComplexType " + bulk));
for (int i = 0; i < ITERATIONS; i++) {
ComplexProduct product = uow.newEntity(ComplexProduct.class);
String id = product.identity().get();
if (i % 1000 == 0) {
uow.complete();
bulk++;
uow = module.newUnitOfWork(newUsecase("createEntityInBulkWithComplexType " + bulk));
}
}
uow.complete();
report.stop(ITERATIONS);
writeReport(report);
return null;
}
});
} finally {
cleanUp();
}
}
use of org.qi4j.bootstrap.Assembler in project qi4j-sdk by Qi4j.
the class AbstractEntityStorePerformanceTest method whenCreateEntityWithSinglePropertyInBatchThenRecordIterationsPerSecond.
@Test
public void whenCreateEntityWithSinglePropertyInBatchThenRecordIterationsPerSecond() throws Exception {
try {
Assembler assembler = new Assembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.entities(SimpleProduct.class);
}
};
createQi4jRuntime(assembler);
profile(new Callable<Void>() {
@Override
public Void call() throws Exception {
Report report = new Report(storeName);
report.start("createEntityInBulkWithSingleProperty");
int bulk = 0;
UnitOfWork uow = module.newUnitOfWork(newUsecase("createEntityInBulkWithSingleProperty " + bulk));
for (int i = 0; i < ITERATIONS; i++) {
SimpleProduct product = uow.newEntity(SimpleProduct.class);
String id = product.identity().get();
if (i % 1000 == 0) {
uow.complete();
bulk++;
uow = module.newUnitOfWork(newUsecase("createEntityInBulkWithSingleProperty " + bulk));
}
}
uow.complete();
report.stop(ITERATIONS);
writeReport(report);
return null;
}
});
} finally {
cleanUp();
}
}
Aggregations