Search in sources :

Example 6 with ScheduleApprovalProcessInstance

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);
}
Also used : ScheduleApprovalProcessInstance(io.crnk.activiti.example.model.ScheduleApprovalProcessInstance) Test(org.junit.Test)

Example 7 with ScheduleApprovalProcessInstance

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);
}
Also used : ScheduleApprovalProcessInstance(io.crnk.activiti.example.model.ScheduleApprovalProcessInstance) Test(org.junit.Test)

Example 8 with ScheduleApprovalProcessInstance

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;
}
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 ScheduleApprovalProcessInstance

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;
}
Also used : ScheduleApprovalProcessInstance(io.crnk.activiti.example.model.ScheduleApprovalProcessInstance) ScheduleApprovalValues(io.crnk.activiti.example.model.ScheduleApprovalValues) QuerySpec(io.crnk.core.queryspec.QuerySpec)

Example 10 with ScheduleApprovalProcessInstance

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);
}
Also used : ScheduleApprovalProcessInstance(io.crnk.activiti.example.model.ScheduleApprovalProcessInstance) Test(org.junit.Test)

Aggregations

ScheduleApprovalProcessInstance (io.crnk.activiti.example.model.ScheduleApprovalProcessInstance)12 Test (org.junit.Test)8 QuerySpec (io.crnk.core.queryspec.QuerySpec)5 ApproveTask (io.crnk.activiti.example.model.ApproveTask)2 ScheduleApprovalValues (io.crnk.activiti.example.model.ScheduleApprovalValues)2 ResourceNotFoundException (io.crnk.core.exception.ResourceNotFoundException)1 FilterSpec (io.crnk.core.queryspec.FilterSpec)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1