Skip to content

Commit

Permalink
BZ-862325: adding test case
Browse files Browse the repository at this point in the history
(cherry picked from commit e089175281d55d30375a1d01c959dd958782e801)
  • Loading branch information
etirelli committed Oct 31, 2012
1 parent 6dc086a commit 21512d5
Showing 1 changed file with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11517,6 +11517,42 @@ public void testConstantLeft() {
assertEquals(1, ksession.fireAllRules());
ksession.dispose();
}

@Test
public void noDormantCheckOnModifies() throws Exception {
// Test case for BZ 862325
String str = "package org.drools;\n"
+ " rule R1\n"
+ " salience 10\n"
+ " when\n"
+ " $c : Cheese( price == 10 ) \n"
+ " $p : Person( ) \n"
+ " then \n"
+ " modify($c) { setPrice( 5 ) }\n"
+ " modify($p) { setAge( 20 ) }\n"
+ "end\n"
+ "rule R2\n"
+ " when\n"
+ " $p : Person( )"
+ " then \n"
+ " // noop\n"
+ "end\n";
// load up the knowledge base
KnowledgeBase kbase = loadKnowledgeBaseFromString(str);
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

org.drools.event.rule.AgendaEventListener ael = mock( org.drools.event.rule.AgendaEventListener.class );
ksession.addEventListener( ael );

ksession.insert( new Person("Bob", 19) );
ksession.insert( new Cheese("brie", 10) );
ksession.fireAllRules();

// both rules should fire exactly once
verify( ael, times(2) ).afterActivationFired( any( org.drools.event.rule.AfterActivationFiredEvent.class ) );
// no cancellations should have happened
verify( ael, never() ).activationCancelled( any( org.drools.event.rule.ActivationCancelledEvent.class ) );
}

@Test
public void testNullConstantLeft() {
Expand Down Expand Up @@ -11873,4 +11909,4 @@ public Date getBirthDate() {
return new Date();
}
}
}
}

0 comments on commit 21512d5

Please sign in to comment.