use of org.qi4j.api.structure.Application in project qi4j-sdk by Qi4j.
the class MixinVisibilityTest method testMultipleMixinsInModuleWillFail.
@Test(expected = AmbiguousTypeException.class)
public void testMultipleMixinsInModuleWillFail() throws Exception {
Energy4Java boot = new Energy4Java();
Assembler[][][] assemblers = new Assembler[][][] { { // Layer
{ // Module 1
new Assembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.setName("Module A");
module.transients(B1Composite.class, B2Composite.class);
module.objects(ObjectA.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.api.structure.Application in project qi4j-sdk by Qi4j.
the class MixinVisibilityTest method testMixinInLayerIsVisible.
@Test
public void testMixinInLayerIsVisible() 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).visibleIn(Visibility.layer);
}
} } } };
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.api.structure.Application 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.api.structure.Application 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.api.structure.Application in project qi4j-sdk by Qi4j.
the class Qi95IssueTest method canCreateAndQueryWithAllInMemory.
@Test
public void canCreateAndQueryWithAllInMemory() throws Exception {
Application application = createApplication(inMemoryRdf, inMemoryStore, domain);
try {
application.activate();
Module domain = application.findModule("Domain", "Domain");
UnitOfWorkFactory unitOfWorkFactory = domain;
createABunchOfStuffAndDoQueries(unitOfWorkFactory, domain);
} finally {
application.passivate();
}
}
Aggregations