During namespace parsing for element in the model, the namespace is trimmed this way, that the closing slash is removed, see the code below:
https://github.com/DecisionToolkit/dsntk-rs/blob/9414b9c6b5f62c9f20ca92a6f0ef27e6d4089adf/common/src/uri.rs#L15
This may unnecessary confuse, when building models, because in the model the slash is at the end, and in the rest of processing there is no ending slash, an such errors may occur:
Assertion error, actual value of the decision does not match the expected value:
expected: 3
actual: null(invocable 'Add' not found in namespace 'https://www.decision-toolkit.org/input-data/')
In the model it looks like this (line 3):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/"
namespace="https://www.decision-toolkit.org/input-data/"
name="Adder">
<decision name="Add">
<variable name="Sum"/>
<informationRequirement>
<requiredInput href="#input-data-a"/>
</informationRequirement>
<informationRequirement>
<requiredInput href="#input-data-b"/>
</informationRequirement>
<literalExpression>
<text>a + b</text>
</literalExpression>
</decision>
<inputData name="a" id="input-data-a">
<variable name="a"/>
</inputData>
<inputData name="b" id="input-data-b">
<variable name="b"/>
</inputData>
</definitions>
and in test like this:
const DMN_0001: &str = include_str!("_0001.dmn");
model_evaluator!(DMN_0001);
const MODEL_NAMESPACE: &str = "https://www.decision-toolkit.org/input-data/";
const MODEL_NAME: &str = "Adder";
#[test]
fn _0001() {
let ctx = context(r#"{a: 1, b: 2}"#);
let invocable = "Add";
let expected = r#"3"#;
assert_decision(&MODEL_EVALUATOR, &MODEL_NAMESPACE, &MODEL_NAME, invocable, &ctx, expected);
}
Namespaces are equal, but the error occurs!
$ cargo run -- pdm model-evaluator/src/tests/input_data/_0001.dmn
shows:
┌───────┐
│ Model │
└───────┘
Adder
├─ FEEL name: Adder
└─ namespace: https://www.decision-toolkit.org/input-data
┌───────────┐
│ Decisions │
└───────────┘
Add
├─ FEEL name: Add
└─ variable (output)
├─ name: Sum
├─ FEEL name: Sum
└─ type: Any
┌────────────┐
│ Input data │
└────────────┘
a
├─ FEEL name: a
├─ id: input-data-a
└─ variable (output)
├─ name: a
├─ FEEL name: a
└─ type: Any
b
├─ FEEL name: b
├─ id: input-data-b
└─ variable (output)
├─ name: b
├─ FEEL name: b
└─ type: Any
So the namespace was trimmed from the closing slash!
During namespace parsing for element in the model, the namespace is trimmed this way, that the closing slash is removed, see the code below:
https://github.com/DecisionToolkit/dsntk-rs/blob/9414b9c6b5f62c9f20ca92a6f0ef27e6d4089adf/common/src/uri.rs#L15
This may unnecessary confuse, when building models, because in the model the slash is at the end, and in the rest of processing there is no ending slash, an such errors may occur:
In the model it looks like this (line 3):
and in test like this:
Namespaces are equal, but the error occurs!
shows:
So the namespace was trimmed from the closing slash!