Search in sources :

Example 6 with TaskSampleSubscription

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);
    });
}
Also used : TaskSampleSubscription(org.ligoj.app.model.TaskSampleSubscription) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 7 with TaskSampleSubscription

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());
}
Also used : TaskSampleSubscription(org.ligoj.app.model.TaskSampleSubscription) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 8 with TaskSampleSubscription

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"));
    });
}
Also used : TaskSampleSubscription(org.ligoj.app.model.TaskSampleSubscription) TaskSampleSubscriptionResource(org.ligoj.app.resource.subscription.TaskSampleSubscriptionResource) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 9 with TaskSampleSubscription

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());
}
Also used : TaskSampleSubscription(org.ligoj.app.model.TaskSampleSubscription) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 10 with TaskSampleSubscription

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());
}
Also used : TaskSampleSubscription(org.ligoj.app.model.TaskSampleSubscription) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Aggregations

TaskSampleSubscription (org.ligoj.app.model.TaskSampleSubscription)11 Test (org.junit.jupiter.api.Test)10 AbstractOrgTest (org.ligoj.app.resource.AbstractOrgTest)10 Date (java.util.Date)2 Subscription (org.ligoj.app.model.Subscription)1 TaskSampleSubscriptionResource (org.ligoj.app.resource.subscription.TaskSampleSubscriptionResource)1