You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/12/03 20:59:27 UTC

[17/50] [abbrv] incubator-usergrid git commit: updated basic geo tests

updated basic geo tests


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

Branch: refs/heads/two-dot-o-events
Commit: 09333ac4bf88670f6ece72f7dd13f6f59bbff4ae
Parents: 2586e9f
Author: Rod Simpson <ro...@apigee.com>
Authored: Mon Nov 24 18:31:12 2014 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Mon Nov 24 18:31:12 2014 -0700

----------------------------------------------------------------------
 .../applications/queries/basicGeoTests.java     | 88 +++++++++++++++++++-
 1 file changed, 86 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/09333ac4/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java
index e921b37..abaf6dd 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java
@@ -59,6 +59,8 @@ public class basicGeoTests extends AbstractRestIT {
 
     /**
      * Create a entity with a geo location point in it
+     * 1. Create entity
+     * 2. Verify that the entity was created
      */
     @Test
     public void createEntityWithGeoLocationPoint() throws IOException {
@@ -67,6 +69,7 @@ public class basicGeoTests extends AbstractRestIT {
         JsonNode node = null;
         Double lat = 37.776753;
         Double lon = -122.407846;
+        //1. Create entity
         Map<String, Double> latLon = hashMap("latitude", lat);
         latLon.put( "longitude", lon );
         Map<String, Object> entityData = new HashMap<String, Object>();
@@ -77,16 +80,97 @@ public class basicGeoTests extends AbstractRestIT {
         }
         catch ( UniformInterfaceException e ) {
             JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
-            fail( node.get( "error" ).textValue() );
+            fail( nodeError.get( "error" ).textValue() );
         }
 
+        //2. Verify that the entity was created
         assertNotNull( node );
-        assertEquals(lat.toString(), node.get("location").get("latitude").asText() );
+        assertEquals( lat.toString(), node.get("location").get("latitude").asText() );
         assertEquals( lon.toString(), node.get( "location" ).get("longitude").asText() );
 
     }
 
     /**
+     * Update an entity with a geo location point in it
+     * 1. create an entity with a geo point
+     * 2. read back that entity make sure it is accurate
+     * 3. update the geo point to a new value
+     * 4. read back the updated entity, make sure it is accurate
+     */
+    @Test
+    public void updateEntityWithGeoLocationPoint() throws IOException {
+
+        String collectionType = "stores";
+        String entityName = "cornerStore";
+        JsonNode entity = null;
+        Double lat = 37.776753;
+        Double lon = -122.407846;
+
+        //1. create an entity with a geo point
+        Map<String, Double> latLon = hashMap("latitude", lat);
+        latLon.put( "longitude", lon );
+        Map<String, Object> entityData = new HashMap<String, Object>();
+        entityData.put( "location", latLon );
+        entityData.put( "name", entityName );
+
+        try {
+            entity = context.collection( collectionType ).post( entityData );
+        }
+        catch ( UniformInterfaceException e ) {
+            JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+            fail( nodeError.get( "error" ).textValue() );
+        }
+
+        assertNotNull(entity);
+        assertEquals( lat.toString(), entity.get("location").get("latitude").asText() );
+        assertEquals( lon.toString(), entity.get( "location" ).get("longitude").asText() );
+
+        context.refreshIndex();
+
+        //2. read back that entity make sure it is accurate
+        /*
+        try {
+            node = context.collection( collectionType ).get(entityName);
+        }
+        catch ( UniformInterfaceException e ) {
+            JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+            fail( nodeError.get( "error" ).textValue() );
+        }
+
+        //3. update the geo point to a new value
+        Double newLat = 35.776753;
+        Double newLon = -119.407846;
+        latLon.put( "latitude", newLat );
+        latLon.put( "longitude", newLon );
+        entityData.put( "location", latLon );
+
+        //TODO PUT should take name property and append it to URL - e.g. PUT /cats/fluffy  not PUT /cats {"name":"fluffy"}
+        try {
+            //node = context.collection( collectionType ).put(entityData);
+            //entity.put(entityData);
+
+        }
+        catch ( UniformInterfaceException e ) {
+            JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+            fail( nodeError.get( "error" ).textValue() );
+        }
+
+        assertNotNull(entity);
+        assertEquals( newLat.toString(), entity.get("location").get("latitude").asText() );
+        assertEquals( newLon.toString(), entity.get( "location" ).get("longitude").asText() );
+  */
+
+        context.refreshIndex();
+
+        //4. read back the updated entity, make sure it is accurate
+
+
+
+
+
+    }
+
+    /**
      * Test exceptions for entities with poorly created geo points
      * 1. misspell latitude
      * 2. misspell longitude