// JBRULES-787, no-loop blocks all dependant tuples for update
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_UpdateActivationCreationNoLoop.drl" ) );
RuleBase ruleBase = loadRuleBase( reader );
ruleBase = SerializationHelper.serializeObject( ruleBase );
final InternalWorkingMemoryActions wm = (InternalWorkingMemoryActions) ruleBase
.newStatefulSession();
final List created = new ArrayList();
final List cancelled = new ArrayList();
final AgendaEventListener l = new DefaultAgendaEventListener() {
@Override
public void activationCreated(ActivationCreatedEvent event,
WorkingMemory workingMemory) {
created.add( event );
}
@Override
public void activationCancelled(ActivationCancelledEvent event,
WorkingMemory workingMemory) {
cancelled.add( event );
}
};
wm.addEventListener( l );
final Cheese stilton = new Cheese( "stilton", 15 );
final FactHandle stiltonHandle = wm.insert( stilton );
final Person p1 = new Person( "p1" );
p1.setCheese( stilton );
wm.insert( p1 );
final Person p2 = new Person( "p2" );
p2.setCheese( stilton );
wm.insert( p2 );
final Person p3 = new Person( "p3" );
p3.setCheese( stilton );
wm.insert( p3 );
assertEquals( 3, created.size() );
assertEquals( 0, cancelled.size() );
final Activation item = ((ActivationCreatedEvent) created.get( 2 ))
.getActivation();
// simulate a modify inside a consequence
wm.update( stiltonHandle, stilton, Long.MAX_VALUE, Object.class, item );
// with true modify, no reactivations should be triggered
assertEquals( 3, created.size() );
assertEquals( 0, cancelled.size() );
}