usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [2/2] incubator-usergrid git commit: Refactor of tests to use query language
Date Fri, 10 Apr 2015 16:25:58 GMT
Refactor of tests to use query language


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/b1e0517e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/b1e0517e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/b1e0517e

Branch: refs/heads/USERGRID-536
Commit: b1e0517ebf468caf263d2f0c94db4b70d6920afd
Parents: 035cb78
Author: Todd Nine <tnine@apigee.com>
Authored: Fri Apr 10 10:25:50 2015 -0600
Committer: Todd Nine <tnine@apigee.com>
Committed: Fri Apr 10 10:25:50 2015 -0600

----------------------------------------------------------------------
 .../corepersistence/CpRelationManager.java      |  19 -
 .../usergrid/batch/job/SchedulerRuntime8IT.java |   6 +-
 .../usergrid/persistence/EntityManagerIT.java   |  30 +-
 .../EntityPropertyComparatorTest.java           | 222 -----
 .../org/apache/usergrid/persistence/GeoIT.java  |  87 +-
 .../persistence/GeoQueryBooleanTest.java        |  20 +-
 .../apache/usergrid/persistence/IndexIT.java    |  42 -
 .../usergrid/persistence/PathQueryIT.java       |  17 +-
 .../apache/usergrid/persistence/QueryTest.java  | 328 --------
 .../cassandra/QueryProcessorTest.java           | 822 -------------------
 .../SimpleIndexShardLocatorImplTest.java        | 177 ----
 ...EntityLocationRefDistanceComparatorTest.java | 104 ---
 .../persistence/query/IteratingQueryIT.java     |  38 +-
 .../query/ir/result/AbstractScanColumnTest.java | 101 ---
 .../query/ir/result/InOrderIterator.java        | 132 ---
 .../ir/result/IntersectionIteratorTest.java     | 308 -------
 .../query/ir/result/IteratorHelper.java         |  34 -
 .../ir/result/SubtractionIteratorTest.java      | 182 ----
 .../query/ir/result/UnionIteratorTest.java      | 468 -----------
 .../cassandra/ManagementServiceImpl.java        |   4 +-
 .../management/export/ExportServiceImpl.java    |   4 +-
 .../management/importer/FileImportJob.java      |   2 +-
 .../management/importer/ImportServiceImpl.java  |   4 +-
 .../security/providers/FacebookProvider.java    |   2 +-
 .../security/providers/FoursquareProvider.java  |   2 +-
 .../apache/usergrid/security/shiro/Realm.java   |   2 +-
 .../services/AbstractCollectionService.java     |   4 +-
 .../services/AbstractConnectionsService.java    |   4 +-
 .../AbstractPathBasedColllectionService.java    |   2 +-
 .../usergrid/services/AbstractService.java      |   2 +-
 .../usergrid/services/ServiceContext.java       |   2 +-
 .../applications/ApplicationsService.java       |   2 +-
 .../services/devices/DevicesService.java        |   2 +-
 .../usergrid/services/groups/GroupsService.java |   2 +-
 .../groups/activities/ActivitiesService.java    |   2 +-
 .../users/activities/ActivitiesService.java     |   4 +-
 .../notifications/InactiveDeviceManager.java    |   2 +-
 .../notifications/NotificationsService.java     |   2 +-
 .../impl/ApplicationQueueManagerImpl.java       |   2 +-
 .../usergrid/services/roles/RolesService.java   |  10 +-
 .../usergrid/services/users/UsersService.java   |   2 +-
 .../users/activities/ActivitiesService.java     |   4 +-
 .../migration/AppInfoMigrationPluginTest.java   |   2 +-
 .../management/importer/ImportCollectionIT.java |   4 +-
 .../importer/ImportConnectionsTest.java         |   2 +-
 .../management/importer/ImportServiceIT.java    |   2 +-
 .../usergrid/services/ActivitiesServiceIT.java  |   2 +-
 .../usergrid/services/RolesServiceIT.java       |   2 +-
 .../usergrid/services/ServiceInvocationIT.java  |   2 +-
 .../AbstractServiceNotificationIT.java          |   2 +-
 .../apns/NotificationsServiceIT.java            |   2 +-
 51 files changed, 132 insertions(+), 3093 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b1e0517e/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 0147740..5044298 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -123,15 +123,8 @@ public class CpRelationManager implements RelationManager {
 
     private ApplicationScope applicationScope;
 
-    private CassandraService cass;
-
-    private IndexBucketLocator indexBucketLocator;
-
     private MetricsFactory metricsFactory;
     private Timer updateCollectionTimer;
-    private Timer createConnectionTimer;
-    private Timer cassConnectionDelete;
-    private Timer esDeleteConnectionTimer;
 
     public CpRelationManager() {}
 
@@ -160,17 +153,9 @@ public class CpRelationManager implements RelationManager {
         this.managerCache = emf.getManagerCache();
         this.applicationScope = CpNamingUtils.getApplicationScope( applicationId );
 
-        this.cass = em.getCass(); // TODO: eliminate need for this via Core Persistence
-        this.indexBucketLocator = indexBucketLocator; // TODO: this also
         this.metricsFactory = metricsFactory;
         this.updateCollectionTimer = metricsFactory
             .getTimer( CpRelationManager.class, "relation.manager.es.update.collection" );
-        this.createConnectionTimer = metricsFactory
-            .getTimer( CpRelationManager.class, "relation.manager.es.create.connection.timer" );
-        this.cassConnectionDelete = metricsFactory
-            .getTimer( CpRelationManager.class, "relation.manager.cassandra.delete.connection.batch.timer" );
-        this.esDeleteConnectionTimer = metricsFactory.getTimer( CpRelationManager.class,
-            "relation.manager.es.delete.connection.batch.timer" );
 
 
         if ( logger.isDebugEnabled() ) {
@@ -1182,8 +1167,4 @@ public class CpRelationManager implements RelationManager {
         }
         return entity;
     }
-
-
-
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b1e0517e/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime8IT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime8IT.java b/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime8IT.java
index 6bba8b3..a8c88ff 100644
--- a/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime8IT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime8IT.java
@@ -66,8 +66,7 @@ public class SchedulerRuntime8IT extends AbstractSchedulerRuntimeIT {
 
         // now query and make sure it equals the saved value
 
-        Query query = new Query();
-        query.addEqualityFilter( "notificationId", notificationId );
+        Query query = Query.fromQL( "notificationId = " +  notificationId );
 
 
         Results r = scheduler.queryJobData( query );
@@ -77,8 +76,7 @@ public class SchedulerRuntime8IT extends AbstractSchedulerRuntimeIT {
         assertEquals( saved.getUuid(), r.getEntity().getUuid() );
 
         // query by uuid
-        query = new Query();
-        query.addEqualityFilter( "stringprop", "test" );
+        query = Query.fromQL(  "stringprop = 'test'" );
 
         r = scheduler.queryJobData( query );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b1e0517e/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
index ec79261..3545739 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
@@ -79,7 +79,7 @@ public class EntityManagerIT extends AbstractCoreIT {
         user = em.get( user );
         assertNotNull( user );
         assertEquals( "user.username not expected value", "edanuff", user.getProperty( "username"));
-        assertEquals( "user.email not expected value", "ed@anuff.com", user.getProperty( "email" ));
+        assertEquals( "user.email not expected value", "ed@anuff.com", user.getProperty( "email" ) );
 
         app.refreshIndex();
 
@@ -93,20 +93,22 @@ public class EntityManagerIT extends AbstractCoreIT {
         LOG.info( "user.username: " + user.getProperty( "username" ) );
         LOG.info( "user.email: " + user.getProperty( "email" ) );
 
-        Results results = em.searchCollection( em.getApplicationRef(), "users",
-                new Query().addEqualityFilter( "username", "edanuff" ) );
+        final Query query = Query.fromQL("username = 'edanuff'");
+
+        Results results = em.searchCollection( em.getApplicationRef(), "users", query );
         assertNotNull( results );
         assertEquals( 1, results.size() );
         user = results.getEntity();
         assertNotNull( user );
-        assertEquals( "user.username not expected value", "edanuff", user.getProperty( "username"));
-        assertEquals( "user.email not expected value", "ed@anuff.com", user.getProperty( "email"));
+        assertEquals( "user.username not expected value", "edanuff", user.getProperty( "username" ) );
+        assertEquals( "user.email not expected value", "ed@anuff.com", user.getProperty( "email" ) );
 
         LOG.info( "user.username: " + user.getProperty( "username" ) );
         LOG.info( "user.email: " + user.getProperty( "email" ) );
 
-        results = em.searchCollection( em.getApplicationRef(), "users",
-                new Query().addEqualityFilter( "email", "ed@anuff.com" ) );
+        final Query emailQuery = Query.fromQL( "email = 'ed@anuff.com'" );
+
+        results = em.searchCollection( em.getApplicationRef(), "users", emailQuery );
         assertNotNull( results );
         assertEquals( 1, results.size() );
         user = results.getEntity();
@@ -287,8 +289,12 @@ public class EntityManagerIT extends AbstractCoreIT {
 
         // now search by username, no results should be returned
 
+
+        final Query emailQuery = Query.fromQL( "name = '" + name +"'" );
+
+
         Results r = em.searchCollection( em.getApplicationRef(), "thing",
-                new Query().addEqualityFilter( "name", name ) );
+               emailQuery );
 
         assertEquals( 0, r.size() );
     }
@@ -320,8 +326,9 @@ public class EntityManagerIT extends AbstractCoreIT {
 
         // now search by username, no results should be returned
 
+        final Query query = Query.fromQL( "username = '" + name + "'" );
         Results r = em.searchCollection( em.getApplicationRef(), "users",
-            new Query().addEqualityFilter( "username", name ) );
+            query );
 
         assertEquals( 0, r.size() );
 
@@ -337,8 +344,9 @@ public class EntityManagerIT extends AbstractCoreIT {
 
         app.refreshIndex();
 
-        r = em.searchCollection( em.getApplicationRef(), "users",
-                new Query().addEqualityFilter( "username", name ) );
+        final Query userNameQuery = Query.fromQL( "username = '" + name + "'" );
+
+        r = em.searchCollection( em.getApplicationRef(), "users", userNameQuery);
 
         assertEquals( 1, r.size() );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b1e0517e/stack/core/src/test/java/org/apache/usergrid/persistence/EntityPropertyComparatorTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityPropertyComparatorTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityPropertyComparatorTest.java
deleted file mode 100644
index b5284a9..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityPropertyComparatorTest.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence;
-
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-
-/** Test for the entity comparator */
-public class EntityPropertyComparatorTest {
-
-
-    @Test
-    public void testNulls() throws Exception {
-
-        DynamicEntity first = new DynamicEntity();
-        first.setProperty( "test", true );
-
-        EntityPropertyComparator forward = new EntityPropertyComparator( "test", false );
-
-
-        assertEquals( 0, forward.compare( null, null ) );
-
-        assertEquals( -1, forward.compare( first, null ) );
-
-        assertEquals( 1, forward.compare( null, first ) );
-
-
-        //now test in reverse
-
-        EntityPropertyComparator reverse = new EntityPropertyComparator( "test", true );
-
-
-        assertEquals( 0, reverse.compare( null, null ) );
-
-        assertEquals( -1, reverse.compare( first, null ) );
-
-        assertEquals( 1, reverse.compare( null, first ) );
-    }
-
-
-    @Test
-    public void testBooleans() throws Exception {
-
-        DynamicEntity second = new DynamicEntity();
-        second.setProperty( "test", true );
-
-
-        DynamicEntity first = new DynamicEntity();
-        first.setProperty( "test", false );
-
-        EntityPropertyComparator forward = new EntityPropertyComparator( "test", false );
-
-
-        assertEquals( 0, forward.compare( second, second ) );
-
-        assertEquals( 1, forward.compare( second, first ) );
-
-        assertEquals( -1, forward.compare( first, second ) );
-
-
-        //now test in reverse
-
-        EntityPropertyComparator reverse = new EntityPropertyComparator( "test", true );
-
-
-        assertEquals( 0, reverse.compare( second, second ) );
-
-        assertEquals( 1, reverse.compare( first, second ) );
-
-        assertEquals( -1, reverse.compare( second, first ) );
-    }
-
-
-    @Test
-    public void testFloat() throws Exception {
-
-        DynamicEntity second = new DynamicEntity();
-        second.setProperty( "test", 1.0f );
-
-
-        DynamicEntity first = new DynamicEntity();
-        first.setProperty( "test", 0.0f );
-
-        EntityPropertyComparator forward = new EntityPropertyComparator( "test", false );
-
-
-        assertEquals( 0, forward.compare( second, second ) );
-
-        assertEquals( 1, forward.compare( second, first ) );
-
-        assertEquals( -1, forward.compare( first, second ) );
-
-
-        //now test in reverse
-
-        EntityPropertyComparator reverse = new EntityPropertyComparator( "test", true );
-
-
-        assertEquals( 0, reverse.compare( second, second ) );
-
-        assertEquals( 1, reverse.compare( first, second ) );
-
-        assertEquals( -1, reverse.compare( second, first ) );
-    }
-
-
-    @Test
-    public void testLong() throws Exception {
-
-        DynamicEntity second = new DynamicEntity();
-        second.setProperty( "test", 1l );
-
-
-        DynamicEntity first = new DynamicEntity();
-        first.setProperty( "test", 0l );
-
-        EntityPropertyComparator forward = new EntityPropertyComparator( "test", false );
-
-
-        assertEquals( 0, forward.compare( second, second ) );
-
-        assertEquals( 1, forward.compare( second, first ) );
-
-        assertEquals( -1, forward.compare( first, second ) );
-
-
-        //now test in reverse
-
-        EntityPropertyComparator reverse = new EntityPropertyComparator( "test", true );
-
-
-        assertEquals( 0, reverse.compare( second, second ) );
-
-        assertEquals( 1, reverse.compare( first, second ) );
-
-        assertEquals( -1, reverse.compare( second, first ) );
-    }
-
-
-    @Test
-    public void testDouble() throws Exception {
-
-        DynamicEntity second = new DynamicEntity();
-        second.setProperty( "test", 1d );
-
-
-        DynamicEntity first = new DynamicEntity();
-        first.setProperty( "test", 0d );
-
-
-        EntityPropertyComparator forward = new EntityPropertyComparator( "test", false );
-
-
-        assertEquals( 0, forward.compare( second, second ) );
-
-        assertEquals( 1, forward.compare( second, first ) );
-
-        assertEquals( -1, forward.compare( first, second ) );
-
-
-        //now test in reverse
-
-        EntityPropertyComparator reverse = new EntityPropertyComparator( "test", true );
-
-
-        assertEquals( 0, reverse.compare( second, second ) );
-
-        assertEquals( 1, reverse.compare( first, second ) );
-
-        assertEquals( -1, reverse.compare( second, first ) );
-    }
-
-
-    @Test
-    public void testString() throws Exception {
-
-        DynamicEntity second = new DynamicEntity();
-        second.setProperty( "test", "b" );
-
-
-        DynamicEntity first = new DynamicEntity();
-        first.setProperty( "test", "a" );
-
-        EntityPropertyComparator forward = new EntityPropertyComparator( "test", false );
-
-
-        assertEquals( 0, forward.compare( second, second ) );
-
-        assertEquals( 1, forward.compare( second, first ) );
-
-        assertEquals( -1, forward.compare( first, second ) );
-
-
-        //now test in reverse
-
-        EntityPropertyComparator reverse = new EntityPropertyComparator( "test", true );
-
-
-        assertEquals( 0, reverse.compare( second, second ) );
-
-        assertEquals( 1, reverse.compare( first, second ) );
-
-        assertEquals( -1, reverse.compare( second, first ) );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b1e0517e/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
index ebf0a6a..614e5f6 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
@@ -28,8 +28,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.usergrid.AbstractCoreIT;
-import org.apache.usergrid.persistence.geo.model.Point;
-import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.persistence.model.field.value.Location;
 import org.apache.usergrid.utils.MapUtils;
 
@@ -143,10 +141,11 @@ public class GeoIT extends AbstractCoreIT {
         assertNotNull(user);
         app.refreshIndex();
 
-        Point center = new Point(37.776753, -122.407846);
+        final double lat = 37.776753;
+        final double lon = -122.407846;
         //2. Query from a point near the entity's location
         Query query = Query.fromQL("select * where location within 100 of "
-            + center.getLat() + "," + center.getLon());
+            + lat + "," + lon);
         Results listResults = em.searchCollection(em.getApplicationRef(), "users", query);
         assertEquals(1, listResults.size());
 
@@ -263,9 +262,10 @@ public class GeoIT extends AbstractCoreIT {
         EntityManager em = loadGeolocationTestEntities();
         //2. Query the collection from a point more than 10000m from the locations
         // and ensure that no entities are returned when restricted to a 10000m radius
-        Point center = new Point(37.776753, -122.407846);
+        final double lat = 37.776753;
+        final double lon = -122.407846;
         Query query = Query.fromQL("select * where location within " + NEARBY_RADIUS + " of "
-            + center.getLat() + "," + center.getLon());
+            + lat + "," + lon);
         Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
 
         assertEquals("Results within " + NEARBY_RADIUS + "m from center", 0, listResults.size());
@@ -273,7 +273,7 @@ public class GeoIT extends AbstractCoreIT {
         // and ensure that all entities are returned when the distance is set to the
         // circumference of the earth
         Query query2 = Query.fromQL("select * where location within " + CIRCUMFERENCE_OF_THE_EARTH + " of "
-            + center.getLat() + "," + center.getLon());
+            + lat + "," + lon);
         listResults = em.searchCollection(em.getApplicationRef(), "stores", query2);
 
         assertEquals("Results within " + CIRCUMFERENCE_OF_THE_EARTH
@@ -292,27 +292,28 @@ public class GeoIT extends AbstractCoreIT {
      *    circumference of the earth
      */
     public void testGeoFromNearbyLocation() throws Exception {
-        LOG.info("GeoIT.testGeoFromNearbyLocation");
+        LOG.info( "GeoIT.testGeoFromNearbyLocation" );
         //1. create entities with geo
         EntityManager em = loadGeolocationTestEntities();
 
-        Point center = new Point(-33.746369, 150.952185);
+        final double lat = -33.746369;
+        final double lon = 150.952185;
 
         //2. Query the collection from a point less than 10000m from the locations
         // and ensure that one entity is returned when restricted to a 10000m radius
         Query query = Query.fromQL("select * where location within " + NEARBY_RADIUS + " of "
-            + center.getLat() + "," + center.getLon());
+            + lat + "," + lon);
         Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
-        assertEquals("Results within " + NEARBY_RADIUS + "m from center", 1, listResults.size());
+        assertEquals( "Results within " + NEARBY_RADIUS + "m from center", 1, listResults.size() );
 
         //3. Query the collection from a point less than 10000m from the locations
         // and ensure that all entities are returned when the distance is set to the
         // circumference of the earth
-        query = Query.fromQL("select * where location within " + CIRCUMFERENCE_OF_THE_EARTH + " of "
-            + center.getLat() + "," + center.getLon());
+        query = Query.fromQL(
+            "select * where location within " + CIRCUMFERENCE_OF_THE_EARTH + " of " + lat + "," + lon );
         listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
-        assertEquals("Results within " + CIRCUMFERENCE_OF_THE_EARTH
-                + "m from center", LOCATION_PROPERTIES.size(), listResults.size());
+        assertEquals( "Results within " + CIRCUMFERENCE_OF_THE_EARTH + "m from center", LOCATION_PROPERTIES.size(),
+            listResults.size() );
     }
 
     /**
@@ -332,26 +333,29 @@ public class GeoIT extends AbstractCoreIT {
         //1 Create entities with geo
         EntityManager em = loadGeolocationTestEntities();
         //2 Create a list of points from different geographic areas
-        List<Point> points = new ArrayList<Point>();
-        points.add(new Point(-90.000000, 90.000000));//Antarctica
-        points.add(new Point(90, 90));//Santa's house
-        points.add(new Point(33.746369, -89));//Woodland, MS
-        points.add(new Point(34.35, 58.22)); //Buenos Aires
-        points.add(new Point(39.55, 116.25));//Beijing, China
-        points.add(new Point(44.52, 20.32)); //Belgrade, Serbia
-        points.add(new Point(-1.000000, 102.000000));//Somewhere in Indonesia
-        for (Point center : points) {
+        List<double[]> points = new ArrayList<>();
+        points.add(new double[]{-90.000000, 90.000000});//Antarctica
+        points.add(new double[]{90, 90});;//Santa's house
+        points.add( new double[]{ 33.746369, -89});;//Woodland, MS
+        points.add( new double[] { 34.35, 58.22 } );; //Buenos Aires
+        points.add( new double[] { 39.55, 116.25 } );;//Beijing, China
+        points.add( new double[]{ 44.52, 20.32});; //Belgrade, Serbia
+        points.add( new double[] { -1.000000, 102.000000 } );;//Somewhere in Indonesia
+        for (double[] center : points) {
             //3 Query the collection from each point
             //  and ensure that no entities are returned when restricted to a 10000m radius
+            final double lat = center[0];
+            final double lon = center[1];
+
             Query query = Query.fromQL("select * where location within 10000 of "
-                + center.getLat() + "," + center.getLon());
+                + lat + "," + lon);
             Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
             assertEquals("Results less than 10000m away from center", 0, listResults.size());
             //4 Query the collection from each point
             //  and ensure that all entities are returned when the distance is set to the
             //  circumference of the earth
             Query query2 = Query.fromQL("select * where location within 40000000 of "
-                + center.getLat() + "," + center.getLon());
+                + lat + "," + lon);
             listResults = em.searchCollection(em.getApplicationRef(), "stores", query2);
             assertEquals("Results from center point to ridiculously far",
                     LOCATION_PROPERTIES.size(), listResults.size());
@@ -364,7 +368,7 @@ public class GeoIT extends AbstractCoreIT {
 
 
         EntityManager em = app.getEntityManager();
-        assertNotNull(em);
+        assertNotNull( em );
 
         // save objects in a diagonal line from -90 -180 to 90 180
 
@@ -394,11 +398,11 @@ public class GeoIT extends AbstractCoreIT {
 
         app.refreshIndex();
 
-        Query query = new Query();
-        // earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
+         // earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
         // just to be save
-        query.addFilter("location within 50000000 of -90, -180");
-        query.setLimit(100);
+        Query query = Query.fromQL("location within 50000000 of -90, -180" );
+
+        query.setLimit( 100 );
 
         int count = 0;
         Results results;
@@ -417,7 +421,7 @@ public class GeoIT extends AbstractCoreIT {
         while (results.getCursor() != null);
 
         // check we got back all 500 entities
-        assertEquals(numEntities, count);
+        assertEquals( numEntities, count );
     }
 
 
@@ -441,11 +445,10 @@ public class GeoIT extends AbstractCoreIT {
 
         app.refreshIndex();
 
-        Query query = new Query();
         // earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
-        // just to be save
-        query.addFilter("location within 50000000 of 0, 0");
-        query.setLimit(100);
+                // just to be save
+        Query query = Query.fromQL("location within 50000000 of 0, 0" );
+        query.setLimit( 100 );
 
         int count = 0;
         Results results;
@@ -502,10 +505,10 @@ public class GeoIT extends AbstractCoreIT {
 
         app.refreshIndex();
 
-        Query query = new Query();
-        // earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
+         // earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
         // just to be save
-        query.addFilter("location within 50000000 of -90, -180");
+        Query query = Query.fromQL( "location within 50000000 of -90, -180" );
+
         query.setLimit(100);
 
         int count = 0;
@@ -529,7 +532,7 @@ public class GeoIT extends AbstractCoreIT {
     public void testGeoWithIntersection() throws Exception {
 
         EntityManager em = app.getEntityManager();
-        assertNotNull(em);
+        assertNotNull( em );
 
         int size = 100;
         int min = 50;
@@ -643,9 +646,7 @@ public class GeoIT extends AbstractCoreIT {
             long startTime = System.currentTimeMillis();
 
             //now test at the EM level, there should be 0 results.
-            Query query = new Query();
-
-            query.addFilter("location within 1000 of 48.38626, 9.94175"); // lat, lon
+            Query query = Query.fromQL( "location within 1000 of 48.38626, 9.94175");
             query.setLimit(limit);
 
             Results results = em.searchCollection(em.getApplicationRef(), "stores", query);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b1e0517e/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
index 1248276..8d01754 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
@@ -26,12 +26,8 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.commons.lang3.RandomStringUtils;
 
 import org.apache.usergrid.AbstractCoreIT;
-import org.apache.usergrid.persistence.geo.model.Point;
-import org.apache.usergrid.persistence.Query;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -87,22 +83,23 @@ public class GeoQueryBooleanTest extends AbstractCoreIT {
         app.refreshIndex();
 
         // define center point about 300m from that location
-        Point center = new Point( 37.774277, -122.404744 );
+        final double lat = 37.774277;
+        final double lon = -122.404744 ;
 
         Query query = Query.fromQL( "select * where location within 400 of "
-                                    + center.getLat() + "," + center.getLon());
+                                    + lat + "," + lon);
         Results listResults = em.searchCollection( em.getApplicationRef(), "users", query );
         assertEquals( 2, listResults.size() );
 
         query = Query.fromQL( "select * where employer='Apigee' or location within 100 of "
-                                    + center.getLat() + "," + center.getLon());
+                                    + lat + "," + lon);
         listResults = em.searchCollection( em.getApplicationRef(), "users", query );
 
         // no results because geo filter applied after query even in the case or 'or'
         assertEquals( 0, listResults.size() );
 
         query = Query.fromQL( "select * where employer='Apigee' or location within 400 of "
-                                    + center.getLat() + "," + center.getLon());
+                                    + lat + "," + lon);
         listResults = em.searchCollection( em.getApplicationRef(), "users", query );
 
         // only one result because geo filter applied after query even in the case or 'or'
@@ -166,19 +163,20 @@ public class GeoQueryBooleanTest extends AbstractCoreIT {
         app.refreshIndex();
 
         // define center point about 300m from that location
-        Point center = new Point( 37.774277, -122.404744 );
+        final double lat = 37.774277;
+        final double lon =  -122.404744 ;
 
         // one user within 400 meters IS NOT blocked by bart
         Query query = Query.fromQL(
             "select * where NOT blockedBy.name='bart' and location within 400 of "
-               + center.getLat() + "," + center.getLon());
+               + lat + "," + lon);
         Results listResults = em.searchCollection( em.getApplicationRef(), "users", query );
         assertEquals( 1, listResults.size() );
 
         // one user within 400 meters IS blocked by bart
         query = Query.fromQL(
             "select * where blockedBy.name='bart' and location within 400 of "
-               + center.getLat() + "," + center.getLon());
+               + lat + "," + lon);
         listResults = em.searchCollection( em.getApplicationRef(), "users", query );
         assertEquals( 1, listResults.size() );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b1e0517e/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
index 0ba8926..97f0045 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
@@ -29,10 +29,6 @@ import org.slf4j.LoggerFactory;
 import org.apache.usergrid.AbstractCoreIT;
 import org.apache.usergrid.cassandra.SpringResource;
 import org.apache.usergrid.persistence.cassandra.CassandraService;
-import org.apache.usergrid.persistence.cassandra.IndexUpdate;
-import org.apache.usergrid.persistence.cassandra.IndexUpdate.IndexEntry;
-import org.apache.usergrid.persistence.cassandra.RelationManagerImpl;
-import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.utils.JsonUtils;
 import org.apache.usergrid.utils.UUIDUtils;
 
@@ -437,43 +433,5 @@ public class IndexIT extends AbstractCoreIT {
 
 
 
-        //now read the index and see what properties are there
-
-        RelationManager rm = em.getRelationManager( entity2Ref );
-
-        if ( rm instanceof RelationManagerImpl ) { // only relevant for old-school EntityManagers
-
-            RelationManagerImpl impl = (RelationManagerImpl)rm;
-
-            CassandraService cass = SpringResource.getInstance().getBean( CassandraService.class );
-
-            ByteBufferSerializer buf = ByteBufferSerializer.get();
-
-            Keyspace ko = cass.getApplicationKeyspace( applicationId );
-            Mutator<ByteBuffer> m = createMutator( ko, buf );
-
-            IndexUpdate update = impl.batchStartIndexUpdate( m, entity1Ref,
-                    "status", "ignore", UUIDUtils.newTimeUUID(), false, false, true, false );
-
-            int count = 0;
-
-            IndexEntry lastMatch = null;
-
-            for ( IndexEntry entry : update.getPrevEntries() ) {
-                if ( "status".equals( entry.getPath() ) ) {
-                    count++;
-                    lastMatch = entry;
-                }
-            }
-
-            assertEquals( 1, count );
-
-            if ( lastMatch != null ) {
-                assertEquals( "herring", lastMatch.getValue() );
-            }
-            else {
-                fail( "The last match was null but should have been herring!" );
-            }
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b1e0517e/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
index d0b1b28..c5873ea 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
@@ -71,11 +71,9 @@ public class PathQueryIT extends AbstractCoreIT {
 
         int pageSize = 10; // shouldn't affect these tests
 
-        Query userQuery = new Query();
+        Query userQuery = Query.fromQL( "select * where index >= 2 AND index <= 13" );
         userQuery.setCollection( "users" );
         userQuery.setLimit( pageSize );
-        userQuery.addFilter( "index >= 2" );
-        userQuery.addFilter( "index <= 13" );
         int expectedUserQuerySize = 12;
 
         // query the users, ignoring page boundaries
@@ -89,10 +87,9 @@ public class PathQueryIT extends AbstractCoreIT {
         assertEquals( count, expectedUserQuerySize + 2 );
 
         // query devices as a sub-query of the users, ignoring page boundaries
-        Query deviceQuery = new Query();
+        Query deviceQuery = Query.fromQL( "select * where index >= 2 " );
         deviceQuery.setCollection( "devices" );
         deviceQuery.setLimit( pageSize );
-        deviceQuery.addFilter( "index >= 2" );
         int expectedDeviceQuerySize = 3;
 
         PathQuery<EntityRef> usersPQ = new PathQuery<EntityRef>(
@@ -160,23 +157,19 @@ public class PathQueryIT extends AbstractCoreIT {
 
         int pageSize = 3; // ensure we're crossing page boundaries
 
-        Query groupQuery = new Query();
+        Query groupQuery = Query.fromQL( "select * where index <= 7 " );
         groupQuery.setCollection( "groups" );
         groupQuery.setLimit( pageSize );
-        groupQuery.addFilter( "index <= 7" );
         int expectedGroupQuerySize = 4;
 
-        Query userQuery = new Query();
+        Query userQuery = Query.fromQL( "select * where index >= 2 AND index <= 6" );
         userQuery.setCollection( "users" );
         userQuery.setLimit( pageSize );
-        userQuery.addFilter( "index >= 2" );
-        userQuery.addFilter( "index <= 6" );
         int expectedUserQuerySize = 5;
 
-        Query deviceQuery = new Query();
+        Query deviceQuery = Query.fromQL( "select * where index >= 4 " );
         deviceQuery.setCollection( "devices" );
         deviceQuery.setLimit( pageSize );
-        deviceQuery.addFilter( "index >= 4" );
         int expectedDeviceQuerySize = 3;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b1e0517e/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java
deleted file mode 100644
index 5d16e11..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence;
-
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.usergrid.persistence.index.exceptions.QueryParseException;
-import org.apache.usergrid.persistence.Query;
-import org.apache.usergrid.persistence.Query.SortDirection;
-import org.apache.usergrid.persistence.Query.SortPredicate;
-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.Equal;
-import org.apache.usergrid.persistence.index.query.tree.FloatLiteral;
-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.LongLiteral;
-import org.apache.usergrid.persistence.index.query.tree.NotOperand;
-import org.apache.usergrid.persistence.index.query.tree.StringLiteral;
-import org.apache.usergrid.persistence.index.query.tree.WithinOperand;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
-
-public class QueryTest {
-
-    private static final Logger LOG = LoggerFactory.getLogger( QueryTest.class );
-
-
-    @Test
-    public void testQueryTree() throws Exception {
-        LOG.info( "testQuery" );
-
-        Query q = new Query();
-
-        try {
-            q.addFilter( "blah" );
-            fail( "'blah' shouldn't be a valid operation." );
-        }
-        catch ( RuntimeException e ) {
-            // this is correct
-        }
-
-        q.addFilter( "a=5" );
-        q.addFilter( "b='hello'" );
-        q.addFilter( "c < 7" );
-        q.addFilter( "d gt 5" );
-        // q.addFilter("e in 5,6");
-        q.addFilter( "f = 6.0" );
-        q.addFilter( "g = .05" );
-        q.addFilter( "loc within .05 of 5.0,6.0" );
-        q.addFilter( "not h eq 4" );
-
-        AndOperand and = ( AndOperand ) q.getRootOperand();
-
-        NotOperand not = ( NotOperand ) and.getRight();
-        Equal equal = ( Equal ) not.getOperation();
-        assertEquals( "h", equal.getProperty().getValue() );
-        assertEquals( 4.0f, ( ( LongLiteral ) equal.getLiteral() ).getValue(), 0 );
-
-        and = ( AndOperand ) and.getLeft();
-        WithinOperand op = ( WithinOperand ) and.getRight();
-
-        assertEquals( "loc", op.getProperty().getValue() );
-        assertEquals( .05f, op.getDistance().getFloatValue(), 0 );
-        assertEquals( 5f, op.getLatitude().getFloatValue(), 0 );
-        assertEquals( 6f, op.getLongitude().getFloatValue(), 0 );
-
-        and = ( AndOperand ) and.getLeft();
-        equal = ( Equal ) and.getRight();
-
-        assertEquals( "g", equal.getProperty().getValue() );
-        assertEquals( .05f, ( ( FloatLiteral ) equal.getLiteral() ).getValue(), 0 );
-
-        and = ( AndOperand ) and.getLeft();
-        equal = ( Equal ) and.getRight();
-
-        assertEquals( "f", equal.getProperty().getValue() );
-        assertEquals( 6.0f, ( ( FloatLiteral ) equal.getLiteral() ).getValue(), 0 );
-
-        and = ( AndOperand ) and.getLeft();
-        GreaterThan gt = ( GreaterThan ) and.getRight();
-
-        assertEquals( "d", gt.getProperty().getValue() );
-        assertEquals( 5, ( ( LongLiteral ) gt.getLiteral() ).getValue(), 0 );
-
-        and = ( AndOperand ) and.getLeft();
-        LessThan lt = ( LessThan ) and.getRight();
-
-        assertEquals( "c", lt.getProperty().getValue() );
-        assertEquals( 7, ( ( LongLiteral ) lt.getLiteral() ).getValue(), 0 );
-
-        and = ( AndOperand ) and.getLeft();
-        equal = ( Equal ) and.getRight();
-
-        assertEquals( "b", equal.getProperty().getValue() );
-        assertEquals( "hello", ( ( StringLiteral ) equal.getLiteral() ).getValue() );
-
-        equal = ( Equal ) and.getLeft();
-
-        assertEquals( "a", equal.getProperty().getValue() );
-        assertEquals( 5, ( ( LongLiteral ) equal.getLiteral() ).getValue().intValue() );
-    }
-
-    @Test
-    public void withinDistanceCorrect(){
-        final Query query = Query.fromQL( "location within 2000 of 37.776753, -122.407846" );
-
-        WithinOperand withinOperand = ( WithinOperand ) query.getRootOperand();
-
-        final float distance = withinOperand.getDistance().getFloatValue();
-        final float lat = withinOperand.getLatitude().getFloatValue();
-        final float lon = withinOperand.getLongitude().getFloatValue();
-
-        assertEquals( 2000f, distance, 0f );
-        assertEquals( 37.776753f, lat, 0f );
-        assertEquals( -122.407846f, lon, 0f );
-    }
-
-
-    @Test
-    public void testCodeEquals() {
-        Query query = new Query();
-        query.addEqualityFilter( "foo", "bar" );
-
-        Equal equal = ( Equal ) query.getRootOperand();
-
-        assertEquals( "foo", equal.getProperty().getValue() );
-        assertEquals( "bar", equal.getLiteral().getValue() );
-    }
-
-
-    @Test
-    public void testCodeLessThan() {
-        Query query = new Query();
-        query.addLessThanFilter( "foo", 5 );
-
-        LessThan equal = ( LessThan ) query.getRootOperand();
-
-        assertEquals( "foo", equal.getProperty().getValue() );
-        assertEquals( 5l, equal.getLiteral().getValue() );
-    }
-
-
-    @Test
-    public void testCodeLessThanEqual() {
-        Query query = new Query();
-        query.addLessThanEqualFilter( "foo", 5 );
-
-        LessThanEqual equal = ( LessThanEqual ) query.getRootOperand();
-
-        assertEquals( "foo", equal.getProperty().getValue() );
-        assertEquals( 5l, equal.getLiteral().getValue() );
-    }
-
-
-    @Test
-    public void testCodeGreaterThan() {
-        Query query = new Query();
-        query.addGreaterThanFilter( "foo", 5 );
-
-        GreaterThan equal = ( GreaterThan ) query.getRootOperand();
-
-        assertEquals( "foo", equal.getProperty().getValue() );
-        assertEquals( 5l, equal.getLiteral().getValue() );
-    }
-
-
-    @Test
-    public void testCodeGreaterThanEqual() {
-        Query query = new Query();
-        query.addGreaterThanEqualFilter( "foo", 5 );
-
-        GreaterThanEqual equal = ( GreaterThanEqual ) query.getRootOperand();
-
-        assertEquals( "foo", equal.getProperty().getValue() );
-        assertEquals( 5l, equal.getLiteral().getValue() );
-    }
-
-
-    @Test
-    public void testFromJson() throws QueryParseException {
-        String s = "{\"filter\":\"a contains 'ed'\"}";
-        Query q = Query.fromJsonString( s );
-        assertNotNull( q );
-
-        ContainsOperand contains = ( ContainsOperand ) q.getRootOperand();
-
-        assertEquals( "a", contains.getProperty().getValue() );
-        assertEquals( "ed", contains.getString().getValue() );
-    }
-
-
-    @Test
-    public void testCompoundQueryWithNot() throws QueryParseException {
-        String s = "name contains 'm' and not name contains 'grover'";
-        Query q = Query.fromQL( s );
-        assertNotNull( q );
-
-        AndOperand and = ( AndOperand ) q.getRootOperand();
-
-        ContainsOperand contains = ( ContainsOperand ) and.getLeft();
-        assertEquals( "name", contains.getProperty().getValue() );
-        assertEquals( "m", contains.getString().getValue() );
-
-        NotOperand not = ( NotOperand ) and.getRight();
-        contains = ( ContainsOperand ) not.getOperation();
-        assertEquals( "name", contains.getProperty().getValue() );
-        assertEquals( "grover", contains.getString().getValue() );
-    }
-
-
-    @Test
-    public void badGrammar() throws QueryParseException {
-        // from isn't allowed
-        String s = "select * from where name = 'bob'";
-
-        String error = null;
-
-        try {
-            Query.fromQL( s );
-        }
-        catch ( QueryParseException qpe ) {
-            error = qpe.getMessage();
-        }
-
-        assertEquals( "The query cannot be parsed. The token 'from' at column 4 on line 1 cannot be parsed", error );
-    }
-
-
-    @Test
-    public void testTruncation() {
-
-        Query query = new Query();
-        query.setLimit( Query.MAX_LIMIT * 2 );
-
-        assertEquals( Query.MAX_LIMIT, query.getLimit() );
-    }
-
-
-    @Test
-    public void testTruncationFromParams() throws QueryParseException {
-
-        HashMap<String, List<String>> params = new HashMap<String, List<String>>();
-
-        params.put( "limit", Collections.singletonList( "2000" ) );
-
-        Query query = Query.fromQueryParams( params );
-
-        assertEquals( Query.MAX_LIMIT, query.getLimit() );
-    }
-
-
-    @Test
-    public void badOrderByBadGrammar() throws QueryParseException {
-        // from isn't allowed
-        String s = "select * where name = 'bob' order by";
-
-        String error = null;
-
-        try {
-            Query.fromQL( s );
-        }
-        catch ( QueryParseException qpe ) {
-            error = qpe.getMessage();
-        }
-
-        assertEquals( "The query cannot be parsed. The token '<EOF>' at column 13 on line 1 cannot be parsed", error );
-    }
-
-
-    @Test
-    public void badOrderByGrammarAsc() throws QueryParseException {
-        // from isn't allowed
-        String s = "select * where name = 'bob' order by name asc";
-
-        Query q = Query.fromQL( s );
-
-        List<SortPredicate> sorts = q.getSortPredicates();
-
-        assertEquals( 1, sorts.size() );
-
-        assertEquals( "name", sorts.get( 0 ).getPropertyName() );
-        assertEquals( SortDirection.ASCENDING, sorts.get( 0 ).getDirection() );
-    }
-
-
-    @Test
-    public void badOrderByGrammarDesc() throws QueryParseException {
-        // from isn't allowed
-        String s = "select * where name = 'bob' order by name desc";
-
-        Query q = Query.fromQL( s );
-
-        List<SortPredicate> sorts = q.getSortPredicates();
-
-        assertEquals( 1, sorts.size() );
-
-        assertEquals( "name", sorts.get( 0 ).getPropertyName() );
-        assertEquals( SortDirection.DESCENDING, sorts.get( 0 ).getDirection() );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b1e0517e/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java
deleted file mode 100644
index b04c419..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java
+++ /dev/null
@@ -1,822 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.cassandra;
-
-
-import java.math.BigInteger;
-import java.util.Iterator;
-import java.util.UUID;
-
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.TokenRewriteStream;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import org.apache.usergrid.mq.QueryFilterLexer;
-import org.apache.usergrid.mq.QueryFilterParser;
-import org.apache.usergrid.persistence.exceptions.PersistenceException;
-import org.apache.usergrid.persistence.Query;
-import org.apache.usergrid.persistence.index.query.tree.CpQueryFilterLexer;
-import org.apache.usergrid.persistence.index.query.tree.CpQueryFilterParser;
-import org.apache.usergrid.persistence.query.ir.AndNode;
-import org.apache.usergrid.persistence.query.ir.NotNode;
-import org.apache.usergrid.persistence.query.ir.OrNode;
-import org.apache.usergrid.persistence.query.ir.QuerySlice;
-import org.apache.usergrid.persistence.query.ir.SliceNode;
-import org.apache.usergrid.persistence.query.ir.WithinNode;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-
-/**
- * @author tnine
- */
-
-public class QueryProcessorTest {
-
-    @Test
-    public void equality() throws Exception {
-        String queryString = "select * where a = 5";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        SliceNode node = ( SliceNode ) processor.getFirstNode();
-
-        Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertEquals( BigInteger.valueOf( 5 ), slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-        assertEquals( BigInteger.valueOf( 5 ), slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-    }
-
-
-    @Test
-    public void lessThan() throws Exception {
-        String queryString = "select * where a < 5";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        SliceNode node = ( SliceNode ) processor.getFirstNode();
-
-        Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertNull( slice.getStart() );
-
-        assertEquals( BigInteger.valueOf( 5 ), slice.getFinish().getValue() );
-        assertFalse( slice.getFinish().isInclusive() );
-    }
-
-
-    @Test
-    public void lessThanEquals() throws Exception {
-        String queryString = "select * where a <= 5";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        SliceNode node = ( SliceNode ) processor.getFirstNode();
-
-        Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertNull( slice.getStart() );
-
-        assertEquals( BigInteger.valueOf( 5 ), slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-    }
-
-
-    @Test
-    public void greaterThan() throws Exception {
-        String queryString = "select * where a > 5";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        SliceNode node = ( SliceNode ) processor.getFirstNode();
-
-        Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertEquals( BigInteger.valueOf( 5 ), slice.getStart().getValue() );
-        assertFalse( slice.getStart().isInclusive() );
-
-        assertNull( slice.getFinish() );
-    }
-
-
-    @Test
-    public void greaterThanEquals() throws Exception {
-        String queryString = "select * where a >= 5";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        SliceNode node = ( SliceNode ) processor.getFirstNode();
-
-        Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertEquals( BigInteger.valueOf( 5 ), slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-
-        assertNull( slice.getFinish() );
-    }
-
-
-    @Test
-    public void contains() throws Exception {
-        String queryString = "select * where a contains 'foo'";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        SliceNode node = ( SliceNode ) processor.getFirstNode();
-
-        Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertEquals( "a.keywords", slice.getPropertyName() );
-
-        assertEquals( "foo", slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-
-        assertEquals( "foo", slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-    }
-
-
-    @Test
-    public void containsLower() throws Exception {
-        String queryString = "select * where a contains 'FOO'";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        SliceNode node = ( SliceNode ) processor.getFirstNode();
-
-        Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertEquals( "a.keywords", slice.getPropertyName() );
-
-        assertEquals( "foo", slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-
-        assertEquals( "foo", slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-    }
-
-
-    @Test
-    public void containsRange() throws Exception, PersistenceException {
-
-        String queryString = "select * where a contains 'foo*'";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        if ( !(processor.getEntityManager() instanceof EntityManagerImpl) ) {
-            return; // only relevant for old entity manager
-        }
-
-        SliceNode node = ( SliceNode ) processor.getFirstNode();
-
-        Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertEquals( "a.keywords", slice.getPropertyName() );
-
-        assertEquals( "foo", slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-
-        assertEquals( "foo\uffff", slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-    }
-
-
-    @Test
-    public void within() throws Exception {
-        String queryString = "select * where a within .5 of 157.00, 0.00";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        WithinNode node = ( WithinNode ) processor.getFirstNode();
-
-        assertEquals( "a.coordinates", node.getPropertyName() );
-        assertEquals( .5f, node.getDistance(), 0 );
-        assertEquals( 157f, node.getLattitude(), 0 );
-        assertEquals( 0f, node.getLongitude(), 0 );
-    }
-
-
-    @Test
-    public void andEquality() throws Exception {
-        assertAndQuery( "select * where a = 1 and b = 2 and c = 3" );
-        assertAndQuery( "select * where a = 1 AND b = 2 and c = 3" );
-        assertAndQuery( "select * where a = 1 AnD b = 2 and c = 3" );
-        assertAndQuery( "select * where a = 1 ANd b = 2 and c = 3" );
-        assertAndQuery( "select * where a = 1 anD b = 2 and c = 3" );
-        assertAndQuery( "select * where a = 1 ANd b = 2 and c = 3" );
-        assertAndQuery( "select * where a = 1 && b = 2 && c = 3" );
-    }
-
-
-    private void assertAndQuery( String queryString ) throws Exception {
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        SliceNode node = ( SliceNode ) processor.getFirstNode();
-
-        Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-
-        assertEquals( "a", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 1 ), slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-        assertEquals( BigInteger.valueOf( 1 ), slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-
-        slice = slices.next();
-
-        assertEquals( "b", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 2 ), slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-        assertEquals( BigInteger.valueOf( 2 ), slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-
-        slice = slices.next();
-
-        assertEquals( "c", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 3 ), slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-        assertEquals( BigInteger.valueOf( 3 ), slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-    }
-
-
-    @Test
-    public void orEquality() throws Exception {
-        assertOrQuery( "select * where a = 1 or b = 2" );
-        assertOrQuery( "select * where a = 1 OR b = 2" );
-        assertOrQuery( "select * where a = 1 oR b = 2" );
-        assertOrQuery( "select * where a = 1 Or b = 2" );
-        assertOrQuery( "select * where a = 1 || b = 2" );
-    }
-
-
-    private void assertOrQuery( String queryString ) throws Exception {
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        OrNode node = ( OrNode ) processor.getFirstNode();
-
-        SliceNode sliceNode = ( SliceNode ) node.getLeft();
-
-        Iterator<QuerySlice> slices = sliceNode.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertEquals( "a", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 1 ), slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-        assertEquals( BigInteger.valueOf( 1 ), slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-
-        sliceNode = ( SliceNode ) node.getRight();
-
-        slices = sliceNode.getAllSlices().iterator();
-
-        slice = slices.next();
-
-        assertEquals( "b", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 2 ), slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-        assertEquals( BigInteger.valueOf( 2 ), slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-    }
-
-
-    /** Tests that when properties are not siblings, they are properly assigned to a SliceNode */
-    @Test
-    public void nestedCompression() throws Exception {
-        String queryString =
-                "select * where (a > 1 and b > 10 and a < 10 and b < 20 ) or ( c >= 20 and d >= 30 and c <= 30 and d "
-                        + "<= 40)";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        OrNode node = ( OrNode ) processor.getFirstNode();
-
-        SliceNode sliceNode = ( SliceNode ) node.getLeft();
-
-        Iterator<QuerySlice> slices = sliceNode.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-
-        assertEquals( "a", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 1 ), slice.getStart().getValue() );
-        assertFalse( slice.getStart().isInclusive() );
-
-        assertEquals( BigInteger.valueOf( 10 ), slice.getFinish().getValue() );
-        assertFalse( slice.getFinish().isInclusive() );
-
-
-        slice = slices.next();
-
-
-        assertEquals( "b", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 10 ), slice.getStart().getValue() );
-        assertFalse( slice.getStart().isInclusive() );
-
-        assertEquals( BigInteger.valueOf( 20 ), slice.getFinish().getValue() );
-        assertFalse( slice.getFinish().isInclusive() );
-
-
-        sliceNode = ( SliceNode ) node.getRight();
-
-        slices = sliceNode.getAllSlices().iterator();
-
-        slice = slices.next();
-
-
-        assertEquals( "c", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 20 ), slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-        assertEquals( BigInteger.valueOf( 30 ), slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-
-        slice = slices.next();
-
-        assertEquals( "d", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 30 ), slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-        assertEquals( BigInteger.valueOf( 40 ), slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-    }
-
-
-    /** Tests that when there are multiple or with and clauses, the tree is constructed correctly */
-    @Test
-    public void nestedOrCompression() throws Exception {
-        String queryString =
-                "select * where ((a > 1 and  a < 10) or (b > 10 and b < 20 )) or (( c >= 20 and c <= 30 ) or (d >= 30"
-                        + "  and d <= 40))";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        OrNode rootNode = ( OrNode ) processor.getFirstNode();
-
-        OrNode node = ( OrNode ) rootNode.getLeft();
-
-        // get the left node of the or
-
-        SliceNode sliceNode = ( SliceNode ) node.getLeft();
-
-        Iterator<QuerySlice> slices = sliceNode.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertEquals( "a", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 1 ), slice.getStart().getValue() );
-        assertFalse( slice.getStart().isInclusive() );
-
-        assertEquals( BigInteger.valueOf( 10 ), slice.getFinish().getValue() );
-        assertFalse( slice.getFinish().isInclusive() );
-
-        // get our right node
-        sliceNode = ( SliceNode ) node.getRight();
-
-        slices = sliceNode.getAllSlices().iterator();
-
-        slice = slices.next();
-
-        assertEquals( "b", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 10 ), slice.getStart().getValue() );
-        assertFalse( slice.getStart().isInclusive() );
-
-        assertEquals( BigInteger.valueOf( 20 ), slice.getFinish().getValue() );
-        assertFalse( slice.getFinish().isInclusive() );
-
-        node = ( OrNode ) rootNode.getRight();
-
-        sliceNode = ( SliceNode ) node.getLeft();
-
-        slices = sliceNode.getAllSlices().iterator();
-
-        slice = slices.next();
-
-        assertEquals( "c", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 20 ), slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-        assertEquals( BigInteger.valueOf( 30 ), slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-
-        sliceNode = ( SliceNode ) node.getRight();
-
-        slices = sliceNode.getAllSlices().iterator();
-
-        slice = slices.next();
-
-        assertEquals( "d", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 30 ), slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-        assertEquals( BigInteger.valueOf( 40 ), slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-    }
-
-
-    /** Tests that when NOT is not the root operand the tree has a different root */
-    @Test
-    public void andNot() throws Exception {
-        String queryString = "select * where a > 1 and not b = 2";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        AndNode rootNode = ( AndNode ) processor.getFirstNode();
-
-        SliceNode sliceNode = ( SliceNode ) rootNode.getLeft();
-
-        Iterator<QuerySlice> slices = sliceNode.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertEquals( "a", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 1 ), slice.getStart().getValue() );
-        assertFalse( slice.getStart().isInclusive() );
-
-        assertNull( slice.getFinish() );
-
-        NotNode notNode = ( NotNode ) rootNode.getRight();
-
-        // now get the child of the not node
-        sliceNode = ( SliceNode ) notNode.getSubtractNode();
-
-        slices = sliceNode.getAllSlices().iterator();
-
-        slice = slices.next();
-
-        assertEquals( "b", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 2 ), slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-        assertEquals( BigInteger.valueOf( 2 ), slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-    }
-
-
-    /** Tests that when NOT is the root operand, a full scan range is performed. */
-    @Test
-    public void notRootOperand() throws Exception {
-        String queryString = "select * where not b = 2";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        NotNode rootNode = ( NotNode ) processor.getFirstNode();
-
-        SliceNode sliceNode = ( SliceNode ) rootNode.getSubtractNode();
-
-        Iterator<QuerySlice> slices = sliceNode.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertEquals( "b", slice.getPropertyName() );
-        assertEquals( BigInteger.valueOf( 2 ), slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-        assertEquals( BigInteger.valueOf( 2 ), slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-    }
-
-
-    @Test
-    public void stringWithSpaces() throws Exception {
-        String queryString = "select * where a = 'foo with bar'";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        SliceNode node = ( SliceNode ) processor.getFirstNode();
-
-        Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertEquals( "a", slice.getPropertyName() );
-
-        assertEquals( "foo with bar", slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-
-        assertEquals( "foo with bar", slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-    }
-
-
-    @Test
-    public void fieldWithDash() throws Exception {
-        String queryString = "select * where a-foo = 5";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        SliceNode node = ( SliceNode ) processor.getFirstNode();
-
-        Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertEquals( "a-foo", slice.getPropertyName() );
-
-        assertEquals( BigInteger.valueOf( 5 ), slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-        assertEquals( BigInteger.valueOf( 5 ), slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-    }
-
-
-    @Test
-    public void stringWithDash() throws Exception {
-        String queryString = "select * where a = 'foo-bar'";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        SliceNode node = ( SliceNode ) processor.getFirstNode();
-
-        Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertEquals( "a", slice.getPropertyName() );
-
-        assertEquals( "foo-bar", slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-
-        assertEquals( "foo-bar", slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-    }
-
-
-    @Test
-    public void uuidParse() throws Exception {
-
-        //    UUID value = UUID.fromString("4b91a9c2-86a1-11e2-b7fa-68a86d52fa56");
-        //
-        //
-        //    String queryString = "select * where uuid = 4b91a9c2-86a1-11e2-b7fa-68a86d52fa56";
-
-        UUID value = UUID.fromString( "c6ee8a1c-3ef4-11e2-8861-02e81adcf3d0" );
-        String queryString = "select * where uuid = c6ee8a1c-3ef4-11e2-8861-02e81adcf3d0";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        Query query = parser.ql().query;
-
-        QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
-        SliceNode node = ( SliceNode ) processor.getFirstNode();
-
-        Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
-        QuerySlice slice = slices.next();
-
-        assertEquals( "uuid", slice.getPropertyName() );
-
-        assertEquals( value, slice.getStart().getValue() );
-        assertTrue( slice.getStart().isInclusive() );
-        assertEquals( value, slice.getFinish().getValue() );
-        assertTrue( slice.getFinish().isInclusive() );
-    }
-
-
-    @Test
-    @Ignore("no longer relevant for two-dot-o")
-    public void validateHintSizeForOrder() throws Exception {
-        String queryString = "order by name desc";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        QueryFilterLexer lexer = new QueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        QueryFilterParser parser = new QueryFilterParser( tokens );
-
-        /**
-         * Test set limit
-         */
-
-        final int limit = 105;
-
-//        Query query = parser.ql().query;
-//        query.setLimit( limit );
-//
-//        QueryProcessor processor = new QueryProcessor( query, null, null, null );
-//
-//        OrderByNode node = ( OrderByNode ) processor.getFirstNode();
-//
-//        assertEquals( limit, processor.getPageSizeHint( node ) );
-    }
-
-
-    @Test
-    @Ignore("no longer relevant for two-dot-o")
-    public void validateHintSizeForEquality() throws Exception {
-        String queryString = "select * where X = 'Foo'";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        /**
-         * Test set limit
-         */
-
-        final int limit = 105;
-
-        Query query = parser.ql().query;
-        query.setLimit( limit );
-
-//        QueryProcessor processor = new QueryProcessor( query, null, null, null );
-//
-//        SliceNode node = ( SliceNode ) processor.getFirstNode();
-//
-//        assertEquals( limit, processor.getPageSizeHint( node ) );
-    }
-
-
-    @Test
-    @Ignore("no longer relevant for two-dot-o")
-    public void validateHintSizeForComplexQueries() throws Exception {
-        //        String queryString = "select * where y = 'Foo' AND z = 'Bar'";
-
-        String queryString = "select * where y = 'Foo' AND z = 'Bar'";
-
-        ANTLRStringStream in = new ANTLRStringStream( queryString );
-        CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
-        TokenRewriteStream tokens = new TokenRewriteStream( lexer );
-        CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
-        /**
-         * Test set limit
-         */
-
-        final int limit = 105;
-
-        Query query = parser.ql().query;
-        query.setLimit( limit );
-
-//        QueryProcessor processor = new QueryProcessor( query, null, null, null );
-//
-//        QueryNode slice =  processor.getFirstNode();
-//
-//        assertEquals( 1000, processor.getPageSizeHint( slice ) );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b1e0517e/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/SimpleIndexShardLocatorImplTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/SimpleIndexShardLocatorImplTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/SimpleIndexShardLocatorImplTest.java
deleted file mode 100644
index 2618e49..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/SimpleIndexShardLocatorImplTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.cassandra;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-
-import org.junit.Test;
-
-import org.apache.usergrid.persistence.IndexBucketLocator.IndexType;
-import org.apache.usergrid.utils.UUIDUtils;
-
-import com.yammer.metrics.Metrics;
-import com.yammer.metrics.core.Timer;
-import com.yammer.metrics.core.TimerContext;
-
-import static org.junit.Assert.assertEquals;
-
-
-/** @author tnine */
-
-public class SimpleIndexShardLocatorImplTest {
-    @Test
-    public void oneBucket() {
-
-        UUID appId = UUIDUtils.newTimeUUID();
-        String entityType = "user";
-        String propName = "firstName";
-
-        SimpleIndexBucketLocatorImpl locator = new SimpleIndexBucketLocatorImpl( 1 );
-
-        List<String> buckets = locator.getBuckets( appId, IndexType.COLLECTION, entityType, propName );
-
-        assertEquals( 1, buckets.size() );
-
-        UUID testId1 = UUIDUtils.minTimeUUID( 0l );
-
-        UUID testId2 = UUIDUtils.minTimeUUID( Long.MAX_VALUE / 2 );
-
-        UUID testId3 = UUIDUtils.minTimeUUID( Long.MAX_VALUE );
-
-        String bucket1 = locator.getBucket( appId, IndexType.COLLECTION, testId1, entityType, propName );
-
-        String bucket2 = locator.getBucket( appId, IndexType.COLLECTION, testId2, entityType, propName );
-
-        String bucket3 = locator.getBucket( appId, IndexType.COLLECTION, testId3, entityType, propName );
-
-        assertEquals( bucket1, "000000000000000000000000000000000000000" );
-        assertEquals( bucket2, "000000000000000000000000000000000000000" );
-        assertEquals( bucket3, "000000000000000000000000000000000000000" );
-    }
-
-
-    @Test
-    public void twoBuckets() {
-
-        UUID appId = UUIDUtils.newTimeUUID();
-        String entityType = "user";
-        String propName = "firstName";
-
-        SimpleIndexBucketLocatorImpl locator = new SimpleIndexBucketLocatorImpl( 2 );
-
-        List<String> buckets = locator.getBuckets( appId, IndexType.COLLECTION, entityType, propName );
-
-        assertEquals( 2, buckets.size() );
-
-        UUID testId1 = UUIDUtils.minTimeUUID( 0l );
-
-        UUID testId2 = UUIDUtils.maxTimeUUID( Long.MAX_VALUE / 2 );
-
-        UUID testId3 = UUIDUtils.minTimeUUID( Long.MAX_VALUE );
-
-        String bucket1 = locator.getBucket( appId, IndexType.COLLECTION, testId1, entityType, propName );
-
-        String bucket2 = locator.getBucket( appId, IndexType.COLLECTION, testId2, entityType, propName );
-
-        String bucket3 = locator.getBucket( appId, IndexType.COLLECTION, testId3, entityType, propName );
-
-        assertEquals( bucket1, "000000000000000000000000000000000000000" );
-        assertEquals( bucket2, "085070591730234615865843651857942052863" );
-        assertEquals( bucket3, "000000000000000000000000000000000000000" );
-    }
-
-
-    @Test
-    public void evenDistribution() {
-
-        UUID appId = UUIDUtils.newTimeUUID();
-        String entityType = "user";
-        String propName = "firstName";
-
-        int bucketSize = 20;
-        float distributionPercentage = .05f;
-
-        // test 100 elements
-        SimpleIndexBucketLocatorImpl locator = new SimpleIndexBucketLocatorImpl( bucketSize );
-
-        List<String> buckets = locator.getBuckets( appId, IndexType.COLLECTION, entityType, propName );
-
-        assertEquals( bucketSize, buckets.size() );
-
-        int testSize = 2000000;
-
-        Map<String, Float> counts = new HashMap<String, Float>();
-
-        final Timer hashes =
-                Metrics.newTimer( SimpleIndexShardLocatorImplTest.class, "responses", TimeUnit.MILLISECONDS,
-                        TimeUnit.SECONDS );
-
-        // ConsoleReporter.enable(1, TimeUnit.SECONDS);
-
-        /**
-         * Loop through each new UUID and add it's hash to our map
-         */
-        for ( int i = 0; i < testSize; i++ ) {
-            UUID id = UUIDUtils.newTimeUUID();
-
-            final TimerContext context = hashes.time();
-
-            String bucket = locator.getBucket( appId, IndexType.COLLECTION, id, entityType, propName );
-
-            context.stop();
-
-            Float count = counts.get( bucket );
-
-            if ( count == null ) {
-                count = 0f;
-            }
-
-            counts.put( bucket, ++count );
-        }
-
-        /**
-         * Check each entry is within +- 5% of every subsequent entry
-         */
-        List<String> keys = new ArrayList<String>( counts.keySet() );
-        int keySize = keys.size();
-
-        assertEquals( bucketSize, keySize );
-
-        for ( int i = 0; i < keySize; i++ ) {
-
-            float sourceCount = counts.get( keys.get( i ) );
-
-            for ( int j = i + 1; j < keySize; j++ ) {
-                float destCount = counts.get( keys.get( j ) );
-
-                // find the maximum allowed value for the assert based on the
-                // largest value in the pair
-                float maxDelta = Math.max( sourceCount, destCount ) * distributionPercentage;
-
-                assertEquals(
-                        String.format( "Not within %f as percentage for keys '%s' and '%s'", distributionPercentage,
-                                keys.get( i ), keys.get( j ) ), sourceCount, destCount, maxDelta );
-            }
-        }
-    }
-}


Mime
View raw message