You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by ro...@apache.org on 2014/12/17 04:08:57 UTC

incubator-usergrid git commit: changed appResource to app, sub resource to name

Repository: incubator-usergrid
Updated Branches:
  refs/heads/UG-rest-test-framework-overhaul b5f2c5f31 -> 25f3e46d4


changed appResource to app, sub resource to name


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

Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 25f3e46d4ef9b116c685f168be0f2966a2d485c3
Parents: b5f2c5f
Author: Rod Simpson <ro...@apigee.com>
Authored: Tue Dec 16 20:08:39 2014 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Tue Dec 16 20:08:39 2014 -0700

----------------------------------------------------------------------
 .../collection/groups/GroupResourceIT.java      | 33 +++++++++++++++++---
 .../test/resource2point0/AbstractRestIT.java    |  2 +-
 .../endpoints/AbstractCollectionResource.java   | 12 ++++---
 3 files changed, 38 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/25f3e46d/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 1a78865..bb12e20 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
@@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.JsonNode;
 import java.io.IOException;
 import com.sun.jersey.api.client.UniformInterfaceException;
 import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource2point0.model.Group;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -46,7 +47,7 @@ public class GroupResourceIT extends AbstractRestIT {
         String groupName = "testgroup";
         String groupPath = "testgroup";
         Group group = new Group(groupName, groupPath);
-        Group testGroup = this.getAppResource().groups().post(group);
+        Group testGroup = this.app().groups().post(group);
         assertNull(testGroup.get("errors"));
         assertEquals(testGroup.get("path"), groupPath);
 
@@ -60,10 +61,11 @@ public class GroupResourceIT extends AbstractRestIT {
     @Test()
     public void createGroupSlashInNameAndPathValidation() throws IOException {
 
+        //create the group with a slash in the name
         String groupNameSlash = "test/group";
         String groupPathSlash = "test/group";
         Group group = new Group(groupNameSlash, groupPathSlash);
-        Group testGroup = this.getAppResource().groups().post(group);
+        Group testGroup = this.app().groups().post(group);
         assertNull(testGroup.get("errors"));
         assertEquals(testGroup.get("path"), groupPathSlash);
 
@@ -77,10 +79,11 @@ public class GroupResourceIT extends AbstractRestIT {
     @Test()
     public void createGroupSpaceInNameValidation() throws IOException {
 
+        //create the group with a space in the name
         String groupSpaceName = "test group";
         String groupPath = "testgroup";
         Group group = new Group(groupSpaceName, groupPath);
-        Group testGroup = this.getAppResource().groups().post(group);
+        Group testGroup = this.app().groups().post(group);
         assertNull(testGroup.get("errors"));
         assertEquals(testGroup.get("path"), groupPath);
 
@@ -99,7 +102,7 @@ public class GroupResourceIT extends AbstractRestIT {
         Group group = new Group(groupName, groupSpacePath);
 
         try {
-            Group testGroup = this.getAppResource().groups().post(group);
+            Group testGroup = this.app().groups().post(group);
         } catch (UniformInterfaceException e) {
             //verify the correct error was returned
             JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
@@ -110,6 +113,28 @@ public class GroupResourceIT extends AbstractRestIT {
 
     /***
      *
+     * Verify that we can create a group and then change the name
+     */
+    @Test()
+    public void changeGroupNameValidation() throws IOException {
+
+        String groupName = "testgroup";
+        String groupPath = "testgroup";
+        String newGroupPath = "newtestgroup";
+        Group testGroup = this.app().groups().post(new Group(groupName, groupPath));
+        assertNull(testGroup.get("errors"));
+        assertEquals(testGroup.get("path"), groupPath);
+
+        //now change the name
+        testGroup.put("path", newGroupPath);
+        Group group = this.app().groups().name(testGroup.getName()).put(testGroup);
+        assertNull(testGroup.get("errors"));
+        assertEquals(testGroup.get("path"), newGroupPath);
+    }
+
+
+    /***
+     *
      * Verify that we cannot create a group with a space in the path
      */
     /*

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/25f3e46d/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
index 4bc35d7..0447b1c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
@@ -111,7 +111,7 @@ public class AbstractRestIT extends JerseyTest {
         return clientSetup.restClient.org(clientSetup.getOrganization().getName()).app(clientSetup.getAppName());
     }
 
-    protected ApplicationsResource getAppResource(){
+    protected ApplicationsResource app(){
         return getApplicationResource();
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/25f3e46d/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/AbstractCollectionResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/AbstractCollectionResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/AbstractCollectionResource.java
index 083a1f0..28efbd3 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/AbstractCollectionResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/AbstractCollectionResource.java
@@ -31,13 +31,17 @@ import javax.ws.rs.core.MediaType;
 /**
  * Classy class class.
  */
-public abstract class AbstractCollectionResource<T extends Entity,Subresource> extends NamedResource {
+public abstract class AbstractCollectionResource<T extends Entity,SubResource> extends NamedResource {
     public AbstractCollectionResource(String name, ClientContext context, UrlResource parent) {
         super(name, context, parent);
     }
 
-    public Subresource getSubresource(final String identifier){
-        return instantiateSubresource(identifier, context, this);
+    public SubResource getSubResource(final String identifier){
+        return instantiateSubResource(identifier, context, this);
+    }
+
+    public SubResource name(final String identifier){
+        return instantiateSubResource(identifier, context, this);
     }
 
     /**
@@ -83,6 +87,6 @@ public abstract class AbstractCollectionResource<T extends Entity,Subresource> e
 
     protected abstract T instantiateT(ApiResponse response);
 
-    protected abstract Subresource instantiateSubresource(String identifier, ClientContext context, UrlResource parent);
+    protected abstract SubResource instantiateSubResource(String identifier, ClientContext context, UrlResource parent);
 
 }