use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceImplWithDeploymentIdTest method testStartProcessAndAbortThenChangeVariables.
@Test
public void testStartProcessAndAbortThenChangeVariables() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
Map<String, Object> params = new HashMap<String, Object>();
params.put("approval_document", "test");
params.put("approval_reviewComment", "need review");
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", params);
assertNotNull(processInstanceId);
processService.abortProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
assertNull(pi);
try {
processService.getProcessInstanceVariable(deploymentUnit.getIdentifier(), processInstanceId, "approval_reviewComment");
fail("Process instance was aborted so variables do not exist");
} catch (ProcessInstanceNotFoundException e) {
// expected
}
try {
processService.getProcessInstanceVariable(deploymentUnit.getIdentifier(), processInstanceId, "approval_reviewComment");
fail("Process instance was aborted so variables do not exist");
} catch (ProcessInstanceNotFoundException e) {
// expected
}
params = new HashMap<String, Object>();
params.put("approval_document", "updated document");
params.put("approval_reviewComment", "final review");
try {
processService.setProcessVariables(deploymentUnit.getIdentifier(), processInstanceId, params);
fail("Process instance was aborted so cannot be changed");
} catch (ProcessInstanceNotFoundException e) {
// expected
}
try {
processService.setProcessVariable(deploymentUnit.getIdentifier(), processInstanceId, "approval_reviewComment", "updated review comment");
fail("Process instance was aborted so cannot be changed");
} catch (ProcessInstanceNotFoundException e) {
// expected
}
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceImplWithDeploymentIdTest method testStartAndSignalProcesses.
@Test
public void testStartAndSignalProcesses() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
assertTrue(isDeployed);
assertNotNull(processService);
// first start first instance
long processInstanceId1 = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.signal");
assertNotNull(processInstanceId1);
ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId1);
assertNotNull(pi);
// then start second instance
long processInstanceId2 = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.signal");
assertNotNull(processInstanceId2);
ProcessInstance pi2 = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId2);
assertNotNull(pi2);
List<Long> instances = new ArrayList<Long>();
instances.add(processInstanceId1);
instances.add(processInstanceId2);
// and lastly cancel both
processService.signalProcessInstances(deploymentUnit.getIdentifier(), instances, "MySignal", null);
pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId1);
assertNull(pi);
pi2 = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId2);
assertNull(pi2);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceImplWithDeploymentIdTest method testStartProcessAndGetWorkItems.
@Test
public void testStartProcessAndGetWorkItems() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
assertTrue(isDeployed);
assertNotNull(processService);
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
assertNotNull(pi);
Collection<NodeInstanceDesc> activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
assertEquals("Write a Document", activeNodes.iterator().next().getName());
List<WorkItem> wis = processService.getWorkItemByProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
assertNotNull(wis);
assertEquals(1, wis.size());
assertEquals("Human Task", wis.get(0).getName());
assertEquals("Write a Document", wis.get(0).getParameter("NodeName"));
processService.abortProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
assertNull(pi);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceImplWithDeploymentIdTest method testStartAndSignalProcess.
@Test
public void testStartAndSignalProcess() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
assertTrue(isDeployed);
assertNotNull(processService);
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.signal");
assertNotNull(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
assertNotNull(pi);
Collection<String> signals = processService.getAvailableSignals(deploymentUnit.getIdentifier(), processInstanceId);
assertNotNull(signals);
assertEquals(1, signals.size());
assertTrue(signals.contains("MySignal"));
processService.signalProcessInstance(deploymentUnit.getIdentifier(), processInstanceId, "MySignal", null);
pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
assertNull(pi);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceImplWithoutAuditTest method testStartProcessAndAbortThenChangeVariables.
@Test
public void testStartProcessAndAbortThenChangeVariables() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
final Map<String, Object> params = new HashMap<String, Object>();
params.put("approval_document", "test");
params.put("approval_reviewComment", "need review");
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", params);
assertNotNull(processInstanceId);
processService.abortProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
assertNull(pi);
assertThatExceptionOfType(ProcessInstanceNotFoundException.class).isThrownBy(() -> {
processService.getProcessInstanceVariable(deploymentUnit.getIdentifier(), processInstanceId, "approval_reviewComment");
});
params.clear();
params.put("approval_document", "updated document");
params.put("approval_reviewComment", "final review");
assertThatExceptionOfType(ProcessInstanceNotFoundException.class).isThrownBy(() -> {
processService.setProcessVariables(deploymentUnit.getIdentifier(), processInstanceId, params);
});
assertThatExceptionOfType(ProcessInstanceNotFoundException.class).isThrownBy(() -> {
processService.setProcessVariable(deploymentUnit.getIdentifier(), processInstanceId, "approval_reviewComment", "updated review comment");
});
}
Aggregations