use of org.activiti.cdi.BusinessProcess in project Activiti by Activiti.
the class BusinessProcessBeanTest method testResolveTaskBean.
@Test
@Deployment(resources = "org/activiti/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.activiti.cdi.BusinessProcess in project Activiti by Activiti.
the class BusinessProcessBeanTest method testProcessWithoutWaitState.
@Test
@Deployment
public void testProcessWithoutWaitState() {
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.activiti.cdi.BusinessProcess in project Activiti by Activiti.
the class BusinessProcessContext method get.
@Override
public <T> T get(Contextual<T> contextual, CreationalContext<T> arg1) {
Bean<T> bean = (Bean<T>) contextual;
String variableName = bean.getName();
BusinessProcess businessProcess = getBusinessProcess();
Object variable = businessProcess.getVariable(variableName);
if (variable != null) {
if (logger.isDebugEnabled()) {
if (businessProcess.isAssociated()) {
logger.debug("Getting instance of bean '{}' from Execution[{}]", variableName, businessProcess.getExecutionId());
} else {
logger.debug("Getting instance of bean '{}' from transient bean store", variableName);
}
}
return (T) variable;
} else {
if (logger.isDebugEnabled()) {
if (businessProcess.isAssociated()) {
logger.debug("Creating instance of bean '{}' in business process context representing Execution[{}]", variableName, businessProcess.getExecutionId());
} else {
logger.debug("Creating instance of bean '{}' in transient bean store", variableName);
}
}
T beanInstance = bean.create(arg1);
businessProcess.setVariable(variableName, beanInstance);
return beanInstance;
}
}
use of org.activiti.cdi.BusinessProcess in project Activiti by Activiti.
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();
}
use of org.activiti.cdi.BusinessProcess in project Activiti by Activiti.
the class BusinessProcessBeanTest method test.
/* General test asserting that the business process bean is functional */
@Test
@Deployment
public void test() throws Exception {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
// start the process
businessProcess.startProcessByKey("businessProcessBeanTest").getId();
// ensure that the process is started:
assertNotNull(processEngine.getRuntimeService().createProcessInstanceQuery().singleResult());
// ensure that there is a single task waiting
Task task = processEngine.getTaskService().createTaskQuery().singleResult();
assertNotNull(task);
String value = "value";
businessProcess.setVariable("key", value);
assertEquals(value, businessProcess.getVariable("key"));
// complete the task
assertEquals(task.getId(), businessProcess.startTask(task.getId()).getId());
businessProcess.completeTask();
// assert the task is completed
assertNull(processEngine.getTaskService().createTaskQuery().singleResult());
// assert that the process is ended:
assertNull(processEngine.getRuntimeService().createProcessInstanceQuery().singleResult());
}
Aggregations