Search in sources :

Example 21 with ExitCriterion

use of org.camunda.bpm.model.cmmn.instance.ExitCriterion in project camunda-bpm-platform by camunda.

the class StagePlanItemHandlerTest 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));
}
Also used : CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) SentryHandler(org.camunda.bpm.engine.impl.cmmn.handler.SentryHandler) IfPart(org.camunda.bpm.model.cmmn.instance.IfPart) CasePlanModelHandler(org.camunda.bpm.engine.impl.cmmn.handler.CasePlanModelHandler) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) Sentry(org.camunda.bpm.model.cmmn.instance.Sentry) EntryCriterion(org.camunda.bpm.model.cmmn.instance.EntryCriterion) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) ExitCriterion(org.camunda.bpm.model.cmmn.instance.ExitCriterion) Body(org.camunda.bpm.model.cmmn.instance.Body) Test(org.junit.Test)

Example 22 with ExitCriterion

use of org.camunda.bpm.model.cmmn.instance.ExitCriterion in project camunda-bpm-platform by camunda.

the class TaskPlanItemHandlerTest 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);
    conditionExpression1.setText("${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);
    conditionExpression2.setText("${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));
}
Also used : CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) SentryHandler(org.camunda.bpm.engine.impl.cmmn.handler.SentryHandler) IfPart(org.camunda.bpm.model.cmmn.instance.IfPart) CasePlanModelHandler(org.camunda.bpm.engine.impl.cmmn.handler.CasePlanModelHandler) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) Sentry(org.camunda.bpm.model.cmmn.instance.Sentry) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) ExitCriterion(org.camunda.bpm.model.cmmn.instance.ExitCriterion) Test(org.junit.Test)

Example 23 with ExitCriterion

use of org.camunda.bpm.model.cmmn.instance.ExitCriterion in project camunda-cmmn-model by camunda.

the class ExitCriterionImpl method registerType.

public static void registerType(ModelBuilder modelBuilder) {
    ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(ExitCriterion.class, CMMN_ELEMENT_EXIT_CRITERION).extendsType(Criterion.class).namespaceUri(CMMN11_NS).instanceProvider(new ModelTypeInstanceProvider<ExitCriterion>() {

        public ExitCriterion newInstance(ModelTypeInstanceContext instanceContext) {
            return new ExitCriterionImpl(instanceContext);
        }
    });
    typeBuilder.build();
}
Also used : ModelElementTypeBuilder(org.camunda.bpm.model.xml.type.ModelElementTypeBuilder) ExitCriterion(org.camunda.bpm.model.cmmn.instance.ExitCriterion) ModelTypeInstanceContext(org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)

Example 24 with ExitCriterion

use of org.camunda.bpm.model.cmmn.instance.ExitCriterion in project camunda-cmmn-model by camunda.

the class PlanItemImpl method getExitCriteria.

public Collection<Sentry> getExitCriteria() {
    if (!isCmmn11()) {
        return Collections.unmodifiableCollection(getExitCriterias());
    } else {
        List<Sentry> sentries = new ArrayList<Sentry>();
        Collection<ExitCriterion> exitCriterions = getExitCriterions();
        for (ExitCriterion exitCriterion : exitCriterions) {
            Sentry sentry = exitCriterion.getSentry();
            if (sentry != null) {
                sentries.add(sentry);
            }
        }
        return Collections.unmodifiableCollection(sentries);
    }
}
Also used : ArrayList(java.util.ArrayList) Sentry(org.camunda.bpm.model.cmmn.instance.Sentry) ExitCriterion(org.camunda.bpm.model.cmmn.instance.ExitCriterion)

Example 25 with ExitCriterion

use of org.camunda.bpm.model.cmmn.instance.ExitCriterion in project camunda-cmmn-model by camunda.

the class Cmmn10Test method shouldGetCasePlanModelExitCriterion.

@Test
public void shouldGetCasePlanModelExitCriterion() {
    CmmnModelInstance modelInstance = getCmmnModelInstance();
    CasePlanModel casePlanModel = modelInstance.getModelElementsByType(CasePlanModel.class).iterator().next();
    Collection<Sentry> exitCriterias = casePlanModel.getExitCriterias();
    assertThat(exitCriterias).hasSize(1);
    Collection<Sentry> exitCriteria = casePlanModel.getExitCriteria();
    assertThat(exitCriteria).hasSize(1);
    Collection<ExitCriterion> exitCriterions = casePlanModel.getExitCriterions();
    assertThat(exitCriterions).isEmpty();
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) Sentry(org.camunda.bpm.model.cmmn.instance.Sentry) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) ExitCriterion(org.camunda.bpm.model.cmmn.instance.ExitCriterion) Test(org.junit.Test)

Aggregations

ExitCriterion (org.camunda.bpm.model.cmmn.instance.ExitCriterion)26 Sentry (org.camunda.bpm.model.cmmn.instance.Sentry)25 Test (org.junit.Test)23 SentryHandler (org.camunda.bpm.engine.impl.cmmn.handler.SentryHandler)21 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)21 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)21 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)21 IfPart (org.camunda.bpm.model.cmmn.instance.IfPart)21 CasePlanModelHandler (org.camunda.bpm.engine.impl.cmmn.handler.CasePlanModelHandler)19 Body (org.camunda.bpm.model.cmmn.instance.Body)14 EntryCriterion (org.camunda.bpm.model.cmmn.instance.EntryCriterion)7 ArrayList (java.util.ArrayList)2 CmmnModelInstance (org.camunda.bpm.model.cmmn.CmmnModelInstance)2 CasePlanModel (org.camunda.bpm.model.cmmn.instance.CasePlanModel)1 PlanItem (org.camunda.bpm.model.cmmn.instance.PlanItem)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1