null,
equals.getEvaluator( ValueType.STRING_TYPE, Operator.EQUAL ) );
final SingleIndex singleIndex = new SingleIndex( new FieldIndex[]{fieldIndex},
1 );
final RightTupleList index = new RightTupleList( 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 );
RightTuple h1RightTuple = new RightTuple( h1, null );
RightTuple h2RightTuple = new RightTuple( h2, null );
RightTuple h3RightTuple = new RightTuple( h3, null );
// test add
index.add( h1RightTuple );
index.add( h2RightTuple );
index.add( h3RightTuple );
assertEquals( h1,
index.first.getFactHandle() );
assertEquals( h2,
((RightTuple) index.first.getNext()).getFactHandle() );
assertEquals( h3,
((RightTuple) index.first.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( h3RightTuple );
assertEquals( h1,
index.first.getFactHandle() );
assertEquals( h2,
((RightTuple) index.first.getNext()).getFactHandle() );
index.add( h3RightTuple );
index.remove( h2RightTuple );
assertEquals( h1,
index.first.getFactHandle() );
assertEquals( h3,
((RightTuple) index.first.getNext()).getFactHandle() );
index.add( h2RightTuple );
index.remove( h1RightTuple );
assertEquals( h3,
index.first.getFactHandle() );
assertEquals( h2,
((RightTuple) index.first.getNext()).getFactHandle() );
index.remove( index.first );
// check index type does not change, as this fact is removed
stilton2.setType( "cheddar" );
}