Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Has the closing slash to be removed? #54

Open
DariuszDepta opened this issue Sep 13, 2024 · 0 comments
Open

Has the closing slash to be removed? #54

DariuszDepta opened this issue Sep 13, 2024 · 0 comments
Labels
backlog Issues to be done some day
Milestone

Comments

@DariuszDepta
Copy link
Member

During namespace parsing for element in the model, the namespace is trimmed this way, that the closing slash is removed, see the code below:

return Ok(uri.to_string().trim().trim_end_matches('/').to_string());

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!

@DariuszDepta DariuszDepta added the question Further information is requested label Sep 13, 2024
@DariuszDepta DariuszDepta added this to the 0.0.9 milestone Sep 17, 2024
@DariuszDepta DariuszDepta added backlog Issues to be done some day and removed question Further information is requested labels Sep 24, 2024
@DariuszDepta DariuszDepta modified the milestones: 0.0.9, Backlog Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Issues to be done some day
Projects
None yet
Development

No branches or pull requests

1 participant