Search in sources :

Example 31 with Position

use of org.apache.geode.cache.query.data.Position in project geode by apache.

the class IUMJUnitTest method testWithOutIndexCreatedMultiCondQueryTest.

@Test
public void testWithOutIndexCreatedMultiCondQueryTest() throws Exception {
    Region region = CacheUtils.createRegion("portfolios", Portfolio.class);
    for (int i = 0; i < 4; i++) {
        region.put("" + i, new Portfolio(i));
    // CacheUtils.log(new Portfolio(i));
    }
    CacheUtils.getQueryService();
    String[] queries = { "SELECT DISTINCT * from /portfolios pf , pf.positions.values pos where pos.getSecId = 'IBM' and status = 'inactive'" };
    for (int i = 0; i < queries.length; i++) {
        Query q = null;
        try {
            q = CacheUtils.getQueryService().newQuery(queries[i]);
            Object r3 = q.execute();
            resType3 = (StructType) ((SelectResults) r3).getCollectionType().getElementType();
            resSize3 = (((SelectResults) r3).size());
            // CacheUtils.log(resType3);
            strg3 = resType3.getFieldNames();
            // CacheUtils.log(strg3[0]);
            // CacheUtils.log(strg2[1]);
            set3 = (((SelectResults) r3).asSet());
            Iterator iter = set3.iterator();
            while (iter.hasNext()) {
                Struct stc3 = (Struct) iter.next();
                valPf2 = stc3.get(strg3[0]);
                valPos2 = stc3.get(strg3[1]);
                isActive3 = ((Portfolio) stc3.get(strg3[0])).isActive();
            // CacheUtils.log(valPf2);
            // CacheUtils.log(valPos2);
            }
        } catch (Exception e) {
            e.printStackTrace();
            fail(q.getQueryString());
        }
    }
    itert3 = set3.iterator();
    while (itert3.hasNext()) {
        Struct stc3 = (Struct) itert3.next();
        if (!((Position) stc3.get(strg3[1])).secId.equals("IBM"))
            fail("FAILED:  secId found is not IBM");
        if (((Portfolio) stc3.get(strg3[0])).isActive() != false)
            fail("FAILED:Portfolio in Search result is Active");
    }
}
Also used : SelectResults(org.apache.geode.cache.query.SelectResults) Query(org.apache.geode.cache.query.Query) Position(org.apache.geode.cache.query.data.Position) Portfolio(org.apache.geode.cache.query.data.Portfolio) Iterator(java.util.Iterator) Region(org.apache.geode.cache.Region) Struct(org.apache.geode.cache.query.Struct) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

Position (org.apache.geode.cache.query.data.Position)31 Portfolio (org.apache.geode.cache.query.data.Portfolio)30 Region (org.apache.geode.cache.Region)27 SelectResults (org.apache.geode.cache.query.SelectResults)27 Test (org.junit.Test)26 Query (org.apache.geode.cache.query.Query)24 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)23 Index (org.apache.geode.cache.query.Index)20 LocalRegion (org.apache.geode.internal.cache.LocalRegion)14 QueryService (org.apache.geode.cache.query.QueryService)12 Struct (org.apache.geode.cache.query.Struct)9 QueryObserver (org.apache.geode.cache.query.internal.QueryObserver)9 Iterator (java.util.Iterator)8 HashMap (java.util.HashMap)5 CacheException (org.apache.geode.cache.CacheException)5 Properties (java.util.Properties)3 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)3 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)3 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)3 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)3