use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class ObjectBuilderFactoryTest method givenClassWithInnerClassesWhenInstantiateThenInstantiateInnerClass.
@Test
public void givenClassWithInnerClassesWhenInstantiateThenInstantiateInnerClass() throws ActivationException, AssemblyException {
SingletonAssembler assembler = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.objects(OuterClass.class);
}
};
Assert.assertThat("inner class has been injected", assembler.module().newObject(OuterClass.class).name(), equalTo("Module 1"));
}
use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class ObjectBuilderFactoryTest method newInstanceForRegisteredObject.
/**
* Tests that an object can be created for an registered object class.
*/
@Test
public void newInstanceForRegisteredObject() throws ActivationException, AssemblyException {
SingletonAssembler assembler = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.objects(AnyObject.class);
}
};
assembler.module().newObject(AnyObject.class);
}
use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class ActivatableServiceTest method testActivatable.
@Test
public void testActivatable() throws Exception {
SingletonAssembler assembly = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.objects(ActivatableServiceTest.class);
module.services(ActivatableComposite.class).withActivators(TestActivator.class).instantiateOnStartup();
}
};
assertTrue(isActive);
assembly.module().injectTo(this);
assertTrue(isActive);
service.get();
assertTrue(isActive);
assembly.application().passivate();
assertFalse(isActive);
}
use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class AvailableServiceTest method givenAvailableServiceWhenCheckServiceReferenceThenReturnTrue.
@Test
public void givenAvailableServiceWhenCheckServiceReferenceThenReturnTrue() throws ActivationException, AssemblyException {
SingletonAssembler assembler = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.services(TestServiceComposite1.class);
}
};
ServiceReference<TestServiceComposite1> serviceRef = assembler.module().findService(TestServiceComposite1.class);
assertThat("service is available", serviceRef.isAvailable(), equalTo(true));
}
use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class AvailableServiceTest method givenEnablableServiceWhenCheckAvailableThenReturnEnabledStatus.
@Test
public void givenEnablableServiceWhenCheckAvailableThenReturnEnabledStatus() throws ActivationException, AssemblyException {
SingletonAssembler assembler = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.services(TestServiceComposite2.class);
module.entities(TestServiceConfiguration.class);
new EntityTestAssembler().assemble(module);
}
};
ServiceReference<TestServiceComposite2> serviceRef = assembler.module().findService(TestServiceComposite2.class);
assertThat("service is unavailable", serviceRef.isAvailable(), equalTo(false));
serviceRef.get().get().enabled().set(true);
serviceRef.get().save();
assertThat("service is available", serviceRef.isAvailable(), equalTo(true));
}
Aggregations