usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [1/9] git commit: Fix for partial update error
Date Thu, 02 Oct 2014 07:31:46 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/esbatching c051fdaec -> 38885fa8e


Fix for partial update error


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

Branch: refs/heads/esbatching
Commit: a5b6274864b11f27c8c95d9f1781a96c2b8b01f6
Parents: 0cc97c6
Author: amuramoto <amuramoto@apigee.com>
Authored: Tue Sep 30 15:37:13 2014 -0700
Committer: amuramoto <amuramoto@apigee.com>
Committed: Tue Sep 30 15:37:13 2014 -0700

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        |  2 +-
 .../apache/usergrid/rest/PartialUpdateTest.java | 50 +++++++++++++-------
 2 files changed, 34 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a5b62748/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index b27a61d..5e46d7f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -505,7 +505,7 @@ public class CpEntityManager implements EntityManager {
             logger.debug("About to Write {}:{} version {}", new Object[] { 
                 cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion()
});
 
-            cpEntity = ecm.write( cpEntity ).toBlockingObservable().last();
+            cpEntity = ecm.update( cpEntity ).toBlockingObservable().last();
 
             logger.debug("Wrote {}:{} version {}", new Object[] { 
                 cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion()
});

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a5b62748/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
index 366df14..e150755 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
@@ -23,13 +23,14 @@ import java.io.IOException;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import javax.ws.rs.core.MediaType;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+
 import org.junit.Rule;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.junit.Assert.*;
+
 
 /**
  * Partial update test. 
@@ -40,15 +41,23 @@ public class PartialUpdateTest extends AbstractRestIT {
     @Rule
     public TestContextSetup context = new TestContextSetup( this );
 
+    double latitude=37.772837;
+    double longitude=-122.409895;
+
+    Map<String, Object> geolocation = new LinkedHashMap<String, Object>() {{
+        put("latitude", latitude);
+        put("longitude", longitude);
+    }};
+
     @Test 
     public void testPartialUpdate() throws IOException {
 
         // create user bart
-
         Map<String, Object> userProperties = new LinkedHashMap<String, Object>()
{{
             put( "username", "bart" );
             put( "employer", "Brawndo" );
             put( "email", "bart@personal-email.example.com" );
+            put( "location", geolocation);
         }};
 
         JsonNode userNode = mapper.readTree( 
@@ -64,22 +73,29 @@ public class PartialUpdateTest extends AbstractRestIT {
 
         refreshIndex( "test-organization", "test-app" );
 
-        // update user bart passing only an update to his employer
-
-        Map<String, Object> updateProperties = new LinkedHashMap<String, Object>()
{{
-            put( "employer", "Initech" );
-        }};
+        // update user bart passing only an update to a property
+        for(int i=1; i<20; i++) {
+            geolocation.put("latitude", latitude += 0.00001);
+            geolocation.put("longitude", longitude += 0.00001);
+            Map<String, Object> updateProperties = new LinkedHashMap<String, Object>()
{{
+                put("employer", "Initech");
+                put("location", geolocation);
+            }};
 
-        try {
-            JsonNode updatedNode = mapper.readTree( 
-                resource().path( "/test-organization/test-app/user/" + uuid )
-                    .queryParam( "access_token", adminAccessToken )
-                    .accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON )
-                    .put( String.class, updateProperties ));
+            try {
+                JsonNode updatedNode = mapper.readTree(
+                        resource().path("/test-organization/test-app/user/" + uuid)
+                                .queryParam("access_token", adminAccessToken)
+                                .accept(MediaType.APPLICATION_JSON)
+                                .type(MediaType.APPLICATION_JSON)
+                                .put(String.class, updateProperties));
+                assertNotNull(updatedNode);
+                assertNotEquals(latitude, updatedNode.get("entities").get(0).get("location").get("latitude"));
+                assertNotEquals(longitude, updatedNode.get("entities").get(0).get("location").get("longitude"));
 
-        } catch ( UniformInterfaceException uie ) {
-            fail("Update failed due to: " + uie.getResponse().getEntity(String.class));
+            } catch (UniformInterfaceException uie) {
+                fail("Update failed due to: " + uie.getResponse().getEntity(String.class));
+            }
         }
     }
 }


Mime
View raw message