Search in sources :

Example 6 with ApproveTask

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

the class TaskResourceRepositoryTest method checkOrderByPriorityAsc.

@Test
public void checkOrderByPriorityAsc() {
    addTask("otherTask", 14);
    QuerySpec querySpec = new QuerySpec(ApproveTask.class);
    querySpec.addSort(new SortSpec(Arrays.asList("priority"), Direction.ASC));
    ResourceList<ApproveTask> resources = taskRepository.findAll(querySpec);
    Assert.assertEquals(2, resources.size());
    Assert.assertEquals("testTask", resources.get(0).getName());
    Assert.assertEquals("otherTask", 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 7 with ApproveTask

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

the class TaskResourceRepositoryTest method createTask.

@Test
public void createTask() {
    QuerySpec querySpec = new QuerySpec(ApproveTask.class);
    ApproveTask resource = new ApproveTask();
    resource.setName("testTask");
    resource.setDescription(ENFORCED_DESCRIPTION);
    ApproveTask createdTask = taskRepository.create(resource);
    Assert.assertEquals("testTask", createdTask.getName());
    createdTask = taskRepository.findOne(task.getId(), querySpec);
    Assert.assertNotNull(createdTask);
}
Also used : QuerySpec(io.crnk.core.queryspec.QuerySpec) ApproveTask(io.crnk.activiti.example.model.ApproveTask) Test(org.junit.Test)

Example 8 with ApproveTask

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

the class ApprovalIntTest method verifyApprovalStarted.

private ApproveTask verifyApprovalStarted(Schedule schedule) {
    // check approval process started
    ResourceList<ScheduleApprovalProcessInstance> scheduleApprovals = approvalRepo.findAll(new QuerySpec(ScheduleApprovalProcessInstance.class));
    Assert.assertEquals(1, scheduleApprovals.size());
    checkOpenApproval(schedule, scheduleApprovals.get(0));
    // check relationship from resource to approval process
    ScheduleApprovalProcessInstance scheduleApproval = approvalRelRepo.findOneTarget(schedule.getId().toString(), "approval", new QuerySpec(ScheduleApprovalProcessInstance.class));
    checkOpenApproval(schedule, scheduleApproval);
    // check relationship from approval process to task
    ApproveTask approveTask = processTaskRepo.findOneTarget(scheduleApprovals.get(0).getId(), "approveTask", new QuerySpec(ApproveTask.class));
    Assert.assertNotNull(approveTask);
    // check task created
    QuerySpec taskQuery = new QuerySpec(ApproveTask.class);
    taskQuery.includeRelation(Arrays.asList("form"));
    ResourceList<ApproveTask> tasks = taskRepo.findAll(taskQuery);
    Assert.assertEquals(1, tasks.size());
    ApproveTask task = tasks.get(0);
    checkApproveTaskCreated(schedule, task);
    // check search for task by process
    QuerySpec querySpec = new QuerySpec(ApproveTask.class);
    querySpec.addFilter(new FilterSpec(Arrays.asList("processInstance", "id"), FilterOperator.EQ, scheduleApproval.getId()));
    ResourceList<ApproveTask> results = taskRepo.findAll(querySpec);
    Assert.assertEquals(1, results.size());
    Assert.assertEquals(scheduleApproval.getId(), results.get(0).getProcessInstanceId());
    return task;
}
Also used : ScheduleApprovalProcessInstance(io.crnk.activiti.example.model.ScheduleApprovalProcessInstance) QuerySpec(io.crnk.core.queryspec.QuerySpec) FilterSpec(io.crnk.core.queryspec.FilterSpec) ApproveTask(io.crnk.activiti.example.model.ApproveTask)

Example 9 with ApproveTask

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

the class TaskResourceRepositoryTest method checkFilterEnforcementOnSave.

@Test(expected = BadRequestException.class)
public void checkFilterEnforcementOnSave() {
    ApproveTask resource = new ApproveTask();
    // => will not be able to hijack isolated task
    resource.setId(isolatedTask.getId());
    resource.setName("testTask");
    resource.setDescription(ENFORCED_DESCRIPTION);
    taskRepository.save(resource);
}
Also used : ApproveTask(io.crnk.activiti.example.model.ApproveTask) Test(org.junit.Test)

Example 10 with ApproveTask

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

the class TaskResourceRepositoryTest method checkResourceMapping.

@Test
public void checkResourceMapping() {
    QuerySpec querySpec = new QuerySpec(TaskResource.class);
    ApproveTask resource = taskRepository.findOne(task.getId(), querySpec);
    Assert.assertEquals(task.getPriority(), resource.getPriority());
    Assert.assertEquals(task.getAssignee(), resource.getAssignee());
    Assert.assertEquals(task.getCategory(), resource.getCategory());
    Assert.assertEquals(task.getName(), resource.getName());
    Assert.assertEquals(task.getOwner(), resource.getOwner());
    Assert.assertEquals(task.getDescription(), resource.getDescription());
    Assert.assertEquals(task.getTenantId(), resource.getTenantId());
    Assert.assertFalse(resource.isCompleted());
    Assert.assertEquals(task.getDueDate().toInstant(), resource.getDueDate().toInstant());
}
Also used : QuerySpec(io.crnk.core.queryspec.QuerySpec) ApproveTask(io.crnk.activiti.example.model.ApproveTask) Test(org.junit.Test)

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