use of org.ligoj.app.model.TaskSampleSubscription in project ligoj-api by ligoj.
the class LongTaskRunnerTest method deleteTaskRunnging.
@Test
public void deleteTaskRunnging() {
final TaskSampleSubscription taskSample = newTaskSample();
taskSample.setEnd(null);
repository.saveAndFlush(taskSample);
em.flush();
em.clear();
Assertions.assertThrows(BusinessException.class, () -> {
resource.deleteTask(subscription);
});
}
use of org.ligoj.app.model.TaskSampleSubscription in project ligoj-api by ligoj.
the class LongTaskRunnerTest method endTask.
@Test
public void endTask() {
final TaskSampleSubscription newTaskSample = newTaskSample();
newTaskSample.setEnd(null);
repository.saveAndFlush(newTaskSample);
resource.endTask(subscription, true);
TaskSampleSubscription task = resource.getTask(subscription);
assertTask(task);
Assertions.assertTrue(task.isFailed());
Assertions.assertNotNull(task.getEnd());
}
use of org.ligoj.app.model.TaskSampleSubscription in project ligoj-api by ligoj.
the class LongTaskRunnerTest method startTaskRunningRemote.
/**
* Task is locally finished, but not from the external system view.
*/
@Test
public void startTaskRunningRemote() {
resource = new TaskSampleSubscriptionResource() {
@Override
public boolean isFinished(final TaskSampleSubscription task) {
// Never remotely finished
return false;
}
};
applicationContext.getAutowireCapableBeanFactory().autowireBean(resource);
final TaskSampleSubscription newTaskSample = newTaskSample();
repository.saveAndFlush(newTaskSample);
Assertions.assertThrows(BusinessException.class, () -> {
resource.startTask(subscription, task -> task.setData("init"));
});
}
use of org.ligoj.app.model.TaskSampleSubscription in project ligoj-api by ligoj.
the class LongTaskRunnerTest method nextStep.
@Test
public void nextStep() {
final TaskSampleSubscription newTaskSample = newTaskSample();
newTaskSample.setEnd(null);
repository.saveAndFlush(newTaskSample);
resource.nextStep(subscription, t -> t.setData("step2"));
Assertions.assertEquals("step2", newTaskSample.getData());
}
use of org.ligoj.app.model.TaskSampleSubscription in project ligoj-api by ligoj.
the class LongTaskRunnerTest method deleteTaskNotRunnging.
@Test
public void deleteTaskNotRunnging() {
final TaskSampleSubscription taskSample = newTaskSample();
repository.saveAndFlush(taskSample);
em.flush();
em.clear();
resource.deleteTask(subscription);
Assertions.assertEquals(0, repository.count());
}
Aggregations