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

Kie issues#1448 - matches() function wrongly behaves - negation syntax translation #6083

Closed
wants to merge 10 commits into from

Conversation

bncriju
Copy link
Contributor

@bncriju bncriju commented Sep 13, 2024

Fixes apache/incubator-kie-issues#1448

Thank you for submitting this pull request

NOTE!: Double-check the target branch for this PR.
The default is main so it will target Drools 8 / Kogito.

Ports If a forward-port or a backport is needed, paste the forward port PR here

Issue: (please edit the GitHub Issues link if it exists)

referenced Pull Requests: (please edit the URLs of referenced pullrequests if they exist)

  • paste the link(s) from GitHub here
  • link 2
  • link 3 etc.
How to replicate CI configuration locally?

Build Chain tool does "simple" maven build(s), the builds are just Maven commands, but because the repositories relates and depends on each other and any change in API or class method could affect several of those repositories there is a need to use build-chain tool to handle cross repository builds and be sure that we always use latest version of the code for each repository.

build-chain tool is a build tool which can be used on command line locally or in Github Actions workflow(s), in case you need to change multiple repositories and send multiple dependent pull requests related with a change you can easily reproduce the same build by executing it on Github hosted environment or locally in your development environment. See local execution details to get more information about it.

How to retest this PR or trigger a specific build:
  • for pull request and downstream checks

    • Push a new commit to the PR. An empty commit would be enough.
  • for a full downstream build

    • for github actions job: add the label run_fdb
  • for Jenkins PR check only

@kie-ci3
Copy link

kie-ci3 commented Sep 13, 2024

PR job #1 was: UNSTABLE
Possible explanation: This should be test failures

Reproducer

build-chain build full_downstream -f 'https://raw.githubusercontent.com/${AUTHOR:apache}/incubator-kie-kogito-pipelines/${BRANCH:main}/.ci/buildchain-config-pr-cdb.yaml' -o 'bc' -p apache/incubator-kie-drools -u #6083 --skipParallelCheckout

NOTE: To install the build-chain tool, please refer to https://github.com/kiegroup/github-action-build-chain#local-execution

Please look here: https://ci-builds.apache.org/job/KIE/job/drools/job/main/job/pullrequest_jobs/job/drools-pr/job/PR-6083/1/display/redirect

Test results:

  • PASSED: 22320
  • FAILED: 31

Those are the test failures:

org.kie.dmn.feel.documentation.ADocFEELExamplesTest.test Cannot invoke "java.net.URL.toURI()" because "resource" is null
org.kie.dmn.feel.documentation.FromSpecificationNotInAdocTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[21] [Evaluating: 'matches("foobar", "^fo*b") = true']
expected: true
but was: false
org.kie.dmn.feel.documentation.FromSpecificationNotInAdocTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[22] [Evaluating: 'matches("foobar", "^fo*b") = true']
expected: true
but was: false
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[3] [Evaluating: 'replace( " foo bar zed ", "^(\s)+|(\s)+$|\s+(?=\s)", "" )']
expected: "foo bar zed"
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[4] [Evaluating: 'replace( " foo bar zed ", "^(\s)+|(\s)+$|\s+(?=\s)", "" )']
expected: "foo bar zed"
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[71] [Evaluating: 'matches("foo", "[a-z]{3}")']
expected: true
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[72] [Evaluating: 'matches("foo", "[a-z]{3}")']
expected: true
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[73] [Evaluating: 'matches("banana", "[a-z]{3}")']
expected: true
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[74] [Evaluating: 'matches("banana", "[a-z]{3}")']
expected: true
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[75] [Evaluating: 'matches("two \n lines", "two.*lines")']
expected: false
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[76] [Evaluating: 'matches("two \n lines", "two.*lines")']
expected: false
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[79] [Evaluating: 'matches("one\ntwo\nthree", "^two$")']
expected: false
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[80] [Evaluating: 'matches("one\ntwo\nthree", "^two$")']
expected: false
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[83] [Evaluating: 'matches("FoO", "foo")']
expected: false
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[84] [Evaluating: 'matches("FoO", "foo")']
expected: false
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[87] [Evaluating: 'replace("banana","a","o")']
expected: "bonono"
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[88] [Evaluating: 'replace("banana","a","o")']
expected: "bonono"
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[89] [Evaluating: 'replace("banana","(an)+", "**")']
expected: "b**a"
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[90] [Evaluating: 'replace("banana","(an)+", "**")']
expected: "b**a"
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[91] [Evaluating: 'replace("banana","[aeiouy]","[$0]")']
expected: "b[a]n[a]n[a]"
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[92] [Evaluating: 'replace("banana","[aeiouy]","[$0]")']
expected: "b[a]n[a]n[a]"
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[93] [Evaluating: 'replace("0123456789","(\d{3})(\d{3})(\d{4})","($1) $2-$3")']
expected: "(012) 345-6789"
but was: null
org.kie.dmn.feel.runtime.FEELFunctionsTest.instanceTest(String, Object, Severity, FEEL_TARGET, Boolean, FEELDialect)[94] [Evaluating: 'replace("0123456789","(\d{3})(\d{3})(\d{4})","($1) $2-$3")']
expected: "(012) 345-6789"
but was: null
org.kie.dmn.feel.runtime.functions.RangeFunctionTest.evaluateWithInvalidFunctionInvocationNode Expected 'retrieved.isLeft()' from, [matches("foo", "[a-z]{3}")..matches("foo", "[a-z]{3}")]
org.kie.dmn.feel.runtime.functions.ReplaceFunctionTest.invokeWithoutFlagsPatternNotMatches java.lang.ClassCastException: Cannot cast net.sf.saxon.str.BMPString to java.lang.String
org.kie.dmn.feel.runtime.functions.ReplaceFunctionTest.invokeWithFlagDotAll java.lang.ClassCastException: Cannot cast net.sf.saxon.str.BMPString to java.lang.String
org.kie.dmn.feel.runtime.functions.ReplaceFunctionTest.invokeWithFlagMultiline java.lang.ClassCastException: Cannot cast net.sf.saxon.str.BMPString to java.lang.String
org.kie.dmn.feel.runtime.functions.ReplaceFunctionTest.invokeWithAllFlags java.lang.ClassCastException: Cannot cast net.sf.saxon.str.BMPString to java.lang.String
org.kie.dmn.feel.runtime.functions.ReplaceFunctionTest.invokeWithFlagCaseInsensitive java.lang.ClassCastException: Cannot cast net.sf.saxon.str.Twine16 to java.lang.String
org.kie.dmn.feel.runtime.functions.ReplaceFunctionTest.invokeWithoutFlagsPatternMatches java.lang.ClassCastException: Cannot cast net.sf.saxon.str.Twine16 to java.lang.String
org.kie.dmn.feel.util.XQueryImplUtilTest.executeReplaceFunctionTest java.lang.ClassCastException: Cannot cast net.sf.saxon.str.Twine16 to java.lang.String

Copy link
Contributor

@yesamer yesamer left a comment

Choose a reason for hiding this comment

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

@bncriju Thank you for your PR! After @gitgabrio and I analyzed your changes, we discovered more parts of the code that require to be improved. So, we agreed to open a new PR based on your PR to apply the adjustments.

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</dependency>
Copy link
Contributor

Choose a reason for hiding this comment

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

@bncriju I guess this is not required

@@ -144,7 +162,7 @@
<directory>${project.basedir}/src/test/resources</directory>
</testResource>
<testResource>
<directory>${project.basedir}/</directory>
<directory>${project.basedir}/../</directory>
Copy link
Contributor

Choose a reason for hiding this comment

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

@bncriju I guess this change is not required

@@ -39,21 +36,24 @@ private MatchesFunction() {
super( "matches" );
}

public FEELFnResult<Boolean> invoke(@ParameterName("input") String input, @ParameterName("pattern") String pattern) {
public FEELFnResult<Boolean> FEELFnResult(@ParameterName("input") String input, @ParameterName("pattern") String pattern) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@bncriju Wrong method name

@yesamer
Copy link
Contributor

yesamer commented Sep 16, 2024

Superseded by #6085

@yesamer yesamer closed this Sep 16, 2024
Copy link
Contributor

@pibizza pibizza left a comment

Choose a reason for hiding this comment

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

Make the tests without reused variables. either separate tests or make them just parametric.

boolean retrieved = XQueryImplUtil.executeMatchesFunction(input, pattern,
flags);
boolean expected = true;
assertThat(retrieved).isNotNull().isEqualTo(expected);
Copy link
Contributor

Choose a reason for hiding this comment

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

One general comment. Do not reuse variables. Either separate the tests or make a parametric test. a test should be quite simple and very easy to read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

matches() function wrongly behaves
4 participants