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/09/16 16:58:47 UTC

git commit: Put partial update test in more sensible package.

Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o 9755c9ccc -> 5f5c0c67a


Put partial update test in more sensible package.


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

Branch: refs/heads/two-dot-o
Commit: 5f5c0c67a0f799b37f9e83df125c337cce52adfd
Parents: 9755c9c
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Sep 16 10:58:31 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Sep 16 10:58:31 2014 -0400

----------------------------------------------------------------------
 .../apache/usergrid/rest/PartialUpdateTest.java | 88 ++++++++++++++++++++
 .../collection/activities/PutTest.java          | 50 -----------
 2 files changed, 88 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f5c0c67/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
new file mode 100644
index 0000000..8996eef
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.rest;
+
+
+import org.apache.usergrid.rest.applications.collection.activities.*;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.sun.jersey.api.client.UniformInterfaceException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import javax.ws.rs.core.MediaType;
+import org.apache.usergrid.rest.AbstractRestIT;
+import org.apache.usergrid.rest.TestContextSetup;
+import org.apache.usergrid.rest.test.resource.CustomCollection;
+import static org.apache.usergrid.utils.MapUtils.hashMap;
+
+import static org.junit.Assert.assertEquals;
+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;
+
+
+/**
+ * Test update and partial update.
+ */
+public class PartialUpdateTest extends AbstractRestIT {
+    private static final Logger log= LoggerFactory.getLogger(PartialUpdateTest.class );
+    
+    @Rule
+    public TestContextSetup context = new TestContextSetup( this );
+
+
+    @Test //USERGRID-545
+    public void putMassUpdateTest() throws IOException {
+
+        CustomCollection activities = context.collection( "activities" );
+
+        Map actor = hashMap( "displayName", "Erin" );
+        Map newActor = hashMap( "displayName", "Bob" );
+        Map props = new HashMap();
+
+        props.put( "actor", actor );
+        props.put( "verb", "go" );
+        props.put( "content", "bragh" );
+
+
+        for ( int i = 0; i < 5; i++ ) {
+            props.put( "ordinal", i );
+            JsonNode activity = activities.create( props );
+        }
+
+        refreshIndex(context.getOrgName(), context.getAppName());
+
+        String query = "select * ";
+
+        JsonNode node = activities.withQuery( query ).get();
+        String uuid = node.get( "entities" ).get( 0 ).get( "uuid" ).textValue();
+        StringBuilder buf = new StringBuilder( uuid );
+
+        activities.addToUrlEnd( buf );
+        props.put( "actor", newActor );
+        node = activities.put( props );
+
+        refreshIndex(context.getOrgName(), context.getAppName());
+
+        node = activities.withQuery( query ).get();
+        assertEquals( 6, node.get( "entities" ).size() );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f5c0c67/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PutTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PutTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PutTest.java
index cb40fdf..778f33e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PutTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PutTest.java
@@ -18,20 +18,14 @@ package org.apache.usergrid.rest.applications.collection.activities;
 
 
 import com.fasterxml.jackson.databind.JsonNode;
-import com.sun.jersey.api.client.UniformInterfaceException;
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.LinkedHashMap;
 import java.util.Map;
-import javax.ws.rs.core.MediaType;
 import org.apache.usergrid.rest.AbstractRestIT;
 import org.apache.usergrid.rest.TestContextSetup;
 import org.apache.usergrid.rest.test.resource.CustomCollection;
 import static org.apache.usergrid.utils.MapUtils.hashMap;
-
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
 import org.junit.Rule;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -84,48 +78,4 @@ public class PutTest extends AbstractRestIT {
         node = activities.withQuery( query ).get();
         assertEquals( 6, node.get( "entities" ).size() );
     }
-
-    @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" );
-        }};
-
-        JsonNode userNode = mapper.readTree( 
-            resource().path( "/test-organization/test-app/users" )
-                .queryParam( "access_token", adminAccessToken )
-                .accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON )
-                .post( String.class, userProperties ));
-
-        assertNotNull( userNode );
-        String uuid = userNode.withArray("entities").get(0).get("uuid").asText();
-        assertNotNull( uuid );
-
-        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" );
-        }};
-
-        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 ));
-
-        } catch ( UniformInterfaceException uie ) {
-            fail("Update failed due to: " + uie.getResponse().getEntity(String.class));
-        }
-
-    }
 }