use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class ExpressionResolverTest method resolveExpressionsMap_should_keepExpressionContent_when_ObjecNodeContainsAnExpressionUnableToBeResolved.
@Test
public void resolveExpressionsMap_should_keepExpressionContent_when_ObjecNodeContainsAnExpressionUnableToBeResolved() throws IOException {
// given
Expression nameExpression = buildExpression("${name}");
given(expressionEvaluator.evaluate(nameExpression, expressionManager, delegateInterceptor)).willThrow(new ActivitiException("Invalid property"));
JsonNode node = mapper.readTree("{\"name\":\"${name}\",\"age\": 30}");
// when
Map<String, Object> result = expressionResolver.resolveExpressionsMap(expressionEvaluator, singletonMap("node", node));
// then
assertThat(result).containsEntry("node", map("name", "${name}", "age", 30));
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class ExpressionResolverTest method resolveExpressionsMap_should_keepExpressionContent_when_notAbleToResolveIt.
@Test
public void resolveExpressionsMap_should_keepExpressionContent_when_notAbleToResolveIt() {
// given
Expression expression = buildExpression("${nonResolvableExpression}");
given(expressionEvaluator.evaluate(expression, expressionManager, delegateInterceptor)).willThrow(new ActivitiException("Invalid property"));
// when
Map<String, Object> result = expressionResolver.resolveExpressionsMap(expressionEvaluator, singletonMap("result", "${nonResolvableExpression}"));
// then
assertThat(result).containsEntry("result", "${nonResolvableExpression}");
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class ExpressionResolverTest method resolveExpressionsMap_should_keepExpressionContent_when_notAbleToResolveExpressionInString.
@Test
public void resolveExpressionsMap_should_keepExpressionContent_when_notAbleToResolveExpressionInString() {
// given
Expression expression = buildExpression("${nonResolvableExpression}");
given(expressionEvaluator.evaluate(expression, expressionManager, delegateInterceptor)).willThrow(new ActivitiException("Invalid property"));
// when
Map<String, Object> result = expressionResolver.resolveExpressionsMap(expressionEvaluator, singletonMap("result", "Welcome to ${nonResolvableExpression}!"));
// then
assertThat(result).containsEntry("result", "Welcome to ${nonResolvableExpression}!");
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class ExecuteActivityForAdhocSubProcessCmd method execute.
public Execution execute(CommandContext commandContext) {
ExecutionEntity execution = commandContext.getExecutionEntityManager().findById(executionId);
if (execution == null) {
throw new ActivitiObjectNotFoundException("No execution found for id '" + executionId + "'", ExecutionEntity.class);
}
if (!(execution.getCurrentFlowElement() instanceof AdhocSubProcess)) {
throw new ActivitiException("The current flow element of the requested execution is not an ad-hoc sub process");
}
FlowNode foundNode = null;
AdhocSubProcess adhocSubProcess = (AdhocSubProcess) execution.getCurrentFlowElement();
// if sequential ordering, only one child execution can be active
if (adhocSubProcess.hasSequentialOrdering()) {
if (execution.getExecutions().size() > 0) {
throw new ActivitiException("Sequential ad-hoc sub process already has an active execution");
}
}
for (FlowElement flowElement : adhocSubProcess.getFlowElements()) {
if (activityId.equals(flowElement.getId()) && flowElement instanceof FlowNode) {
FlowNode flowNode = (FlowNode) flowElement;
if (flowNode.getIncomingFlows().size() == 0) {
foundNode = flowNode;
}
}
}
if (foundNode == null) {
throw new ActivitiException("The requested activity with id " + activityId + " can not be enabled");
}
ExecutionEntity activityExecution = Context.getCommandContext().getExecutionEntityManager().createChildExecution(execution);
activityExecution.setCurrentFlowElement(foundNode);
Context.getAgenda().planContinueProcessOperation(activityExecution);
return activityExecution;
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class CommandContext method getSession.
@SuppressWarnings({ "unchecked" })
public <T> T getSession(Class<T> sessionClass) {
Session session = sessions.get(sessionClass);
if (session == null) {
SessionFactory sessionFactory = sessionFactories.get(sessionClass);
if (sessionFactory == null) {
throw new ActivitiException("no session factory configured for " + sessionClass.getName());
}
session = sessionFactory.openSession(this);
sessions.put(sessionClass, session);
}
return (T) session;
}
Aggregations