[jboss-jira] [JBoss JIRA] (DROOLS-625) Implement a passive pattern
Tibor Zimányi (JIRA)
issues at jboss.org
Wed Jul 11 07:14:00 EDT 2018
[ https://issues.jboss.org/browse/DROOLS-625?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tibor Zimányi closed DROOLS-625.
--------------------------------
Resolution: Done
Closing this as it was done, based on the linked commits.
> 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
(v7.5.0#75005)
More information about the jboss-jira
mailing list