yurloc commented on code in PR #5767:
URL: 
https://github.com/apache/incubator-kie-drools/pull/5767#discussion_r1514685340


##########
drools-drl/drools-drl-parser-tests/src/test/java/org/drools/drl/parser/antlr4/MiscDRLParserTest.java:
##########
@@ -3538,4 +3539,74 @@ void ruleDescrProperties() {
         assertThat(ruleDescr.getName()).isEqualTo("R1");
         assertThat(ruleDescr.getNamespace()).isEqualTo("org.drools");
     }
+
+    /**
+     * Each test input is a constraint expression covering one of the existing 
keywords. The test is successful if the parser has
+     * no errors and the descriptor's expression string is equal to the input.
+     *
+     * @param constraint expression using a keyword
+     */
+    @ParameterizedTest
+    @ValueSource(strings = {
+            "country matches \"[a-z]*\"",
+            "country not matches \"[a-z]*\"",
+            "person memberOf $europeanDescendants",
+            "person not memberOf $europeanDescendants",
+            "countries contains \"UK\"",
+            "countries not contains \"UK\"",
+            "countries excludes \"UK\"",
+            "countries not excludes \"UK\"",
+            "firstName soundslike \"John\"",
+            "firstName not soundslike \"John\"",
+            "routingValue str[startsWith] \"R1\"",
+            "routingValue not str[startsWith] \"R1\""
+    })
+    void constraintKeywords(String constraint) {

Review Comment:
   ```suggestion
       void constraintOperators(String constraint) {
   ```



##########
drools-drl/drools-drl-parser-tests/src/test/java/org/drools/drl/parser/antlr4/MiscDRLParserTest.java:
##########
@@ -3538,4 +3539,74 @@ void ruleDescrProperties() {
         assertThat(ruleDescr.getName()).isEqualTo("R1");
         assertThat(ruleDescr.getNamespace()).isEqualTo("org.drools");
     }
+
+    /**
+     * Each test input is a constraint expression covering one of the existing 
keywords. The test is successful if the parser has
+     * no errors and the descriptor's expression string is equal to the input.
+     *
+     * @param constraint expression using a keyword
+     */
+    @ParameterizedTest
+    @ValueSource(strings = {
+            "country matches \"[a-z]*\"",
+            "country not matches \"[a-z]*\"",
+            "person memberOf $europeanDescendants",
+            "person not memberOf $europeanDescendants",
+            "countries contains \"UK\"",
+            "countries not contains \"UK\"",
+            "countries excludes \"UK\"",
+            "countries not excludes \"UK\"",
+            "firstName soundslike \"John\"",
+            "firstName not soundslike \"John\"",
+            "routingValue str[startsWith] \"R1\"",
+            "routingValue not str[startsWith] \"R1\""
+    })
+    void constraintKeywords(String constraint) {
+        final String text = "package org.drools\n" +
+                "rule R1\n" +
+                "when\n" +
+                "    $p : Person(" + constraint + ")\n" +
+                "then\n" +
+                "end\n";
+
+        PackageDescr packageDescr = parser.parse(text);
+
+        RuleDescr ruleDescr = packageDescr.getRules().get(0);
+        AndDescr lhs = ruleDescr.getLhs();
+        PatternDescr patternDescr = (PatternDescr) lhs.getDescrs().get(0);
+        ExprConstraintDescr exprConstraintDescr = (ExprConstraintDescr) 
patternDescr.getConstraint().getDescrs().get(0);
+        
assertThat(exprConstraintDescr.getExpression()).isEqualToIgnoringWhitespace(constraint);
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {
+            "country matches \"[a-z]*\" || matches \"[A-Z]*\"",
+            "country not matches \"[a-z]*\" || not matches \"[A-Z]*\"",
+            "person memberOf $europeanDescendants || memberOf 
$africanDescendants",
+            "person not memberOf $europeanDescendants || not memberOf 
$africanDescendants",
+            "countries contains \"UK\" || contains \"US\"",
+            "countries not contains \"UK\" || not contains \"US\"",
+            "countries excludes \"UK\" || excludes \"US\"",
+            "countries not excludes \"UK\" || not excludes \"US\"",
+            "firstName soundslike \"John\" || soundslike \"Paul\"",
+            "firstName not soundslike \"John\" && not soundslike \"Paul\"",
+            "routingValue str[startsWith] \"R1\" || str[startsWith] \"R2\"",
+            "routingValue not str[startsWith] \"R1\" && not str[startsWith] 
\"R2\""
+    })
+    void halfConstraintKeywords(String constraint) {

Review Comment:
   ```suggestion
       void halfConstraintOperators(String constraint) {
   ```



##########
drools-drl/drools-drl-parser-tests/src/test/java/org/drools/drl/parser/antlr4/MiscDRLParserTest.java:
##########
@@ -3538,4 +3539,74 @@ void ruleDescrProperties() {
         assertThat(ruleDescr.getName()).isEqualTo("R1");
         assertThat(ruleDescr.getNamespace()).isEqualTo("org.drools");
     }
+
+    /**
+     * Each test input is a constraint expression covering one of the existing 
keywords. The test is successful if the parser has
+     * no errors and the descriptor's expression string is equal to the input.
+     *
+     * @param constraint expression using a keyword

Review Comment:
   ```suggestion
        * @param constraint expression using an operator
   ```



##########
drools-drl/drools-drl-parser-tests/src/test/java/org/drools/drl/parser/antlr4/MiscDRLParserTest.java:
##########
@@ -3538,4 +3539,74 @@ void ruleDescrProperties() {
         assertThat(ruleDescr.getName()).isEqualTo("R1");
         assertThat(ruleDescr.getNamespace()).isEqualTo("org.drools");
     }
+
+    /**
+     * Each test input is a constraint expression covering one of the existing 
keywords. The test is successful if the parser has

Review Comment:
   ```suggestion
        * Each test input is a constraint expression covering one of the 
existing DRL operators. The test is successful if the parser has
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to