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

[DROOLS-7635] ansible-rulebook : Raise an error when a condition comp… #117

Merged

Conversation

tkobayas
Copy link
Collaborator

@tkobayas tkobayas commented Oct 4, 2024

…ares incompatible types

  • alpha index test, beta index test

@tkobayas tkobayas force-pushed the DROOLS-7635-error-incompatible-type-02 branch 2 times, most recently from f0a727e to f47528d Compare October 8, 2024 05:06
@tkobayas tkobayas marked this pull request as ready for review October 8, 2024 05:07
@tkobayas
Copy link
Collaborator Author

tkobayas commented Oct 8, 2024

Added test cases:

  • alphaIndex : Not match when type mismatch (expected). No error log (limitation)
  • betaIndex : Not match when type mismatch (expected). No error log (limitation)
  • negation : Not match when type mismatch (expected). Error log produced (expected)
  • any: Rule Matches when type mismatch on one condition, but the other condition properly matches (expected). Error log produced (expected)

A fix in this PR is for negation test to pass.

@tkobayas tkobayas requested a review from mariofusco October 8, 2024 05:18
…ares incompatible types

- alpha index test, beta index test

beta index test fix

add negate test and any test
@tkobayas tkobayas force-pushed the DROOLS-7635-error-incompatible-type-02 branch from f47528d to ca9eda4 Compare October 9, 2024 02:28
// if not compatible type, return false regardless of the result
// but let the operator be executed anyway so that the error message specific to the constraint is logged
boolean result = !toBeNegated.asPredicate().test(t, v);
return isCompatibleType(t, v) ? result : false;
Copy link
Member

Choose a reason for hiding this comment

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

Minor performance improvement: isn't necessary to compute the result if types aren't compatible.

Copy link
Collaborator Author

@tkobayas tkobayas Oct 11, 2024

Choose a reason for hiding this comment

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

I wanted to let the operator log the type check error. But yes, I can refactor it to make it cleaner.

Copy link
Member

@mariofusco mariofusco left a comment

Choose a reason for hiding this comment

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

Ok for me, I just added a suggestion for a minor improvement.

@tkobayas tkobayas merged commit 081fb11 into kiegroup:main Oct 11, 2024
1 check passed
tkobayas added a commit to tkobayas/drools-ansible-rulebook-integration that referenced this pull request Oct 15, 2024
kiegroup#117)

* [DROOLS-7635] ansible-rulebook : Raise an error when a condition compares incompatible types
- alpha index test, beta index test

beta index test fix

add negate test and any test

* refactor

* minor comment fix
mariofusco pushed a commit that referenced this pull request Oct 18, 2024
…on compares incompatible types (#120)

* Merge pull request #114 from tkobayas/DROOLS-7635-error-incompatible-type-02

[DROOLS-7635] ansible-rulebook : Raise an error when a condition compares incompatible types

* [DROOLS-7635] ansible-rulebook : Raise an error when a condition comp… (#117)

* [DROOLS-7635] ansible-rulebook : Raise an error when a condition compares incompatible types
- alpha index test, beta index test

beta index test fix

add negate test and any test

* refactor

* minor comment fix
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.

2 participants