Search in sources :

Example 11 with ScheduleApprovalProcessInstance

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

the class ProcessInstanceRepositoryTest method addProcessInstance.

private ProcessInstance addProcessInstance() {
    ScheduleApprovalValues newValues = new ScheduleApprovalValues();
    newValues.setName("newName");
    ScheduleApprovalProcessInstance resource = new ScheduleApprovalProcessInstance();
    resource.setResourceType("schedules");
    resource.setResourceId("12");
    resource.setNewValues(newValues);
    Map<String, Object> processVariables = resourceMapper.mapToVariables(resource);
    runtimeService = processEngine.getRuntimeService();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("scheduleChange", "testBusinessKey", processVariables);
    runtimeService.setProcessInstanceName(processInstance.getId(), "testName");
    processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).includeProcessVariables().singleResult();
    return processInstance;
}
Also used : ScheduleApprovalProcessInstance(io.crnk.activiti.example.model.ScheduleApprovalProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ScheduleApprovalProcessInstance(io.crnk.activiti.example.model.ScheduleApprovalProcessInstance) ScheduleApprovalValues(io.crnk.activiti.example.model.ScheduleApprovalValues)

Example 12 with ScheduleApprovalProcessInstance

use of io.crnk.activiti.example.model.ScheduleApprovalProcessInstance 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

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