use of io.vertigo.dynamo.task.data.domain.SuperHero in project vertigo by KleeGroup.
the class TaskEngineSelectDynamicTest method testWhereInTab.
/**
* Test exécution d'une tache.
*/
@Test
public void testWhereInTab() {
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final TaskDefinition taskDefinition = registerTaskList("TK_WHERE_ID_TEST", "select * from SUPER_HERO where\tID in\t(#DTC_SUPER_HERO_IN.ROWNUM.ID#)");
final DtList<SuperHero> ids = DtList.of(createSuperHero(10001L + 1), createSuperHero(10001L + 3));
final Task task = Task.builder(taskDefinition).addValue(DTC_SUPER_HERO_IN, ids).build();
final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
Assert.assertEquals(2, resultList.size());
Assert.assertEquals(10001L + 1, resultList.get(0).getId().longValue());
Assert.assertEquals(10001L + 3, resultList.get(1).getId().longValue());
}
}
use of io.vertigo.dynamo.task.data.domain.SuperHero in project vertigo by KleeGroup.
the class TaskEngineSelectDynamicTest method testScriptVar.
/**
* Test des scripts.
*/
@Test
public void testScriptVar() {
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final TaskDefinition taskDefinition = registerTaskObject("TK_SCRIPT_TEST", "select * from SUPER_HERO <%if(dtoSuperHero.getId() == 10002L) {%>where ID = #DTO_SUPER_HERO.ID#<%}%>");
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(1, resultList.size());
Assert.assertEquals(10001L + 1, resultList.get(0).getId().longValue());
}
}
use of io.vertigo.dynamo.task.data.domain.SuperHero in project vertigo by KleeGroup.
the class SuperHeroDataBase method populateSuperHero.
void populateSuperHero(final StoreManager storeManager, final int size) {
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
// -----
for (int i = 0; i < size; i++) {
final SuperHero superHero = new SuperHero();
superHero.setName("SuperHero ( " + i + ")");
storeManager.getDataStore().create(superHero);
}
transaction.commit();
}
}
use of io.vertigo.dynamo.task.data.domain.SuperHero in project vertigo by KleeGroup.
the class TaskEngineProcBatchTest method testInsertBatchWithAdditionalParam.
/**
* Tests batch insertion with a task
*/
@Test
public void testInsertBatchWithAdditionalParam() {
final String request = new StringBuilder("insert into SUPER_HERO(ID, NAME) values (").append("#").append(DTC_SUPER_HERO_IN + ".ID").append("# , ").append("#").append(OTHER_PARAM_IN).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)).addInRequired(OTHER_PARAM_IN, getApp().getDefinitionSpace().resolve(DO_STRING, Domain.class)).withRequest(request).build();
final DtList<SuperHero> superHeroes = SuperHeroDataBase.getSuperHeroes();
final Task task = Task.builder(taskDefinition).addValue(DTC_SUPER_HERO_IN, superHeroes).addValue(OTHER_PARAM_IN, "test").build();
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
taskManager.execute(task);
transaction.commit();
}
Assert.assertEquals(superHeroes.size(), selectHeroes().size());
}
use of io.vertigo.dynamo.task.data.domain.SuperHero in project vertigo by KleeGroup.
the class TaskEngineProcBatchTest method testInsertBatchPrimitive.
/**
* Tests batch insertion with a task
*/
@Test
public void testInsertBatchPrimitive() {
final String request = new StringBuilder("insert into SUPER_HERO(ID, NAME) values (").append("#").append(SUPER_HERO_ID_LIST_IN).append("# , 'test' ").append(" )").toString();
final TaskDefinition taskDefinition = TaskDefinition.builder("TK_TEST_INSERT_BATCH").withEngine(TaskEngineProcBatch.class).addInRequired(SUPER_HERO_ID_LIST_IN, getApp().getDefinitionSpace().resolve(DO_LONGS, Domain.class)).withRequest(request).build();
final List<Long> superHeroesIds = SuperHeroDataBase.getSuperHeroes().stream().map(superHero -> superHero.getId()).collect(Collectors.toList());
final Task task = Task.builder(taskDefinition).addValue(SUPER_HERO_ID_LIST_IN, superHeroesIds).build();
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
taskManager.execute(task);
transaction.commit();
}
Assert.assertEquals(superHeroesIds.size(), selectHeroes().size());
}
Aggregations