use of org.drools.core.util.index.TupleIndexHashTable.FieldIndexHashTableFullIterator in project drools by kiegroup.
the class RightTupleIndexHashTableIteratorTest method testLastBucketInTheTable.
@Test
public void testLastBucketInTheTable() {
// JBRULES-2574
// setup the entry array with an element in the first bucket, one
// in the middle and one in the last bucket
Entry[] entries = new Entry[10];
entries[0] = mock(TupleList.class);
entries[5] = mock(TupleList.class);
entries[9] = mock(TupleList.class);
RightTuple[] tuples = new RightTuple[] { mock(RightTuple.class), mock(RightTuple.class), mock(RightTuple.class) };
// set return values for methods
when(entries[0].getNext()).thenReturn(null);
when(((TupleList) entries[0]).getFirst()).thenReturn(tuples[0]);
when(entries[5].getNext()).thenReturn(null);
when(((TupleList) entries[5]).getFirst()).thenReturn(tuples[1]);
when(entries[9].getNext()).thenReturn(null);
when(((TupleList) entries[9]).getFirst()).thenReturn(tuples[2]);
// create the mock table for the iterator
AbstractHashTable table = mock(AbstractHashTable.class);
when(table.getTable()).thenReturn(entries);
// create the iterator
FieldIndexHashTableFullIterator iterator = new FieldIndexHashTableFullIterator(table);
// test it
assertThat(iterator.next(), sameInstance((Object) tuples[0]));
assertThat(iterator.next(), sameInstance((Object) tuples[1]));
assertThat(iterator.next(), sameInstance((Object) tuples[2]));
assertThat(iterator.next(), is((Object) null));
}
use of org.drools.core.util.index.TupleIndexHashTable.FieldIndexHashTableFullIterator in project drools by kiegroup.
the class LeftLeftTupleIndexHashTableIteratorTest method testLastBucketInTheTable.
@Test
public void testLastBucketInTheTable() {
// JBRULES-2574
// setup the entry array with an element in the first bucket, one
// in the middle and one in the last bucket
Entry[] entries = new Entry[10];
entries[0] = mock(TupleList.class);
entries[5] = mock(TupleList.class);
entries[9] = mock(TupleList.class);
LeftTupleImpl[] tuples = new LeftTupleImpl[] { mock(LeftTupleImpl.class), mock(LeftTupleImpl.class), mock(LeftTupleImpl.class) };
// set return values for methods
when(entries[0].getNext()).thenReturn(null);
when(((TupleList) entries[0]).getFirst()).thenReturn(tuples[0]);
when(entries[5].getNext()).thenReturn(null);
when(((TupleList) entries[5]).getFirst()).thenReturn(tuples[1]);
when(entries[9].getNext()).thenReturn(null);
when(((TupleList) entries[9]).getFirst()).thenReturn(tuples[2]);
// create the mock table for the iterator
AbstractHashTable table = mock(AbstractHashTable.class);
when(table.getTable()).thenReturn(entries);
// create the iterator
FieldIndexHashTableFullIterator iterator = new FieldIndexHashTableFullIterator(table);
// test it
assertThat(iterator.next(), sameInstance((Object) tuples[0]));
assertThat(iterator.next(), sameInstance((Object) tuples[1]));
assertThat(iterator.next(), sameInstance((Object) tuples[2]));
assertThat(iterator.next(), is((Object) null));
}
use of org.drools.core.util.index.TupleIndexHashTable.FieldIndexHashTableFullIterator in project drools by kiegroup.
the class LeftTupleIndexHashTableIteratorTest method testLastBucketInTheTable.
@Test
public void testLastBucketInTheTable() {
// JBRULES-2574
// setup the entry array with an element in the first bucket, one
// in the middle and one in the last bucket
Entry[] entries = new Entry[10];
entries[0] = mock(TupleList.class);
entries[5] = mock(TupleList.class);
entries[9] = mock(TupleList.class);
LeftTupleImpl[] tuples = new LeftTupleImpl[] { mock(LeftTupleImpl.class), mock(LeftTupleImpl.class), mock(LeftTupleImpl.class) };
// set return values for methods
when(entries[0].getNext()).thenReturn(null);
when(((TupleList) entries[0]).getFirst()).thenReturn(tuples[0]);
when(entries[5].getNext()).thenReturn(null);
when(((TupleList) entries[5]).getFirst()).thenReturn(tuples[1]);
when(entries[9].getNext()).thenReturn(null);
when(((TupleList) entries[9]).getFirst()).thenReturn(tuples[2]);
// create the mock table for the iterator
AbstractHashTable table = mock(AbstractHashTable.class);
when(table.getTable()).thenReturn(entries);
// create the iterator
FieldIndexHashTableFullIterator iterator = new FieldIndexHashTableFullIterator(table);
// test it
assertThat(iterator.next(), sameInstance((Object) tuples[0]));
assertThat(iterator.next(), sameInstance((Object) tuples[1]));
assertThat(iterator.next(), sameInstance((Object) tuples[2]));
assertThat(iterator.next(), is((Object) null));
}
use of org.drools.core.util.index.TupleIndexHashTable.FieldIndexHashTableFullIterator in project drools by kiegroup.
the class RightTupleIndexHashTableIteratorTest method testLastBucketInTheTable.
@Test
public void testLastBucketInTheTable() {
// JBRULES-2574
// setup the entry array with an element in the first bucket, one
// in the middle and one in the last bucket
Entry[] entries = new Entry[10];
entries[0] = mock(TupleList.class);
entries[5] = mock(TupleList.class);
entries[9] = mock(TupleList.class);
RightTuple[] tuples = new RightTuple[] { mock(RightTuple.class), mock(RightTuple.class), mock(RightTuple.class) };
// set return values for methods
when(entries[0].getNext()).thenReturn(null);
when(((TupleList) entries[0]).getFirst()).thenReturn(tuples[0]);
when(entries[5].getNext()).thenReturn(null);
when(((TupleList) entries[5]).getFirst()).thenReturn(tuples[1]);
when(entries[9].getNext()).thenReturn(null);
when(((TupleList) entries[9]).getFirst()).thenReturn(tuples[2]);
// create the mock table for the iterator
AbstractHashTable table = mock(AbstractHashTable.class);
when(table.getTable()).thenReturn(entries);
// create the iterator
FieldIndexHashTableFullIterator iterator = new FieldIndexHashTableFullIterator(table);
// test it
assertThat(iterator.next(), sameInstance((Object) tuples[0]));
assertThat(iterator.next(), sameInstance((Object) tuples[1]));
assertThat(iterator.next(), sameInstance((Object) tuples[2]));
assertThat(iterator.next(), is((Object) null));
}
Aggregations