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: The invocation of a non-existing function returns null #692

Merged
merged 9 commits into from
Jul 25, 2023

Conversation

saig0
Copy link
Member

@saig0 saig0 commented Jul 25, 2023

Description

  • Change the behavior of the engine if an expression invokes a non-existing function. Instead of failing the evaluation, the invocation returns null.
  • Additionally, the evaluation reports a failure that the function doesn't exist.
  • Extend and refactor the test cases for the function invocation to verify the evaluation result and the reported failures.

Related issues

closes #670

If a function is invoked with wrong parameter, the invocation should return null (instead of failing the evaluation).
A function invocation returns null if the function is invoked with wrong parameters, or no function exists with this name.
Change the name of some test cases to bring the focus on the invocation of functions.
Add new test cases for a function invocation that return null.
If a function invocation returns null, we want to verify that a failure is reported.

A user of the API can access the evaluation failures to understand why an evaluation returned null. So, we should verify the reported failures.

To verify the failures, we need a new base test class that returns the whole evaluation result, instead of only the return value. Create a new test matcher to increase the readability of the tests and better failure messages.
Migrate the test class from FeelIntegrationTest to FeelEngineTest. The new base test class allows using the EvaluationResultMatchers that can check for reported failures and produces better failure messages.
Replace the internal test methods by using FeelEngineTest and EvaluationResultMatchers.
Align the failure message if no function was found.
Move test case from SuppressedFailuresTest to InterpreterFunctionTest that bundles all function related test cases.

Remove test cases from SuppressedFailuresTest that are already covered in InterpreterFunctionTest.
@saig0 saig0 requested a review from nicpuppa July 25, 2023 08:02
Copy link
Contributor

@nicpuppa nicpuppa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

💭 We must remember to refactor the other test cases to the new standard
💭 Is there any docs to update ?

import org.camunda.feel.api.{EvaluationFailure, EvaluationFailureType, EvaluationResult, FailedEvaluationResult, SuccessfulEvaluationResult}
import org.scalatest.matchers.{MatchResult, Matcher}

trait EvaluationResultMatchers {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it so much, made test cases way more readable 💪

@saig0
Copy link
Member Author

saig0 commented Jul 25, 2023

@nicpuppa thank you for your fast review. 🍰

We must remember to refactor the other test cases to the new standard

Yes. Let's migrate the other tests step-by-step when we're touching them. 🚀

Is there any docs to update?

No. But I will add more details about the handling of null when working on #581. 👍

@saig0 saig0 merged commit 41c057c into main Jul 25, 2023
3 checks passed
@saig0 saig0 deleted the 670-function-invocation branch July 25, 2023 11: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.

The invocation of a non-existing function should return null
2 participants