tkobayas commented on code in PR #7202:
URL: https://github.com/apache/incubator-kie/pull/7202#discussion_r4320576173


##########
drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/sequential/SequentialNodeSharingTest.java:
##########
@@ -0,0 +1,437 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.drools.mvel.integrationtests.sequential;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Stream;
+
+import org.drools.mvel.compiler.Address;
+import org.drools.mvel.compiler.Cheese;
+import org.drools.mvel.compiler.Person;
+import org.drools.testcoverage.common.util.KieBaseTestConfiguration;
+import org.drools.testcoverage.common.util.KieBaseUtil;
+import org.drools.testcoverage.common.util.KieUtil;
+import org.drools.testcoverage.common.util.TestParametersUtil2;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.kie.api.KieBase;
+import org.kie.api.builder.KieModule;
+import org.kie.api.conf.SequentialOption;
+import org.kie.api.runtime.StatelessKieSession;
+import org.kie.internal.command.CommandFactory;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Tests that sequential mode disables beta node sharing by default,
+ * producing correct results for all beta node types (FromNode, JoinNode,
+ * AccumulateNode, NotNode, ExistsNode) when rules use modify().
+ *
+ * @see <a 
href="https://github.com/apache/incubator-kie/issues/7201";>incubator-kie#7201</a>
+ */
+public class SequentialNodeSharingTest {
+
+    public static Stream<KieBaseTestConfiguration> parameters() {
+        return 
TestParametersUtil2.getKieBaseCloudConfigurations(true).stream();
+    }
+
+    // =====================================================================
+    // FromNode tests
+    // =====================================================================
+
+    /**
+     * FromNode - left update: R1 modifies $p (the from source), R2 shares the 
same from node.
+     * Previously caused NPE in PhreakFromNode.doLeftUpdates.
+     */
+    @ParameterizedTest(name = "KieBase type={0}")
+    @MethodSource("parameters")
+    public void testFromNodeLeftUpdate(KieBaseTestConfiguration 
kieBaseTestConfiguration) {
+        String str =
+                "package org.drools.mvel.compiler.test\n" +
+                "import " + Person.class.getCanonicalName() + "\n" +
+                "import " + Address.class.getCanonicalName() + "\n" +
+                "global " + List.class.getCanonicalName() + " list\n" +
+                "rule R1 salience 100 no-loop when\n" +
+                "    $p : Person( age >= 0 )\n" +
+                "    $a : Address() from $p.addresses\n" +
+                "then\n" +
+                "    modify( $p ) { setAge( $p.getAge() + 1 ) };\n" +
+                "    list.add( \"R1\" );\n" +
+                "end\n" +
+                "rule R2 when\n" +
+                "    $p : Person( age >= 0 )\n" +
+                "    $a : Address() from $p.addresses\n" +
+                "then\n" +
+                "    list.add( \"R2:\" + $a.getStreet() );\n" +
+                "end\n";

Review Comment:
   These tests look similar, but they follow different evaluation paths. It's 
better to keep the DRLs separate and self-contained so that each test is easier 
to understand.



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