usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [3/9] git commit: update to partialUpdateTest
Date Thu, 02 Oct 2014 07:31:48 GMT
update to partialUpdateTest


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

Branch: refs/heads/esbatching
Commit: 76b3421bad587c2339bd9a8772179f9586fae751
Parents: 16d497e
Author: amuramoto <amuramoto@apigee.com>
Authored: Tue Sep 30 16:37:34 2014 -0700
Committer: amuramoto <amuramoto@apigee.com>
Committed: Tue Sep 30 16:37:34 2014 -0700

----------------------------------------------------------------------
 .../apache/usergrid/rest/PartialUpdateTest.java | 86 +++++++++-----------
 1 file changed, 38 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/76b3421b/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 c2f3fcb..7053160 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,19 +23,14 @@ import java.io.IOException;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import javax.ws.rs.core.MediaType;
-<<<<<<< HEAD
 
-=======
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
->>>>>>> e5bcbb23be66d12e428d817fd8b0b495793a939c
 import org.junit.Rule;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotEquals;
 
 
 /**
@@ -63,14 +58,7 @@ public class PartialUpdateTest extends AbstractRestIT {
             put( "username", "bart" );
             put( "employer", "Brawndo" );
             put( "email", "bart@personal-email.example.com" );
-<<<<<<< HEAD
             put( "location", geolocation);
-=======
-            put( "location", new LinkedHashMap<String, Object>() {{
-                put("latitude", "37.3638875323994");
-                put("longitude", "-122.12334411518498");
-            }} );
->>>>>>> e5bcbb23be66d12e428d817fd8b0b495793a939c
         }};
 
         JsonNode userNode = mapper.readTree( 
@@ -85,14 +73,13 @@ public class PartialUpdateTest extends AbstractRestIT {
         assertNotNull( uuid );
         refreshIndex( "test-organization", "test-app" );
 
+        Map<String, Object> updateProperties = new LinkedHashMap<String, Object>();
         // update user bart passing only an update to a property
-        for(int i=1; i<20; i++) {
+        for(int i=1; i<10; 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);
-            }};
+            updateProperties.put("employer", "Initech");
+            updateProperties.put("location", geolocation);
 
             try {
                 JsonNode updatedNode = mapper.readTree(
@@ -102,22 +89,23 @@ public class PartialUpdateTest extends AbstractRestIT {
                                 .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));
             }
-        }
-        refreshIndex( "test-organization", "test-app" );
-
-        userNode = mapper.readTree( 
-            resource().path( "/test-organization/test-app/users/" + uuid )
-                .queryParam( "access_token", adminAccessToken )
-                .accept( MediaType.APPLICATION_JSON )
-                .get( String.class ));
-        assertNotNull( userNode );
-        assertEquals( "Initech", userNode.withArray("entities").get(0).get("employer").asText());
 
+            refreshIndex("test-organization", "test-app");
+
+            userNode = mapper.readTree(
+                    resource().path("/test-organization/test-app/users/" + uuid)
+                            .queryParam("access_token", adminAccessToken)
+                            .accept(MediaType.APPLICATION_JSON)
+                            .get(String.class));
+            assertNotNull(userNode);
+            assertEquals("Initech", userNode.withArray("entities").get(0).get("employer").asText());
+            assertNotEquals(latitude, userNode.withArray("entities").get(0).get("location").get("latitude"));
+            assertNotEquals(longitude, userNode.withArray("entities").get(0).get("location").get("longitude"));
+        }
 
         // Update bart's employer without specifying any required fields 
         // (this time with username specified in URL)
@@ -126,25 +114,27 @@ public class PartialUpdateTest extends AbstractRestIT {
             put( "employer", "ACME Corporation" );
         }};
 
-        try {
-            mapper.readTree( 
-                resource().path( "/test-organization/test-app/users/bart")
-                    .queryParam( "access_token", adminAccessToken )
-                    .accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON )
-                    .put( String.class, updateProperties ));
+        for(int i=1; i<10; i++) {
+            try {
+                mapper.readTree(
+                        resource().path("/test-organization/test-app/users/bart")
+                                .queryParam("access_token", adminAccessToken)
+                                .accept(MediaType.APPLICATION_JSON)
+                                .type(MediaType.APPLICATION_JSON)
+                                .put(String.class, updateProperties));
 
-        } 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));
+            }
+            refreshIndex("test-organization", "test-app");
+
+            userNode = mapper.readTree(
+                    resource().path("/test-organization/test-app/users/bart")
+                            .queryParam("access_token", adminAccessToken)
+                            .accept(MediaType.APPLICATION_JSON)
+                            .get(String.class));
+            assertNotNull(userNode);
+            assertEquals("ACME Corporation", userNode.withArray("entities").get(0).get("employer").asText());
         }
-        refreshIndex( "test-organization", "test-app" );
-
-        userNode = mapper.readTree( 
-            resource().path( "/test-organization/test-app/users/bart" )
-                .queryParam( "access_token", adminAccessToken )
-                .accept( MediaType.APPLICATION_JSON )
-                .get( String.class ));
-        assertNotNull( userNode );
-        assertEquals( "ACME Corporation", userNode.withArray("entities").get(0).get("employer").asText());
     }
 }


Mime
View raw message