usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [1/4] incubator-usergrid git commit: removed UpdateGroupIT, merged test into GroupResourceIT
Date Tue, 06 Jan 2015 04:38:40 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/Usergrid-310 1404292b9 -> fe7719ab8


removed UpdateGroupIT, merged test into GroupResourceIT


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

Branch: refs/heads/Usergrid-310
Commit: 132b63041e74732326df31877ace542e51e37064
Parents: 8961fec
Author: Rod Simpson <rod@apigee.com>
Authored: Mon Jan 5 20:29:02 2015 -0700
Committer: Rod Simpson <rod@apigee.com>
Committed: Mon Jan 5 20:29:02 2015 -0700

----------------------------------------------------------------------
 .../collection/groups/GroupResourceIT.java      |  32 ++++++
 .../collection/groups/UpdateGroupIT.java        | 114 -------------------
 .../rest/test/resource2point0/model/Entity.java |   4 +
 3 files changed, 36 insertions(+), 114 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/132b6304/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
index e7acf4b..08b6fa6 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
@@ -48,9 +48,14 @@ public class GroupResourceIT extends AbstractRestIT {
      *
      */
     private Entity createGroup(String groupName, String groupPath) throws IOException{
+        String title = "title";
+        return createGroup(groupName, groupPath, title);
+    }
+    private Entity createGroup(String groupName, String groupPath, String groupTitle) throws
IOException{
         Entity payload = new Entity();
         payload.put("name", groupName);
         payload.put("path", groupPath);
+        payload.put("title", groupTitle);
         Entity entity = this.app().collection("groups").post(payload);
         assertEquals(entity.get("name"), groupName);
         assertEquals(entity.get("path"), groupPath);
@@ -507,5 +512,32 @@ public class GroupResourceIT extends AbstractRestIT {
 
     }
 
+    public void updateGroupWithSameNameAsApp() throws IOException {
+
+
+        // create groupMap with same name as app
+        String groupPath = this.clientSetup.getAppName();
+        String groupName = this.clientSetup.getAppName();
+        String title = "Old Title";
+        Entity group = this.createGroup(groupName, groupPath, title);
+
+        String newTitle = "New Title";
+        group.put("title", newTitle);
+        Entity groupResponse = this.app().collection("groups").entity(group).put(group);
+        assertEquals(groupResponse.get("title"), newTitle);
+        this.refreshIndex();
+
+        // update that group by giving it a new title and using UUID in URL
+        String evenNewerTitle = "Even New Title";
+        group.put("title", newTitle);
+        String uuid = group.getString("uuid");
+        groupResponse = this.app().collection("groups").uniqueID(uuid).put(group);
+        assertEquals(groupResponse.get("title"), evenNewerTitle);
+        this.refreshIndex();
+
+
+
+    }
+
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/132b6304/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java
deleted file mode 100644
index 7bbd95b..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.applications.collection.groups;
-
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.junit.Rule;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.rest.TestContextSetup;
-
-import org.apache.commons.io.IOUtils;
-
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.WebResource;
-
-import junit.framework.Assert;
-
-import static org.junit.Assert.fail;
-
-
-public class UpdateGroupIT extends AbstractRestIT {
-    private static final Logger logger = LoggerFactory.getLogger( UpdateGroupIT.class );
-
-    @Rule
-    public TestContextSetup context = new TestContextSetup( this );
-
-
-    @Test // USERGRID-1729
-    public void updateGroupWithSameNameAsApp() throws IOException {
-
-        // create groupMap with same name as app
-        String groupId = null;
-        String groupPath = context.getAppName();
-        try {
-            Map<String, Object> groupMap = new HashMap<String, Object>();
-            groupMap.put( "title", "Old Title" );
-            groupMap.put( "path", groupPath );
-            String path = context.getOrgName() + "/" + context.getAppName() + "/groups";
-            JsonNode groupJson = mapper.readTree( webResourceBuilder( path ).post( String.class,
groupMap ));
-            groupId = groupJson.get( "entities" ).get( 0 ).get( "uuid" ).textValue();
-        }
-        catch ( UniformInterfaceException e ) {
-            fail( "Error creating group: " + IOUtils.toString( e.getResponse().getEntityInputStream()
) );
-        }
-
-        assertTitle( groupId, "Old Title" );
-
-        refreshIndex(context.getOrgName(), context.getAppName());
-
-        // update that group by giving it a new title and using group path in URL
-        try {
-            Map<String, Object> group = new HashMap<String, Object>();
-            group.put( "title", "New Title" );
-            String path = context.getOrgName() + "/" + context.getAppName() + "/groups/"
+ groupPath;
-            webResourceBuilder( path ).put( String.class, group );
-        }
-        catch ( UniformInterfaceException e ) {
-            fail( "Error updating group: " + IOUtils.toString( e.getResponse().getEntityInputStream()
) );
-        }
-
-        assertTitle( groupId, "New Title" );
-
-        refreshIndex(context.getOrgName(), context.getAppName());
-
-        // update that group by giving it a new title and using UUID in URL
-        try {
-            Map<String, Object> group = new HashMap<String, Object>();
-            group.put( "title", "Even Newer Title" );
-            String path = context.getOrgName() + "/" + context.getAppName() + "/groups/"
+ groupId;
-            webResourceBuilder( path ).put( String.class, group );
-        }
-        catch ( UniformInterfaceException e ) {
-            fail( "Error updating group: " + IOUtils.toString( e.getResponse().getEntityInputStream()
) );
-        }
-
-        assertTitle( groupId, "Even Newer Title" );
-    }
-
-
-    private WebResource.Builder webResourceBuilder( String path ) {
-        return resource().path( path ).queryParam( "access_token", context.getActiveUser().getToken()
)
-                .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE
);
-    }
-
-
-    private void assertTitle( String groupId, String title ) throws IOException {
-        String path = context.getOrgName() + "/" + context.getAppName() + "/groups/" + groupId;
-        JsonNode groupJson = mapper.readTree( webResourceBuilder( path ).get( String.class
));
-        Assert.assertEquals( title, groupJson.get( "entities" ).get( 0 ).get( "title" ).textValue()
);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/132b6304/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
index 3a4b2b0..13416c0 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
@@ -118,6 +118,10 @@ public class Entity implements Serializable, Map<String,Object>
{
         //All values are strings , so doing the cast here saves doing the cast elsewhere
         return getDynamicProperties().get( key );
     }
+    public String getString( final Object key ) {
+        //All values are strings , so doing the cast here saves doing the cast elsewhere
+        return String.valueOf(getDynamicProperties().get( key ));
+    }
 
     public String getError () {
         return (String) this.get("error").toString();


Mime
View raw message