use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.
the class QueryServiceImplTest method cleanup.
@After
public void cleanup() {
System.clearProperty("org.jbpm.ht.callback");
System.clearProperty("org.jbpm.ht.custom.callback");
if (query != null) {
try {
queryService.unregisterQuery(query.getName());
} catch (QueryNotFoundException e) {
}
}
if (processInstanceId != null) {
try {
// let's abort process instance to leave the system in clear state
processService.abortProcessInstance(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(processInstanceId);
assertNull(pi);
} catch (ProcessInstanceNotFoundException e) {
// ignore it as it was already completed/aborted
}
}
cleanupSingletonSessionId();
if (units != null && !units.isEmpty()) {
for (DeploymentUnit unit : units) {
try {
deploymentService.undeploy(unit);
} catch (Exception e) {
// do nothing in case of some failed tests to avoid next test to fail as well
}
}
units.clear();
}
close();
}
use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.
the class RuntimeDataServiceImplTaskLookupTest method cleanup.
@After
public void cleanup() {
System.clearProperty("org.jbpm.ht.callback");
System.clearProperty("org.jbpm.ht.custom.callback");
if (processInstanceId != null) {
try {
// let's abort process instance to leave the system in clear state
processService.abortProcessInstance(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(processInstanceId);
assertNull(pi);
} catch (ProcessInstanceNotFoundException e) {
// ignore it as it was already completed/aborted
}
}
cleanupSingletonSessionId();
if (units != null && !units.isEmpty()) {
for (DeploymentUnit unit : units) {
try {
deploymentService.undeploy(unit);
} catch (Exception e) {
// do nothing in case of some failed tests to avoid next test to fail as well
}
}
units.clear();
}
close();
}
use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.
the class ProcessServiceImplPerProcessInstanceTest method testExecuteCommandOnAbortedProcess.
@Test
public void testExecuteCommandOnAbortedProcess() {
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), PROCESS_ID_HUMAN_TASK);
assertNotNull(processInstanceId);
processService.abortProcessInstance(processInstanceId);
try {
processService.execute(deploymentUnit.getIdentifier(), new GetProcessInstanceCommand(processInstanceId));
fail("Executing command on already aborted process instance should throw ProcessInstanceNotFoundException.");
} catch (ProcessInstanceNotFoundException e) {
// expected
}
}
use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.
the class ProcessServiceImplTest method testStartAndAbortProcessInExternalTransactions.
protected void testStartAndAbortProcessInExternalTransactions(RuntimeStrategy strategy) throws Exception {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
customDescriptor.getBuilder().runtimeStrategy(strategy);
deploymentUnit.setDeploymentDescriptor(customDescriptor);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
assertNotNull(processService);
boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
assertTrue(isDeployed);
UserTransaction ut = InitialContext.doLookup("java:comp/UserTransaction");
ut.begin();
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
processService.signalEvent(deploymentUnit.getIdentifier(), "test", null);
ut.commit();
// now let's start another transaction
ut.begin();
processService.abortProcessInstance(processInstanceId);
ut.commit();
try {
processService.getProcessInstance(processInstanceId);
} catch (ProcessInstanceNotFoundException e) {
// expected
}
}
use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.
the class ProcessServiceImplTest 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(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(processInstanceId);
assertNull(pi);
try {
processService.getProcessInstanceVariable(processInstanceId, "approval_reviewComment");
fail("Process instance was aborted so variables do not exist");
} catch (ProcessInstanceNotFoundException e) {
// expected
}
try {
processService.getProcessInstanceVariable(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(processInstanceId, params);
fail("Process instance was aborted so cannot be changed");
} catch (ProcessInstanceNotFoundException e) {
// expected
}
try {
processService.setProcessVariable(processInstanceId, "approval_reviewComment", "updated review comment");
fail("Process instance was aborted so cannot be changed");
} catch (ProcessInstanceNotFoundException e) {
// expected
}
}
Aggregations