-
Notifications
You must be signed in to change notification settings - Fork 51
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
feat: create new assert function #704
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.
@nicpuppa well done. 🎉
I found a few minor issues and one major issue. The function doesn't work in all cases. Please have a look at my comments. 🍪
src/main/scala/org/camunda/feel/impl/builtin/BooleanBuiltinFunctions.scala
Outdated
Show resolved
Hide resolved
src/main/scala/org/camunda/feel/impl/interpreter/FeelInterpreter.scala
Outdated
Show resolved
Hide resolved
src/test/scala/org/camunda/feel/impl/builtin/BuiltinFunctionsTest.scala
Outdated
Show resolved
Hide resolved
@nicpuppa it seems that the SLA bot doesn't like your commits. Please check if the email address of the commits match your GitHub account. |
b3e699b
to
af1069a
Compare
Hi @saig0 thanks for the review 🚀 I applied all the suggestions, please have another look 👀 Sorry for the CLA, new pc 😂 |
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.
@nicpuppa nice! 👍
One remaining task is to provide the custom failure message to the user. Please have a look at my comments. 🍰
src/main/scala/org/camunda/feel/impl/interpreter/FeelInterpreter.scala
Outdated
Show resolved
Hide resolved
Created newbuilt-in assert function to verify that a certain condition is met
Updated the FeelInterpreter in order to return a ValError (instead of ValNull) if the condition of the new assert function is not fulfilled Added a new evaluation failure type ASSERT_FAILURE, for every evaluation error of the new assert() function Added also a checker for wrapped function, if an ASSERT_FAILURE is raised during the evaluation an error is returned instead of null
Created new tests to verify the correct behaviour of the new assert function Use the new FeelEngineTest and EvaluationResultMatchers to a better readability refactor: remove unused imports
Make sure that even if the assert() function is wrapped inside other functions the engine should return the error message provided by the user Adjust the tests to verify the logic above
261bf5e
to
93a3b23
Compare
Applied all suggestions, please have another look @saig0 👀 |
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.
@nicpuppa looks good. 👍
Before merging, please fix the test failure. I guess that you rebased on main
but didn't take all the changes. On main
, this test case is ignored.
Ignore test cases due to: #695
Description
Create new
assert(value, condition)
function in order to allow users to verify if a variable met a certain condition, and return an error if the condition is not fulfilled. This function should help users to migrate to 8.3 easily if they rely on validation error.Users can provide also a custom error message by
assert(value, condition, cause)
Related issues
closes #675