Mario Fusco created DROOLS-625:
----------------------------------
Summary: Implement a passive pattern
Key: DROOLS-625
URL:
https://issues.jboss.org/browse/DROOLS-625
Project: Drools
Issue Type: Feature Request
Reporter: Mario Fusco
Assignee: Mario Fusco
Prepending a pattern with a '?' should make it passive (i.e. non reactive to right
insertions) as dimostrated by the following test case.
{code}
@Test
public void testPassiveInsert() throws Exception {
String str =
"global java.util.List list\n" +
"rule R when\n" +
" $i : Integer()\n" +
" ?String( this == $i.toString() )\n" +
"then\n" +
" list.add( $i );\n" +
"end\n";
KieSession ksession = new KieHelper()
.addContent(str, ResourceType.DRL)
.build()
.newKieSession();
List<Integer> list = new ArrayList<Integer>();
ksession.setGlobal("list", list);
ksession.insert(1);
ksession.insert("2");
ksession.fireAllRules();
assertEquals(0, list.size());
ksession.insert("1");
ksession.fireAllRules();
assertEquals(0, list.size());
ksession.insert(2);
ksession.fireAllRules();
assertEquals(1, list.size());
assertEquals(2, (int)list.get(0));
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)