Search in sources :

Example 11 with BusinessProcess

use of org.camunda.bpm.engine.cdi.BusinessProcess in project camunda-bpm-platform by camunda.

the class ProcessVariableTypedTest method testProcessVariableTypeAnnotation.

@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/annotation/CompleteTaskTest.bpmn20.xml")
public void testProcessVariableTypeAnnotation() {
    BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
    VariableMap variables = Variables.createVariables().putValue("injectedValue", "camunda");
    businessProcess.startProcessByKey("keyOfTheProcess", variables);
    TypedValue value = getBeanInstance(DeclarativeProcessController.class).getInjectedValue();
    assertNotNull(value);
    assertTrue(value instanceof StringValue);
    assertEquals(ValueType.STRING, value.getType());
    assertEquals("camunda", value.getValue());
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) DeclarativeProcessController(org.camunda.bpm.engine.cdi.test.impl.beans.DeclarativeProcessController) StringValue(org.camunda.bpm.engine.variable.value.StringValue) BusinessProcess(org.camunda.bpm.engine.cdi.BusinessProcess) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 12 with BusinessProcess

use of org.camunda.bpm.engine.cdi.BusinessProcess in project camunda-bpm-platform by camunda.

the class ProcessVariableLocalTypedTest method testProcessVariableLocalTypeAnnotation.

@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/annotation/CompleteTaskTest.bpmn20.xml")
public void testProcessVariableLocalTypeAnnotation() {
    BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
    VariableMap variables = Variables.createVariables().putValue("injectedLocalValue", "camunda");
    businessProcess.startProcessByKey("keyOfTheProcess", variables);
    TypedValue value = getBeanInstance(DeclarativeProcessController.class).getInjectedLocalValue();
    assertNotNull(value);
    assertTrue(value instanceof StringValue);
    assertEquals(ValueType.STRING, value.getType());
    assertEquals("camunda", value.getValue());
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) DeclarativeProcessController(org.camunda.bpm.engine.cdi.test.impl.beans.DeclarativeProcessController) StringValue(org.camunda.bpm.engine.variable.value.StringValue) BusinessProcess(org.camunda.bpm.engine.cdi.BusinessProcess) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 13 with BusinessProcess

use of org.camunda.bpm.engine.cdi.BusinessProcess in project camunda-bpm-platform by camunda.

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.isLoggable(Level.FINE)) {
            if (businessProcess.isAssociated()) {
                logger.fine("Getting instance of bean '" + variableName + "' from Execution[" + businessProcess.getExecutionId() + "].");
            } else {
                logger.fine("Getting instance of bean '" + variableName + "' from transient bean store");
            }
        }
        return (T) variable;
    } else {
        return null;
    }
}
Also used : Bean(javax.enterprise.inject.spi.Bean) BusinessProcess(org.camunda.bpm.engine.cdi.BusinessProcess)

Example 14 with BusinessProcess

use of org.camunda.bpm.engine.cdi.BusinessProcess in project camunda-bpm-platform by camunda.

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.isLoggable(Level.FINE)) {
            if (businessProcess.isAssociated()) {
                logger.fine("Getting instance of bean '" + variableName + "' from Execution[" + businessProcess.getExecutionId() + "].");
            } else {
                logger.fine("Getting instance of bean '" + variableName + "' from transient bean store");
            }
        }
        return (T) variable;
    } else {
        if (logger.isLoggable(Level.FINE)) {
            if (businessProcess.isAssociated()) {
                logger.fine("Creating instance of bean '" + variableName + "' in business process context representing Execution[" + businessProcess.getExecutionId() + "].");
            } else {
                logger.fine("Creating instance of bean '" + variableName + "' in transient bean store");
            }
        }
        T beanInstance = bean.create(arg1);
        businessProcess.setVariable(variableName, beanInstance);
        return beanInstance;
    }
}
Also used : Bean(javax.enterprise.inject.spi.Bean) BusinessProcess(org.camunda.bpm.engine.cdi.BusinessProcess)

Example 15 with BusinessProcess

use of org.camunda.bpm.engine.cdi.BusinessProcess in project camunda-bpm-platform by camunda.

the class MultiInstanceTest method testParallelMultiInstanceServiceTasks.

@Test
@Deployment
public void testParallelMultiInstanceServiceTasks() {
    BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
    businessProcess.setVariable("list", Arrays.asList(new String[] { "1", "2" }));
    businessProcess.startProcessByKey("miParallelScriptTask");
}
Also used : BusinessProcess(org.camunda.bpm.engine.cdi.BusinessProcess) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

BusinessProcess (org.camunda.bpm.engine.cdi.BusinessProcess)28 Test (org.junit.Test)26 Deployment (org.camunda.bpm.engine.test.Deployment)25 ProcessEngineCdiException (org.camunda.bpm.engine.cdi.ProcessEngineCdiException)7 Task (org.camunda.bpm.engine.task.Task)6 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)6 DeclarativeProcessController (org.camunda.bpm.engine.cdi.test.impl.beans.DeclarativeProcessController)4 VariableMap (org.camunda.bpm.engine.variable.VariableMap)4 StringValue (org.camunda.bpm.engine.variable.value.StringValue)3 Bean (javax.enterprise.inject.spi.Bean)2 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)2 HashMap (java.util.HashMap)1 TaskService (org.camunda.bpm.engine.TaskService)1 CreditCard (org.camunda.bpm.engine.cdi.test.impl.beans.CreditCard)1 Execution (org.camunda.bpm.engine.runtime.Execution)1 Ignore (org.junit.Ignore)1