use of org.qi4j.test.EntityTestAssembler 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));
}
use of org.qi4j.test.EntityTestAssembler in project qi4j-sdk by Qi4j.
the class ConfigurationTest method assemble.
public void assemble(ModuleAssembly module) throws AssemblyException {
module.objects(this.getClass());
module.entities(HelloWorldConfiguration.class);
module.services(HelloWorldService.class).identifiedBy("HelloWorldService");
new EntityTestAssembler().assemble(module);
}
use of org.qi4j.test.EntityTestAssembler in project qi4j-sdk by Qi4j.
the class TypeToCompositeLookupTest method entitiesAmbiguousDeclaration.
@Test
public void entitiesAmbiguousDeclaration() throws UnitOfWorkCompletionException, ActivationException, AssemblyException {
Module module = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
new EntityTestAssembler().assemble(module);
module.entities(SomeOtherFoo.class, BasicFoo.class);
}
}.module();
UnitOfWork uow = module.newUnitOfWork();
SomeOtherFoo someOtherFoo = uow.newEntityBuilder(SomeOtherFoo.class).newInstance();
BasicFoo basicFoo = uow.newEntityBuilder(BasicFoo.class).newInstance();
try {
uow.newEntityBuilder(Foo.class).newInstance();
fail("Ambiguous type exception not detected for Entities");
} catch (AmbiguousTypeException expected) {
}
// Specific Type used
assertEquals(CATHEDRAL, uow.newEntityBuilder(SomeOtherFoo.class).newInstance().bar());
// Specific Type used
assertEquals(BAZAR, uow.newEntityBuilder(BasicFoo.class).newInstance().bar());
String someOtherFooIdentity = ((Identity) someOtherFoo).identity().get();
String basicFooIdentity = ((Identity) basicFoo).identity().get();
uow.complete();
uow = module.newUnitOfWork();
assertEquals(CATHEDRAL, uow.get(SomeOtherFoo.class, someOtherFooIdentity).bar());
assertEquals(BAZAR, uow.get(BasicFoo.class, basicFooIdentity).bar());
assertEquals(CATHEDRAL, uow.get(Foo.class, someOtherFooIdentity).bar());
assertEquals(BAZAR, uow.get(Foo.class, basicFooIdentity).bar());
uow.discard();
}
use of org.qi4j.test.EntityTestAssembler in project qi4j-sdk by Qi4j.
the class VoldemortTest method assemble.
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
super.assemble(module);
ModuleAssembly config = module.layer().module("config");
new EntityTestAssembler().assemble(config);
config.entities(VoldemortConfiguration.class).visibleIn(Visibility.layer);
new OrgJsonValueSerializationAssembler().assemble(module);
new VoldemortAssembler(Visibility.layer).assemble(module);
}
use of org.qi4j.test.EntityTestAssembler in project qi4j-sdk by Qi4j.
the class PostgreSQLEntityStoreTest method assemble.
@Override
public // START SNIPPET: assembly
void assemble(ModuleAssembly module) throws AssemblyException {
// END SNIPPET: assembly
super.assemble(module);
ModuleAssembly config = module.layer().module("config");
new EntityTestAssembler().assemble(config);
new OrgJsonValueSerializationAssembler().assemble(module);
// START SNIPPET: assembly
// DataSourceService
new DBCPDataSourceServiceAssembler().identifiedBy("postgresql-datasource-service").visibleIn(Visibility.module).withConfig(config).withConfigVisibility(Visibility.layer).assemble(module);
// DataSource
new DataSourceAssembler().withDataSourceServiceIdentity("postgresql-datasource-service").identifiedBy("postgresql-datasource").visibleIn(Visibility.module).withCircuitBreaker();
// SQL EntityStore
new PostgreSQLEntityStoreAssembler().visibleIn(Visibility.application).withConfig(config).withConfigVisibility(Visibility.layer).assemble(module);
}
Aggregations