Rikkola commented on code in PR #6584:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6584#discussion_r2774117651


##########
drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/BiLinearTest.java:
##########
@@ -0,0 +1,836 @@
+/*
+ * 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;
+
+import org.drools.base.common.NetworkNode;
+import org.drools.mvel.integrationtests.phreak.A;
+import org.drools.mvel.integrationtests.phreak.B;
+import org.drools.mvel.integrationtests.phreak.C;
+import org.drools.mvel.integrationtests.phreak.D;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.kie.api.KieBase;
+import org.kie.api.io.ResourceType;
+import org.kie.api.runtime.KieSession;
+import org.kie.internal.utils.KieHelper;
+
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class BiLinearTest {
+
+    @BeforeEach
+    public void setUp() {
+        System.setProperty("drools.bilinear.enabled", "true");
+    }
+
+    @AfterEach
+    public void cleanup() {
+        System.clearProperty("drools.bilinear.enabled");
+    }
+
+    @Test
+    public void testBiLinear() {
+        System.out.println("\nšŸ” Testing BiLinear functionality...");
+
+        String drl =
+                "import " + A.class.getCanonicalName() + "\n" +
+                        "import " + B.class.getCanonicalName() + "\n" +
+                        "import " + C.class.getCanonicalName() + "\n" +
+                        "import " + D.class.getCanonicalName() + "\n" +
+                        "\n" +
+                        "rule \"Rule1\"\n" +
+                        "when\n" +
+                        "    $a : A()\n" +
+                        "    $b : B()\n" +
+                        "    $c : C()\n" +
+                        "    $d : D()\n" +
+                        "then\n" +
+                        "    System.out.println(\"Rule1 fired\" );\n" +
+                        "end\n" +
+                        "\n" +
+                        "rule \"Rule2\"\n" +
+                        "when\n" +
+                        "    $c : C()\n" +
+                        "    $d : D()\n" +
+                        "then\n" +
+                        "    System.out.println(\"Rule2 fired\" );\n" +
+                        "end\n";
+
+        System.out.println("šŸ”§ Building KieBase with BiLinear enabled...");
+        KieBase kieBase = buildKieBase(drl);
+
+        System.out.println("šŸ“Š Network structure:");
+        NetworkVisitor visitor = new NetworkVisitor();
+        visitor.debugNetworkStructure(kieBase);
+
+        System.out.println("\nšŸš€ Testing execution...");
+        KieSession session = kieBase.newKieSession();
+        session.insert(new A(5));
+        session.insert(new B(10));
+        session.insert(new C(10));
+        session.insert(new D(10));
+
+        int firedRules = session.fireAllRules();
+        System.out.println("šŸ“ˆ Rules fired: " + firedRules);
+
+        assertEquals(2, firedRules);
+
+        assertBiLinearNodeCount(visitor, kieBase, 1);
+
+        session.dispose();
+        System.out.println("āœ… BiLinear test completed");
+    }
+
+
+    @Test
+    public void testBiLinearSwapOrder() {
+        System.out.println("\nšŸ” Testing BiLinear functionality...");
+
+        String drl =
+                "import " + A.class.getCanonicalName() + "\n" +
+                        "import " + B.class.getCanonicalName() + "\n" +
+                        "import " + C.class.getCanonicalName() + "\n" +
+                        "import " + D.class.getCanonicalName() + "\n" +
+                        "\n" +
+                        "rule \"Rule1\"\n" +
+                        "when\n" +
+                        "    $c : C()\n" +
+                        "    $d : D()\n" +
+                        "then\n" +
+                        "    System.out.println(\"Rule1 fired\" );\n" +
+                        "end\n" +
+                        "\n" +
+                        "rule \"Rule2\"\n" +
+                        "when\n" +
+                        "    $a : A()\n" +
+                        "    $b : B()\n" +
+                        "    $c : C()\n" +
+                        "    $d : D()\n" +
+                        "then\n" +
+                        "    System.out.println(\"Rule2 fired\" );\n" +
+                        "end\n";
+
+        System.out.println("šŸ”§ Building KieBase with BiLinear enabled...");
+        KieBase kieBase = buildKieBase(drl);
+
+        System.out.println("šŸ“Š Network structure:");
+        NetworkVisitor visitor = new NetworkVisitor();
+        visitor.debugNetworkStructure(kieBase);
+
+        System.out.println("\nšŸš€ Testing execution...");
+        KieSession session = kieBase.newKieSession();
+        session.insert(new A(5));
+        session.insert(new B(10));
+        session.insert(new C(10));
+        session.insert(new D(10));
+
+        int firedRules = session.fireAllRules();
+        System.out.println("šŸ“ˆ Rules fired: " + firedRules);
+
+        assertEquals(2, firedRules);
+
+        assertBiLinearNodeCount(visitor, kieBase, 1);
+
+        session.dispose();
+        System.out.println("āœ… BiLinear test completed");
+    }
+
+
+
+    @Test
+    public void testBiLinear3RuleSetup() {
+        System.out.println("\nšŸ” Testing BiLinear functionality...");
+
+        String drl =
+                "import " + A.class.getCanonicalName() + "\n" +
+                        "import " + B.class.getCanonicalName() + "\n" +
+                        "import " + C.class.getCanonicalName() + "\n" +
+                        "import " + D.class.getCanonicalName() + "\n" +
+                        "\n" +
+                        "rule \"Rule1\"\n" +
+                        "when\n" +
+                        "    $a : A()\n" +
+                        "    $b : B()\n" +
+                        "    $c : C()\n" +
+                        "    $d : D()\n" +
+                        "then\n" +
+                        "    System.out.println(\"Rule1 fired\" );\n" +
+                        "end\n" +
+                        "\n" +
+                        "rule \"Rule2\"\n" +
+                        "when\n" +
+                        "    $a : A()\n" +
+                        "    $b : B()\n" +
+                        "    $c : C()\n" +
+                        "    $d : D()\n" +
+                        "then\n" +
+                        "    System.out.println(\"Rule2 fired\" );\n" +
+                        "end\n" +
+                        "\n" +
+                        "rule \"Rule3\"\n" +
+                        "when\n" +
+                        "    $c : C()\n" +
+                        "    $d : D()\n" +
+                        "then\n" +
+                        "    System.out.println(\"Rule3 fired\" );\n" +
+                        "end\n";
+
+        System.out.println("šŸ”§ Building KieBase with BiLinear enabled...");
+        KieBase kieBase = buildKieBase(drl);
+
+        System.out.println("šŸ“Š Network structure:");
+        NetworkVisitor visitor = new NetworkVisitor();
+        visitor.debugNetworkStructure(kieBase);
+
+        System.out.println("\nšŸš€ Testing execution...");
+        KieSession session = kieBase.newKieSession();
+        session.insert(new A(5));
+        session.insert(new B(10));
+        session.insert(new C(10));
+        session.insert(new D(10));
+
+        int firedRules = session.fireAllRules();
+        System.out.println("šŸ“ˆ Rules fired: " + firedRules);
+
+        assertEquals(3, firedRules);
+
+        assertBiLinearNodeCount(visitor, kieBase, 1);
+
+        session.dispose();
+        System.out.println("āœ… BiLinear test completed");
+    }
+
+
+    @Test
+    public void testBiLinear3RuleSetupShort() {
+        System.out.println("\nšŸ” Testing BiLinear functionality...");
+
+        String drl =
+                "import " + A.class.getCanonicalName() + "\n" +
+                        "import " + B.class.getCanonicalName() + "\n" +
+                        "import " + C.class.getCanonicalName() + "\n" +
+                        "import " + D.class.getCanonicalName() + "\n" +
+                        "\n" +
+                        "rule \"Rule1\"\n" +
+                        "when\n" +
+                        "    $b : B()\n" +
+                        "    $c : C()\n" +
+                        "    $d : D()\n" +
+                        "then\n" +
+                        "    System.out.println(\"Rule1 fired\" );\n" +
+                        "end\n" +
+                        "\n" +
+                        "rule \"Rule2\"\n" +
+                        "when\n" +
+                        "    $b : B()\n" +
+                        "    $c : C()\n" +
+                        "    $d : D()\n" +
+                        "then\n" +
+                        "    System.out.println(\"Rule2 fired\" );\n" +
+                        "end\n" +
+                        "\n" +
+                        "rule \"Rule3\"\n" +
+                        "when\n" +
+                        "    $c : C()\n" +
+                        "    $d : D()\n" +
+                        "then\n" +
+                        "    System.out.println(\"Rule3 fired\" );\n" +
+                        "end\n";
+
+        System.out.println("šŸ”§ Building KieBase with BiLinear enabled...");
+        KieBase kieBase = buildKieBase(drl);
+
+        System.out.println("šŸ“Š Network structure:");
+        NetworkVisitor visitor = new NetworkVisitor();
+        visitor.debugNetworkStructure(kieBase);
+
+        System.out.println("\nšŸš€ Testing execution...");
+        KieSession session = kieBase.newKieSession();
+        session.insert(new A(5));
+        session.insert(new B(10));
+        session.insert(new C(10));
+        session.insert(new D(10));
+
+        int firedRules = session.fireAllRules();
+        System.out.println("šŸ“ˆ Rules fired: " + firedRules);
+
+        assertEquals(3, firedRules);
+
+        assertBiLinearNodeCount(visitor, kieBase, 1);
+
+        session.dispose();
+        System.out.println("āœ… BiLinear test completed");
+    }
+
+    @Test
+    public void testBiLinear3RuleSetup2() {
+        System.out.println("\nšŸ” Testing BiLinear functionality...");
+
+        String drl =
+                "import " + A.class.getCanonicalName() + "\n" +
+                        "import " + B.class.getCanonicalName() + "\n" +
+                        "import " + C.class.getCanonicalName() + "\n" +
+                        "import " + D.class.getCanonicalName() + "\n" +
+                        "\n" +
+                        "rule \"Rule1\"\n" +
+                        "when\n" +
+                        "    $a : A()\n" +
+                        "    $c : C()\n" +
+                        "    $d : D()\n" +
+                        "then\n" +
+                        "    System.out.println(\"Rule1 fired\" );\n" +
+                        "end\n" +
+                        "\n" +
+                        "rule \"Rule2\"\n" +
+                        "when\n" +
+                        "    $b : B()\n" +
+                        "    $c : C()\n" +
+                        "    $d : D()\n" +
+                        "then\n" +
+                        "    System.out.println(\"Rule2 fired\" );\n" +
+                        "end\n" +
+                        "\n" +
+                        "rule \"Rule3\"\n" +
+                        "when\n" +
+                        "    $c : C()\n" +
+                        "    $d : D()\n" +
+                        "then\n" +
+                        "    System.out.println(\"Rule3 fired\" );\n" +
+                        "end\n";
+
+        System.out.println("šŸ”§ Building KieBase with BiLinear enabled...");
+        KieBase kieBase = buildKieBase(drl);
+
+        System.out.println("šŸ“Š Network structure:");
+        NetworkVisitor visitor = new NetworkVisitor();
+        visitor.debugNetworkStructure(kieBase);
+
+        System.out.println("\nšŸš€ Testing execution...");
+        KieSession session = kieBase.newKieSession();
+        session.insert(new A(5));
+        session.insert(new B(10));
+        session.insert(new C(10));
+        session.insert(new D(10));
+
+        int firedRules = session.fireAllRules();
+        System.out.println("šŸ“ˆ Rules fired: " + firedRules);
+
+        assertEquals(3, firedRules);
+
+        assertBiLinearNodeCount(visitor, kieBase, 2);
+
+        session.dispose();
+        System.out.println("āœ… BiLinear test completed");
+    }
+
+    @Test
+    public void testBiLinearSayAAAAAAAAA() {
+        System.out.println("\nšŸ” Testing BiLinear functionality...");
+
+        System.setProperty("drools.bilinear.enabled", "false");

Review Comment:
   Not an issue.



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