@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 planItem.getEntryCriterias().add(sentry); planItem.getExitCriterias().add(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)); }
@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 planItem.getEntryCriterias().add(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 planItem.getEntryCriterias().add(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)); }
@Test public void testRequiredRuleByDefaultPlanItemControl() { // given PlanItemControl defaultControl = createElement(caseTask, "ItemControl_1", DefaultControl.class); RequiredRule requiredRule = createElement(defaultControl, "RequiredRule_1", RequiredRule.class); ConditionExpression expression = createElement(requiredRule, "Expression_1", ConditionExpression.class); Body body = createElement(expression, Body.class); body.setTextContent("${true}"); Cmmn.validateModel(modelInstance); // when CmmnActivity newActivity = handler.handleElement(planItem, context); // then Object rule = newActivity.getProperty(PROPERTY_REQUIRED_RULE); assertNotNull(rule); assertTrue(rule instanceof CaseControlRule); }
@Test public void testManualActivationRule() { // given ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class); ManualActivationRule manualActivationRule = createElement(itemControl, "ManualActivationRule_1", ManualActivationRule.class); ConditionExpression expression = createElement(manualActivationRule, "Expression_1", ConditionExpression.class); Body body = createElement(expression, Body.class); body.setTextContent("${true}"); Cmmn.validateModel(modelInstance); // when CmmnActivity newActivity = handler.handleElement(planItem, context); // then Object rule = newActivity.getProperty(PROPERTY_MANUAL_ACTIVATION_RULE); assertNotNull(rule); assertTrue(rule instanceof CaseControlRule); }