use of org.apache.geode.cache.query.internal.types.ObjectTypeImpl in project geode by apache.
the class ResultsCollectionWrapperLimitJUnitTest method testAsList.
@Test
public void testAsList() {
List ordered = new ArrayList();
for (int i = 1; i < 11; ++i) {
ordered.add(new Integer(i));
}
ResultsCollectionWrapper wrapper = new ResultsCollectionWrapper(new ObjectTypeImpl(Object.class), ordered, 5);
List toList = wrapper.asList();
List newList = new ArrayList();
for (int i = 1; i < 6; ++i) {
newList.add(new Integer(i));
}
assertEquals(newList.size(), toList.size());
assertTrue(newList.containsAll(toList));
ordered = new ArrayList();
for (int i = 1; i < 11; ++i) {
ordered.add(new Integer(i));
}
wrapper = new ResultsCollectionWrapper(new ObjectTypeImpl(Object.class), ordered, 2);
toList = wrapper.asList();
newList = new ArrayList();
for (int i = 1; i < 3; ++i) {
newList.add(new Integer(i));
}
assertEquals(newList.size(), toList.size());
assertTrue(newList.containsAll(toList));
}
use of org.apache.geode.cache.query.internal.types.ObjectTypeImpl in project geode by apache.
the class ResultsCollectionWrapperLimitJUnitTest method testRemove.
@Test
public void testRemove() {
List ordered = new ArrayList();
for (int i = 1; i < 11; ++i) {
ordered.add(new Integer(i));
}
ResultsCollectionWrapper wrapper = new ResultsCollectionWrapper(new ObjectTypeImpl(Object.class), ordered, 5);
assertFalse(wrapper.remove(new Integer(6)));
assertTrue(wrapper.remove(new Integer(4)));
assertEquals(4, wrapper.size());
List newList = new ArrayList();
for (int i = 1; i < 6; ++i) {
newList.add(new Integer(i));
}
newList.remove(3);
assertTrue(wrapper.containsAll(newList));
}
use of org.apache.geode.cache.query.internal.types.ObjectTypeImpl in project geode by apache.
the class ResultsCollectionWrapperLimitJUnitTest method testContains.
@Test
public void testContains() {
// Create a Collection of unordered data elements
HashSet unordered = new HashSet();
for (int i = 1; i < 11; ++i) {
unordered.add(new Integer(i));
}
ResultsCollectionWrapper wrapper = new ResultsCollectionWrapper(new ObjectTypeImpl(Object.class), unordered, 15);
assertTrue(wrapper.contains(new Integer(10)));
assertFalse(wrapper.contains(new Integer(11)));
List ordered = new ArrayList();
for (int i = 1; i < 11; ++i) {
ordered.add(new Integer(i));
}
wrapper = new ResultsCollectionWrapper(new ObjectTypeImpl(Object.class), ordered, 20);
assertTrue(wrapper.contains(new Integer(10)));
assertFalse(wrapper.contains(new Integer(11)));
wrapper = new ResultsCollectionWrapper(new ObjectTypeImpl(Object.class), ordered, 5);
assertTrue(wrapper.contains(new Integer(1)));
}
use of org.apache.geode.cache.query.internal.types.ObjectTypeImpl in project geode by apache.
the class ResultsCollectionWrapperLimitJUnitTest method testRetainAll.
@Test
public void testRetainAll() {
List ordered = new ArrayList();
for (int i = 1; i < 11; ++i) {
ordered.add(new Integer(i));
}
ResultsCollectionWrapper wrapper = new ResultsCollectionWrapper(new ObjectTypeImpl(Object.class), ordered, 5);
List newList = new ArrayList();
for (int i = 1; i < 6; ++i) {
newList.add(new Integer(i));
}
assertFalse(wrapper.retainAll(newList));
assertEquals(5, wrapper.size());
for (int i = 6; i < 11; ++i) {
newList.add(new Integer(i));
}
assertFalse(wrapper.retainAll(newList));
assertEquals(5, wrapper.size());
for (int i = 1; i < 6; ++i) {
newList.remove(0);
}
assertTrue(wrapper.retainAll(newList));
assertEquals(0, wrapper.size());
Iterator itr = wrapper.iterator();
assertFalse(itr.hasNext());
}
use of org.apache.geode.cache.query.internal.types.ObjectTypeImpl in project geode by apache.
the class ResultsCollectionWrapperLimitJUnitTest method testContainsAll.
@Test
public void testContainsAll() {
List ordered = new ArrayList();
for (int i = 1; i < 11; ++i) {
ordered.add(new Integer(i));
}
ResultsCollectionWrapper wrapper = new ResultsCollectionWrapper(new ObjectTypeImpl(Object.class), ordered, 5);
assertFalse(wrapper.containsAll(ordered));
List newList = new ArrayList();
for (int i = 0; i < 5; ++i) {
newList.add(ordered.get(4 - i));
}
assertTrue(wrapper.containsAll(newList));
}
Aggregations