use of org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration in project camunda-bpm-platform by camunda.
the class SentryHandlerTest method sentryTransformWithSameVariableOnPartTwice.
@Test
public void sentryTransformWithSameVariableOnPartTwice() {
// given
ExtensionElements extensionElements = createElement(sentry, "extensionElements", ExtensionElements.class);
CamundaVariableOnPart variableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
createElement(variableOnPart, null, CamundaVariableTransitionEvent.class);
variableOnPart.setVariableEvent(VariableTransition.create);
variableOnPart.setVariableName("aVariable");
CamundaVariableOnPart additionalVariableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
createElement(additionalVariableOnPart, null, CamundaVariableTransitionEvent.class);
additionalVariableOnPart.setVariableEvent(VariableTransition.create);
additionalVariableOnPart.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());
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration in project camunda-bpm-platform by camunda.
the class SentryHandlerTest method testSentryWithOnPartReferencesSentry.
@Test
public void testSentryWithOnPartReferencesSentry() {
// given
Sentry exitSentry = createElement(casePlanModel, "anotherSentry", Sentry.class);
IfPart ifPart = createElement(exitSentry, "IfPart_1", IfPart.class);
ConditionExpression conditionExpression = createElement(ifPart, "con_1", ConditionExpression.class);
Body body = createElement(conditionExpression, null, Body.class);
body.setTextContent("${test}");
onPart.setSentry(exitSentry);
CmmnActivity casePlanModelActivity = new CasePlanModelHandler().handleElement(casePlanModel, context);
context.setParent(casePlanModelActivity);
CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);
CmmnSentryDeclaration exitSentryDeclaration = sentryHandler.handleElement(exitSentry, context);
CmmnActivity source = taskItemHandler.handleElement(planItem, context);
// when
sentryHandler.initializeOnParts(sentry, context);
// then
assertNotNull(sentryDeclaration);
List<CmmnOnPartDeclaration> onParts = sentryDeclaration.getOnParts();
assertNotNull(onParts);
assertFalse(onParts.isEmpty());
assertEquals(1, onParts.size());
List<CmmnOnPartDeclaration> onPartsAssociatedWithSource = sentryDeclaration.getOnParts(source.getId());
assertNotNull(onPartsAssociatedWithSource);
assertFalse(onPartsAssociatedWithSource.isEmpty());
assertEquals(1, onParts.size());
CmmnOnPartDeclaration onPartDeclaration = onPartsAssociatedWithSource.get(0);
assertNotNull(onPartDeclaration);
// source
assertEquals(source, onPartDeclaration.getSource());
assertEquals(onPart.getSource().getId(), onPartDeclaration.getSource().getId());
// standardEvent
assertEquals(onPart.getStandardEvent().name(), onPartDeclaration.getStandardEvent());
// sentry
assertNotNull(onPartDeclaration.getSentry());
assertEquals(exitSentryDeclaration, onPartDeclaration.getSentry());
assertNull(sentryDeclaration.getIfPart());
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest 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 HumanTaskPlanItemHandlerTest method testMultipleEntryCriteria.
@Test
public void testMultipleEntryCriteria() {
// 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 entryCriteria
EntryCriterion criterion1 = createElement(planItem, EntryCriterion.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 entryCriteria
EntryCriterion criterion2 = createElement(planItem, EntryCriterion.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.getExitCriteria().isEmpty());
assertFalse(newActivity.getEntryCriteria().isEmpty());
assertEquals(2, newActivity.getEntryCriteria().size());
assertTrue(newActivity.getEntryCriteria().contains(firstSentryDeclaration));
assertTrue(newActivity.getEntryCriteria().contains(secondSentryDeclaration));
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest 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 entryCriterion
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));
}
Aggregations