You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2015/03/16 23:39:03 UTC

[1/2] incubator-usergrid git commit: Created test that makes 10 cats and gets them back.

Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-460 [created] 65ff858db


Created test that makes 10 cats and gets them back.


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

Branch: refs/heads/USERGRID-460
Commit: 7c5b070215647137dde868fed1a47c03da96ebcf
Parents: b0a07ba
Author: GERey <gr...@apigee.com>
Authored: Mon Mar 16 11:10:49 2015 -0700
Committer: GERey <gr...@apigee.com>
Committed: Mon Mar 16 11:10:49 2015 -0700

----------------------------------------------------------------------
 .../applications/queries/GeoPagingTest.java     | 42 ++++++++++++++++++++
 1 file changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7c5b0702/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
index f9fe5b3..38ebeaf 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
@@ -197,6 +197,48 @@ public class GeoPagingTest extends AbstractRestIT {
     }
   }
 
+    /**
+     * Test that geo-query returns co-located entities in expected order.
+     */
+    @Test // USERGRID-1401
+    public void groupQueriesWithDistanceOrderedResults() throws IOException {
+
+        int maxRangeLimit = 10;
+        Entity[] cats = new Entity[maxRangeLimit];
+
+        // 1. Create several entities
+        for (int i = 0; i < maxRangeLimit; i++) {
+            float latDelta = i;
+            Entity cat = new Entity();
+            cat.put("name", "cat" + i);
+            cat.put("location", new MapUtils.HashMapBuilder<String, Double>()
+                .map("latitude", 37.0+(latDelta/10))
+                .map("longitude", (-75.0)));
+            cats[i] = cat;
+            this.app().collection("cats").post(cat);
+        }
+        this.refreshIndex();
+
+        QueryParameters params = new QueryParameters();
+        String query = String.format(
+            "select * where location within 1000000 of 37, -75");
+        params.setQuery(query);
+        Collection collection = this.app().collection("cats").get(params);
+        assertNotNull( collection );
+        List entities = collection.getResponse().getEntities();
+        assertNotNull( entities );
+
+        for (int consistent = 0; consistent < maxRangeLimit; consistent++) {
+//got entities back, just need to page through them and make sure that i got them in location order.
+            Object entity = entities.get( consistent );
+            assertNotNull( entity );
+
+
+
+
+        }
+    }
+
 
   /**
    * Creates a store right on top of the center store and checks to see if we can find that store, then find both


[2/2] incubator-usergrid git commit: Added test that checks entities written to a collection in reverse and proves that locations queried are returned in collection order instead of distance order.

Posted by gr...@apache.org.
Added test that checks entities written to a collection in reverse and proves that locations queried are returned in collection order instead of distance order.


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

Branch: refs/heads/USERGRID-460
Commit: 65ff858dbf9b2e30a7322ad4612fd5d8a4120914
Parents: 7c5b070
Author: GERey <gr...@apigee.com>
Authored: Mon Mar 16 13:15:23 2015 -0700
Committer: GERey <gr...@apigee.com>
Committed: Mon Mar 16 13:15:23 2015 -0700

----------------------------------------------------------------------
 .../applications/queries/GeoPagingTest.java     | 25 ++++++++++----------
 1 file changed, 12 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/65ff858d/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
index 38ebeaf..a444fbd 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
@@ -203,17 +203,16 @@ public class GeoPagingTest extends AbstractRestIT {
     @Test // USERGRID-1401
     public void groupQueriesWithDistanceOrderedResults() throws IOException {
 
-        int maxRangeLimit = 10;
-        Entity[] cats = new Entity[maxRangeLimit];
+        int maxRangeLimit = 9;
+        Entity[] cats = new Entity[maxRangeLimit+1];
 
         // 1. Create several entities
-        for (int i = 0; i < maxRangeLimit; i++) {
-            float latDelta = i;
+        for (int i = maxRangeLimit; i >= 0; i--) {
             Entity cat = new Entity();
             cat.put("name", "cat" + i);
-            cat.put("location", new MapUtils.HashMapBuilder<String, Double>()
-                .map("latitude", 37.0+(latDelta/10))
-                .map("longitude", (-75.0)));
+            cat.put( "location",
+                new MapUtils.HashMapBuilder<String, Double>().map( "latitude", 37.0 + i )
+                                                             .map( "longitude", ( -75.0 + i) ) );
             cats[i] = cat;
             this.app().collection("cats").post(cat);
         }
@@ -221,7 +220,7 @@ public class GeoPagingTest extends AbstractRestIT {
 
         QueryParameters params = new QueryParameters();
         String query = String.format(
-            "select * where location within 1000000 of 37, -75");
+            "select * where location within 1500000 of 37, -75");
         params.setQuery(query);
         Collection collection = this.app().collection("cats").get(params);
         assertNotNull( collection );
@@ -229,12 +228,12 @@ public class GeoPagingTest extends AbstractRestIT {
         assertNotNull( entities );
 
         for (int consistent = 0; consistent < maxRangeLimit; consistent++) {
-//got entities back, just need to page through them and make sure that i got them in location order.
-            Object entity = entities.get( consistent );
+            //got entities back, just need to page through them and make sure that i got them in location order.
+            Entity entity = (Entity) entities.get( consistent );
             assertNotNull( entity );
-
-
-
+            LinkedHashMap location = ( LinkedHashMap ) entity.get( "location" );
+            assertEquals( 37.0+ consistent,location.get( "latitude" ) );
+            assertEquals( -75.0+ consistent , location.get( "longitude" ) );
 
         }
     }