usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [1/2] incubator-usergrid git commit: Removed obsolete query object. Now a single utility builder and a ParsedQuery that represents our result
Date Wed, 01 Apr 2015 22:35:37 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-536 [created] 2699dd30f


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2699dd30/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index 1fc9237..b28fb54 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -22,15 +22,16 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.usergrid.persistence.index.*;
-import org.junit.*;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -42,9 +43,14 @@ import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
 import org.apache.usergrid.persistence.core.test.UseModules;
 import org.apache.usergrid.persistence.core.util.Health;
+import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
+import org.apache.usergrid.persistence.index.EntityIndex;
+import org.apache.usergrid.persistence.index.EntityIndexBatch;
+import org.apache.usergrid.persistence.index.EntityIndexFactory;
+import org.apache.usergrid.persistence.index.IndexScope;
+import org.apache.usergrid.persistence.index.SearchTypes;
 import org.apache.usergrid.persistence.index.guice.TestIndexModule;
 import org.apache.usergrid.persistence.index.query.CandidateResults;
-import org.apache.usergrid.persistence.index.query.Query;
 import org.apache.usergrid.persistence.index.utils.UUIDUtils;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
@@ -69,8 +75,8 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 
-@RunWith(EsRunner.class)
-@UseModules({ TestIndexModule.class })
+@RunWith( EsRunner.class )
+@UseModules( { TestIndexModule.class } )
 public class EntityIndexTest extends BaseIT {
 
     private static final Logger log = LoggerFactory.getLogger( EntityIndexTest.class );
@@ -85,69 +91,73 @@ public class EntityIndexTest extends BaseIT {
     @Rule
     public MigrationManagerRule migrationManagerRule;
 
+
     @Before
-    public  void setup(){
+    public void setup() {
         ei.initialize();
     }
 
+
     @Test
     public void testIndex() throws IOException, InterruptedException {
-        Id appId = new SimpleId("application");
+        Id appId = new SimpleId( "application" );
 
-        ApplicationScope applicationScope = new ApplicationScopeImpl(appId);
-        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
+        ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
+        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
 
 
         final String entityType = "thing";
-        IndexScope indexScope = new IndexScopeImpl(appId, "things");
-        final SearchTypes searchTypes = SearchTypes.fromTypes(entityType);
+        IndexScope indexScope = new IndexScopeImpl( appId, "things" );
+        final SearchTypes searchTypes = SearchTypes.fromTypes( entityType );
 
-        insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json", 101, 0);
+        insertJsonBlob( entityIndex, entityType, indexScope, "/sample-large.json", 101, 0 );
 
         ei.refresh();
 
-        testQueries(indexScope, searchTypes, entityIndex);
+        testQueries( indexScope, searchTypes, entityIndex );
     }
 
+
     @Test
-    @Ignore("this is a problem i will work on when i can breathe")
+    @Ignore( "this is a problem i will work on when i can breathe" )
     public void testIndexVariations() throws IOException {
         Id appId = new SimpleId( "application" );
 
         ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
 
-        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
+        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
 
         final String entityType = "thing";
         IndexScope indexScope = new IndexScopeImpl( appId, "things" );
-        final SearchTypes searchTypes = SearchTypes.fromTypes(entityType);
+        final SearchTypes searchTypes = SearchTypes.fromTypes( entityType );
         EntityIndexBatch batch = entityIndex.createBatch();
         Entity entity = new Entity( entityType );
-        EntityUtils.setVersion(entity, UUIDGenerator.newTimeUUID());
-        entity.setField(new UUIDField(IndexingUtils.ENTITYID_ID_FIELDNAME, UUID.randomUUID()));
-        entity.setField(new StringField("testfield","test"));
-        batch.index(indexScope, entity);
+        EntityUtils.setVersion( entity, UUIDGenerator.newTimeUUID() );
+        entity.setField( new UUIDField( IndexingUtils.ENTITYID_ID_FIELDNAME, UUID.randomUUID() ) );
+        entity.setField( new StringField( "testfield", "test" ) );
+        batch.index( indexScope, entity );
         batch.execute().get();
 
-        EntityUtils.setVersion(entity, UUIDGenerator.newTimeUUID());
+        EntityUtils.setVersion( entity, UUIDGenerator.newTimeUUID() );
         List<String> list = new ArrayList<>();
-        list.add("test");
-        entity.setField(new ArrayField<String>("testfield", list));
-        batch.index(indexScope, entity);
+        list.add( "test" );
+        entity.setField( new ArrayField<String>( "testfield", list ) );
+        batch.index( indexScope, entity );
         batch.execute().get();
 
-        EntityUtils.setVersion(entity, UUIDGenerator.newTimeUUID());
+        EntityUtils.setVersion( entity, UUIDGenerator.newTimeUUID() );
         EntityObject testObj = new EntityObject();
-        testObj.setField(new StringField("test","testFiedl"));
-        entity.setField(new EntityObjectField("testfield", testObj));
-        batch.index(indexScope, entity);
+        testObj.setField( new StringField( "test", "testFiedl" ) );
+        entity.setField( new EntityObjectField( "testfield", testObj ) );
+        batch.index( indexScope, entity );
         batch.execute().get();
 
         ei.refresh();
 
-        testQueries(indexScope, searchTypes, entityIndex);
+        testQueries( indexScope, searchTypes, entityIndex );
     }
 
+
     @Test
     public void testIndexThreads() throws IOException {
         final Id appId = new SimpleId( "application" );
@@ -157,90 +167,95 @@ public class EntityIndexTest extends BaseIT {
         long now = System.currentTimeMillis();
         final int threads = 20;
         final int size = 30;
-        final ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
-        final IndexScope indexScope = new IndexScopeImpl(appId, "things");
+        final ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
+        final IndexScope indexScope = new IndexScopeImpl( appId, "things" );
         final String entityType = "thing";
 
-        final CountDownLatch latch = new CountDownLatch(threads);
-        final AtomicLong failTime=new AtomicLong(0);
-        InputStream is = this.getClass().getResourceAsStream(  "/sample-large.json" );
+        final CountDownLatch latch = new CountDownLatch( threads );
+        final AtomicLong failTime = new AtomicLong( 0 );
+        InputStream is = this.getClass().getResourceAsStream( "/sample-large.json" );
         ObjectMapper mapper = new ObjectMapper();
         final List<Object> sampleJson = mapper.readValue( is, new TypeReference<List<Object>>() {} );
-        for(int i=0;i<threads;i++) {
-            Thread thread = new Thread(new Runnable() {
+        for ( int i = 0; i < threads; i++ ) {
+            Thread thread = new Thread( new Runnable() {
                 public void run() {
                     try {
                         EntityIndexBatch batch = entityIndex.createBatch();
-                        insertJsonBlob(sampleJson,batch, entityType, indexScope, size, 0);
+                        insertJsonBlob( sampleJson, batch, entityType, indexScope, size, 0 );
                         batch.execute().get();
-                    } catch (Exception e) {
-                        synchronized (failTime) {
-                            if (failTime.get() == 0) {
-                                failTime.set(System.currentTimeMillis());
+                    }
+                    catch ( Exception e ) {
+                        synchronized ( failTime ) {
+                            if ( failTime.get() == 0 ) {
+                                failTime.set( System.currentTimeMillis() );
                             }
                         }
-                        System.out.println(e.toString());
-                        fail("threw exception");
-                    }finally {
+                        System.out.println( e.toString() );
+                        fail( "threw exception" );
+                    }
+                    finally {
                         latch.countDown();
                     }
                 }
-            });
+            } );
             thread.start();
         }
         try {
             latch.await();
-        }catch (InterruptedException ie){
-            throw new RuntimeException(ie);
         }
-        assertTrue("system must have failed at " + (failTime.get() - now), failTime.get() == 0);
+        catch ( InterruptedException ie ) {
+            throw new RuntimeException( ie );
+        }
+        assertTrue( "system must have failed at " + ( failTime.get() - now ), failTime.get() == 0 );
     }
 
+
     @Test
-    public void testMultipleIndexInitializations(){
+    public void testMultipleIndexInitializations() {
         Id appId = new SimpleId( "application" );
 
         ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
 
-        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
+        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
 
-        for(int i=0;i<10;i++) {
+        for ( int i = 0; i < 10; i++ ) {
 
         }
-
     }
 
+
     @Test
     public void testAddMultipleIndexes() throws IOException {
         Id appId = new SimpleId( "application" );
 
         ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
 
-        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
+        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
 
 
         final String entityType = "thing";
         IndexScope indexScope = new IndexScopeImpl( appId, "things" );
-        final SearchTypes searchTypes = SearchTypes.fromTypes(entityType);
+        final SearchTypes searchTypes = SearchTypes.fromTypes( entityType );
 
-        insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",101,0);
+        insertJsonBlob( entityIndex, entityType, indexScope, "/sample-large.json", 101, 0 );
 
-       ei.refresh();
+        ei.refresh();
 
-        testQueries(indexScope, searchTypes, entityIndex);
+        testQueries( indexScope, searchTypes, entityIndex );
 
-        ei.addIndex("v2", 1, 0, "one");
+        ei.addIndex( "v2", 1, 0, "one" );
 
-        insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json", 101, 100);
+        insertJsonBlob( entityIndex, entityType, indexScope, "/sample-large.json", 101, 100 );
 
-       ei.refresh();
+        ei.refresh();
 
         //Hilda Youn
-        testQuery(indexScope, searchTypes, entityIndex, "name = 'Hilda Young'", 1 );
+        testQuery( indexScope, searchTypes, entityIndex, "name = 'Hilda Young'", 1 );
 
-        testQuery(indexScope, searchTypes, entityIndex, "name = 'Lowe Kelley'", 1 );
+        testQuery( indexScope, searchTypes, entityIndex, "name = 'Lowe Kelley'", 1 );
     }
 
+
     @Test
     public void testDeleteWithAlias() throws IOException {
         Id appId = new SimpleId( "application" );
@@ -254,46 +269,50 @@ public class EntityIndexTest extends BaseIT {
         IndexScope indexScope = new IndexScopeImpl( appId, "things" );
         final SearchTypes searchTypes = SearchTypes.fromTypes( entityType );
 
-        insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",1,0);
+        insertJsonBlob( entityIndex, entityType, indexScope, "/sample-large.json", 1, 0 );
 
         ei.refresh();
 
-        ei.addIndex("v2", 1, 0, "one");
+        ei.addIndex( "v2", 1, 0, "one" );
 
-        insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json", 1, 0);
+        insertJsonBlob( entityIndex, entityType, indexScope, "/sample-large.json", 1, 0 );
 
         ei.refresh();
-        CandidateResults crs = testQuery(indexScope, searchTypes, entityIndex, "name = 'Bowers Oneil'", 2);
+        CandidateResults crs = testQuery( indexScope, searchTypes, entityIndex, "name = 'Bowers Oneil'", 2 );
 
         EntityIndexBatch entityIndexBatch = entityIndex.createBatch();
-        entityIndexBatch.deindex(indexScope, crs.get(0));
-        entityIndexBatch.deindex(indexScope, crs.get(1));
+        entityIndexBatch.deindex( indexScope, crs.get( 0 ) );
+        entityIndexBatch.deindex( indexScope, crs.get( 1 ) );
         entityIndexBatch.execute().get();
         ei.refresh();
 
         //Hilda Youn
-        testQuery(indexScope, searchTypes, entityIndex, "name = 'Bowers Oneil'", 0);
-
+        testQuery( indexScope, searchTypes, entityIndex, "name = 'Bowers Oneil'", 0 );
     }
-    private void insertJsonBlob(ApplicationEntityIndex entityIndex, String entityType, IndexScope indexScope, String filePath,final int max,final int startIndex) throws IOException {
+
+
+    private void insertJsonBlob( ApplicationEntityIndex entityIndex, String entityType, IndexScope indexScope,
+                                 String filePath, final int max, final int startIndex ) throws IOException {
         InputStream is = this.getClass().getResourceAsStream( filePath );
         ObjectMapper mapper = new ObjectMapper();
         List<Object> sampleJson = mapper.readValue( is, new TypeReference<List<Object>>() {} );
         EntityIndexBatch batch = entityIndex.createBatch();
-        insertJsonBlob(sampleJson,batch, entityType, indexScope, max, startIndex);
+        insertJsonBlob( sampleJson, batch, entityType, indexScope, max, startIndex );
         batch.execute().get();
         ei.refresh();
     }
 
-    private void insertJsonBlob(List<Object> sampleJson, EntityIndexBatch batch, String entityType, IndexScope indexScope,final int max,final int startIndex) throws IOException {
+
+    private void insertJsonBlob( List<Object> sampleJson, EntityIndexBatch batch, String entityType,
+                                 IndexScope indexScope, final int max, final int startIndex ) throws IOException {
         int count = 0;
         StopWatch timer = new StopWatch();
         timer.start();
 
 
-        if(startIndex > 0){
-            for(int i =0; i<startIndex;i++){
-                sampleJson.remove(0);
+        if ( startIndex > 0 ) {
+            for ( int i = 0; i < startIndex; i++ ) {
+                sampleJson.remove( 0 );
             }
         }
 
@@ -302,10 +321,10 @@ public class EntityIndexTest extends BaseIT {
             Map<String, Object> item = ( Map<String, Object> ) o;
 
             Entity entity = new Entity( entityType );
-            entity = EntityIndexMapUtils.fromMap(entity, item);
-            EntityUtils.setVersion(entity, UUIDGenerator.newTimeUUID());
-            entity.setField(new UUIDField(IndexingUtils.ENTITYID_ID_FIELDNAME, UUID.randomUUID()));
-            batch.index(indexScope, entity);
+            entity = EntityIndexMapUtils.fromMap( entity, item );
+            EntityUtils.setVersion( entity, UUIDGenerator.newTimeUUID() );
+            entity.setField( new UUIDField( IndexingUtils.ENTITYID_ID_FIELDNAME, UUID.randomUUID() ) );
+            batch.index( indexScope, entity );
             batch.execute().get();
 
 
@@ -315,8 +334,8 @@ public class EntityIndexTest extends BaseIT {
         }
 
         timer.stop();
-        log.info("Total time to index {} entries {}ms, average {}ms/entry",
-                new Object[]{count, timer.getTime(), timer.getTime() / count } );
+        log.info( "Total time to index {} entries {}ms, average {}ms/entry",
+                new Object[] { count, timer.getTime(), timer.getTime() / count } );
     }
 
 
@@ -329,7 +348,7 @@ public class EntityIndexTest extends BaseIT {
 
         IndexScope indexScope = new IndexScopeImpl( appId, "fastcars" );
 
-        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
+        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
 
 
         Map entityMap = new HashMap() {{
@@ -342,68 +361,73 @@ public class EntityIndexTest extends BaseIT {
         Entity entity = EntityIndexMapUtils.fromMap( entityMap );
         EntityUtils.setId( entity, new SimpleId( "fastcar" ) );
         EntityUtils.setVersion( entity, UUIDGenerator.newTimeUUID() );
-        entity.setField(new UUIDField(IndexingUtils.ENTITYID_ID_FIELDNAME, UUID.randomUUID()));
+        entity.setField( new UUIDField( IndexingUtils.ENTITYID_ID_FIELDNAME, UUID.randomUUID() ) );
 
-        entityIndex.createBatch().index(indexScope , entity ).execute().get();
+        entityIndex.createBatch().index( indexScope, entity ).execute().get();
         ei.refresh();
 
-        CandidateResults candidateResults = entityIndex.search( indexScope,
-            SearchTypes.fromTypes( entity.getId().getType() ), Query.fromQL( "name contains 'Ferrari*'" ) );
+        CandidateResults candidateResults = entityIndex
+                .search( indexScope, SearchTypes.fromTypes( entity.getId().getType() ), "name contains 'Ferrari*'",
+                        10 );
         assertEquals( 1, candidateResults.size() );
 
         EntityIndexBatch batch = entityIndex.createBatch();
-        batch.deindex(indexScope, entity).execute().get();
+        batch.deindex( indexScope, entity ).execute().get();
         batch.execute().get();
         ei.refresh();
 
-        candidateResults = entityIndex.search( indexScope, SearchTypes.fromTypes(entity.getId().getType()), Query.fromQL( "name contains 'Ferrari*'" ) );
+        candidateResults = entityIndex
+                .search( indexScope, SearchTypes.fromTypes( entity.getId().getType() ), "name contains 'Ferrari*'",
+                        10 );
         assertEquals( 0, candidateResults.size() );
     }
 
 
-    private CandidateResults testQuery(final IndexScope scope, final SearchTypes searchTypes, final ApplicationEntityIndex entityIndex, final String queryString, final int num ) {
+    private CandidateResults testQuery( final IndexScope scope, final SearchTypes searchTypes,
+                                        final ApplicationEntityIndex entityIndex, final String queryString,
+                                        final int num ) {
 
         StopWatch timer = new StopWatch();
         timer.start();
-        Query query = Query.fromQL( queryString );
         CandidateResults candidateResults = null;
-        candidateResults = entityIndex.search( scope, searchTypes, query,num+1 );
+        candidateResults = entityIndex.search( scope, searchTypes, queryString, num + 1 );
 
         timer.stop();
 
-        assertEquals( num,candidateResults.size() );
+        assertEquals( num, candidateResults.size() );
         log.debug( "Query time {}ms", timer.getTime() );
         return candidateResults;
     }
 
 
-    private void testQueries(final IndexScope scope, SearchTypes searchTypes, final ApplicationEntityIndex entityIndex ) {
+    private void testQueries( final IndexScope scope, SearchTypes searchTypes,
+                              final ApplicationEntityIndex entityIndex ) {
 
-        testQuery(scope, searchTypes, entityIndex, "name = 'Morgan Pierce'", 1 );
+        testQuery( scope, searchTypes, entityIndex, "name = 'Morgan Pierce'", 1 );
 
-        testQuery(scope, searchTypes, entityIndex, "name = 'morgan pierce'", 1 );
+        testQuery( scope, searchTypes, entityIndex, "name = 'morgan pierce'", 1 );
 
-        testQuery(scope, searchTypes, entityIndex, "name = 'Morgan'", 0 );
+        testQuery( scope, searchTypes, entityIndex, "name = 'Morgan'", 0 );
 
-        testQuery(scope, searchTypes, entityIndex, "name contains 'Morgan'", 1 );
+        testQuery( scope, searchTypes, entityIndex, "name contains 'Morgan'", 1 );
 
-        testQuery(scope, searchTypes, entityIndex, "company > 'GeoLogix'", 64 );
+        testQuery( scope, searchTypes, entityIndex, "company > 'GeoLogix'", 64 );
 
-        testQuery(scope, searchTypes, entityIndex, "gender = 'female'", 45 );
+        testQuery( scope, searchTypes, entityIndex, "gender = 'female'", 45 );
 
-        testQuery(scope, searchTypes, entityIndex, "name = 'Minerva Harrell' and age > 39", 1 );
+        testQuery( scope, searchTypes, entityIndex, "name = 'Minerva Harrell' and age > 39", 1 );
 
-        testQuery(scope, searchTypes, entityIndex, "name = 'Minerva Harrell' and age > 39 and age < 41", 1 );
+        testQuery( scope, searchTypes, entityIndex, "name = 'Minerva Harrell' and age > 39 and age < 41", 1 );
 
-        testQuery(scope, searchTypes, entityIndex, "name = 'Minerva Harrell' and age > 40", 0 );
+        testQuery( scope, searchTypes, entityIndex, "name = 'Minerva Harrell' and age > 40", 0 );
 
-        testQuery(scope, searchTypes, entityIndex, "name = 'Minerva Harrell' and age >= 40", 1 );
+        testQuery( scope, searchTypes, entityIndex, "name = 'Minerva Harrell' and age >= 40", 1 );
 
-        testQuery(scope, searchTypes, entityIndex, "name = 'Minerva Harrell' and age <= 40", 1 );
+        testQuery( scope, searchTypes, entityIndex, "name = 'Minerva Harrell' and age <= 40", 1 );
 
-        testQuery(scope, searchTypes, entityIndex, "name = 'Morgan* '", 1 );
+        testQuery( scope, searchTypes, entityIndex, "name = 'Morgan* '", 1 );
 
-        testQuery(scope, searchTypes, entityIndex, "name = 'Morgan*'", 1 );
+        testQuery( scope, searchTypes, entityIndex, "name = 'Morgan*'", 1 );
 
 
         // test a couple of array sub-property queries
@@ -411,17 +435,16 @@ public class EntityIndexTest extends BaseIT {
         int totalUsers = 102;
 
         // nobody has a friend named Jack the Ripper
-        testQuery(scope, searchTypes, entityIndex, "friends.name = 'Jack the Ripper'", 0 );
+        testQuery( scope, searchTypes, entityIndex, "friends.name = 'Jack the Ripper'", 0 );
 
         // everybody doesn't have a friend named Jack the Ripper
-        testQuery(scope,  searchTypes,entityIndex, "not (friends.name = 'Jack the Ripper')", totalUsers );
+        testQuery( scope, searchTypes, entityIndex, "not (friends.name = 'Jack the Ripper')", totalUsers );
 
         // one person has a friend named Shari Hahn
-        testQuery(scope, searchTypes, entityIndex, "friends.name = 'Wendy Moody'", 1 );
+        testQuery( scope, searchTypes, entityIndex, "friends.name = 'Wendy Moody'", 1 );
 
         // everybody but 1 doesn't have a friend named Shari Hahh
-        testQuery(scope, searchTypes, entityIndex, "not (friends.name = 'Shari Hahn')", totalUsers - 1);
-
+        testQuery( scope, searchTypes, entityIndex, "not (friends.name = 'Shari Hahn')", totalUsers - 1 );
     }
 
 
@@ -451,6 +474,7 @@ public class EntityIndexTest extends BaseIT {
         }
     }
 
+
     @Test
     public void deleteVerification() throws Throwable {
 
@@ -461,7 +485,7 @@ public class EntityIndexTest extends BaseIT {
 
         IndexScope appScope = new IndexScopeImpl( ownerId, "user" );
 
-        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
+        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
 
 
         final String middleName = "middleName" + UUIDUtils.newTimeUUID();
@@ -479,28 +503,28 @@ public class EntityIndexTest extends BaseIT {
 
         EntityIndexBatch batch = entityIndex.createBatch();
 
-        batch.index( appScope, user);
+        batch.index( appScope, user );
         batch.execute().get();
         ei.refresh();
 
-        Query query = new Query();
-        query.addEqualityFilter( "username", "edanuff" );
-        CandidateResults r = entityIndex.search( appScope, SearchTypes.fromTypes( "edanuff" ), query );
+        final String query = "where username = 'edanuff'";
+
+        CandidateResults r = entityIndex.search( appScope, SearchTypes.fromTypes( "edanuff" ), query, 10 );
         assertEquals( user.getId(), r.get( 0 ).getId() );
 
-        batch.deindex(appScope, user.getId(), user.getVersion() );
+        batch.deindex( appScope, user.getId(), user.getVersion() );
         batch.execute().get();
         ei.refresh();
 
         // EntityRef
-        query = new Query();
-        query.addEqualityFilter( "username", "edanuff" );
 
-        r = entityIndex.search(appScope,SearchTypes.fromTypes( "edanuff" ),  query );
+
+        r = entityIndex.search( appScope, SearchTypes.fromTypes( "edanuff" ), query, 10 );
 
         assertFalse( r.iterator().hasNext() );
     }
 
+
     @Test
     public void multiValuedTypes() {
 
@@ -510,7 +534,7 @@ public class EntityIndexTest extends BaseIT {
 
         IndexScope appScope = new IndexScopeImpl( ownerId, "user" );
 
-        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
+        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
 
         entityIndex.createBatch();
 
@@ -518,17 +542,17 @@ public class EntityIndexTest extends BaseIT {
         Map billMap = new HashMap() {{
             put( "username", "bill" );
             put( "email", "bill@example.com" );
-            put( "age", "thirtysomething");
-            put( "favorites", "scallops, croquet, wine");
-            put( "retirementGoal", 100000);
+            put( "age", "thirtysomething" );
+            put( "favorites", "scallops, croquet, wine" );
+            put( "retirementGoal", 100000 );
         }};
         Entity bill = EntityIndexMapUtils.fromMap( billMap );
-        EntityUtils.setId( bill, new SimpleId( UUIDGenerator.newTimeUUID(), "user"  ) );
+        EntityUtils.setId( bill, new SimpleId( UUIDGenerator.newTimeUUID(), "user" ) );
         EntityUtils.setVersion( bill, UUIDGenerator.newTimeUUID() );
 
         EntityIndexBatch batch = entityIndex.createBatch();
 
-        batch.index( appScope,  bill );
+        batch.index( appScope, bill );
 
         // Fred has age as int, favorites as object and retirement goal as object
         Map fredMap = new HashMap() {{
@@ -536,43 +560,36 @@ public class EntityIndexTest extends BaseIT {
             put( "email", "fred@example.com" );
             put( "age", 41 );
             put( "favorites", new HashMap<String, Object>() {{
-                put("food", "cheezewiz");
-                put("sport", "nascar");
-                put("beer", "budwizer");
-            }});
+                put( "food", "cheezewiz" );
+                put( "sport", "nascar" );
+                put( "beer", "budwizer" );
+            }} );
             put( "retirementGoal", new HashMap<String, Object>() {{
-                put("car", "Firebird");
-                put("home", "Mobile");
-            }});
+                put( "car", "Firebird" );
+                put( "home", "Mobile" );
+            }} );
         }};
         Entity fred = EntityIndexMapUtils.fromMap( fredMap );
-        EntityUtils.setId( fred, new SimpleId( UUIDGenerator.newTimeUUID(), "user"  ) );
+        EntityUtils.setId( fred, new SimpleId( UUIDGenerator.newTimeUUID(), "user" ) );
         EntityUtils.setVersion( fred, UUIDGenerator.newTimeUUID() );
-        batch.index( appScope, fred);
+        batch.index( appScope, fred );
 
         batch.execute().get();
         ei.refresh();
 
         final SearchTypes searchTypes = SearchTypes.fromTypes( "user" );
 
-        Query query = new Query();
-        query.addEqualityFilter( "username", "bill" );
-        CandidateResults r = entityIndex.search( appScope, searchTypes,  query );
+
+        CandidateResults r = entityIndex.search( appScope, searchTypes, "where username = 'bill'", 10 );
         assertEquals( bill.getId(), r.get( 0 ).getId() );
 
-        query = new Query();
-        query.addEqualityFilter( "username", "fred" );
-        r = entityIndex.search( appScope, searchTypes,  query );
+        r = entityIndex.search( appScope, searchTypes, "where username = 'fred'", 10 );
         assertEquals( fred.getId(), r.get( 0 ).getId() );
 
-        query = new Query();
-        query.addEqualityFilter( "age", 41 );
-        r = entityIndex.search( appScope, searchTypes,  query );
+        r = entityIndex.search( appScope, searchTypes, "where age = 41", 10 );
         assertEquals( fred.getId(), r.get( 0 ).getId() );
 
-        query = new Query();
-        query.addEqualityFilter( "age", "thirtysomething" );
-        r = entityIndex.search(  appScope, searchTypes, query );
+        r = entityIndex.search( appScope, searchTypes, "where age = 'thirtysomething'", 10 );
         assertEquals( bill.getId(), r.get( 0 ).getId() );
     }
 
@@ -583,8 +600,8 @@ public class EntityIndexTest extends BaseIT {
         Id ownerId = new SimpleId( "multivaluedtype" );
         ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
         assertNotEquals( "cluster should be ok", Health.RED, ei.getClusterHealth() );
-        assertEquals("index should be ready", Health.GREEN, ei.getIndexHealth());
-        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
+        assertEquals( "index should be ready", Health.GREEN, ei.getIndexHealth() );
+        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
 
         ei.refresh();
 
@@ -604,7 +621,7 @@ public class EntityIndexTest extends BaseIT {
         IndexScope indexScope = new IndexScopeImpl( ownerId, "users" );
 
 
-        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
+        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
 
 
         final EntityIndexBatch batch = entityIndex.createBatch();
@@ -616,6 +633,7 @@ public class EntityIndexTest extends BaseIT {
 
 
         for ( int i = 0; i < size; i++ ) {
+
             final String middleName = "middleName" + UUIDUtils.newTimeUUID();
 
             Map entityMap = new HashMap() {{
@@ -641,7 +659,7 @@ public class EntityIndexTest extends BaseIT {
 
 
         batch.execute().get();
-       ei.refresh();
+        ei.refresh();
 
 
         final int limit = 1;
@@ -654,15 +672,17 @@ public class EntityIndexTest extends BaseIT {
 
         for ( int i = 0; i < expectedPages; i++ ) {
             //**
-            Query query = Query.fromQL( "select * order by created" );
+            final String query = "select * order by created";
 
-            final CandidateResults results = cursor == null ?  entityIndex.search( indexScope, SearchTypes.allTypes(), query , limit) : entityIndex.getNextPage(cursor, limit);
+            final CandidateResults results =
+                    cursor == null ? entityIndex.search( indexScope, SearchTypes.allTypes(), query, limit ) :
+                    entityIndex.getNextPage( cursor, limit );
 
             assertTrue( results.hasCursor() );
 
             cursor = results.getCursor();
 
-            assertEquals("Should be 16 bytes as hex", 32, cursor.length());
+            assertEquals( "Should be 16 bytes as hex", 32, cursor.length() );
 
 
             assertEquals( 1, results.size() );
@@ -671,8 +691,6 @@ public class EntityIndexTest extends BaseIT {
             assertEquals( results.get( 0 ).getId(), entities.get( i ) );
         }
     }
-
-
 }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2699dd30/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
index b03f09d..64d87d9 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
@@ -45,7 +45,6 @@ import org.apache.usergrid.persistence.index.SearchTypes;
 import org.apache.usergrid.persistence.index.guice.IndexTestFig;
 import org.apache.usergrid.persistence.index.guice.TestIndexModule;
 import org.apache.usergrid.persistence.index.query.CandidateResults;
-import org.apache.usergrid.persistence.index.query.Query;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
@@ -208,10 +207,10 @@ public class IndexLoadTestsIT extends BaseIT {
 
                         //execute our search
                         final CandidateResults results = appEntityIndex
-                            .search( indexScope, SearchTypes.fromTypes( indexScope.getName() ), Query.fromQLNullSafe(
+                            .search( indexScope, SearchTypes.fromTypes( indexScope.getName() ),
                                 "select * where " + FIELD_WORKER_INDEX + "  = " + workerIndex + " AND " + FIELD_ORDINAL
                                     + " = " + ordinal + " AND " + FIELD_UNIQUE_IDENTIFIER + " = '" + uniqueIdentifier
-                                    + "'" ) );
+                                    + "'" , 100 );
 
                         queryTps.mark();
                         queryTimerContext.stop();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2699dd30/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java
index 792fe3a..b8bf873 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java
@@ -19,37 +19,39 @@
 package org.apache.usergrid.persistence.query.tree;
 
 
+import java.util.Collection;
+import java.util.UUID;
+
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.TokenRewriteStream;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.junit.Test;
+
 import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
+import org.apache.usergrid.persistence.index.exceptions.QueryParseException;
 import org.apache.usergrid.persistence.index.impl.IndexScopeImpl;
 import org.apache.usergrid.persistence.index.impl.SearchRequestBuilderStrategy;
-import org.apache.usergrid.persistence.index.query.tree.LongLiteral;
+import org.apache.usergrid.persistence.index.query.ParsedQuery;
+import org.apache.usergrid.persistence.index.query.ParsedQueryBuilder;
+import org.apache.usergrid.persistence.index.query.SelectFieldMapping;
+import org.apache.usergrid.persistence.index.query.tree.AndOperand;
+import org.apache.usergrid.persistence.index.query.tree.ContainsOperand;
 import org.apache.usergrid.persistence.index.query.tree.CpQueryFilterLexer;
 import org.apache.usergrid.persistence.index.query.tree.CpQueryFilterParser;
-import org.apache.usergrid.persistence.index.query.tree.ContainsOperand;
-import org.apache.usergrid.persistence.index.query.tree.NotOperand;
-import org.apache.usergrid.persistence.index.query.tree.LessThan;
-import org.apache.usergrid.persistence.index.query.tree.AndOperand;
+import org.apache.usergrid.persistence.index.query.tree.Equal;
 import org.apache.usergrid.persistence.index.query.tree.GreaterThan;
+import org.apache.usergrid.persistence.index.query.tree.GreaterThanEqual;
+import org.apache.usergrid.persistence.index.query.tree.LessThan;
 import org.apache.usergrid.persistence.index.query.tree.LessThanEqual;
-import org.apache.usergrid.persistence.index.query.tree.UUIDLiteral;
+import org.apache.usergrid.persistence.index.query.tree.LongLiteral;
+import org.apache.usergrid.persistence.index.query.tree.NotOperand;
 import org.apache.usergrid.persistence.index.query.tree.Operand;
-import org.apache.usergrid.persistence.index.query.tree.WithinOperand;
 import org.apache.usergrid.persistence.index.query.tree.OrOperand;
 import org.apache.usergrid.persistence.index.query.tree.StringLiteral;
-import org.apache.usergrid.persistence.index.query.tree.GreaterThanEqual;
-import org.apache.usergrid.persistence.index.query.tree.Equal;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.RecognitionException;
-import org.antlr.runtime.TokenRewriteStream;
-import org.apache.usergrid.persistence.index.exceptions.QueryParseException;
+import org.apache.usergrid.persistence.index.query.tree.UUIDLiteral;
+import org.apache.usergrid.persistence.index.query.tree.WithinOperand;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.junit.Test;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.elasticsearch.index.query.QueryBuilder;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -71,7 +73,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         Operand root = query.getRootOperand();
 
@@ -94,7 +96,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         Operand root = query.getRootOperand();
 
@@ -111,7 +113,7 @@ public class GrammarTreeTest {
         tokens = new TokenRewriteStream( lexer );
         parser = new CpQueryFilterParser( tokens );
 
-        query = parser.ql().query;
+        query = parser.ql().parsedQuery;
 
         root = query.getRootOperand();
 
@@ -134,7 +136,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         Operand root = query.getRootOperand();
 
@@ -151,7 +153,7 @@ public class GrammarTreeTest {
         tokens = new TokenRewriteStream( lexer );
         parser = new CpQueryFilterParser( tokens );
 
-        query = parser.ql().query;
+        query = parser.ql().parsedQuery;
 
         root = query.getRootOperand();
 
@@ -174,7 +176,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         Operand root = query.getRootOperand();
 
@@ -191,7 +193,7 @@ public class GrammarTreeTest {
         tokens = new TokenRewriteStream( lexer );
         parser = new CpQueryFilterParser( tokens );
 
-        query = parser.ql().query;
+        query = parser.ql().parsedQuery;
 
         root = query.getRootOperand();
 
@@ -214,7 +216,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         Operand root = query.getRootOperand();
 
@@ -231,7 +233,7 @@ public class GrammarTreeTest {
         tokens = new TokenRewriteStream( lexer );
         parser = new CpQueryFilterParser( tokens );
 
-        query = parser.ql().query;
+        query = parser.ql().parsedQuery;
 
         root = query.getRootOperand();
 
@@ -254,7 +256,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         Operand root = query.getRootOperand();
 
@@ -284,7 +286,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         Operand root = query.getRootOperand();
 
@@ -314,7 +316,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         Operand root = query.getRootOperand();
 
@@ -339,7 +341,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         Operand root = query.getRootOperand();
 
@@ -364,9 +366,9 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
-        Set<String> identifiers = query.getSelectSubjects();
+        Collection<SelectFieldMapping> identifiers = query.getSelectFieldMappings();
 
         assertEquals( 0, identifiers.size() );
     }
@@ -381,7 +383,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         WithinOperand operand = ( WithinOperand ) query.getRootOperand();
 
@@ -401,7 +403,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         WithinOperand operand = ( WithinOperand ) query.getRootOperand();
 
@@ -422,7 +424,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         AndOperand andOp1 = ( AndOperand ) query.getRootOperand();
         AndOperand andOp2 = ( AndOperand ) andOp1.getLeft();
@@ -433,9 +435,10 @@ public class GrammarTreeTest {
         assertEquals( 37f, withinOperand.getLatitude().getFloatValue(), 0 );
         assertEquals( -75f, withinOperand.getLongitude().getFloatValue(), 0 );
 
-        SearchRequestBuilderStrategy builderStrategy = new SearchRequestBuilderStrategy(null,new ApplicationScopeImpl(new SimpleId("test")),null,100);
-        QueryBuilder qb =builderStrategy.createQueryBuilder(new IndexScopeImpl(new SimpleId("owner"),"app"),query);
-
+        SearchRequestBuilderStrategy builderStrategy =
+                new SearchRequestBuilderStrategy( null, new ApplicationScopeImpl( new SimpleId( "test" ) ), null, 100 );
+        QueryBuilder qb =
+                builderStrategy.createQueryBuilder( new IndexScopeImpl( new SimpleId( "owner" ), "app" ), query );
     }
 
 
@@ -448,7 +451,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         ContainsOperand operand = ( ContainsOperand ) query.getRootOperand();
 
@@ -467,11 +470,14 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
+
+        Collection<SelectFieldMapping> identifiers = query.getSelectFieldMappings();
 
-        Set<String> identifiers = query.getSelectSubjects();
+        final SelectFieldMapping fieldMapping = identifiers.iterator().next();
 
-        assertTrue( identifiers.contains( "c" ) );
+        assertEquals( "c", fieldMapping.getSourceFieldName() );
+        assertEquals( "c", fieldMapping.getTargetFieldName() );
     }
 
 
@@ -485,11 +491,15 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
+
+        Collection<SelectFieldMapping> identifiers = query.getSelectFieldMappings();
 
-        Map<String, String> identifiers = query.getSelectAssignments();
+        final SelectFieldMapping fieldMapping = identifiers.iterator().next();
+
+        assertEquals( "source", fieldMapping.getSourceFieldName() );
+        assertEquals( "target", fieldMapping.getTargetFieldName() );
 
-        assertEquals( "target", identifiers.get( "source" ) );
     }
 
 
@@ -502,7 +512,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         OrOperand rootNode = ( OrOperand ) query.getRootOperand();
 
@@ -534,7 +544,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         Equal rootNode = ( Equal ) query.getRootOperand();
 
@@ -553,7 +563,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         AndOperand rootNode = ( AndOperand ) query.getRootOperand();
 
@@ -586,7 +596,7 @@ public class GrammarTreeTest {
         TokenRewriteStream tokens = new TokenRewriteStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
 
-        Query query = parser.ql().query;
+        ParsedQuery query = parser.ql().parsedQuery;
 
         Equal rootNode = ( Equal ) query.getRootOperand();
 
@@ -601,7 +611,7 @@ public class GrammarTreeTest {
 
         String s = "select * where name = 'bob' order by name asc";
 
-        Query query = Query.fromQL( s );
+        ParsedQuery query = ParsedQueryBuilder.build( s );
 
         assertEquals( 1, query.getSortPredicates().size() );
     }
@@ -615,34 +625,35 @@ public class GrammarTreeTest {
         String error = null;
 
         try {
-            Query.fromQL( s );
+            ParsedQueryBuilder.build ( s );
         }
         catch ( QueryParseException qpe ) {
             error = qpe.getMessage();
         }
 
-        assertTrue( error.startsWith("The query cannot be parsed") );
+        assertTrue( error.startsWith( "The query cannot be parsed" ) );
     }
 
-    @Test
-       public void badOperand() throws QueryParseException {
-           // from isn't allowed
-           String s = "select * where name != 'bob'";
-
-           String error = null;
 
-           try {
-               Query.fromQL( s );
-               fail("should throw an exception");
-           }
-           catch ( RuntimeException qpe ) {
-               error = qpe.getMessage();
-           }
-
-           assertEquals( "NoViableAltException('!'@[1:1: Tokens : ( T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | LT | LTE | EQ | GT | GTE | BOOLEAN | AND | OR | NOT | ASC | DESC | CONTAINS | WITHIN | OF | UUID | ID | LONG | FLOAT | STRING | WS );])",
-                   error );
-       }
+    @Test
+    public void badOperand() throws QueryParseException {
+        // from isn't allowed
+        String s = "select * where name != 'bob'";
 
+        String error = null;
 
+        try {
+            ParsedQueryBuilder.build( s );
+            fail( "should throw an exception" );
+        }
+        catch ( RuntimeException qpe ) {
+            error = qpe.getMessage();
+        }
 
+        assertEquals(
+                "NoViableAltException('!'@[1:1: Tokens : ( T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | "
+                        + "T__38 | T__39 | T__40 | LT | LTE | EQ | GT | GTE | BOOLEAN | AND | OR | NOT | ASC | DESC |"
+                        + " CONTAINS | WITHIN | OF | UUID | ID | LONG | FLOAT | STRING | WS );])",
+                error );
+    }
 }


Mime
View raw message