@Test
public void testBasicWorkingMemoryActions() {
InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase();
StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newStatefulKnowledgeSession();
final TruthMaintenanceSystem tms = ((NamedEntryPoint)ksession.getWorkingMemoryEntryPoint(EntryPointId.DEFAULT.getEntryPointId()) ).getTruthMaintenanceSystem();
final String string = "test";
ksession.insert( string );
FactHandle fd = ksession.insertLogical(string);
assertEquals( 1,
tms.getEqualityKeyMap().size() );
EqualityKey key = tms.get( string );
assertSame( fd,
key.getFactHandle() );
assertEquals( 1, key.size() );
ksession.update( fd, string );
assertEquals( 1,
tms.getEqualityKeyMap().size() );
key = tms.get( string );
assertSame( fd,
key.getFactHandle() );
assertEquals( 1, key.size() );
ksession.retract( fd );
assertEquals( 0,
tms.getEqualityKeyMap().size() );
key = tms.get( string );
assertNull( key );
fd = ksession.insert( string );
assertEquals( 1,
tms.getEqualityKeyMap().size() );
assertEquals( 1,
tms.getEqualityKeyMap().size() );
key = tms.get( string );
assertSame( fd,
key.getFactHandle() );
assertEquals( 1, key.size() );
}