use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class TransientVariableTest method testStartMessageCorrelationWithTransientVariable.
@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());
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class TransientVariableTest method createTransientVariablesUsingVariableMap.
@Test
public void createTransientVariablesUsingVariableMap() throws URISyntaxException {
// given
BpmnModelInstance instance = Bpmn.createExecutableProcess("Process").startEvent().serviceTask().camundaClass(ReadTransientVariablesOfAllTypesDelegate.class.getName()).userTask("user").endEvent().done();
testRule.deploy(instance);
// when
runtimeService.startProcessInstanceByKey("Process", Variables.createVariables().putValue("a", Variables.stringValue("bar", true)).putValue("b", Variables.booleanValue(true, true)).putValue("c", Variables.byteArrayValue("test".getBytes(), true)).putValue("d", Variables.dateValue(new Date(), true)).putValue("e", Variables.doubleValue(20., true)).putValue("f", Variables.integerValue(10, true)).putValue("g", Variables.longValue((long) 10, true)).putValue("h", Variables.shortValue((short) 10, true)).putValue("i", Variables.objectValue(new Integer(100), true).create()).putValue("j", Variables.untypedValue(null, true)).putValue("k", Variables.untypedValue(Variables.booleanValue(true), true)).putValue("l", Variables.fileValue(new File(this.getClass().getClassLoader().getResource("org/camunda/bpm/engine/test/standalone/variables/simpleFile.txt").toURI()), true)));
// then
List<HistoricVariableInstance> historicVariableInstances = historyService.createHistoricVariableInstanceQuery().list();
List<VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().list();
assertEquals(0, historicVariableInstances.size());
assertEquals(0, variableInstances.size());
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class TransientVariableTest method createTransientVariablesUsingFluentBuilder.
@Test
public void createTransientVariablesUsingFluentBuilder() {
// given
BpmnModelInstance simpleInstanceWithListener = Bpmn.createExecutableProcess("Process").startEvent().camundaExecutionListenerClass(ExecutionListener.EVENTNAME_END, ReadTransientVariableExecutionListener.class).userTask().endEvent().done();
testRule.deploy(simpleInstanceWithListener);
// when
runtimeService.createProcessInstanceByKey("Process").setVariables(Variables.createVariables().putValue(VARIABLE_NAME, Variables.stringValue("dlsd", true))).execute();
// then
List<VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().list();
List<HistoricVariableInstance> historicVariableInstances = historyService.createHistoricVariableInstanceQuery().list();
assertEquals(0, variableInstances.size());
assertEquals(0, historicVariableInstances.size());
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class TransientVariableTest method testParallelProcessWithSetVariableTransientAfterReachingEventBasedGW.
@Test
public void testParallelProcessWithSetVariableTransientAfterReachingEventBasedGW() {
BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_PROCESS_KEY).startEvent().parallelGateway().id("parallel").userTask("taskBeforeGw").eventBasedGateway().id("evenBased").intermediateCatchEvent().conditionalEventDefinition().condition(VAR_CONDITION).camundaVariableEvents(Arrays.asList("create", "update")).conditionalEventDefinitionDone().userTask().name("taskAfter").endEvent().moveToNode("parallel").userTask("taskBefore").serviceTask().camundaClass(SetVariableTransientDelegate.class.getName()).endEvent().done();
testRule.deploy(modelInstance);
// given
ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_PROCESS_KEY);
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
Task taskBeforeEGW = taskService.createTaskQuery().taskDefinitionKey("taskBeforeGw").singleResult();
Task taskBeforeServiceTask = taskService.createTaskQuery().taskDefinitionKey("taskBefore").singleResult();
// when task before event based gateway is completed and after that task before service task
taskService.complete(taskBeforeEGW.getId());
taskService.complete(taskBeforeServiceTask.getId());
// then event based gateway is reached and executions stays there
// variable is set after reaching event based gateway
// after setting variable the conditional event is triggered and evaluated to true
Task task = taskQuery.singleResult();
assertNotNull(task);
assertEquals("taskAfter", task.getName());
// completing this task ends process instance
taskService.complete(task.getId());
assertNull(taskQuery.singleResult());
assertNull(runtimeService.createProcessInstanceQuery().singleResult());
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method restartProcessInstanceWithNotMatchingProcessDefinition.
@Test
public void restartProcessInstanceWithNotMatchingProcessDefinition() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
runtimeService.deleteProcessInstance(processInstance.getId(), null);
BpmnModelInstance instance2 = Bpmn.createExecutableProcess().done();
ProcessDefinition processDefinition2 = testRule.deployAndGetDefinition(instance2);
// when
Batch batch = runtimeService.restartProcessInstances(processDefinition2.getId()).startBeforeActivity("userTask1").processInstanceIds(processInstance.getId()).executeAsync();
try {
helper.completeBatch(batch);
fail("exception expected");
} catch (ProcessEngineException e) {
// then
Assert.assertThat(e.getMessage(), containsString("Its process definition '" + processDefinition.getId() + "' does not match given process definition '" + processDefinition2.getId() + "'"));
}
}
Aggregations