use of org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration in project camunda-bpm-platform by camunda.
the class DecisionTaskPlanItemHandlerTest method testEntryCriteria.
@Test
public void testEntryCriteria() {
// given
// create sentry containing ifPart
Sentry sentry = createElement(casePlanModel, "Sentry_1", Sentry.class);
IfPart ifPart = createElement(sentry, "abc", IfPart.class);
ConditionExpression conditionExpression = createElement(ifPart, "def", ConditionExpression.class);
Body body = createElement(conditionExpression, null, Body.class);
body.setTextContent("${test}");
// set entryCriteria
EntryCriterion criterion = createElement(planItem, EntryCriterion.class);
criterion.setSentry(sentry);
// transform casePlanModel as parent
CmmnActivity parent = new CasePlanModelHandler().handleElement(casePlanModel, context);
context.setParent(parent);
// transform Sentry
CmmnSentryDeclaration sentryDeclaration = new SentryHandler().handleElement(sentry, context);
// when
CmmnActivity newActivity = handler.handleElement(planItem, context);
// then
assertTrue(newActivity.getExitCriteria().isEmpty());
assertFalse(newActivity.getEntryCriteria().isEmpty());
assertEquals(1, newActivity.getEntryCriteria().size());
assertEquals(sentryDeclaration, newActivity.getEntryCriteria().get(0));
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration in project camunda-bpm-platform by camunda.
the class DecisionTaskPlanItemHandlerTest method testEntryCriteriaAndExitCriteria.
@Test
public void testEntryCriteriaAndExitCriteria() {
// given
// create sentry containing ifPart
Sentry sentry = createElement(casePlanModel, "Sentry_1", Sentry.class);
IfPart ifPart = createElement(sentry, "abc", IfPart.class);
ConditionExpression conditionExpression = createElement(ifPart, "def", ConditionExpression.class);
Body body = createElement(conditionExpression, null, Body.class);
body.setTextContent("${test}");
// set entry-/exitCriteria
EntryCriterion criterion1 = createElement(planItem, EntryCriterion.class);
criterion1.setSentry(sentry);
ExitCriterion criterion2 = createElement(planItem, ExitCriterion.class);
criterion2.setSentry(sentry);
// transform casePlanModel as parent
CmmnActivity parent = new CasePlanModelHandler().handleElement(casePlanModel, context);
context.setParent(parent);
// transform Sentry
CmmnSentryDeclaration sentryDeclaration = new SentryHandler().handleElement(sentry, context);
// when
CmmnActivity newActivity = handler.handleElement(planItem, context);
// then
assertFalse(newActivity.getExitCriteria().isEmpty());
assertEquals(1, newActivity.getExitCriteria().size());
assertEquals(sentryDeclaration, newActivity.getExitCriteria().get(0));
assertFalse(newActivity.getEntryCriteria().isEmpty());
assertEquals(1, newActivity.getEntryCriteria().size());
assertEquals(sentryDeclaration, newActivity.getEntryCriteria().get(0));
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration in project camunda-bpm-platform by camunda.
the class DecisionTaskPlanItemHandlerTest method testMultipleExitCriteria.
@Test
public void testMultipleExitCriteria() {
// given
// create first sentry containing ifPart
Sentry sentry1 = createElement(casePlanModel, "Sentry_1", Sentry.class);
IfPart ifPart1 = createElement(sentry1, "abc", IfPart.class);
ConditionExpression conditionExpression1 = createElement(ifPart1, "def", ConditionExpression.class);
Body body1 = createElement(conditionExpression1, null, Body.class);
body1.setTextContent("${test}");
// set first exitCriteria
ExitCriterion criterion1 = createElement(planItem, ExitCriterion.class);
criterion1.setSentry(sentry1);
// create first sentry containing ifPart
Sentry sentry2 = createElement(casePlanModel, "Sentry_2", Sentry.class);
IfPart ifPart2 = createElement(sentry2, "ghi", IfPart.class);
ConditionExpression conditionExpression2 = createElement(ifPart2, "jkl", ConditionExpression.class);
Body body2 = createElement(conditionExpression2, null, Body.class);
body2.setTextContent("${test}");
// set second exitCriteria
ExitCriterion criterion2 = createElement(planItem, ExitCriterion.class);
criterion2.setSentry(sentry2);
// transform casePlanModel as parent
CmmnActivity parent = new CasePlanModelHandler().handleElement(casePlanModel, context);
context.setParent(parent);
// transform Sentry
CmmnSentryDeclaration firstSentryDeclaration = new SentryHandler().handleElement(sentry1, context);
CmmnSentryDeclaration secondSentryDeclaration = new SentryHandler().handleElement(sentry2, context);
// when
CmmnActivity newActivity = handler.handleElement(planItem, context);
// then
assertTrue(newActivity.getEntryCriteria().isEmpty());
assertFalse(newActivity.getExitCriteria().isEmpty());
assertEquals(2, newActivity.getExitCriteria().size());
assertTrue(newActivity.getExitCriteria().contains(firstSentryDeclaration));
assertTrue(newActivity.getExitCriteria().contains(secondSentryDeclaration));
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration in project camunda-bpm-platform by camunda.
the class SentryHandlerTest method sentryTransformWithMultipleVariableEvent.
@Test
public void sentryTransformWithMultipleVariableEvent() {
// given
ExtensionElements extensionElements = createElement(sentry, "extensionElements", ExtensionElements.class);
CamundaVariableOnPart variableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
CamundaVariableTransitionEvent transitionEvent = createElement(variableOnPart, null, CamundaVariableTransitionEvent.class);
transitionEvent.setTextContent("create");
CamundaVariableTransitionEvent additionalTransitionEvent = createElement(variableOnPart, null, CamundaVariableTransitionEvent.class);
additionalTransitionEvent.setTextContent("delete");
variableOnPart.setVariableName("aVariable");
CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);
// then
assertNotNull(sentryDeclaration);
List<CmmnVariableOnPartDeclaration> variableOnParts = sentryDeclaration.getVariableOnParts();
assertNotNull(variableOnParts);
assertFalse(variableOnParts.isEmpty());
assertEquals(1, variableOnParts.size());
CmmnVariableOnPartDeclaration transformedVariableOnPart = variableOnParts.get(0);
assertEquals("aVariable", transformedVariableOnPart.getVariableName());
// when there are multiple variable events then, only first variable event is considered.
assertEquals(VariableTransition.create.name(), transformedVariableOnPart.getVariableEvent());
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration in project camunda-bpm-platform by camunda.
the class SentryHandlerTest method testSentryWithIfPartWithMultipleCondition.
@Test
public void testSentryWithIfPartWithMultipleCondition() {
// given
IfPart ifPart = createElement(sentry, "abc", IfPart.class);
ConditionExpression firstConditionExpression = createElement(ifPart, "con_1", ConditionExpression.class);
Body firstBody = createElement(firstConditionExpression, null, Body.class);
String firstExpression = "${firstExpression}";
firstBody.setTextContent(firstExpression);
ConditionExpression secondConditionExpression = createElement(ifPart, "con_2", ConditionExpression.class);
Body secondBody = createElement(secondConditionExpression, null, Body.class);
String secondExpression = "${secondExpression}";
secondBody.setTextContent(secondExpression);
// when
CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);
// then
assertNotNull(sentryDeclaration);
CmmnIfPartDeclaration ifPartDeclaration = sentryDeclaration.getIfPart();
assertNotNull(ifPartDeclaration);
Expression condition = ifPartDeclaration.getCondition();
assertNotNull(condition);
assertEquals(firstExpression, condition.getExpressionText());
// the second condition will be ignored!
assertTrue(sentryDeclaration.getOnParts().isEmpty());
}
Aggregations