use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class SearchManagerStoreTest method testIndexNewData.
/**
* Test de mise à jour de l'index après une creation.
* La création s'effectue dans une seule transaction.
*/
@Test
public void testIndexNewData() {
testIndexAllQuery();
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final Item item = createNewItem();
storeManager.getDataStore().create(item);
transaction.commit();
}
waitIndexation();
Assert.assertEquals(initialDbItemSize + 1, query("*:*"));
Assert.assertEquals(1, query("DESCRIPTION:légende"));
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class SuperHeroDataBase method createDataBase.
void createDataBase() {
// A chaque test on recrée la table SUPER_HERO
try (VTransactionWritable tx = transactionManager.createCurrentTransaction()) {
execStatement("create table SUPER_HERO(id BIGINT , name varchar(255));");
execStatement("create sequence SEQ_SUPER_HERO start with 10001 increment by 1");
}
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class TaskEngineProcBatchTest method testInsertBatch.
/**
* Tests batch insertion with a task
*/
@Test
public void testInsertBatch() {
final String request = new StringBuilder("insert into SUPER_HERO(ID, NAME) values (").append("#").append(DTC_SUPER_HERO_IN + ".ID").append("# , ").append("#").append(DTC_SUPER_HERO_IN + ".NAME").append("# ) ").toString();
final TaskDefinition taskDefinition = TaskDefinition.builder("TK_TEST_INSERT_BATCH").withEngine(TaskEngineProcBatch.class).addInRequired(DTC_SUPER_HERO_IN, getApp().getDefinitionSpace().resolve(DO_DT_SUPER_HERO_DTC, Domain.class)).withRequest(request).build();
final DtList<SuperHero> superHeroes = SuperHeroDataBase.getSuperHeroes();
final Task task = Task.builder(taskDefinition).addValue(DTC_SUPER_HERO_IN, superHeroes).build();
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
taskManager.execute(task);
transaction.commit();
}
Assert.assertEquals(superHeroes.size(), selectHeroes().size());
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class TaskEngineSelectDynamicTest method testNullable.
/**
* Test des nullable.
*/
@Test
public void testNullable() {
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final TaskDefinition taskDefinition = registerTaskWithNullableIn("TK_NULLABLE_TEST", "select * from SUPER_HERO where ID = #PARAM_1#<%if(param2!=null) {%> OR ID = #PARAM_2#+2 <%}%><%if(param3!=null) {%> OR ID = #PARAM_3#+3<%}%>");
final Task task = Task.builder(taskDefinition).addValue("PARAM_1", 10002).addValue("PARAM_2", null).addValue("PARAM_3", 10002).build();
final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
Assert.assertEquals(2, resultList.size());
Assert.assertEquals(10002L, resultList.get(0).getId().longValue());
Assert.assertEquals(10002L + 3, resultList.get(1).getId().longValue());
}
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class TaskEngineSelectDynamicTest method testTrim.
/**
* Test du preprocessor trim.
* Note: nous n'avons pas accès à la chaine trimée, on check juste que la requete est valide.
*/
@Test
public void testTrim() {
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final TaskDefinition taskDefinition = registerTaskObject("TK_SCRIPT_TEST", "select * from SUPER_HERO \n<%if(false) {%>\nwhere ID = #DTO_SUPER_HERO.ID#\n<%}%>\n");
final SuperHero superHero = new SuperHero();
superHero.setId(10001L + 1);
final Task task = Task.builder(taskDefinition).addValue(DTO_SUPER_HERO, superHero).build();
final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
Assert.assertEquals(10, resultList.size());
}
}
Aggregations