agenda.createAgendaItem((LeftTuple)item1, 0, null, null, null, null);
agenda.createAgendaItem((LeftTuple)item2, 0, null, null, null, null);
agenda.createAgendaItem((LeftTuple)item3, 0, null, null, null, null);
// use same data structure as testAddition
DefaultKnowledgeHelper kcontext = new DefaultKnowledgeHelper( ksession );
kcontext.setActivation( item1 );
// set blockers
kcontext.blockMatch( item2 );
kcontext.blockMatch( item3 );
// set blocked
kcontext.reset();
kcontext.setActivation( item2 );
kcontext.blockMatch( item3 );
// Check all references are updated correctly when item1 is deleted
item1.removeAllBlockersAndBlocked(agenda);
assertEquals( 0, item2.getBlockers().size() );
assertEquals( 1, item2.getBlocked().size() );
assertEquals(1, item3.getBlockers().size());
assertNull(item3.getBlocked());
assertSame( item2, ((LogicalDependency)item2.getBlocked().getFirst()).getJustifier() );
assertSame( item3, ((LogicalDependency)item2.getBlocked().getFirst()).getJustified() );
// now retract item2
item2.removeAllBlockersAndBlocked(agenda);
assertEquals( 0, item3.getBlockers().size() );
assertNull( item3.getBlocked() );
assertNull( item2.getBlocked() );
assertNull( item2.getBlocked() );
assertNull( item1.getBlocked() );
assertNull( item1.getBlocked() );
// reblock with item2, so that we can retract item3
kcontext.blockMatch( item3 );
assertNull( item2.getBlockers() );
assertEquals( 1, item2.getBlocked().size() );
assertEquals(1, item3.getBlockers().size());
assertNull(item3.getBlocked());
assertSame( item2, ((LogicalDependency)item2.getBlocked().getFirst()).getJustifier() );