• Icon: Sub-task Sub-task
    • Resolution: Done
    • Icon: Major Major
    • None
    • None
    • None
    • NEW
    • NEW

          @Test
          public void testWronglyMatchAlsoEqualsTris() {
              String drl =
                      "import org.drools.compiler.xpath.*;\n" +
                      "global java.util.Set duplicateNames; \n" +
                      "\n" +
                      "rule DIFF_FILES_BUT_WITH_SAME_FILENAME when\n" +
                      "  $ic1 : TMFileWithParentObj( parent instanceof TMFileSet ,\n" + 
                      "                              $curName : name,\n" + 
                      "                              $ic2: /parent{#TMFileSet}/files{name == $curName, this != $ic1 } )\n" +
                      "then\n" +
                      "  System.out.println( $ic1 + \" \" + $ic2 );\n" +
                      "  duplicateNames.add( $ic1.getName() );\n" +
                      "end\n";
      
              KieSession ksession = new KieHelper().addContent( drl, ResourceType.DRL )
                                                   .build()
                                                   .newKieSession();
              
              Set duplicateNames = new HashSet();
              ksession.setGlobal("duplicateNames", duplicateNames);
              
              TMFileSet x = new TMFileSet("X");
              TMFileWithParentObj file0 = new TMFileWithParentObj(0, "File0", 47, x);
              TMFileWithParentObj file1 = new TMFileWithParentObj(1, "File1", 47, x);
              TMFileWithParentObj file2 = new TMFileWithParentObj(2, "File0", 47, x);
              x.getFiles().addAll(Arrays.asList(new TMFile[]{file0, file1, file2}));
              
              ksession.insert( x );
              ksession.insert( file0 );
              ksession.insert( file1 );
              ksession.insert( file2 );
              ksession.fireAllRules();
              
              assertTrue( duplicateNames.contains("File0") );
              assertFalse( duplicateNames.contains("File1") );
          }
      

              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: