-
Notifications
You must be signed in to change notification settings - Fork 637
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
fix: Store duration values in a normalized format #27161
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void shouldReturnNormalizedPeriod() { | ||
final var evaluationResult = evaluateExpression("=duration(\"P2Y\")"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Should we also add a test case for period and duration with two separate units?
e.g.
P2Y3M
P5DT3H2M
@Test | ||
public void shouldReturnNormalizedDuration() { | ||
final var evaluationResult = evaluateExpression("=duration(\"P5D\")"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 We could show the normalization by starting with a non-normalized format:
PT120H
->P5D
.../test/java/io/camunda/zeebe/engine/processing/variable/mapping/ActivityInputMappingTest.java
Show resolved
Hide resolved
Add a test case to verify that a duration value is stored in a normalized format.
Use toString() of FEEL duration to serialize the value into a JSON variable. Compared to the Java's duration value, the FEEL value returns the duration in a normalized format (i.e. in the biggest available unit).
Adjust the duration value of existing test cases to expect a normalized format.
e56f6ff
to
10cda94
Compare
Update the JUnit Maven dependency and the test annotations from JUnit 4 to JUnit 5.
Add more cases to verify the normalized duration formation using JUnit's parameterized tests.
10cda94
to
71aa2d3
Compare
## Description Use `toString()` of FEEL duration to serialize the value into a JSON variable. Compared to the Java's duration value, the FEEL value returns the duration in a normalized format (i.e. in the biggest available unit). This fix aligns the engine with the [docs](https://docs.camunda.io/docs/components/modeler/feel/language-guide/feel-temporal-expressions/#subtraction) and avoids the workaround using the [string()](https://docs.camunda.io/docs/components/modeler/feel/builtin-functions/feel-built-in-functions-conversion/#stringfrom) function. ``` // before "PT120H" // after "P5D" ``` ## Related issues closes #27098
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-27161-to-stable/8.3
git worktree add --checkout .worktree/backport-27161-to-stable/8.3 backport-27161-to-stable/8.3
cd .worktree/backport-27161-to-stable/8.3
git reset --hard HEAD^
git cherry-pick -x e7aed5e34b8b24f3dc5078a45a4351db5def4d85 8fb4232e6a65d65c34218a7498fe2942ea2a8ea0 8ee6f31d622d76755dffa2376510ecabde259005 71aa2d3eef0b6d7d553db5b054c6711d354e4664
git push --force-with-lease |
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-27161-to-stable/8.4
git worktree add --checkout .worktree/backport-27161-to-stable/8.4 backport-27161-to-stable/8.4
cd .worktree/backport-27161-to-stable/8.4
git reset --hard HEAD^
git cherry-pick -x e7aed5e34b8b24f3dc5078a45a4351db5def4d85 8fb4232e6a65d65c34218a7498fe2942ea2a8ea0 8ee6f31d622d76755dffa2376510ecabde259005 71aa2d3eef0b6d7d553db5b054c6711d354e4664
git push --force-with-lease |
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-27161-to-stable/8.5
git worktree add --checkout .worktree/backport-27161-to-stable/8.5 backport-27161-to-stable/8.5
cd .worktree/backport-27161-to-stable/8.5
git reset --hard HEAD^
git cherry-pick -x e7aed5e34b8b24f3dc5078a45a4351db5def4d85 8fb4232e6a65d65c34218a7498fe2942ea2a8ea0 8ee6f31d622d76755dffa2376510ecabde259005 71aa2d3eef0b6d7d553db5b054c6711d354e4664
git push --force-with-lease |
Successfully created backport PR for |
Successfully created backport PR for |
Description
Use
toString()
of FEEL duration to serialize the value into a JSON variable. Compared to the Java's duration value, theFEEL value returns the duration in a normalized format (i.e. in the biggest available unit).
This fix aligns the engine with the docs and avoids the workaround using the string() function.
Related issues
closes #27098