Search in sources :

Example 11 with ApproveTask

use of io.crnk.activiti.example.model.ApproveTask in project crnk-framework by crnk-project.

the class TaskResourceRepositoryTest method checkDefaultsOnEnforcedAttributeOnCreate.

@Test
public void checkDefaultsOnEnforcedAttributeOnCreate() {
    ApproveTask resource = new ApproveTask();
    resource.setName("newTask");
    // default will be set
    resource.setDescription(null);
    ApproveTask savedTask = taskRepository.create(resource);
    Assert.assertEquals(ENFORCED_DESCRIPTION, savedTask.getDescription());
}
Also used : ApproveTask(io.crnk.activiti.example.model.ApproveTask) Test(org.junit.Test)

Example 12 with ApproveTask

use of io.crnk.activiti.example.model.ApproveTask in project crnk-framework by crnk-project.

the class TaskResourceRepositoryTest method completeTask.

@Test
public void completeTask() {
    QuerySpec querySpec = new QuerySpec(ApproveTask.class);
    ApproveTask resource = taskRepository.findOne(task.getId(), querySpec);
    Assert.assertFalse(resource.isCompleted());
    resource.setCompleted(true);
    ApproveTask updatedResource = taskRepository.save(resource);
    Assert.assertTrue(updatedResource.isCompleted());
    try {
        taskRepository.findOne(task.getId(), querySpec);
        Assert.fail();
    } catch (ResourceNotFoundException e) {
    // ok
    }
}
Also used : QuerySpec(io.crnk.core.queryspec.QuerySpec) ResourceNotFoundException(io.crnk.core.exception.ResourceNotFoundException) ApproveTask(io.crnk.activiti.example.model.ApproveTask) Test(org.junit.Test)

Example 13 with ApproveTask

use of io.crnk.activiti.example.model.ApproveTask in project crnk-framework by crnk-project.

the class TaskResourceRepositoryTest method checkIsolation.

@Test
public void checkIsolation() {
    addTask("otherTask1", 14);
    addTask("otherTask2", 15);
    addTask("otherTask3", 16);
    QuerySpec querySpec = new QuerySpec(ApproveTask.class);
    querySpec.addSort(new SortSpec(Arrays.asList("priority"), Direction.ASC));
    querySpec.setOffset(1);
    querySpec.setLimit(2L);
    ResourceList<ApproveTask> resources = taskRepository.findAll(querySpec);
    Assert.assertEquals(2, resources.size());
    Assert.assertEquals("otherTask1", resources.get(0).getName());
    Assert.assertEquals("otherTask2", resources.get(1).getName());
}
Also used : QuerySpec(io.crnk.core.queryspec.QuerySpec) ApproveTask(io.crnk.activiti.example.model.ApproveTask) SortSpec(io.crnk.core.queryspec.SortSpec) Test(org.junit.Test)

Example 14 with ApproveTask

use of io.crnk.activiti.example.model.ApproveTask in project crnk-framework by crnk-project.

the class TaskResourceRepositoryTest method checkPaging.

@Test
public void checkPaging() {
    addTask("otherTask1", 14);
    addTask("otherTask2", 15);
    addTask("otherTask3", 16);
    QuerySpec querySpec = new QuerySpec(ApproveTask.class);
    querySpec.addSort(new SortSpec(Arrays.asList("priority"), Direction.ASC));
    querySpec.setOffset(1);
    querySpec.setLimit(2L);
    ResourceList<ApproveTask> resources = taskRepository.findAll(querySpec);
    Assert.assertEquals(2, resources.size());
    Assert.assertEquals("otherTask1", resources.get(0).getName());
    Assert.assertEquals("otherTask2", resources.get(1).getName());
}
Also used : QuerySpec(io.crnk.core.queryspec.QuerySpec) ApproveTask(io.crnk.activiti.example.model.ApproveTask) SortSpec(io.crnk.core.queryspec.SortSpec) Test(org.junit.Test)

Example 15 with ApproveTask

use of io.crnk.activiti.example.model.ApproveTask in project crnk-framework by crnk-project.

the class ApprovalIntTest method verifyApprovalCompleted.

private void verifyApprovalCompleted(Schedule schedule) {
    QuerySpec taskQuery = new QuerySpec(ApproveTask.class);
    taskQuery.includeRelation(Arrays.asList("form"));
    // check approval completed
    ResourceList<ApproveTask> tasks = taskRepo.findAll(taskQuery);
    Assert.assertEquals(0, tasks.size());
    // check no approval for schedule in progress
    ScheduleApprovalProcessInstance scheduleApproval = approvalRelRepo.findOneTarget(schedule.getId().toString(), "approval", new QuerySpec(ScheduleApprovalProcessInstance.class));
    // no approval in progress
    Assert.assertNull(scheduleApproval);
}
Also used : ScheduleApprovalProcessInstance(io.crnk.activiti.example.model.ScheduleApprovalProcessInstance) QuerySpec(io.crnk.core.queryspec.QuerySpec) ApproveTask(io.crnk.activiti.example.model.ApproveTask)

Aggregations

ApproveTask (io.crnk.activiti.example.model.ApproveTask)16 Test (org.junit.Test)13 QuerySpec (io.crnk.core.queryspec.QuerySpec)11 SortSpec (io.crnk.core.queryspec.SortSpec)4 ScheduleApprovalProcessInstance (io.crnk.activiti.example.model.ScheduleApprovalProcessInstance)2 ResourceNotFoundException (io.crnk.core.exception.ResourceNotFoundException)2 CrnkBoot (io.crnk.core.boot.CrnkBoot)1 FilterSpec (io.crnk.core.queryspec.FilterSpec)1 TestModule (io.crnk.test.mock.TestModule)1 Schedule (io.crnk.test.mock.models.Schedule)1 OffsetDateTime (java.time.OffsetDateTime)1 JerseyTest (org.glassfish.jersey.test.JerseyTest)1 Before (org.junit.Before)1