Skip to content

Commit

Permalink
Merge pull request #16109 from camunda/backport-16103-to-stable/8.4
Browse files Browse the repository at this point in the history
[Backport stable/8.4] Provide default values in DMN deployment records
  • Loading branch information
abbasadel authored Jan 26, 2024
2 parents b8be5b7 + a8f7ee3 commit 5dc913b
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public final class DmnDeploymentTest {
"/dmn/decision-table-with-invalid-expression.dmn";
private static final String DMN_WITH_TWO_DECISIONS = "/dmn/drg-force-user.dmn";

private static final String DMN_MISSING_DECISION_NAME =
"/dmn/decision-table-with-missing-decision-name.dmn";

@Rule public final EngineRule engine = EngineRule.singlePartition();

@Rule
Expand Down Expand Up @@ -118,6 +121,25 @@ public void shouldRejectInvalidDmnResource() {
.contains("FEEL unary-tests: failed to parse expression");
}

@Test
public void shouldRejectDmnResourceWithMissingDecisionName() {
// when
final var deploymentEvent =
engine
.deployment()
.withXmlClasspathResource(DMN_MISSING_DECISION_NAME)
.expectRejection()
.deploy();

// then
Assertions.assertThat(deploymentEvent)
.hasIntent(DeploymentIntent.CREATE)
.hasRecordType(RecordType.COMMAND_REJECTION)
.hasRejectionType(RejectionType.INVALID_ARGUMENT);

assertThat(deploymentEvent.getRejectionReason()).contains("because \"value\" is null");
}

@Test
public void shouldWriteDecisionRequirementsRecord() {
// when
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" id="_6f87b3aa-d613-4c41-93ad-832f021c8318" name="definitions" namespace="http://camunda.org/schema/1.0/dmn">
<decision id="_51711_44808585-3491-42a8-87ea-3c4fcda46eff" name="">
<decisionTable id="_07c6fdc3-7bdf-459a-a016-2ae12e474bd2">
<input id="_f00d0717-d08a-4918-ad51-568788e92038" label="Percent Responsible (Loan Roles)">
<inputExpression id="_0b922041-84c3-47bf-b94c-1dd423c394ae" typeRef="number">
<text>proposedLoan.loanRoles.percentResponsible</text>
</inputExpression>
</input>
<output id="_b304292d-98e5-4dde-8fbd-0de1981c97ea" label="" name="out" typeRef="string">
<outputValues id="UnaryTests_1yu7moy">
<text>"Approve","Decline","Review"</text>
</outputValues>
</output>
<rule id="DecisionRule_1j6jzzn">
<inputEntry id="UnaryTests_105fhm8">
<text></text>
</inputEntry>
<outputEntry id="LiteralExpression_1ucr6zl">
<text>"Approve"</text>
</outputEntry>
</rule>
</decisionTable>
</decision>
</definitions>
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

public final class DecisionRecord extends UnifiedRecordValue implements DecisionRecordValue {

private final StringProperty decisionIdProp = new StringProperty("decisionId");
private final StringProperty decisionNameProp = new StringProperty("decisionName");
private final IntegerProperty versionProp = new IntegerProperty("version");
private final LongProperty decisionKeyProp = new LongProperty("decisionKey");
private final StringProperty decisionIdProp = new StringProperty("decisionId", "");
private final StringProperty decisionNameProp = new StringProperty("decisionName", "");
private final IntegerProperty versionProp = new IntegerProperty("version", -1);
private final LongProperty decisionKeyProp = new LongProperty("decisionKey", -1);

private final StringProperty decisionRequirementsIdProp =
new StringProperty("decisionRequirementsId");
new StringProperty("decisionRequirementsId", "");
private final LongProperty decisionRequirementsKeyProp =
new LongProperty("decisionRequirementsKey");
new LongProperty("decisionRequirementsKey", -1);

private final BooleanProperty isDuplicateProp = new BooleanProperty("isDuplicate", false);
private final StringProperty tenantIdProp =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@
import io.camunda.zeebe.protocol.record.value.TenantOwned;
import io.camunda.zeebe.protocol.record.value.deployment.DecisionRequirementsMetadataValue;
import org.agrona.DirectBuffer;
import org.agrona.concurrent.UnsafeBuffer;

public class DecisionRequirementsMetadataRecord extends UnifiedRecordValue
implements DecisionRequirementsMetadataValue {

private final StringProperty decisionRequirementsIdProp =
new StringProperty("decisionRequirementsId");
new StringProperty("decisionRequirementsId", "");
private final StringProperty decisionRequirementsNameProp =
new StringProperty("decisionRequirementsName");
new StringProperty("decisionRequirementsName", "");
private final IntegerProperty decisionRequirementsVersionProp =
new IntegerProperty("decisionRequirementsVersion");
new IntegerProperty("decisionRequirementsVersion", -1);
private final LongProperty decisionRequirementsKeyProp =
new LongProperty("decisionRequirementsKey");
private final StringProperty namespaceProp = new StringProperty("namespace");
new LongProperty("decisionRequirementsKey", -1);
private final StringProperty namespaceProp = new StringProperty("namespace", "");

private final StringProperty resourceNameProp = new StringProperty("resourceName");
private final BinaryProperty checksumProp = new BinaryProperty("checksum");
private final StringProperty resourceNameProp = new StringProperty("resourceName", "");
private final BinaryProperty checksumProp = new BinaryProperty("checksum", new UnsafeBuffer());

private final BooleanProperty isDuplicateProp = new BooleanProperty("isDuplicate", false);
private final StringProperty tenantIdProp =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@
import io.camunda.zeebe.protocol.record.value.TenantOwned;
import io.camunda.zeebe.protocol.record.value.deployment.DecisionRequirementsRecordValue;
import org.agrona.DirectBuffer;
import org.agrona.concurrent.UnsafeBuffer;

public final class DecisionRequirementsRecord extends UnifiedRecordValue
implements DecisionRequirementsRecordValue {

private final StringProperty decisionRequirementsIdProp =
new StringProperty("decisionRequirementsId");
new StringProperty("decisionRequirementsId", "");
private final StringProperty decisionRequirementsNameProp =
new StringProperty("decisionRequirementsName");
new StringProperty("decisionRequirementsName", "");
private final IntegerProperty decisionRequirementsVersionProp =
new IntegerProperty("decisionRequirementsVersion");
new IntegerProperty("decisionRequirementsVersion", -1);
private final LongProperty decisionRequirementsKeyProp =
new LongProperty("decisionRequirementsKey");
new LongProperty("decisionRequirementsKey", -1);
private final StringProperty namespaceProp = new StringProperty("namespace", "");

private final StringProperty resourceNameProp = new StringProperty("resourceName");
private final BinaryProperty checksumProp = new BinaryProperty("checksum");
private final BinaryProperty resourceProp = new BinaryProperty("resource");
private final StringProperty resourceNameProp = new StringProperty("resourceName", "");
private final BinaryProperty checksumProp = new BinaryProperty("checksum", new UnsafeBuffer());
private final BinaryProperty resourceProp = new BinaryProperty("resource", new UnsafeBuffer());
private final StringProperty tenantIdProp =
new StringProperty("tenantId", TenantOwned.DEFAULT_TENANT_IDENTIFIER);

Expand Down

0 comments on commit 5dc913b

Please sign in to comment.