All,<br><br>I'm having a problem using memberOf combined with a collect statement. My test includes 3 rules each written to output the same results (I think), but I get different results (depending on which version of Drools I use).
<br><br>The rules are:<br><br><br>rule "TestMemberOf"<br> salience 10<br> when<br> $messages: ArrayList() from collect (Message(status == 100))<br> $wrappers: ArrayList() from collect (Wrapper(message memberOf $messages))
<br> then<br> System.out.println("TestMemberOf: " + $wrappers.size());<br>end<br><br>rule "TestEval1"<br> salience 9<br> when<br> $messages: ArrayList() from collect (Message(status == 100))
<br> $wrappers: ArrayList() from collect (Wrapper($message: message, eval($messages.contains($message))))<br> then<br> System.out.println("TestEval1: " + $wrappers.size());<br>end<br><br>rule "TestEval2"
<br> salience 8<br> when<br> $wrappers: ArrayList() from collect (Wrapper($message: message, eval($message.getStatus() == 100)))<br> then<br> System.out.println("TestEval2: " + $wrappers.size());
<br>end<br><br><br><br>The output is (by version):<br><br>4.0.0<br><br>TestMemberOf: 0<br>TestEval1: 0<br>TestEval2: 2<br><br>4.0.1<br><br>TestMemberOf: 0<br>TestEval1: 2<br>TestEval2: 2<br><br>4.0.2.SNAPSHOT (taken 9/18/07)
<br><br>TestMemberOf: 0<br>TestEval1: 2<br>TestEval2: 2<br><br><br>The correct output should be:<br><br>TestMemberOf: 2<br>
TestEval1: 2<br>
TestEval2: 2<br><br><br>Am I using memberOf correctly? Is there some issue using an eval to test conditions on a list created by a collect?<br><br>Any help would be appreciated.<br><br>Attached is the full example.<br><br>
Thanks,<br>-Chris West<br>
<br><br>