use of org.camunda.bpm.engine.cdi.BusinessProcess in project camunda-bpm-platform by camunda.
the class BusinessProcessBeanTest method testGetVariableLocal.
@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
public void testGetVariableLocal() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
ProcessInstance processInstance = businessProcess.startProcessByKey("businessProcessBeanTest");
TaskService taskService = getBeanInstance(TaskService.class);
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(task);
businessProcess.startTask(task.getId());
businessProcess.setVariableLocal("aVariableName", "aVariableValue");
// Flushing and re-getting should retain the value (CAM-1806):
businessProcess.flushVariableCache();
assertTrue(businessProcess.getCachedLocalVariableMap().isEmpty());
assertEquals("aVariableValue", businessProcess.getVariableLocal("aVariableName"));
}
use of org.camunda.bpm.engine.cdi.BusinessProcess in project camunda-bpm-platform by camunda.
the class BusinessProcessBeanTest method testProcessWithoutWatestate.
@Test
@Deployment
public void testProcessWithoutWatestate() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
// start the process
businessProcess.startProcessByKey("businessProcessBeanTest").getId();
// assert that the process is ended:
assertNull(processEngine.getRuntimeService().createProcessInstanceQuery().singleResult());
}
use of org.camunda.bpm.engine.cdi.BusinessProcess in project camunda-bpm-platform by camunda.
the class BusinessProcessBeanTest method testResolveTaskBean.
@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
public void testResolveTaskBean() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
assertNull(getBeanInstance(Task.class));
assertNull(getBeanInstance("taskId"));
businessProcess.startProcessByKey("businessProcessBeanTest");
String taskId = taskService.createTaskQuery().singleResult().getId();
businessProcess.startTask(taskId);
// assert that now we can resolve the Task-bean
assertEquals(taskId, getBeanInstance(Task.class).getId());
assertEquals(taskId, getBeanInstance("taskId"));
taskService.complete(taskService.createTaskQuery().singleResult().getId());
}
use of org.camunda.bpm.engine.cdi.BusinessProcess in project camunda-bpm-platform by camunda.
the class ProcessVariableMapTest method testProcessVariableMap.
@Test
public void testProcessVariableMap() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
VariableMap variables = (VariableMap) getBeanInstance("processVariableMap");
assertNotNull(variables);
// /////////////////////////////////////////////////////////////////
// Put a variable via BusinessProcess and get it via VariableMap //
// /////////////////////////////////////////////////////////////////
String aValue = "aValue";
businessProcess.setVariable(VARNAME_1, Variables.stringValue(aValue));
// Legacy API
assertEquals(aValue, variables.get(VARNAME_1));
// Typed variable API
TypedValue aTypedValue = variables.getValueTyped(VARNAME_1);
assertEquals(ValueType.STRING, aTypedValue.getType());
assertEquals(aValue, aTypedValue.getValue());
assertEquals(aValue, variables.getValue(VARNAME_1, String.class));
// Type API with wrong type
try {
variables.getValue(VARNAME_1, Integer.class);
fail("ClassCastException expected!");
} catch (ClassCastException ex) {
assertEquals("Cannot cast variable named 'aVariable' with value 'aValue' to type 'class java.lang.Integer'.", ex.getMessage());
}
// /////////////////////////////////////////////////////////////////
// Put a variable via VariableMap and get it via BusinessProcess //
// /////////////////////////////////////////////////////////////////
String anotherValue = "anotherValue";
variables.put(VARNAME_2, Variables.stringValue(anotherValue));
// Legacy API
assertEquals(anotherValue, businessProcess.getVariable(VARNAME_2));
// Typed variable API
TypedValue anotherTypedValue = businessProcess.getVariableTyped(VARNAME_2);
assertEquals(ValueType.STRING, anotherTypedValue.getType());
assertEquals(anotherValue, anotherTypedValue.getValue());
}
use of org.camunda.bpm.engine.cdi.BusinessProcess in project camunda-bpm-platform by camunda.
the class ProcessVariablesTest method testResolveString.
@Ignore
@Test
@Deployment(resources = "org/activiti/cdi/BusinessProcessBeanTest.test.bpmn20.xml")
public void testResolveString() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
Map<String, Object> processVariables = new HashMap<String, Object>();
businessProcess.setVariable("testKeyString", "testValue");
businessProcess.startProcessByKey("businessProcessBeanTest", processVariables);
businessProcess.startTask(taskService.createTaskQuery().singleResult().getId());
InjectProcessVariable injectProcessVariables = getBeanInstance(InjectProcessVariable.class);
assertEquals("testValue", injectProcessVariables.testKeyString);
businessProcess.completeTask();
}
Aggregations