use of org.qi4j.test.EntityTestAssembler in project qi4j-sdk by Qi4j.
the class OperatorsTest method testOperators.
@Test
public void testOperators() throws UnitOfWorkCompletionException, ActivationException, AssemblyException {
SingletonAssembler assembler = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
new EntityTestAssembler().assemble(module);
module.entities(TestEntity.class);
module.values(TestValue.class);
module.forMixin(TestEntity.class).declareDefaults().foo().set("Bar");
module.forMixin(TestValue.class).declareDefaults().bar().set("Xyz");
}
};
UnitOfWork uow = assembler.module().newUnitOfWork();
try {
EntityBuilder<TestEntity> entityBuilder = uow.newEntityBuilder(TestEntity.class, "123");
entityBuilder.instance().value().set(assembler.module().newValue(TestValue.class));
TestEntity testEntity = entityBuilder.newInstance();
uow.complete();
uow = assembler.module().newUnitOfWork();
Iterable<TestEntity> entities = Iterables.iterable(testEntity = uow.get(testEntity));
QueryBuilder<TestEntity> builder = assembler.module().newQueryBuilder(TestEntity.class);
{
Specification<Composite> where = QueryExpressions.eq(QueryExpressions.templateFor(TestEntity.class).foo(), "Bar");
Assert.assertTrue(where.satisfiedBy(testEntity));
System.out.println(where);
}
{
Specification<Composite> where = QueryExpressions.eq(QueryExpressions.templateFor(TestEntity.class).value().get().bar(), "Xyz");
Assert.assertTrue(where.satisfiedBy(testEntity));
System.out.println(where);
Assert.assertTrue(builder.where(where).newQuery(entities).find().equals(testEntity));
}
} finally {
uow.discard();
}
}
use of org.qi4j.test.EntityTestAssembler in project qi4j-sdk by Qi4j.
the class JCloudsFilesystemTest method assemble.
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
super.assemble(module);
ModuleAssembly config = module.layer().module("config");
new EntityTestAssembler().assemble(config);
new OrgJsonValueSerializationAssembler().assemble(module);
new JCloudsMapEntityStoreAssembler().withConfigIn(config, Visibility.layer).assemble(module);
JCloudsMapEntityStoreConfiguration defaults = config.forMixin(JCloudsMapEntityStoreConfiguration.class).declareDefaults();
defaults.provider().set("filesystem");
Map<String, String> props = new HashMap<String, String>();
props.put(FilesystemConstants.PROPERTY_BASEDIR, "build/tmp/" + getClass().getPackage().getName() + "/es-jclouds-" + System.currentTimeMillis());
defaults.properties().set(props);
}
use of org.qi4j.test.EntityTestAssembler in project qi4j-sdk by Qi4j.
the class JdbmEntityStoreTest method assemble.
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
super.assemble(module);
module.services(FileConfigurationService.class).instantiateOnStartup();
new JdbmEntityStoreAssembler(Visibility.module).assemble(module);
ModuleAssembly config = module.layer().module("config");
config.entities(JdbmConfiguration.class).visibleIn(Visibility.layer);
new EntityTestAssembler().assemble(config);
new OrgJsonValueSerializationAssembler().assemble(module);
}
use of org.qi4j.test.EntityTestAssembler in project qi4j-sdk by Qi4j.
the class HazelcastEntityStoreTest method assemble.
@Override
public // START SNIPPET: assembly
void assemble(ModuleAssembly module) throws AssemblyException {
// END SNIPPET: assembly
super.assemble(module);
ModuleAssembly configModule = module.layer().module("config");
new EntityTestAssembler().assemble(configModule);
new OrgJsonValueSerializationAssembler().assemble(module);
// START SNIPPET: assembly
new HazelcastEntityStoreAssembler().withConfigIn(configModule, Visibility.layer).assemble(module);
}
use of org.qi4j.test.EntityTestAssembler in project qi4j-sdk by Qi4j.
the class RiakHttpMapEntityStoreTest 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
new RiakHttpMapEntityStoreAssembler().withConfigModule(config).assemble(module);
}
Aggregations