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