use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceEJBIntegrationTest method testStartProcessAndExecuteCmd.
@Test
public void testStartProcessAndExecuteCmd() {
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.execute(deploymentUnit.getIdentifier(), new GetProcessInstanceCommand(processInstanceId));
assertNotNull(pi);
processService.abortProcessInstance(processInstanceId);
pi = processService.getProcessInstance(processInstanceId);
assertNull(pi);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceEJBIntegrationTest method testStartProcessAndChangeVariables.
@Test
public void testStartProcessAndChangeVariables() {
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);
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);
ProcessInstance pi = processService.getProcessInstance(processInstanceId);
assertNotNull(pi);
// get variable by name
Object variableValue = processService.getProcessInstanceVariable(processInstanceId, "approval_document");
assertNotNull(variableValue);
assertTrue(variableValue instanceof String);
assertEquals("test", variableValue);
// get all variables
Map<String, Object> variables = processService.getProcessInstanceVariables(processInstanceId);
assertNotNull(variables);
assertEquals(2, variables.size());
assertTrue(variables.containsKey("approval_document"));
assertTrue(variables.containsKey("approval_reviewComment"));
assertEquals("test", variables.get("approval_document"));
assertEquals("need review", variables.get("approval_reviewComment"));
// now change single variable
processService.setProcessVariable(processInstanceId, "approval_reviewComment", "updated review comment");
// let's verify it
variableValue = processService.getProcessInstanceVariable(processInstanceId, "approval_reviewComment");
assertNotNull(variableValue);
assertTrue(variableValue instanceof String);
assertEquals("updated review comment", variableValue);
// and lastly let's update both variables
params = new HashMap<String, Object>();
params.put("approval_document", "updated document");
params.put("approval_reviewComment", "final review");
processService.setProcessVariables(processInstanceId, params);
variables = processService.getProcessInstanceVariables(processInstanceId);
assertNotNull(variables);
assertEquals(2, variables.size());
assertTrue(variables.containsKey("approval_document"));
assertTrue(variables.containsKey("approval_reviewComment"));
assertEquals("updated document", variables.get("approval_document"));
assertEquals("final review", variables.get("approval_reviewComment"));
processService.abortProcessInstance(processInstanceId);
pi = processService.getProcessInstance(processInstanceId);
assertNull(pi);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceEJBIntegrationTest method testStartProcessAndAbortWorkItem.
@Test
public void testStartProcessAndAbortWorkItem() {
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(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());
processService.abortWorkItem(activeNodes.iterator().next().getWorkItemId());
activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
assertNotNull(activeNodes);
assertEquals(2, activeNodes.size());
Object variableValue = processService.getProcessInstanceVariable(processInstanceId, "approval_document");
assertNull(variableValue);
processService.abortProcessInstance(processInstanceId);
pi = processService.getProcessInstance(processInstanceId);
assertNull(pi);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceEJBIntegrationTest method testStartAndAbortProcesses.
@Test
public void testStartAndAbortProcesses() {
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.writedocument");
assertNotNull(processInstanceId1);
ProcessInstance pi = processService.getProcessInstance(processInstanceId1);
assertNotNull(pi);
// then start second instance
long processInstanceId2 = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId2);
ProcessInstance pi2 = processService.getProcessInstance(processInstanceId2);
assertNotNull(pi2);
List<Long> instances = new ArrayList<Long>();
instances.add(processInstanceId1);
instances.add(processInstanceId2);
// and lastly cancel both
processService.abortProcessInstances(instances);
pi = processService.getProcessInstance(processInstanceId1);
assertNull(pi);
pi2 = processService.getProcessInstance(processInstanceId2);
assertNull(pi2);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceEJBIntegrationTest 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(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(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(processInstanceId);
pi = processService.getProcessInstance(processInstanceId);
assertNull(pi);
}
Aggregations