use of io.crnk.activiti.example.model.ScheduleApprovalProcessInstance in project crnk-framework by crnk-project.
the class ProcessInstanceRepositoryTest method patchSuspend.
@Test
public void patchSuspend() {
ScheduleApprovalProcessInstance processInstance = postProcess(null, null, null);
Assert.assertFalse(processInstance.isSuspended());
processInstance.setSuspended(true);
ScheduleApprovalProcessInstance savedProcessInstance = processRepository.save(processInstance);
Assert.assertNotSame(processInstance, savedProcessInstance);
Assert.assertTrue(savedProcessInstance.isSuspended());
processInstance.setSuspended(false);
savedProcessInstance = processRepository.save(processInstance);
Assert.assertFalse(savedProcessInstance.isSuspended());
Assert.assertNotSame(processInstance, savedProcessInstance);
}
use of io.crnk.activiti.example.model.ScheduleApprovalProcessInstance in project crnk-framework by crnk-project.
the class ProcessInstanceRepositoryTest method checkFilterEnforcementOnPatch.
@Test(expected = BadRequestException.class)
public void checkFilterEnforcementOnPatch() {
ScheduleApprovalProcessInstance processInstance = postProcess(null, null, null);
ScheduleApprovalProcessInstance resource = new ScheduleApprovalProcessInstance();
resource.setId(processInstance.getId());
resource.setProcessDefinitionKey("invalidProcessDefinition");
processRepository.save(resource);
}
use of io.crnk.activiti.example.model.ScheduleApprovalProcessInstance 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.ScheduleApprovalProcessInstance in project crnk-framework by crnk-project.
the class ProcessInstanceRepositoryTest method postProcess.
private ScheduleApprovalProcessInstance postProcess(String name, String businessKey, String tenantId) {
QuerySpec querySpec = new QuerySpec(ScheduleApprovalProcessInstance.class);
ScheduleApprovalValues newValues = new ScheduleApprovalValues();
newValues.setName("newScheduleName");
ScheduleApprovalProcessInstance resource = new ScheduleApprovalProcessInstance();
resource.setName(name);
resource.setResourceId("newScheduleId");
resource.setResourceType("schedules");
resource.setTenantId(tenantId);
resource.setBusinessKey(businessKey);
resource.setProcessDefinitionKey("scheduleChange");
resource.setNewValues(newValues);
resource.setDescription(ENFORCED_DESCRIPTION);
ScheduleApprovalProcessInstance createdProcessInstance = processRepository.create(resource);
Assert.assertEquals(name, createdProcessInstance.getName());
Assert.assertNotNull(createdProcessInstance.getId());
createdProcessInstance = processRepository.findOne(createdProcessInstance.getId(), querySpec);
Assert.assertNotNull(createdProcessInstance.getId());
Assert.assertEquals(name, createdProcessInstance.getName());
Assert.assertEquals(businessKey, createdProcessInstance.getBusinessKey());
Assert.assertEquals("newScheduleName", createdProcessInstance.getNewValues().getName());
return createdProcessInstance;
}
use of io.crnk.activiti.example.model.ScheduleApprovalProcessInstance in project crnk-framework by crnk-project.
the class ProcessInstanceRepositoryTest method checkFilterEnforcementOnCreate.
@Test(expected = BadRequestException.class)
public void checkFilterEnforcementOnCreate() {
ScheduleApprovalProcessInstance resource = new ScheduleApprovalProcessInstance();
resource.setProcessDefinitionKey("invalidProcessDefinition");
processRepository.create(resource);
}
Aggregations