use of org.apache.geode.internal.cache.RegionEntry in project geode by apache.
the class MemoryIndexStoreJUnitTest method testDescendingIteratorWithRemovedKeysReturnsExpectedOrderOfEntries.
@Test
public void testDescendingIteratorWithRemovedKeysReturnsExpectedOrderOfEntries() throws Exception {
RegionEntry mockEntry1 = mockEntries[0];
RegionEntry mockEntry2 = mockEntries[1];
RegionEntry mockEntry3 = mockEntries[2];
store.addMapping("1", mockEntry1);
store.addMapping("2", mockEntry2);
store.addMapping("3", mockEntry3);
Set keysToRemove = new HashSet();
keysToRemove.add("2");
Iterator iteratorFirst = store.descendingIterator(keysToRemove);
assertEquals(2, numObjectsIterated(iteratorFirst));
// keysToRemove has been modified by the store, we need to readd the key to remove
keysToRemove.add("2");
Iterator iterator = store.descendingIterator(keysToRemove);
iterator.hasNext();
assertEquals(mockEntry3, ((MemoryIndexStore.MemoryIndexStoreEntry) iterator.next()).getRegionEntry());
iterator.hasNext();
assertEquals(mockEntry1, ((MemoryIndexStore.MemoryIndexStoreEntry) iterator.next()).getRegionEntry());
assertFalse(iterator.hasNext());
}
use of org.apache.geode.internal.cache.RegionEntry in project geode by apache.
the class MemoryIndexStoreJUnitTest method testRemoveMappingRemovesFromBackingMap.
@Test
public void testRemoveMappingRemovesFromBackingMap() throws Exception {
RegionEntry mockEntry1 = mockEntries[0];
RegionEntry mockEntry2 = mockEntries[1];
store.addMapping("1", mockEntry1);
store.addMapping("2", mockEntry2);
store.removeMapping("1", mockEntry1);
assertEquals(1, numObjectsInStore(store));
assertTrue(objectContainedIn(store, mockEntry2));
}
use of org.apache.geode.internal.cache.RegionEntry in project geode by apache.
the class MemoryIndexStoreJUnitTest method testGetWithIndexOnKeysReturnsExpectedIteratorValues.
@Test
public void testGetWithIndexOnKeysReturnsExpectedIteratorValues() throws Exception {
RegionEntry mockEntry1 = mockEntries[0];
RegionEntry mockEntry2 = mockEntries[1];
store.setIndexOnValues(false);
store.setIndexOnRegionKeys(true);
store.addMapping("1", mockEntry1);
store.addMapping("2", mockEntry2);
assertEquals(1, numObjectsIterated(store.get("1")));
}
use of org.apache.geode.internal.cache.RegionEntry in project geode by apache.
the class MemoryIndexStoreJUnitTest method testCorrectlyRemovesEntryProvidedTheWrongKey.
@Test
public void testCorrectlyRemovesEntryProvidedTheWrongKey() throws Exception {
RegionEntry mockEntry1 = mockEntries[0];
RegionEntry mockEntry2 = mockEntries[1];
store.addMapping("1", mockEntry1);
store.addMapping("2", mockEntry2);
store.removeMapping("1", mockEntry2);
assertEquals(1, numObjectsInStore(store));
assertTrue(objectContainedIn(store, mockEntry1));
}
use of org.apache.geode.internal.cache.RegionEntry in project geode by apache.
the class MemoryIndexStoreJUnitTest method createRegionEntry.
private RegionEntry createRegionEntry(Object key, Object value) {
RegionEntry mockEntry = mock(RegionEntry.class);
when(mockEntry.getValue(any())).thenReturn(value);
when(mockEntry.getKey()).thenReturn(key);
return mockEntry;
}
Aggregations