use of org.qi4j.api.structure.Application in project qi4j-sdk by Qi4j.
the class MixinVisibilityTest method testMultipleMixinsInLayerWillFailSameModule.
@Test(expected = AmbiguousTypeException.class)
public void testMultipleMixinsInLayerWillFailSameModule() 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, B2Composite.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 testMixinInModuleIsVisible.
@Test
public void testMixinInModuleIsVisible() 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);
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 ModuleTest method givenFixture1WhenGetModuleForCompositeThenCorrectModuleIsReturned.
@Test
public void givenFixture1WhenGetModuleForCompositeThenCorrectModuleIsReturned() throws AssemblyException {
Application app = givenFixture1();
Module module = app.findModule("Layer 1", "Module 1").newTransient(TestComposite1.class).getModule();
assertThat("module for composite is correct", module, equalTo(module));
}
use of org.qi4j.api.structure.Application in project qi4j-sdk by Qi4j.
the class ModuleTest method givenFixture1WhenFindFromAnotherModuleThenCompositeTypeIsReturned.
@Test
public void givenFixture1WhenFindFromAnotherModuleThenCompositeTypeIsReturned() throws ClassNotFoundException, AssemblyException {
Application app = givenFixture1();
Module module = app.findModule("Layer 1", "Module 1").newTransient(TestComposite1.class).getModule();
module.classLoader().loadClass(TestComposite2.class.getName());
}
use of org.qi4j.api.structure.Application in project qi4j-sdk by Qi4j.
the class ModuleTest method givenFixture1WhenGetNameThenConfiguredNameIsReturned.
@Test
public void givenFixture1WhenGetNameThenConfiguredNameIsReturned() throws AssemblyException {
Application app = givenFixture1();
Module module = app.findModule("Layer 1", "Module 1").newTransient(TestComposite1.class).getModule();
assertThat("module name is correct", module.name(), equalTo("Module 1"));
}
Aggregations