[jboss-jira] [JBoss JIRA] (DROOLS-1376) OOPath 2+ notifyModification() result only the 1st being effective
Matteo Mortari (JIRA)
issues at jboss.org
Fri Dec 9 08:53:00 EST 2016
[ https://issues.jboss.org/browse/DROOLS-1376?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Matteo Mortari reassigned DROOLS-1376:
--------------------------------------
Assignee: Matteo Mortari (was: Mario Fusco)
> OOPath 2+ notifyModification() result only the 1st being effective
> ------------------------------------------------------------------
>
> Key: DROOLS-1376
> URL: https://issues.jboss.org/browse/DROOLS-1376
> Project: Drools
> Issue Type: Bug
> Components: core engine
> Affects Versions: 7.0.0.Beta3
> Reporter: Matteo Mortari
> Assignee: Matteo Mortari
>
> Reproducible by adding in XPathTest:
> {code:java}
> @Test
> public void testDoubleAdd() {
> String drl =
> "import org.drools.compiler.xpath.*;\n" +
> "\n" +
> "rule R2 when\n" +
> " Group( $id: name, $p: /members{age >= 20} )\n" +
> "then\n" +
> " System.out.println( $id + \".\" + $p.getName() );\n" +
> " insertLogical( $id + \".\" + $p.getName() );\n" +
> "end\n";
> KieSession ksession = new KieHelper().addContent( drl, ResourceType.DRL )
> .build()
> .newKieSession();
>
> Group x = new Group("X");
> Group y = new Group("Y");
> ksession.insert( x );
> ksession.insert( y );
> ksession.fireAllRules();
> assertFalse (factsCollection(ksession).contains("X.Ada"));
> assertFalse (factsCollection(ksession).contains("X.Bea"));
> assertFalse (factsCollection(ksession).contains("Y.Ada"));
> assertFalse (factsCollection(ksession).contains("Y.Bea"));
>
> Adult ada = new Adult("Ada", 20);
> Adult bea = new Adult("Bea", 20);
> x.addPerson(ada);
> x.addPerson(bea);
> y.addPerson(ada);
> y.addPerson(bea);
> ksession.fireAllRules();
> assertTrue (factsCollection(ksession).contains("X.Ada"));
> assertTrue (factsCollection(ksession).contains("X.Bea"));
> assertTrue (factsCollection(ksession).contains("Y.Ada"));
> assertTrue (factsCollection(ksession).contains("Y.Bea"));
>
> x.removePerson(ada);
> x.removePerson(bea);
> y.removePerson(ada);
> y.removePerson(bea);
> ksession.fireAllRules();
> assertFalse (factsCollection(ksession).contains("X.Ada"));
> assertFalse (factsCollection(ksession).contains("X.Bea"));
> assertFalse (factsCollection(ksession).contains("Y.Ada"));
> assertFalse (factsCollection(ksession).contains("Y.Bea"));
> }
>
> @Test
> public void testDoubleRemove() {
> String drl =
> "import org.drools.compiler.xpath.*;\n" +
> "\n" +
> "rule R2 when\n" +
> " Group( $id: name, $p: /members{age >= 20} )\n" +
> "then\n" +
> " System.out.println( $id + \".\" + $p.getName() );\n" +
> " insertLogical( $id + \".\" + $p.getName() );\n" +
> "end\n";
> KieSession ksession = new KieHelper().addContent( drl, ResourceType.DRL )
> .build()
> .newKieSession();
>
> Adult ada = new Adult("Ada", 20);
> Adult bea = new Adult("Bea", 20);
> Group x = new Group("X");
> Group y = new Group("Y");
> x.addPerson(ada);
> x.addPerson(bea);
> y.addPerson(ada);
> y.addPerson(bea);
> ksession.insert( x );
> ksession.insert( y );
> ksession.fireAllRules();
> assertTrue (factsCollection(ksession).contains("X.Ada"));
> assertTrue (factsCollection(ksession).contains("X.Bea"));
> assertTrue (factsCollection(ksession).contains("Y.Ada"));
> assertTrue (factsCollection(ksession).contains("Y.Bea"));
>
> x.removePerson(ada);
> x.removePerson(bea);
> y.removePerson(ada);
> y.removePerson(bea);
> ksession.fireAllRules();
> assertFalse (factsCollection(ksession).contains("X.Ada"));
> assertFalse (factsCollection(ksession).contains("X.Bea"));
> assertFalse (factsCollection(ksession).contains("Y.Ada"));
> assertFalse (factsCollection(ksession).contains("Y.Bea"));
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
More information about the jboss-jira
mailing list