diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConverter.java index 3fb4e517d3b..25045eb3549 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConverter.java @@ -41,7 +41,6 @@ import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; -import org.apache.commons.lang3.StringUtils; import org.flowable.cmmn.converter.exception.XMLException; import org.flowable.cmmn.converter.export.AssociationExport; import org.flowable.cmmn.converter.export.CaseExport; @@ -71,7 +70,6 @@ import org.flowable.cmmn.model.Sentry; import org.flowable.cmmn.model.SentryOnPart; import org.flowable.cmmn.model.Stage; -import org.flowable.cmmn.model.Task; import org.flowable.cmmn.model.TextAnnotation; import org.flowable.cmmn.model.TimerEventListener; import org.flowable.common.engine.api.FlowableException; @@ -528,20 +526,7 @@ protected void procesPlanItem(CmmnModel cmmnModel, PlanItem planItem, PlanItemDe } if (!planItem.getExitCriteria().isEmpty()) { - boolean exitCriteriaAllowed = true; - if (planItemDefinition instanceof Task) { - Task task = (Task) planItemDefinition; - if (!task.isBlocking() && StringUtils.isEmpty(task.getBlockingExpression())) { - exitCriteriaAllowed = false; - } - } - - if (exitCriteriaAllowed) { - resolveExitCriteriaSentry(planItem); - } else { - LOGGER.warn("Ignoring exit criteria on plan item {}", planItem.getId()); - planItem.getExitCriteria().clear(); - } + resolveExitCriteriaSentry(planItem); } if (planItemDefinition instanceof Stage) { diff --git a/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/ExitCriteriaNonBlockingCmmnXmlConverterTest.java b/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/ExitCriteriaNonBlockingCmmnXmlConverterTest.java deleted file mode 100644 index cc4917853f6..00000000000 --- a/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/ExitCriteriaNonBlockingCmmnXmlConverterTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.flowable.test.cmmn.converter; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -import org.flowable.cmmn.model.Case; -import org.flowable.cmmn.model.CmmnModel; -import org.flowable.cmmn.model.Criterion; -import org.flowable.cmmn.model.PlanItem; -import org.flowable.cmmn.model.Sentry; -import org.flowable.cmmn.model.SentryOnPart; -import org.flowable.cmmn.model.Stage; -import org.flowable.test.cmmn.converter.util.CmmnXmlConverterTest; - -/** - * @author Filip Hrisafov - */ -public class ExitCriteriaNonBlockingCmmnXmlConverterTest { - - @CmmnXmlConverterTest("org/flowable/test/cmmn/converter/exit-criteria-non-blocking.cmmn") - public void validateModel(CmmnModel cmmnModel) { - assertThat(cmmnModel).isNotNull(); - assertThat(cmmnModel.getCases()).hasSize(1); - - // Case - Case caze = cmmnModel.getCases().get(0); - assertThat(caze.getId()).isEqualTo("exitCriteriaNonBlocking"); - - // Plan model - Stage planModel = caze.getPlanModel(); - assertThat(planModel).isNotNull(); - assertThat(planModel.getId()).isEqualTo("exitCriteriaNonBlockingPlanModel"); - assertThat(planModel.getName()).isEqualTo("Exit Criteria Non Blocking CasePlanModel"); - - PlanItem planItemTaskA = cmmnModel.findPlanItem("taskA"); - assertThat(planItemTaskA).isNotNull(); - assertThat(planItemTaskA.getDefinitionRef()).isEqualTo("taskDefinition"); - - PlanItem planItemTaskB = cmmnModel.findPlanItem("taskB"); - assertThat(planItemTaskB).isNotNull(); - assertThat(planItemTaskB.getDefinitionRef()).isEqualTo("taskDefinition"); - assertThat(planItemTaskB.getExitCriteria()) - .extracting(Criterion::getId, Criterion::getSentryRef) - .isEmpty(); - - assertThat(planModel.getSentries()) - .extracting(Sentry::getId) - .containsOnly("sentry"); - assertThat(planModel.getSentries().get(0).getOnParts()) - .extracting(SentryOnPart::getId, SentryOnPart::getSourceRef, SentryOnPart::getStandardEvent) - .containsOnly( - tuple("onPart_1", "taskA", "complete") - ); - - assertThat(cmmnModel.getAssociations()).isEmpty(); - } - -} diff --git a/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/HumanTaskWithEntryAndExitCriterionCmmnXmlConverterTest.java b/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/HumanTaskWithEntryAndExitCriterionCmmnXmlConverterTest.java new file mode 100644 index 00000000000..58f1fd80675 --- /dev/null +++ b/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/HumanTaskWithEntryAndExitCriterionCmmnXmlConverterTest.java @@ -0,0 +1,37 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.flowable.test.cmmn.converter; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.flowable.cmmn.model.CmmnModel; +import org.flowable.cmmn.model.HumanTask; +import org.flowable.cmmn.model.PlanItem; +import org.flowable.cmmn.model.PlanItemDefinition; +import org.flowable.test.cmmn.converter.util.CmmnXmlConverterTest; + +public class HumanTaskWithEntryAndExitCriterionCmmnXmlConverterTest { + + @CmmnXmlConverterTest("org/flowable/test/cmmn/converter/humanTaskWithEntryAndExitCriterion.cmmn") + public void validateModel(CmmnModel cmmnModel) { + assertThat(cmmnModel).isNotNull(); + + PlanItemDefinition itemDefinition = cmmnModel.findPlanItemDefinition("task1"); + + assertThat(itemDefinition).isInstanceOf(HumanTask.class); + PlanItem planItem = cmmnModel.findPlanItem("planItem1"); + assertThat(planItem.getEntryCriteria()).hasSize(1); + assertThat(planItem.getExitCriteria()).hasSize(1); + } + +} \ No newline at end of file diff --git a/modules/flowable-cmmn-converter/src/test/resources/org/flowable/test/cmmn/converter/exit-criteria-non-blocking.cmmn b/modules/flowable-cmmn-converter/src/test/resources/org/flowable/test/cmmn/converter/exit-criteria-non-blocking.cmmn deleted file mode 100644 index 952996de956..00000000000 --- a/modules/flowable-cmmn-converter/src/test/resources/org/flowable/test/cmmn/converter/exit-criteria-non-blocking.cmmn +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - complete - - - - - - - - diff --git a/modules/flowable-cmmn-converter/src/test/resources/org/flowable/test/cmmn/converter/humanTaskWithEntryAndExitCriterion.cmmn b/modules/flowable-cmmn-converter/src/test/resources/org/flowable/test/cmmn/converter/humanTaskWithEntryAndExitCriterion.cmmn new file mode 100644 index 00000000000..c5b4e2211a4 --- /dev/null +++ b/modules/flowable-cmmn-converter/src/test/resources/org/flowable/test/cmmn/converter/humanTaskWithEntryAndExitCriterion.cmmn @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/runtime/HumanTaskTest.java b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/runtime/HumanTaskTest.java index 9d93e1370d7..6def8de0a20 100644 --- a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/runtime/HumanTaskTest.java +++ b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/runtime/HumanTaskTest.java @@ -596,4 +596,28 @@ public Void execute(CommandContext commandContext) { cmmnEngineConfiguration.getJobServiceConfiguration().setJobHandlers(existingJobHandlers); } } + + @Test + @CmmnDeployment + public void testTaskNonBlockingWithEntryAndExitCriterion() { + CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() + .caseDefinitionKey("myCase") + .start(); + + assertThat(cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(caseInstance.getId()).planItemDefinitionId("task1").list()).hasSize(1); + assertThat(cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(caseInstance.getId()) + .planItemDefinitionId("task1") + .planItemInstanceStateEnabled().list()).hasSize(1); + + cmmnRuntimeService.startPlanItemInstance(cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(caseInstance.getId()) + .planItemDefinitionId("task1") + .planItemInstanceStateEnabled().singleResult().getId()); + + assertThat(cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(caseInstance.getId()) + .planItemDefinitionId("task1") + .planItemInstanceStateActive().list()).hasSize(0); + + assertThat(cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).list()).hasSize(0); + assertThat(cmmnRuntimeService.createCaseInstanceQuery().count()).isZero(); + } } diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/runtime/HumanTaskTest.testTaskNonBlockingWithEntryAndExitCriterion.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/runtime/HumanTaskTest.testTaskNonBlockingWithEntryAndExitCriterion.cmmn new file mode 100644 index 00000000000..06de96a250c --- /dev/null +++ b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/runtime/HumanTaskTest.testTaskNonBlockingWithEntryAndExitCriterion.cmmn @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + ${false} + + + + + + + \ No newline at end of file