Search in sources :

Example 66 with EntityTestAssembler

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());
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) Test(org.junit.Test)

Example 67 with EntityTestAssembler

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);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) RdfNativeSesameStoreAssembler(org.qi4j.index.rdf.assembly.RdfNativeSesameStoreAssembler) JdbmConfiguration(org.qi4j.entitystore.jdbm.JdbmConfiguration) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) NativeConfiguration(org.qi4j.library.rdf.repository.NativeConfiguration) JdbmEntityStoreAssembler(org.qi4j.entitystore.jdbm.assembly.JdbmEntityStoreAssembler)

Example 68 with EntityTestAssembler

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);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) DataSourceAssembler(org.qi4j.library.sql.assembly.DataSourceAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) PostgreSQLIndexQueryAssembler(org.qi4j.index.sql.assembly.PostgreSQLIndexQueryAssembler) ReindexerConfiguration(org.qi4j.index.reindexer.ReindexerConfiguration) DBCPDataSourceServiceAssembler(org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler)

Example 69 with EntityTestAssembler

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);
}
Also used : EntityTestAssembler(org.qi4j.test.EntityTestAssembler)

Example 70 with EntityTestAssembler

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");
}
Also used : MigrationBuilder(org.qi4j.migration.assembly.MigrationBuilder) EntityTestAssembler(org.qi4j.test.EntityTestAssembler)

Aggregations

EntityTestAssembler (org.qi4j.test.EntityTestAssembler)137 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)51 OrgJsonValueSerializationAssembler (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)20 SingletonAssembler (org.qi4j.bootstrap.SingletonAssembler)13 RdfMemoryStoreAssembler (org.qi4j.index.rdf.assembly.RdfMemoryStoreAssembler)10 Test (org.junit.Test)9 FileConfigurationService (org.qi4j.library.fileconfig.FileConfigurationService)8 DataSourceAssembler (org.qi4j.library.sql.assembly.DataSourceAssembler)8 NativeConfiguration (org.qi4j.library.rdf.repository.NativeConfiguration)7 AssemblyException (org.qi4j.bootstrap.AssemblyException)6 ShiroIniConfiguration (org.qi4j.library.shiro.ini.ShiroIniConfiguration)6 DBCPDataSourceServiceAssembler (org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler)6 File (java.io.File)5 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)5 RdfNativeSesameStoreAssembler (org.qi4j.index.rdf.assembly.RdfNativeSesameStoreAssembler)5 Module (org.qi4j.api.structure.Module)4 JdbmConfiguration (org.qi4j.entitystore.jdbm.JdbmConfiguration)4 JdbmEntityStoreAssembler (org.qi4j.entitystore.jdbm.assembly.JdbmEntityStoreAssembler)4 ESFilesystemIndexQueryAssembler (org.qi4j.index.elasticsearch.assembly.ESFilesystemIndexQueryAssembler)4 CurrentUserUoWPrincipal (org.qi4j.library.eventsourcing.domain.factory.CurrentUserUoWPrincipal)4