Search in sources :

Example 11 with ObjectTypeImpl

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));
}
Also used : ArrayList(java.util.ArrayList) ObjectTypeImpl(org.apache.geode.cache.query.internal.types.ObjectTypeImpl) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 12 with ObjectTypeImpl

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));
}
Also used : ArrayList(java.util.ArrayList) ObjectTypeImpl(org.apache.geode.cache.query.internal.types.ObjectTypeImpl) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 13 with ObjectTypeImpl

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)));
}
Also used : ObjectTypeImpl(org.apache.geode.cache.query.internal.types.ObjectTypeImpl) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 14 with ObjectTypeImpl

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());
}
Also used : ArrayList(java.util.ArrayList) ObjectTypeImpl(org.apache.geode.cache.query.internal.types.ObjectTypeImpl) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 15 with ObjectTypeImpl

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));
}
Also used : ArrayList(java.util.ArrayList) ObjectTypeImpl(org.apache.geode.cache.query.internal.types.ObjectTypeImpl) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Aggregations

ObjectTypeImpl (org.apache.geode.cache.query.internal.types.ObjectTypeImpl)53 Test (org.junit.Test)37 SelectResults (org.apache.geode.cache.query.SelectResults)31 ArrayList (java.util.ArrayList)27 Portfolio (org.apache.geode.cache.query.data.Portfolio)27 QueryService (org.apache.geode.cache.query.QueryService)25 ObjectType (org.apache.geode.cache.query.types.ObjectType)25 List (java.util.List)24 Query (org.apache.geode.cache.query.Query)24 Region (org.apache.geode.cache.Region)23 QueryObserverAdapter (org.apache.geode.cache.query.internal.QueryObserverAdapter)23 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)20 UnitTest (org.apache.geode.test.junit.categories.UnitTest)17 Index (org.apache.geode.cache.query.Index)16 StructTypeImpl (org.apache.geode.cache.query.internal.types.StructTypeImpl)14 Collection (java.util.Collection)11 Iterator (java.util.Iterator)10 ResultsBag (org.apache.geode.cache.query.internal.ResultsBag)8 ResultsCollectionWrapper (org.apache.geode.cache.query.internal.ResultsCollectionWrapper)8 AttributesFactory (org.apache.geode.cache.AttributesFactory)7