Search in sources :

Example 1 with SuperHero

use of io.vertigo.dynamo.task.data.domain.SuperHero in project vertigo by KleeGroup.

the class SuperHeroDataBase method createSuperHero.

private static SuperHero createSuperHero(final long id, final String name) {
    final SuperHero superHero = new SuperHero();
    superHero.setId(id);
    superHero.setName(name);
    return superHero;
}
Also used : SuperHero(io.vertigo.dynamo.task.data.domain.SuperHero)

Example 2 with SuperHero

use of io.vertigo.dynamo.task.data.domain.SuperHero 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());
}
Also used : SuperHero(io.vertigo.dynamo.task.data.domain.SuperHero) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) TaskEngineProcBatch(io.vertigo.dynamox.task.TaskEngineProcBatch) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Domain(io.vertigo.dynamo.domain.metamodel.Domain) Test(org.junit.Test)

Example 3 with SuperHero

use of io.vertigo.dynamo.task.data.domain.SuperHero 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());
    }
}
Also used : SuperHero(io.vertigo.dynamo.task.data.domain.SuperHero) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 4 with SuperHero

use of io.vertigo.dynamo.task.data.domain.SuperHero 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());
    }
}
Also used : SuperHero(io.vertigo.dynamo.task.data.domain.SuperHero) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 5 with SuperHero

use of io.vertigo.dynamo.task.data.domain.SuperHero in project vertigo by KleeGroup.

the class TaskEngineSelectDynamicTest method testWhereIn2200.

/**
 * Test where in avec 2200 Id a inclure.
 */
@Test
public void testWhereIn2200() {
    superHeroDataBase.populateSuperHero(storeManager, 4500);
    try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final TaskDefinition taskDefinition = registerTaskList("TK_WHERE_ID_TEST", "select * from SUPER_HERO  where ID in (#DTC_SUPER_HERO_IN.ROWNUM.ID#)");
        final DtList<SuperHero> ids = new DtList<>(SuperHero.class);
        for (int i = 0; i < 2200; i++) {
            ids.add(createSuperHero(10001L + 2 * i));
        }
        final Task task = Task.builder(taskDefinition).addValue(DTC_SUPER_HERO_IN, ids).build();
        final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
        Assert.assertEquals(2200, resultList.size());
    }
}
Also used : SuperHero(io.vertigo.dynamo.task.data.domain.SuperHero) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) DtList(io.vertigo.dynamo.domain.model.DtList) Test(org.junit.Test)

Aggregations

SuperHero (io.vertigo.dynamo.task.data.domain.SuperHero)20 VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)18 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)17 Task (io.vertigo.dynamo.task.model.Task)17 Test (org.junit.Test)17 DtList (io.vertigo.dynamo.domain.model.DtList)7 Domain (io.vertigo.dynamo.domain.metamodel.Domain)3 TaskEngineProcBatch (io.vertigo.dynamox.task.TaskEngineProcBatch)2 AbstractTestCaseJU4 (io.vertigo.AbstractTestCaseJU4)1 VTransactionManager (io.vertigo.commons.transaction.VTransactionManager)1 TaskManager (io.vertigo.dynamo.task.TaskManager)1 TaskEngineSelect (io.vertigo.dynamox.task.TaskEngineSelect)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Assert (org.junit.Assert)1