use of org.camunda.bpm.engine.cdi.ProcessEngineCdiException in project camunda-bpm-platform by camunda.
the class CompleteTaskInterceptor method invoke.
@AroundInvoke
public Object invoke(InvocationContext ctx) throws Exception {
try {
Object result = ctx.proceed();
CompleteTask completeTaskAnnotation = ctx.getMethod().getAnnotation(CompleteTask.class);
boolean endConversation = completeTaskAnnotation.endConversation();
businessProcess.completeTask(endConversation);
return result;
} catch (InvocationTargetException e) {
throw new ProcessEngineCdiException("Error while completing task: " + e.getCause().getMessage(), e.getCause());
}
}
use of org.camunda.bpm.engine.cdi.ProcessEngineCdiException in project camunda-bpm-platform by camunda.
the class BusinessProcessBeanTest method testGetCachedLocalVariableMap.
@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
public void testGetCachedLocalVariableMap() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
// initially the variable cache is empty
assertEquals(Collections.EMPTY_MAP, businessProcess.getCachedLocalVariableMap());
// set a variable - this should fail before the process is started
try {
businessProcess.setVariableLocal("aVariableName", "aVariableValue");
fail("exception expected!");
} catch (ProcessEngineCdiException e) {
assertEquals("Cannot set a local cached variable: neither a Task nor an Execution is associated.", e.getMessage());
}
businessProcess.startProcessByKey("businessProcessBeanTest");
// now the variable cache is empty again:
assertEquals(Collections.EMPTY_MAP, businessProcess.getCachedLocalVariableMap());
// set a variable
businessProcess.setVariableLocal("anotherVariableName", "aVariableValue");
// now the variable is set
assertEquals(Collections.singletonMap("anotherVariableName", "aVariableValue"), businessProcess.getCachedLocalVariableMap());
// getting the variable cache does not empty it:
assertEquals(Collections.singletonMap("anotherVariableName", "aVariableValue"), businessProcess.getCachedLocalVariableMap());
}
use of org.camunda.bpm.engine.cdi.ProcessEngineCdiException in project camunda-bpm-platform by camunda.
the class BusinessProcessBeanTest method testGetVariableLocalCache.
@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
@SuppressWarnings("deprecation")
public void testGetVariableLocalCache() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
// initially the variable cache is empty
assertEquals(Collections.EMPTY_MAP, businessProcess.getVariableLocalCache());
// set a variable - this should fail before the process is started
try {
businessProcess.setVariableLocal("aVariableName", "aVariableValue");
fail("exception expected!");
} catch (ProcessEngineCdiException e) {
assertEquals("Cannot set a local cached variable: neither a Task nor an Execution is associated.", e.getMessage());
}
businessProcess.startProcessByKey("businessProcessBeanTest");
// now the variable cache is empty again:
assertEquals(Collections.EMPTY_MAP, businessProcess.getVariableLocalCache());
// set a variable
businessProcess.setVariableLocal("anotherVariableName", "aVariableValue");
// now the variable is set
assertEquals(Collections.singletonMap("anotherVariableName", "aVariableValue"), businessProcess.getVariableLocalCache());
// getting the variable cache does not empty it:
assertEquals(Collections.singletonMap("anotherVariableName", "aVariableValue"), businessProcess.getVariableLocalCache());
}
use of org.camunda.bpm.engine.cdi.ProcessEngineCdiException in project camunda-bpm-platform by camunda.
the class DefaultContextAssociationManager method setExecution.
@Override
public void setExecution(Execution execution) {
if (execution == null) {
throw new ProcessEngineCdiException("Cannot associate with execution: null");
}
ensureCommandContextNotActive();
ScopedAssociation scopedAssociation = getScopedAssociation();
Execution associatedExecution = scopedAssociation.getExecution();
if (associatedExecution != null && !associatedExecution.getId().equals(execution.getId())) {
throw new ProcessEngineCdiException("Cannot associate " + execution + ", already associated with " + associatedExecution + ". Disassociate first!");
}
if (log.isLoggable(Level.FINE)) {
log.fine("Associating " + execution + " (@" + scopedAssociation.getClass().getAnnotations()[0].annotationType().getSimpleName() + ")");
}
scopedAssociation.setExecution(execution);
}
Aggregations