Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-3046

regression: spurious rule firing for exists(...) or not(...)

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    • Hide

      @Test
      public void testExistsIterativeModifyBug()

      { // JBRULES-3046 // Rule should only fire once String str = ""; str += "declare Fact x : int; y : int end "; str += "rule ins when then insert( new Fact( 1, 10 ) ); insert( new Fact( 2, 20 ) ); end "; str += "rule exornot "; str += "when "; str += " exists Fact( x == 1 ) "; str += " or "; str += " not Fact( x == 2, y == 20 ) "; str += "then "; str += " System.out.println( "SUCCESS" ); "; str += "end"; KnowledgeBase kbase = loadKnowledgeBaseFromString( str ); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); int fired = ksession.fireAllRules(); assertEquals( 1, fired ); ksession.dispose(); }
      Show
      @Test public void testExistsIterativeModifyBug() { // JBRULES-3046 // Rule should only fire once String str = ""; str += "declare Fact x : int; y : int end "; str += "rule ins when then insert( new Fact( 1, 10 ) ); insert( new Fact( 2, 20 ) ); end "; str += "rule exornot "; str += "when "; str += " exists Fact( x == 1 ) "; str += " or "; str += " not Fact( x == 2, y == 20 ) "; str += "then "; str += " System.out.println( "SUCCESS" ); "; str += "end"; KnowledgeBase kbase = loadKnowledgeBaseFromString( str ); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); int fired = ksession.fireAllRules(); assertEquals( 1, fired ); ksession.dispose(); }

    Description

      The DRL code below results in TWO firings of rule exornot. (5.1.1: Only one firing)

      declare Fact
      x : int
      y : int
      end

      rule ins
      when
      then
      insert( new Fact( 1, 10 ) );
      insert( new Fact( 2, 20 ) );
      end

      rule exornot
      when
      exists Fact( x == 1 )
      or
      not Fact( x == 2, y == 20 )
      then
      System.out.println( "SUCCESS" );
      end

      NOTE: If field 'y' is removed from 'Fact' and the rule patterns, the rule fires still twice in 5.3.0, but also twice in 5.1.1.

      Attachments

        Activity

          People

            mproctor@redhat.com Mark Proctor
            laune Wolfgang Laun (Inactive)
            Archiver:
            rhn-support-ceverson Clark Everson

            Dates

              Created:
              Updated:
              Resolved:
              Archived:

              PagerDuty