use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testExternalTaskExecutionTreeExpansion.
@Deployment
public void testExternalTaskExecutionTreeExpansion() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("boundaryExternalTaskProcess");
List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
LockedExternalTask externalTask = tasks.get(0);
// when a non-interrupting boundary event is triggered meanwhile
// such that the execution tree is expanded
runtimeService.correlateMessage("Message");
// then the external task can still be completed
externalTaskService.complete(externalTask.getId(), WORKER_ID);
ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstance.getId());
assertThat(activityInstance).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("afterBoundaryTask").done());
Task afterBoundaryTask = taskService.createTaskQuery().singleResult();
taskService.complete(afterBoundaryTask.getId());
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testCompleteWithVariables.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskProcess.bpmn20.xml")
public void testCompleteWithVariables() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
// when
List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
externalTaskService.complete(externalTasks.get(0).getId(), WORKER_ID, Variables.createVariables().putValue("var", 42));
// then
ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstance.getId());
assertThat(activityInstance).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("afterExternalTask").done());
assertEquals(42, runtimeService.getVariable(processInstance.getId(), "var"));
}
use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class ExternalTaskSupportTest method testExternalTaskSupport.
@Test
public void testExternalTaskSupport() {
// given
ProcessDefinition processDefinition = rule.getRepositoryService().createProcessDefinitionQuery().singleResult();
// when
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(processDefinition.getId());
// then
List<LockedExternalTask> externalTasks = rule.getExternalTaskService().fetchAndLock(1, "aWorker").topic("externalTaskTopic", 5000L).execute();
Assert.assertEquals(1, externalTasks.size());
Assert.assertEquals(processInstance.getId(), externalTasks.get(0).getProcessInstanceId());
// and it is possible to complete the external task successfully and end the process instance
rule.getExternalTaskService().complete(externalTasks.get(0).getId(), "aWorker");
Assert.assertEquals(0L, rule.getRuntimeService().createProcessInstanceQuery().count());
}
use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class FormPropertyDefaultValueTest method testDefaultValue.
@Deployment
public void testDefaultValue() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("FormPropertyDefaultValueTest.testDefaultValue");
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
TaskFormData formData = formService.getTaskFormData(task.getId());
List<FormProperty> formProperties = formData.getFormProperties();
assertEquals(4, formProperties.size());
for (FormProperty prop : formProperties) {
if ("booleanProperty".equals(prop.getId())) {
assertEquals("true", prop.getValue());
} else if ("stringProperty".equals(prop.getId())) {
assertEquals("someString", prop.getValue());
} else if ("longProperty".equals(prop.getId())) {
assertEquals("42", prop.getValue());
} else if ("longExpressionProperty".equals(prop.getId())) {
assertEquals("23", prop.getValue());
} else {
assertTrue("Invalid form property: " + prop.getId(), false);
}
}
Map<String, String> formDataUpdate = new HashMap<String, String>();
formDataUpdate.put("longExpressionProperty", "1");
formDataUpdate.put("booleanProperty", "false");
formService.submitTaskFormData(task.getId(), formDataUpdate);
assertEquals(false, runtimeService.getVariable(processInstance.getId(), "booleanProperty"));
assertEquals("someString", runtimeService.getVariable(processInstance.getId(), "stringProperty"));
assertEquals(42L, runtimeService.getVariable(processInstance.getId(), "longProperty"));
assertEquals(1L, runtimeService.getVariable(processInstance.getId(), "longExpressionProperty"));
}
use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class FormServiceTest method testSubmitStartFormDataTypedVariables.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/form/FormsProcess.bpmn20.xml" })
@Test
public void testSubmitStartFormDataTypedVariables() {
String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
String stringValue = "some string";
String serializedValue = "some value";
ProcessInstance processInstance = formService.submitStartForm(procDefId, createVariables().putValueTyped("boolean", booleanValue(null)).putValueTyped("string", stringValue(stringValue)).putValueTyped("serializedObject", serializedObjectValue(serializedValue).objectTypeName(String.class.getName()).serializationDataFormat(Variables.SerializationDataFormats.JAVA).create()).putValueTyped("object", objectValue(serializedValue).create()));
VariableMap variables = runtimeService.getVariablesTyped(processInstance.getId(), false);
assertEquals(booleanValue(null), variables.getValueTyped("boolean"));
assertEquals(stringValue(stringValue), variables.getValueTyped("string"));
assertNotNull(variables.<ObjectValue>getValueTyped("serializedObject").getValueSerialized());
assertNotNull(variables.<ObjectValue>getValueTyped("object").getValueSerialized());
}
Aggregations