use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.
the class ConstructorInjectionOfThisTest method givenConcernWithThisInConstructorWhenCreatingModelExpectException.
@Test
public void givenConcernWithThisInConstructorWhenCreatingModelExpectException() throws ActivationException, AssemblyException {
SingletonAssembler singletonAssembler = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.values(Does.class).withConcerns(DoesConcern.class);
}
};
Module module = singletonAssembler.application().findModule("Layer 1", "Module 1");
Does does = module.newValue(Does.class);
does.doSomething();
}
use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.
the class ConstructorInjectionOfThisTest method givenSideEffectWithThisInConstructorWhenCreatingModelExpectException.
@Test
public void givenSideEffectWithThisInConstructorWhenCreatingModelExpectException() throws ActivationException, AssemblyException {
SingletonAssembler singletonAssembler = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.values(Does.class).withSideEffects(DoesSideEffect.class);
}
};
Module module = singletonAssembler.application().findModule("Layer 1", "Module 1");
Does does = module.newValue(Does.class);
does.doSomething();
}
use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.
the class ServiceInjectionTest method testInjectionServiceBetweenLayers.
@Test
public void testInjectionServiceBetweenLayers() throws ActivationException, AssemblyException {
SingletonAssembler assembly = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.services(MyServiceComposite.class).identifiedBy("Foo").setMetaInfo(new ServiceName("Foo"));
module.services(StringService.class, LongService.class);
LayerAssembly layerAssembly = module.layer();
module.objects(ServiceUser.class);
ApplicationAssembly applicationAssembly = layerAssembly.application();
LayerAssembly layer2Assembly = applicationAssembly.layer("Other layer");
layerAssembly.uses(layer2Assembly);
ModuleAssembly module2 = layer2Assembly.module("Other module");
ServiceDeclaration service2Decl = module2.services(MyServiceComposite2.class);
service2Decl.identifiedBy("Bar").setMetaInfo(new ServiceName("Bar")).visibleIn(application);
}
};
testInjection(assembly);
}
use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.
the class ServiceInjectionTest method testInjectionServiceBetweenModules.
@Test
public void testInjectionServiceBetweenModules() throws ActivationException, AssemblyException {
SingletonAssembler assembly = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.services(MyServiceComposite.class).identifiedBy("Foo").setMetaInfo(new ServiceName("Foo"));
module.services(StringService.class, LongService.class);
module.objects(ServiceUser.class);
ModuleAssembly module2 = module.layer().module("Other module");
ServiceDeclaration service2Decl = module2.services(MyServiceComposite.class);
service2Decl.identifiedBy("Bar").setMetaInfo(new ServiceName("Bar")).visibleIn(layer);
ServiceDeclaration service3Decl = module2.services(MyServiceComposite2.class);
service3Decl.identifiedBy("Boo").setMetaInfo(new ServiceName("Boo"));
}
};
testInjection(assembly);
}
use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.
the class ImportedServiceActivationTest method testNewObjectImportedServiceActivators.
@Test
public void testNewObjectImportedServiceActivators() throws Exception {
SingletonAssembler assembler = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.importedServices(TestedService.class).importedBy(ImportedServiceDeclaration.NEW_OBJECT).withActivators(TestedActivator.class).importOnStartup();
module.objects(TestedServiceInstance.class);
}
};
Application application = assembler.application();
assertEquals("Activation Level", 2, activationLevel);
application.passivate();
assertEquals("Passivation Level", 2, passivationLevel);
}
Aggregations