[jboss-jira] [JBoss JIRA] (DROOLS-4884) When a variable is reassigned in a consequence the property reactivity for the correspondent fact should be ignored

Mario Fusco (Jira) issues at jboss.org
Wed Dec 18 09:20:49 EST 2019


Mario Fusco created DROOLS-4884:
-----------------------------------

             Summary: When a variable is reassigned in a consequence the property reactivity for the correspondent fact should be ignored
                 Key: DROOLS-4884
                 URL: https://issues.redhat.com/browse/DROOLS-4884
             Project: Drools
          Issue Type: Bug
            Reporter: Mario Fusco
            Assignee: Mario Fusco


When a variable is reassigned in a consequence (not a good practice in general) the property reactivity for the correspondent fact should be ignored. In other word the following test should succeed.

{code}
    @Test
    public void testReassignment() {
        final String str1 =
                "package com.example\n" +
                "\n" +
                "declare Counter\n" +
                "    value1: int\n" +
                "    value2: int\n" +
                "end\n" +
                "\n" +
                "rule \"Init\" when\n" +
                "    not Counter()\n" +
                "then\n" +
                "    drools.insert(new Counter(0, 0));\n" +
                "end\n" +
                "\n" +
                "rule \"Loop\"\n" +
                "when\n" +
                "    $c: Counter( value1 == 0 )\n" +
                "then\n" +
                "    $c = new Counter(0, 0);\n" +
                "    $c.setValue2(1);\n" +
                "    update($c);\n" +
                "end\n\n";

        final KieSession ksession = new KieHelper().addContent( str1, ResourceType.DRL )
                .build()
                .newKieSession();

        assertEquals( 5, ksession.fireAllRules(5) );
    }
{code}



--
This message was sent by Atlassian Jira
(v7.13.8#713008)


More information about the jboss-jira mailing list