Skip to content

Commit

Permalink
Make sure that the ID of the sentryIfPart is exported to XML
Browse files Browse the repository at this point in the history
  • Loading branch information
filiphr committed Jun 23, 2023
1 parent 198e5a7 commit 7ec6c33
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.flowable.cmmn.converter.util.CmmnXmlUtil;
import org.flowable.cmmn.model.CmmnModel;
import org.flowable.cmmn.model.Sentry;
import org.flowable.cmmn.model.SentryIfPart;
import org.flowable.cmmn.model.SentryOnPart;

public class SentryExport implements CmmnXmlConstants {
Expand Down Expand Up @@ -65,10 +66,14 @@ public static void writeSentry(CmmnModel model, Sentry sentry, XMLStreamWriter x
}

// If part
if (sentry.getSentryIfPart() != null) {
SentryIfPart sentryIfPart = sentry.getSentryIfPart();
if (sentryIfPart != null) {
xtw.writeStartElement(ELEMENT_IF_PART);
if (StringUtils.isNotEmpty(sentryIfPart.getId())) {
xtw.writeAttribute(ATTRIBUTE_ID, sentryIfPart.getId());
}
xtw.writeStartElement(ELEMENT_CONDITION);
xtw.writeCData(sentry.getSentryIfPart().getCondition());
xtw.writeCData(sentryIfPart.getCondition());
xtw.writeEndElement();
xtw.writeEndElement();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public void validateModel(CmmnModel cmmnModel) {
tuple("sentry1", "sentry name", "sentry doc")
);

assertThat(planModel.getSentries().get(0).getSentryIfPart())
.isNotNull()
.extracting(SentryIfPart::getCondition)
.isEqualTo("${true}");
SentryIfPart sentryIfPart = planModel.getSentries().get(0).getSentryIfPart();
assertThat(sentryIfPart).isNotNull();
assertThat(sentryIfPart.getId()).isEqualTo("sentryIfPart_sentry1");
assertThat(sentryIfPart.getCondition()).isEqualTo("${true}");

PlanItem planItemTask1 = cmmnModel.findPlanItem("planItem1");
assertThat(planItemTask1).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</planItem>
<sentry id="sentry1" name="sentry name">
<documentation><![CDATA[sentry doc]]></documentation>
<ifPart>
<ifPart id="sentryIfPart_sentry1">
<condition><![CDATA[${true}]]></condition>
</ifPart>
</sentry>
Expand Down

0 comments on commit 7ec6c33

Please sign in to comment.