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

Missing alpha node removal when the only rule using it is removed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 6.3.0.CR2
    • None
    • None
    • None
    • NEW
    • NEW

      When an alpha node has more than one sink and it is used by only one rule doesn't get removed when the rule itself is removed. The following test case demonstrates the problem.

          @Test
          public void testRemoveHasSameConElement() {
              String packageName = "test";
              String rule1 = "package " + packageName + ";" +
                             "import java.util.Map; \n" +
                             "rule 'rule1' \n" +
                             "when \n" +
                             " Map(this['type'] == 'Goods' && this['brand'] == 'a') \n" +
                             " Map(this['type'] == 'Goods' && this['category'] == 'b') \n" +
                             "then \n" +
                             "System.out.println('test rule 1'); \n"+
                             "end";
      
              KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
      
              kbuilder.add( ResourceFactory.newByteArrayResource( rule1.getBytes() ), ResourceType.DRL );
              if ( kbuilder.hasErrors() ) {
                  fail( kbuilder.getErrors().toString() );
              }
              KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
              kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
              kbase.removeKnowledgePackage(packageName);
              StatelessKnowledgeSession session = kbase.newStatelessKnowledgeSession();
              session.execute(new HashMap());
          }
      

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

                Created:
                Updated:
                Resolved: