tkobayas commented on code in PR #6419:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6419#discussion_r2315232870


##########
drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/ActivationGroupDualFactMatchTest.java:
##########
@@ -0,0 +1,205 @@
+/*
+ * 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.model.codegen.execmodel;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.kie.api.event.rule.AfterMatchFiredEvent;
+import org.kie.api.event.rule.DefaultAgendaEventListener;
+import org.kie.api.runtime.KieSession;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
+public class ActivationGroupDualFactMatchTest extends BaseModelTest {
+
+    public static class FactWrapper {
+
+        private final String id;
+        private boolean flag;
+
+        public FactWrapper(String id) {
+            this.id = id;
+            this.flag = false;
+        }
+
+        public String getId() {
+            return id;
+        }
+
+        public boolean isFlag() {
+            return flag;
+        }
+
+        public void setFlag(boolean flag) {
+            this.flag = flag;
+        }
+
+        @Override
+        public String toString() {
+            return "FactWrapper{id='" + id + "', flag=" + flag + '}';
+        }
+    }
+
+    /**
+     * Drools Rule Language (DRL) definition containing three interconnected 
rules
+     * that demonstrate activation group behavior with agenda group 
transitions.
+     * <p>
+     * Rule Definitions:
+     * <p>
+     * "Setup Rule - GroupA":
+     * - Triggers on dynamic facts with flag=false
+     * - Modifies the fact to set flag=true
+     * - Switches agenda focus to GroupB
+     * - Not in any activation group (can fire multiple times)
+     * <p>
+     * "Rule A - GroupA":
+     * - Requires both static fact (flag=true) AND dynamic fact (flag=true)
+     * - In activation-group "TestGroup"
+     * - Should NEVER fire due to activation group mutual exclusion
+     * - Also in GroupA agenda group
+     * <p>
+     * "Rule B - GroupB":
+     * - Requires only dynamic fact (flag=true)
+     * - In activation-group "TestGroup" (same as Rule A)
+     * - Fires first, preventing Rule A from executing
+     * - Executes in GroupB agenda group
+     * <p>
+     * Execution Flow:
+     * 1. Setup Rule fires, modifies dynamic fact, switches to GroupB
+     * 2. Rule B fires in GroupB (satisfies activation group)
+     * 3. Rule A cannot fire because activation group is already satisfied
+     */
+    private static final String DRL = """
+            package com.example
+            
+            import %s.FactWrapper;
+            
+            global org.kie.api.runtime.KieSession ksession;
+            
+            rule "Setup Rule - GroupA"
+                agenda-group "GroupA"
+                when
+                    $d: FactWrapper(id matches "dynamic-\\\\d+", flag == false)
+                then
+                    System.out.println(">>> Fired Setup Rule with fact: " + 
$d);

Review Comment:
   @pibizza Thanks! Fixed. Yeah, the test uses a listener to assert the fired 
rules.



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