null,
StringFactory.getInstance().getEvaluator( Operator.EQUAL ) );
final SingleIndex singleIndex = new SingleIndex( new FieldIndex[]{fieldIndex},
1 );
final FieldIndexEntry index = new FieldIndexEntry( singleIndex,
"stilton".hashCode() );
final Cheese stilton1 = new Cheese( "stilton",
35 );
final InternalFactHandle h1 = new DefaultFactHandle( 1,
stilton1 );
final Cheese stilton2 = new Cheese( "stilton",
59 );
final InternalFactHandle h2 = new DefaultFactHandle( 2,
stilton2 );
final Cheese stilton3 = new Cheese( "stilton",
59 );
final InternalFactHandle h3 = new DefaultFactHandle( 3,
stilton3 );
// test add
index.add( h1 );
index.add( h2 );
index.add( h3 );
assertEquals( h3,
index.getFirst().getFactHandle() );
assertEquals( h2,
((FactEntryImpl) index.getFirst().getNext()).getFactHandle() );
assertEquals( h1,
((FactEntryImpl) index.getFirst().getNext().getNext()).getFactHandle() );
// test get
assertEquals( h1,
index.get( h1 ).getFactHandle() );
assertEquals( h2,
index.get( h2 ).getFactHandle() );
assertEquals( h3,
index.get( h3 ).getFactHandle() );
// test removal for combinations
//remove first
index.remove( h3 );
assertEquals( h2,
index.getFirst().getFactHandle() );
assertEquals( h1,
((FactEntryImpl) index.getFirst().getNext()).getFactHandle() );
index.add( h3 );
index.remove( h2 );
assertEquals( h3,
index.getFirst().getFactHandle() );
assertEquals( h1,
((FactEntryImpl) index.getFirst().getNext()).getFactHandle() );
index.add( h2 );
index.remove( h1 );
assertEquals( h2,
index.getFirst().getFactHandle() );
assertEquals( h3,
((FactEntryImpl) index.getFirst().getNext()).getFactHandle() );
index.remove( index.getFirst().getFactHandle() );
// check index type does not change, as this fact is removed
stilton2.setType( "cheddar" );
}