use of org.drools.core.util.AbstractHashTable.FieldIndex in project drools by kiegroup.
the class FieldIndexEntryTest method testSingleEntry.
@Test
public void testSingleEntry() {
final ClassFieldReader extractor = store.getReader(Cheese.class, "type");
final FieldIndex fieldIndex = new FieldIndex(extractor, null, MvelConstraint.INDEX_EVALUATOR);
final SingleIndex singleIndex = new SingleIndex(new FieldIndex[] { fieldIndex }, 1);
Tuple tuple = new RightTupleImpl(new DefaultFactHandle(1, new Cheese("stilton", 10)));
final TupleList index = new AbstractHashTable.SingleIndexTupleList(singleIndex, tuple, "stilton".hashCode(), false);
// Test initial construction
assertNull(index.getFirst());
assertEquals("stilton".hashCode(), index.hashCode());
final Cheese stilton1 = new Cheese("stilton", 35);
final InternalFactHandle h1 = new DefaultFactHandle(1, stilton1);
// test add
RightTuple h1RightTuple = new RightTupleImpl(h1, null);
index.add(h1RightTuple);
final Tuple entry1 = index.getFirst();
assertSame(h1, entry1.getFactHandle());
assertNull(entry1.getNext());
assertSame(entry1, index.get(h1));
// test get
final Tuple entry2 = index.get(new RightTupleImpl(h1, null));
assertSame(entry1, entry2);
// test remove
index.remove(h1RightTuple);
assertNull(index.getFirst());
}
Aggregations