protected BpmnModelInstance createProcess(String scriptFormat, String scriptText) { return Bpmn.createExecutableProcess("testProcess") .startEvent() .scriptTask() .scriptFormat(scriptFormat) .scriptText(scriptText) .userTask() .endEvent() .done(); }
protected BpmnModelInstance createProcessWithScriptTask(String key) { return Bpmn.createExecutableProcess(key) .startEvent() .scriptTask() .scriptFormat("javascript") .scriptText("return true") .userTask() .endEvent() .done(); }
private BpmnModelInstance prepareFailingScriptTask() { BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .scriptTask() .scriptFormat("groovy") .scriptText("x = 5 / 0") .camundaAsyncBefore() .userTask() .endEvent() .done(); return bpmnModelInstance; }
public void testShouldNotDeployProcessWithMissingScriptElementAndResource() { try { deployProcess(Bpmn.createExecutableProcess("testProcess") .startEvent() .scriptTask() .scriptFormat(RUBY) .userTask() .endEvent() .done()); fail("this process should not be deployable"); } catch (ProcessEngineException e) { // happy path } }
protected static StringAsset createScriptTaskProcess(String scriptFormat, String scriptText) { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .scriptTask() .scriptFormat(scriptFormat) .scriptText(scriptText) .userTask() .endEvent() .done(); return new StringAsset(Bpmn.convertToString(modelInstance)); }
protected static StringAsset createScriptTaskProcess(String scriptFormat, String scriptText, String pdk) { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(pdk) .startEvent() .scriptTask() .scriptFormat(scriptFormat) .scriptText(scriptText) .userTask() .endEvent() .done(); return new StringAsset(Bpmn.convertToString(modelInstance)); }
protected static StringAsset createScriptTaskProcess(String scriptFormat, String scriptText, String pdk) { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(pdk) .startEvent() .scriptTask() .scriptFormat(scriptFormat) .scriptText(scriptText) .userTask() .endEvent() .done(); return new StringAsset(Bpmn.convertToString(modelInstance)); }
protected static StringAsset createScriptTaskProcess(String scriptFormat, String scriptText) { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .scriptTask() .scriptFormat(scriptFormat) .scriptText(scriptText) .camundaResultVariable(RESULT_VARIABLE) .userTask() .endEvent() .done(); return new StringAsset(Bpmn.convertToString(modelInstance)); }
protected static StringAsset createScriptTaskProcess(String scriptFormat, String scriptText) { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .scriptTask() .scriptFormat(scriptFormat) .scriptText(scriptText) .camundaResultVariable("scriptValue") .userTask() .endEvent() .done(); return new StringAsset(Bpmn.convertToString(modelInstance)); }
.scriptTask() .camundaAsyncBefore() .scriptFormat("groovy")
/** * See https://app.camunda.com/jira/browse/CAM-9505 */ @Test public void shouldResolveIncidentWithPreservedCreateTime() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(Bpmn.createExecutableProcess(CALLED_PROCESS_KEY) .startEvent() .scriptTask() .camundaAsyncBefore() .scriptFormat("groovy") .scriptText("if(execution.getIncidents().size() == 0) throw new RuntimeException()") .userTask() .endEvent().done()); ClockUtil.setCurrentTime(START_DATE); runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String jobId = managementService.createJobQuery().singleResult().getId(); managementService.setJobRetries(jobId, 0); try { managementService.executeJob(jobId); } catch (Exception ignored) { } String taskId = historyService.createHistoricTaskInstanceQuery().singleResult().getId(); // when taskService.complete(taskId); List<HistoricIncident> historicIncidents = historyService.createHistoricIncidentQuery().list(); // then assertThat(historicIncidents.get(0).getCreateTime(), is(START_DATE)); assertThat(historicIncidents.get(1).getCreateTime(), is(START_DATE)); }
public void testShouldUseJuelAsDefaultScriptLanguage() { deployProcess(Bpmn.createExecutableProcess("testProcess") .startEvent() .scriptTask() .scriptText("${true}") .userTask() .endEvent() .done()); runtimeService.startProcessInstanceByKey("testProcess"); Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); }
protected void assertStartProcessInstanceFails() { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CALLED_PROCESS_DEF_ID) .startEvent() .scriptTask("scriptTask") .scriptFormat("groovy") .scriptText("throw new RuntimeException(\"BOOOM!\")") .endEvent() .done(); deployModel(modelInstance); // if try { runtimeService.startProcessInstanceByKey(PROCESS_DEF_KEY); fail("exception expected"); } catch(RuntimeException e) { assertTextPresent("BOOOM", e.getMessage()); } // then // starting the process fails and everything is rolled back: assertEquals(0, runtimeService.createExecutionQuery().count()); }
@Test public void testStartMessageCorrelationWithTransientVariable() { // given BpmnModelInstance instance = Bpmn.createExecutableProcess("process") .startEvent() .message("message") .scriptTask("scriptTask") .scriptFormat("javascript") .camundaResultVariable("abc") .scriptText("execution.setVariable('abc', foo);") .endEvent() .done(); testRule.deploy(instance); // when runtimeService.createMessageCorrelation("message") .setVariable("foo", Variables.stringValue("bar", true)) .correlate(); // then List<VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().list(); assertEquals(0, variableInstances.size()); List<HistoricVariableInstance> historicInstances = historyService.createHistoricVariableInstanceQuery().list(); assertEquals(1, historicInstances.size()); assertEquals("abc", historicInstances.get(0).getName()); assertEquals("bar", historicInstances.get(0).getValue()); }
@Test public void testSateOfScriptTaskProcessWithTransactionCommitAndException() { BpmnModelInstance instance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() //add wait state .camundaAsyncAfter() .scriptTask() .scriptText("throw new RuntimeException()") .scriptFormat("groovy") .endEvent() .done(); ProcessDefinition processDefinition = processEngineTestRule.deployAndGetDefinition(instance); try { ProcessInstance pi = processEngineRule.getRuntimeService() .startProcessInstanceById(processDefinition.getId()); processEngineRule.getManagementService().executeJob( processEngineRule.getManagementService().createJobQuery().executable().singleResult().getId()); fail("exception expected"); } catch (Exception e) { //expected } assertThat(processEngineRule.getRuntimeService().createProcessInstanceQuery().active().list().size(), is(1)); HistoricProcessInstance entity = getHistoricProcessInstanceWithAssertion(processDefinition); assertThat(entity.getState(), is(HistoricProcessInstance.STATE_ACTIVE)); assertEquals(1, processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().active().count()); }
.scriptTask() .camundaAsyncBefore() .scriptFormat("groovy")
.subProcess("subprocess").embeddedSubProcess() .startEvent() .scriptTask("scriptTaskInSubprocess") .scriptFormat("groovy") .scriptText("throw new org.camunda.bpm.engine.delegate.BpmnError(\"anErrorCode\");")
protected BpmnModelInstance createProcess(String scriptFormat, String scriptText) { return Bpmn.createExecutableProcess("testProcess") .startEvent() .scriptTask() .scriptFormat(scriptFormat) .scriptText(scriptText) .userTask() .endEvent() .done(); }
protected BpmnModelInstance createProcessWithScriptTask(String key) { return Bpmn.createExecutableProcess(key) .startEvent() .scriptTask() .scriptFormat("javascript") .scriptText("return true") .userTask() .endEvent() .done(); }
private BpmnModelInstance prepareFailingScriptTask() { BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .scriptTask() .scriptFormat("groovy") .scriptText("x = 5 / 0") .camundaAsyncBefore() .userTask() .endEvent() .done(); return bpmnModelInstance; }