Search in sources :

Example 1 with TaskSampleNode

use of org.ligoj.app.model.TaskSampleNode in project ligoj-api by ligoj.

the class LongTaskRunnerTest method cancelNotRunnging.

@Test
public void cancelNotRunnging() {
    final TaskSampleNode task = newTaskSampleNode();
    repositoryNode.saveAndFlush(task);
    Assertions.assertThrows(BusinessException.class, () -> {
        resourceNode.cancel(task.getLocked().getId());
    });
}
Also used : TaskSampleNode(org.ligoj.app.model.TaskSampleNode) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 2 with TaskSampleNode

use of org.ligoj.app.model.TaskSampleNode in project ligoj-api by ligoj.

the class LongTaskRunnerTest method newTaskSampleNode.

private TaskSampleNode newTaskSampleNode() {
    final TaskSampleNode taskSample = new TaskSampleNode();
    taskSample.setAuthor(DEFAULT_USER);
    taskSample.setData("custom");
    taskSample.setStart(new Date());
    taskSample.setEnd(new Date());
    taskSample.setLocked(em.find(Node.class, "service:bt:jira"));
    return taskSample;
}
Also used : TaskSampleNode(org.ligoj.app.model.TaskSampleNode) DelegateNode(org.ligoj.app.model.DelegateNode) TaskSampleNode(org.ligoj.app.model.TaskSampleNode) Node(org.ligoj.app.model.Node) Date(java.util.Date)

Example 3 with TaskSampleNode

use of org.ligoj.app.model.TaskSampleNode in project ligoj-api by ligoj.

the class NodeResourceTest method deleteTasks.

@Test
public void deleteTasks() throws Exception {
    final TaskSampleNodeResource sampleResource = registerSingleton("taskSampleResource", applicationContext.getAutowireCapableBeanFactory().createBean(TaskSampleNodeResource.class));
    try {
        final TaskSampleNode entity = sampleResource.startTask("service:bt:jira:4", task -> task.setData("init"));
        Assertions.assertEquals("service:bt:jira:4", taskSampleRepository.findNotFinishedByLocked("service:bt:jira:4").getLocked().getId());
        Assertions.assertThrows(BusinessException.class, () -> {
            sampleResource.startTask("service:bt:jira:4", task -> task.setData("init"));
        });
        sampleResource.endTask("service:bt:jira:4", false);
        taskSampleRepository.saveAndFlush(entity);
        Assertions.assertNull(taskSampleRepository.findNotFinishedByLocked("service:bt:jira:4"));
        em.flush();
        em.clear();
        Assertions.assertEquals(1, taskSampleRepository.count());
        resource.deleteTasks(sampleResource, "service:bt:jira:4");
        Assertions.assertNull(taskSampleRepository.findNotFinishedByLocked("service:bt:jira:4"));
        Assertions.assertEquals(0, taskSampleRepository.count());
    } finally {
        destroySingleton("taskSampleResource");
    }
}
Also used : TaskSampleNode(org.ligoj.app.model.TaskSampleNode) Test(org.junit.jupiter.api.Test) AbstractAppTest(org.ligoj.app.AbstractAppTest)

Example 4 with TaskSampleNode

use of org.ligoj.app.model.TaskSampleNode in project ligoj-api by ligoj.

the class LongTaskRunnerTest method cancel.

@Test
public void cancel() {
    final TaskSampleNode task = newTaskSampleNode();
    task.setEnd(null);
    Assertions.assertFalse(task.isFailed());
    repositoryNode.saveAndFlush(task);
    resourceNode.cancel(task.getLocked().getId());
    Assertions.assertTrue(resourceNode.getTask(task.getLocked().getId()).isFailed());
}
Also used : TaskSampleNode(org.ligoj.app.model.TaskSampleNode) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Aggregations

TaskSampleNode (org.ligoj.app.model.TaskSampleNode)4 Test (org.junit.jupiter.api.Test)3 AbstractOrgTest (org.ligoj.app.resource.AbstractOrgTest)2 Date (java.util.Date)1 AbstractAppTest (org.ligoj.app.AbstractAppTest)1 DelegateNode (org.ligoj.app.model.DelegateNode)1 Node (org.ligoj.app.model.Node)1