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());
});
}
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;
}
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");
}
}
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());
}
Aggregations