Search in sources :

Example 16 with TaskDefinition

use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.

the class TaskManagerTest method testRegistry.

/**
 * Checks if the task-definition is registered.
 */
@Test
public void testRegistry() {
    final TaskDefinition taskDefinition = getTaskDefinition(TaskDefinitionProvider.TK_ADDITION);
    Assert.assertNotNull(taskDefinition);
}
Also used : TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Test(org.junit.Test)

Example 17 with TaskDefinition

use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.

the class TaskManagerTest method testRegistryWithNull.

/**
 * Checks when the task-definition is not registered (an exception must be thrown).
 */
@Test(expected = NullPointerException.class)
public void testRegistryWithNull() {
    final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
    // L'appel à la résolution doit remonter une assertion
    final TaskDefinition taskDefinition = definitionSpace.resolve(null, TaskDefinition.class);
    nop(taskDefinition);
}
Also used : TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) Test(org.junit.Test)

Example 18 with TaskDefinition

use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.

the class TaskManagerTest method testExecuteAddAdd.

/**
 * Checks that an exception is thrown
 * when a task is executed twice
 */
@Test
public void testExecuteAddAdd() {
    final TaskDefinition taskDefinition = getTaskDefinition(TaskDefinitionProvider.TK_ADDITION);
    final Task task = Task.builder(taskDefinition).addValue(ATTR_IN_INT_1, 1).addValue(ATTR_IN_INT_2, 8).addValue(ATTR_IN_INT_3, 7).build();
    final Integer result1 = taskManager.execute(task).getResult();
    Assert.assertEquals(Integer.valueOf(16), result1);
    final Integer result2 = taskManager.execute(task).getResult();
    Assert.assertEquals(Integer.valueOf(16), result2);
}
Also used : TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) Test(org.junit.Test)

Example 19 with TaskDefinition

use of io.vertigo.dynamo.task.metamodel.TaskDefinition 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 20 with TaskDefinition

use of io.vertigo.dynamo.task.metamodel.TaskDefinition 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)

Aggregations

TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)52 Task (io.vertigo.dynamo.task.model.Task)39 Test (org.junit.Test)26 VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)24 SuperHero (io.vertigo.dynamo.task.data.domain.SuperHero)17 Domain (io.vertigo.dynamo.domain.metamodel.Domain)11 TaskEngineSelect (io.vertigo.dynamox.task.TaskEngineSelect)11 DtList (io.vertigo.dynamo.domain.model.DtList)10 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)7 DefinitionSpace (io.vertigo.core.definition.DefinitionSpace)6 TaskEngineProc (io.vertigo.dynamox.task.TaskEngineProc)6 ArrayList (java.util.ArrayList)6 DtField (io.vertigo.dynamo.domain.metamodel.DtField)5 List (java.util.List)5 URI (io.vertigo.dynamo.domain.model.URI)4 VTransactionManager (io.vertigo.commons.transaction.VTransactionManager)3 TaskManager (io.vertigo.dynamo.task.TaskManager)3 TaskResult (io.vertigo.dynamo.task.model.TaskResult)3 Collectors (java.util.stream.Collectors)3 Inject (javax.inject.Inject)3