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:04 UTC

[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.

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" ) );
 
         }
     }