use of org.activiti.cdi.BusinessProcess in project Activiti by Activiti.
the class BusinessProcessBeanTest method testResolveProcessInstanceBean.
@Test
@Deployment(resources = "org/activiti/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
public void testResolveProcessInstanceBean() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
assertNull(getBeanInstance(ProcessInstance.class));
assertNull(getBeanInstance("processInstanceId"));
assertNull(getBeanInstance(Execution.class));
assertNull(getBeanInstance("executionId"));
String pid = businessProcess.startProcessByKey("businessProcessBeanTest").getId();
// assert that now we can resolve the ProcessInstance-bean
assertEquals(pid, getBeanInstance(ProcessInstance.class).getId());
assertEquals(pid, getBeanInstance("processInstanceId"));
assertEquals(pid, getBeanInstance(Execution.class).getId());
assertEquals(pid, getBeanInstance("executionId"));
taskService.complete(taskService.createTaskQuery().singleResult().getId());
}
use of org.activiti.cdi.BusinessProcess in project Activiti by Activiti.
the class TaskIdTest method testTaskIdInjectable.
@Test
@Deployment
public void testTaskIdInjectable() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
businessProcess.startProcessByKey("keyOfTheProcess");
businessProcess.startTask(taskService.createTaskQuery().singleResult().getId());
// assert that now the 'taskId'-bean can be looked up
assertNotNull(getBeanInstance("taskId"));
businessProcess.completeTask();
}
use of org.activiti.cdi.BusinessProcess in project Activiti by Activiti.
the class BusinessProcessContext method get.
@Override
public <T> T get(Contextual<T> contextual) {
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 {
return null;
}
}
use of org.activiti.cdi.BusinessProcess in project Activiti by Activiti.
the class CompleteTaskTest method testCompleteTask.
@Test
@Deployment(resources = "org/activiti/cdi/test/api/annotation/CompleteTaskTest.bpmn20.xml")
public void testCompleteTask() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
businessProcess.startProcessByKey("keyOfTheProcess");
Task task = taskService.createTaskQuery().singleResult();
// associate current unit of work with the task:
businessProcess.startTask(task.getId());
getBeanInstance(DeclarativeProcessController.class).completeTask();
// assert that now the task is completed
assertNull(taskService.createTaskQuery().singleResult());
}
use of org.activiti.cdi.BusinessProcess in project Activiti by Activiti.
the class StartProcessTest method testStartProcessByName.
@Test
@Deployment(resources = "org/activiti/cdi/test/api/annotation/StartProcessTest.bpmn20.xml")
public void testStartProcessByName() {
assertNull(runtimeService.createProcessInstanceQuery().singleResult());
getBeanInstance(DeclarativeProcessController.class).startProcessByName();
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
assertNotNull(runtimeService.createProcessInstanceQuery().singleResult());
assertEquals("Activiti", businessProcess.getVariable("name"));
businessProcess.startTask(taskService.createTaskQuery().singleResult().getId());
businessProcess.completeTask();
}
Aggregations