Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-4884

When a variable is reassigned in a consequence the property reactivity for the correspondent fact should be ignored

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • None
    • None
    • None
    • 2020 Week 01-03 (from Dec 30)
    • NEW
    • NEW

      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.

          @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) );
          }
      

              mfusco@redhat.com Mario Fusco
              mfusco@redhat.com Mario Fusco
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: