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

feat: create new assert function #704

Merged
merged 9 commits into from
Sep 8, 2023
Merged

feat: create new assert function #704

merged 9 commits into from
Sep 8, 2023

Conversation

nicpuppa
Copy link
Contributor

@nicpuppa nicpuppa commented Sep 5, 2023

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

@nicpuppa nicpuppa requested a review from saig0 as a code owner September 5, 2023 09:27
@CLAassistant
Copy link

CLAassistant commented Sep 5, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@saig0 saig0 left a 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. 🍪

@saig0
Copy link
Member

saig0 commented Sep 7, 2023

@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.

@nicpuppa nicpuppa force-pushed the 675-new-assert-function branch from b3e699b to af1069a Compare September 7, 2023 13:58
@nicpuppa
Copy link
Contributor Author

nicpuppa commented Sep 7, 2023

Hi @saig0 thanks for the review 🚀

I applied all the suggestions, please have another look 👀 Sorry for the CLA, new pc 😂

@nicpuppa nicpuppa requested a review from saig0 September 7, 2023 14:02
Copy link
Member

@saig0 saig0 left a 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/FeelEngine.scala Outdated Show resolved Hide resolved
src/main/scala/org/camunda/feel/FeelEngine.scala Outdated Show resolved Hide resolved
src/main/scala/org/camunda/feel/FeelEngine.scala Outdated Show resolved Hide resolved
Nicola Puppa and others added 7 commits September 8, 2023 09:39
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
@nicpuppa nicpuppa force-pushed the 675-new-assert-function branch from 261bf5e to 93a3b23 Compare September 8, 2023 07:41
@nicpuppa nicpuppa requested a review from saig0 September 8, 2023 07:42
@nicpuppa
Copy link
Contributor Author

nicpuppa commented Sep 8, 2023

Applied all suggestions, please have another look @saig0 👀

Copy link
Member

@saig0 saig0 left a 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
@saig0 saig0 merged commit c3129e9 into main Sep 8, 2023
3 checks passed
@saig0 saig0 deleted the 675-new-assert-function branch September 8, 2023 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assert that a variable is not null
3 participants