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

OOPath use with primitives does not return any match

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • None
    • core engine
    • NEW
    • NEW

      Consider the following reproducer:

          @Test
          public void testPrimitives() {
              String drl =
                      "import org.drools.compiler.xpath.*;\n" +
                      "global java.util.List list\n" +
                      "\n" +
                      "rule R when\n" +
                      "  Adult( $x: /children.age )\n" +
                      "then\n" +
                      "  list.add( $x );\n" +
                      "end\n";
              
              System.out.println(drl);
      
              KieSession ksession = new KieHelper().addContent( drl, ResourceType.DRL )
                                                   .build()
                                                   .newKieSession();
      
              List<String> list = new ArrayList<String>();
              ksession.setGlobal( "list", list );
      
              Man bob = new Man( "Bob", 40 );
              bob.addChild( new Child( "Charles", 12 ) );
              bob.addChild( new Child( "Debbie", 8 ) );
      
              ksession.insert( bob );
              ksession.fireAllRules();
              
              assertEquals(2, list.size());
      
          }
      

      these reproducer/test fails. Does not provide any match of the primitive type returned by age.

      Please note if the rule was instead:

      rule R when
        Adult( $x: /children.name )
      then
        ...
      

      the test would pass.

      Hence appears OOPath is not matching on the primitive types?

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

                Created:
                Updated:
                Resolved: