public void execute(ActivityExecution execution) throws Exception { ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines(); boolean noErrors = true; try { Object result = scriptingEngines.evaluate(script, language, execution, storeScriptVariables); if (resultVariable != null) { execution.setVariable(resultVariable, result); } } catch (ActivitiException e) { LOGGER.warn( "Exception while executing " + execution.getActivity().getId() + " : " + e.getMessage()); noErrors = false; Throwable rootCause = ExceptionUtils.getRootCause(e); if (rootCause instanceof BpmnError) { ErrorPropagation.propagateError((BpmnError) rootCause, execution); } else { throw e; } } if (noErrors) { leave(execution); } }
public void testStartProcessInstanceByIdUnexistingId() { try { runtimeService.startProcessInstanceById("unexistingId"); fail("ActivitiException expected"); } catch (ActivitiException ae) { assertTextPresent("no deployed process definition found with id", ae.getMessage()); } }
public void testSetVariableNullExecutionId() { try { runtimeService.setVariable(null, "variableName", "variableValue"); fail("ActivitiException expected"); } catch (ActivitiException ae) { assertTextPresent("executionId is null", ae.getMessage()); } }
public void testStartProcessInstanceByKeyUnexistingKey() { try { runtimeService.startProcessInstanceByKey("unexistingkey"); fail("ActivitiException expected"); } catch (ActivitiException ae) { assertTextPresent("no processes deployed with key", ae.getMessage()); } }
public void testSetVariableUnexistingExecutionId() { try { runtimeService.setVariable("unexistingExecutionId", "variableName", "value"); fail("ActivitiException expected"); } catch (ActivitiException ae) { assertTextPresent("execution unexistingExecutionId doesn't exist", ae.getMessage()); } }
public void testGetVariablesNullExecutionId() { try { runtimeService.getVariables(null); fail("ActivitiException expected"); } catch (ActivitiException ae) { assertTextPresent("executionId is null", ae.getMessage()); } }
public void testSignalUnexistingExecututionId() { try { runtimeService.signal("unexistingExecutionId"); fail("ActivitiException expected"); } catch (ActivitiException ae) { assertTextPresent("execution unexistingExecutionId doesn't exist", ae.getMessage()); } }
public void testDeleteProcessInstanceNullId() { try { runtimeService.deleteProcessInstance(null, "test null id delete"); fail("ActivitiException expected"); } catch (ActivitiException ae) { assertTextPresent("processInstanceId is null", ae.getMessage()); } }
public void testDeleteProcessInstanceUnexistingId() { try { runtimeService.deleteProcessInstance("enexistingInstanceId", null); fail("ActivitiException expected"); } catch (ActivitiException ae) { assertTextPresent("No process instance found for id", ae.getMessage()); } }
@SuppressWarnings("unchecked") public void testSetVariablesNullExecutionId() { try { runtimeService.setVariables(null, Collections.EMPTY_MAP); fail("ActivitiException expected"); } catch (ActivitiException ae) { assertTextPresent("executionId is null", ae.getMessage()); } }
@Deployment(resources = {"org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void testSetVariableNullVariableName() { try { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); runtimeService.setVariable(processInstance.getId(), null, "variableValue"); fail("ActivitiException expected"); } catch (ActivitiException ae) { assertTextPresent("variableName is null", ae.getMessage()); } }
public void testThrowErrorWithEmptyErrorCode() { try { repositoryService .createDeployment() .addClasspathResource( "org/activiti/engine/test/bpmn/event/error/BoundaryErrorEventTest.testThrowErrorWithEmptyErrorCode.bpmn20.xml") .deploy(); fail("ActivitiException expected"); } catch (ActivitiException re) { assertTextPresent("errorCode is required for an error event", re.getMessage()); } }
public void testSignalEventReceivedNonExistingExecution() { try { runtimeService.signalEventReceived("alert", "nonexistingExecution"); fail("exeception expected"); } catch (ActivitiException e) { // this is good assertTrue( e.getMessage() .contains( "Execution 'nonexistingExecution' has not subscribed to a signal event with name 'alert'")); } }
@Deployment( resources = { "org/activiti/engine/test/api/runtime/RuntimeServiceTest.catchAlertSignal.bpmn20.xml" }) public void testExecutionWaitingForDifferentSignal() { runtimeService.startProcessInstanceByKey("catchAlertSignal"); Execution execution = runtimeService.createExecutionQuery().signalEventSubscription("alert").singleResult(); try { runtimeService.signalEventReceived("bogusSignal", execution.getId()); fail("exeception expected"); } catch (ActivitiException e) { // this is good assertTrue( e.getMessage().contains("has not subscribed to a signal event with name 'bogusSignal'")); } }
public void testDeploymentWithDelayedProcessDefinitionActivation() { Date startTime = new Date(); processEngineConfiguration.getClock().setCurrentTime(startTime); Date inThreeDays = new Date(startTime.getTime() + (3 * 24 * 60 * 60 * 1000)); // Deploy process, but activate after three days org.activiti.engine.repository.Deployment deployment = repositoryService .createDeployment() .addClasspathResource("org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml") .addClasspathResource("org/activiti/engine/test/api/twoTasksProcess.bpmn20.xml") .activateProcessDefinitionsOn(inThreeDays) .deploy(); assertEquals(1, repositoryService.createDeploymentQuery().count()); assertEquals(2, repositoryService.createProcessDefinitionQuery().count()); assertEquals(2, repositoryService.createProcessDefinitionQuery().suspended().count()); assertEquals(0, repositoryService.createProcessDefinitionQuery().active().count()); // Shouldn't be able to start a process instance try { runtimeService.startProcessInstanceByKey("oneTaskProcess"); fail(); } catch (ActivitiException e) { assertTextPresentIgnoreCase("suspended", e.getMessage()); } // Move time four days forward, the timer will fire and the process definitions will be active Date inFourDays = new Date(startTime.getTime() + (4 * 24 * 60 * 60 * 1000)); processEngineConfiguration.getClock().setCurrentTime(inFourDays); waitForJobExecutorToProcessAllJobs(5000L, 50L); assertEquals(1, repositoryService.createDeploymentQuery().count()); assertEquals(2, repositoryService.createProcessDefinitionQuery().count()); assertEquals(0, repositoryService.createProcessDefinitionQuery().suspended().count()); assertEquals(2, repositoryService.createProcessDefinitionQuery().active().count()); // Should be able to start process instance runtimeService.startProcessInstanceByKey("oneTaskProcess"); assertEquals(1, runtimeService.createProcessInstanceQuery().count()); // Cleanup repositoryService.deleteDeployment(deployment.getId(), true); }