use of org.qi4j.test.EntityTestAssembler in project qi4j-sdk by Qi4j.
the class AvailableServiceTest method givenEnablableServiceWhenInjectWithAvailableQualifierThenInjectCorrectly.
@Test
public void givenEnablableServiceWhenInjectWithAvailableQualifierThenInjectCorrectly() throws ActivationException, AssemblyException {
SingletonAssembler assembler = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.objects(TestObject.class);
module.services(TestServiceComposite2.class);
module.entities(TestServiceConfiguration.class);
new EntityTestAssembler().assemble(module);
}
};
TestObject object = assembler.module().newObject(TestObject.class);
assertThat("service is unavailable", object.getService(), nullValue());
ServiceReference<TestServiceComposite2> serviceRef = assembler.module().findService(TestServiceComposite2.class);
serviceRef.get().get().enabled().set(true);
serviceRef.get().save();
object = assembler.module().newObject(TestObject.class);
assertThat("service is available", object.getService(), notNullValue());
}
use of org.qi4j.test.EntityTestAssembler in project qi4j-sdk by Qi4j.
the class ReindexerTest method assemble.
@SuppressWarnings("unchecked")
public void assemble(ModuleAssembly module) throws AssemblyException {
// JDBM EntityStore
new JdbmEntityStoreAssembler(Visibility.module).assemble(module);
// Native Sesame EntityFinder
new RdfNativeSesameStoreAssembler().assemble(module);
// Reindexer
module.services(ReindexerService.class);
// Configuration
ModuleAssembly config = module.layer().module("config");
new EntityTestAssembler().assemble(config);
config.entities(JdbmConfiguration.class, NativeConfiguration.class, ReindexerConfiguration.class).visibleIn(Visibility.layer);
// Test entity
module.entities(MyEntity.class);
}
use of org.qi4j.test.EntityTestAssembler in project qi4j-sdk by Qi4j.
the class SQLTestHelper method doCommonAssembling.
protected static void doCommonAssembling(ModuleAssembly mainModule) throws AssemblyException {
ModuleAssembly config = mainModule.layer().module("config");
new EntityTestAssembler().assemble(config);
// START SNIPPET: assembly
// DataSourceService
new DBCPDataSourceServiceAssembler().identifiedBy("postgres-datasource-service").visibleIn(Visibility.module).withConfig(config).withConfigVisibility(Visibility.layer).assemble(mainModule);
// DataSource
new DataSourceAssembler().withDataSourceServiceIdentity("postgres-datasource-service").identifiedBy("postgres-datasource").visibleIn(Visibility.module).withCircuitBreaker().assemble(mainModule);
// SQL Index/Query
new PostgreSQLIndexQueryAssembler().visibleIn(Visibility.application).withConfig(config).withConfigVisibility(Visibility.layer).assemble(mainModule);
// END SNIPPET: assembly
// Always re-build schema in test scenarios because of possibly different app structure in
// various tests
mainModule.services(RebuildingStrategy.class).withMixins(RebuildingStrategy.AlwaysNeed.class).visibleIn(Visibility.module);
// Always re-index in test scenarios
mainModule.services(ReindexingStrategy.class).withMixins(ReindexingStrategy.AlwaysNeed.class).visibleIn(Visibility.module);
config.entities(ReindexerConfiguration.class).visibleIn(Visibility.layer);
}
use of org.qi4j.test.EntityTestAssembler in project qi4j-sdk by Qi4j.
the class YammerTest method assemble.
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.entities(Person.class);
new EntityTestAssembler().assemble(module);
new YammerMetricsAssembler().assemble(module);
}
use of org.qi4j.test.EntityTestAssembler in project qi4j-sdk by Qi4j.
the class MigrationTest method assemble.
public void assemble(ModuleAssembly module) throws AssemblyException {
new EntityTestAssembler().assemble(module);
module.objects(MigrationEventLogger.class);
module.importedServices(MigrationEventLogger.class).importedBy(NewObjectImporter.class);
module.entities(TestEntity1_0.class, TestEntity1_1.class, TestEntity2_0.class, org.qi4j.migration.moved.TestEntity2_0.class);
MigrationBuilder migration = new MigrationBuilder("1.0");
migration.toVersion("1.1").renameEntity(TestEntity1_0.class.getName(), TestEntity1_1.class.getName()).atStartup(new CustomFixOperation("Fix for 1.1")).forEntities(TestEntity1_1.class.getName()).renameProperty("foo", "newFoo").renameManyAssociation("fooManyAssoc", "newFooManyAssoc").renameAssociation("fooAssoc", "newFooAssoc").end().toVersion("2.0").renameEntity(TestEntity1_1.class.getName(), TestEntity2_0.class.getName()).atStartup(new CustomFixOperation("Fix for 2.0, 1")).atStartup(new CustomFixOperation("Fix for 2.0, 2")).forEntities(TestEntity2_0.class.getName()).addProperty("bar", "Some value").removeProperty("newFoo", "Some value").custom(new CustomBarOperation()).end().toVersion("3.0").renamePackage("org.qi4j.migration", "org.qi4j.migration.moved").withEntities("TestEntity2_0").end();
module.services(MigrationService.class).setMetaInfo(migration);
module.entities(MigrationConfiguration.class);
module.forMixin(MigrationConfiguration.class).declareDefaults().lastStartupVersion().set("1.0");
}
Aggregations