You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2014/11/21 21:35:14 UTC

[3/7] incubator-usergrid git commit: added groups, roles collection, updates to groups tests

added groups, roles collection, updates to groups tests


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

Branch: refs/heads/USERGRID-250-buffer-size-fix
Commit: 884bd0141b72ac53eb2415429bea755cec0a85aa
Parents: 968352d
Author: Rod Simpson <ro...@apigee.com>
Authored: Thu Nov 20 15:51:25 2014 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Thu Nov 20 15:51:25 2014 -0700

----------------------------------------------------------------------
 .../collection/groups/GroupResourceIT.java      | 240 +++++++++++++++++--
 .../applications/queries/GeoPagingTest.java     | 100 +++++++-
 .../usergrid/rest/test/resource/Connection.java |   9 +
 .../rest/test/resource/TestContext.java         |  31 ++-
 .../rest/test/resource/app/Application.java     |   8 +
 .../rest/test/resource/app/Collection.java      |  24 +-
 .../usergrid/rest/test/resource/app/Group.java  |  56 +++++
 .../test/resource/app/GroupsCollection.java     |  66 +++++
 .../usergrid/rest/test/resource/app/Role.java   |  56 +++++
 .../rest/test/resource/app/RolesCollection.java |  64 +++++
 .../rest/test/resource/app/UsersCollection.java |  12 +
 11 files changed, 627 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/884bd014/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 0dd6dc8..5d21eb9 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
@@ -17,13 +17,21 @@
 package org.apache.usergrid.rest.applications.collection.groups;
 
 
+import java.util.Map;
 import java.util.UUID;
 
+import javax.rmi.CORBA.Util;
 import javax.ws.rs.core.MediaType;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import java.io.IOException;
+
+import com.google.gson.JsonObject;
+import com.sun.jersey.api.client.UniformInterfaceException;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+import org.apache.usergrid.utils.JsonUtils;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -31,54 +39,229 @@ import org.apache.usergrid.cassandra.Concurrent;
 import org.apache.usergrid.java.client.Client.Query;
 import org.apache.usergrid.java.client.response.ApiResponse;
 import org.apache.usergrid.rest.AbstractRestIT;
+import org.apache.usergrid.rest.TestContextSetup;
+import org.apache.usergrid.rest.test.resource.app.GroupsCollection;
 import org.apache.usergrid.utils.UUIDUtils;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
+import static org.junit.Assert.*;
 
-/** @author tnine */
+/** @author rockerston */
 @Concurrent()
 public class GroupResourceIT extends AbstractRestIT {
     private static Logger log = LoggerFactory.getLogger( GroupResourceIT.class );
 
-    private static final String GROUP = "testGroup";
+    /*
+    private static final String GROUP = "testGroup" + UUIDUtils.newTimeUUID();
+    private static final String USER = "edanuff" + UUIDUtils.newTimeUUID();
+*/
+
+    @Rule
+    public TestContextSetup context = new TestContextSetup( this );
 
-    private static final String USER = "edanuff";
+    public GroupResourceIT() throws Exception { }
 
-    private static boolean groupCreated = false;
+    /***
+     *
+     * Verify that we can create a group with a standard string in the name and path
+     */
+    @Test()
+    public void createGroupValidation() throws IOException {
 
+        GroupsCollection groups = context.groups();
 
-    public GroupResourceIT() throws Exception {
+        //create a group with a normal name
+        String groupName = "testgroup";
+        String groupPath = "testgroup";
+        JsonNode testGroup = groups.create(groupName, groupPath);
+        //verify the group was created
+        assertNull(testGroup.get("errors"));
+        assertEquals(testGroup.get("path").asText(), groupPath);
+    }
 
+    /***
+     *
+     * Verify that we can create a group with a slash in the name and path
+     */
+    @Test()
+    public void createGroupSlashInNameAndPathValidation() throws IOException {
+
+        GroupsCollection groups = context.groups();
+
+        //create a group with a slash in the name
+        String groupNameSlash = "test/group";
+        String groupPathSlash = "test/group";
+        JsonNode testGroup = groups.create( groupNameSlash, groupPathSlash );
+        //verify the group was created
+        assertNull( testGroup.get( "errors" ) );
+        assertEquals( testGroup.get("path").asText(),groupPathSlash );
     }
 
+    /***
+     *
+     * Verify that we can create a group with a space in the name
+     */
+    @Test()
+    public void createGroupSpaceInNameValidation() throws IOException {
 
-    @Before
-    public void setupGroup() {
-        if ( groupCreated ) {
-            return;
-        }
+        GroupsCollection groups = context.groups();
 
+        //create a group with a space in the name
+        String groupName = "test group";
+        String groupPath = "testgroup";
         try {
-            client.createGroup( GROUP );
-            groupCreated = true;
+            JsonNode testGroup = groups.create(groupName, groupPath);
+        } catch (UniformInterfaceException e) {
+            //verify the correct error was returned
+            JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+            assertEquals( "illegal_argument", node.get( "error" ).textValue() );
         }
-        catch ( Exception e ) {
-            log.error( "Error creating group " + GROUP, e );
+    }
+
+    /***
+     *
+     * Verify that we cannot create a group with a space in the path
+     */
+    @Test()
+    public void createGroupSpaceInPathValidation() throws IOException {
+
+        GroupsCollection groups = context.groups();
+
+        //create a group with a space in the path
+        String groupName = "testgroup";
+        String groupPath = "test group";
+        try {
+            JsonNode testGroup = groups.create(groupName, groupPath);
+        } catch (UniformInterfaceException e) {
+            //verify the correct error was returned
+            JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+            assertEquals( "illegal_argument", node.get( "error" ).textValue() );
         }
+    }
+
+    /***
+     *
+     * Verify that we cannot create a group with a space in the path
+     */
+    @Test
+    public void postGroupActivity() {
+
+/*
+        //1. create a group
+        GroupsCollection groups = context.groups();
+
+        //create a group with a normal name
+        String groupName = "groupTitle";
+        String groupPath = "groupPath";
+        JsonNode testGroup = groups.create(groupName, groupPath);
+        //verify the group was created
+        assertNull(testGroup.get("errors"));
+        assertEquals(testGroup.get("path").asText(), groupPath);
+
+        //2.
+   /*
+        UUID id = UUIDUtils.newTimeUUID();
+
+        String groupPath = "groupPath" + id;
+        String groupTitle = "groupTitle " + id;
+        String groupName = "groupName" + id;
+
+        ApiResponse response = client.createGroup( groupPath, groupTitle, groupName );
+
+        assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
+
         refreshIndex("test-organization", "test-app");
 
+        UUID newId = response.getEntities().get( 0 ).getUuid();
+
+        Query results = client.queryGroups( String.format( "name='%s'", groupName ) );
+
+        response = results.getResponse();
+
+        UUID entityId = response.getEntities().get( 0 ).getUuid();
+
+        assertEquals( newId, entityId );
+
+        results = client.queryGroups( String.format( "title='%s'", groupTitle ) );
+
+        response = results.getResponse();
+
+        entityId = response.getEntities().get( 0 ).getUuid();
+
+        assertEquals( newId, entityId );
+
+        results = client.queryGroups( String.format( "title contains '%s'", id ) );
+
+        response = results.getResponse();
+
+        entityId = response.getEntities().get( 0 ).getUuid();
+
+        assertEquals( newId, entityId );
+
+        results = client.queryGroups( String.format( "path='%s'", groupPath ) );
+
+        response = results.getResponse();
+
+        entityId = response.getEntities().get( 0 ).getUuid();
+
+        assertEquals( newId, entityId );
+        */
     }
+}
 
+/*
+    @Test(expected = IllegalArgumentException.class)
+    public void failGroupNameValidation() throws IOException{
 
-    @Test
-    public void failGroupNameValidation() {
 
-        ApiResponse response = client.createGroup( "groupName/withslash" );
-        assertNull( response.getError() );
+
+        //context.application().groups().group("mygroup").connection("likes").collection("users").entity("bob").post();
+
+
+        /*
+        Map user1 =
+                hashMap( "username", "user1" ).map( "email", "testuser1@usergrid.com" ).map( "fullname", "Bob Smith" );
+
+        users.create( user1 );
+
+        GroupsCollection groups = context.groups();
+
+        /*
+        // set up context
+        String orgName = context.getOrgName();
+        String appName = context.getAppName();
+        String path = "/"+orgName+"/"+appName+"/groups/";
+
+        //-----------------------------------------------
+        // 1. test for group path with slash
+        //-----------------------------------------------
+        String groupPath = "grouppath/slash" + UUIDUtils.newTimeUUID();
+
+        String json = "{\"path\":\""+ groupPath +"\"}";
+        JsonNode node = mapper.readTree( resource().path( path )
+                .queryParam( "access_token", context.getActiveUser().getToken() ).accept( MediaType.APPLICATION_JSON )
+                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, json ));
+
+        //verify
+        assertNull( node.get( "errors" ) );
+        assertEquals( node.get( "entities" ).get(0).get("path").asText(), groupPath);
+
+        //-----------------------------------------------
+        //2. test for group path with space
+        //-----------------------------------------------
+        groupPath = "grouppath space" + UUIDUtils.newTimeUUID();
+        try {
+            json = "{\"path\":\"" + groupPath + "\"}";
+            node = mapper.readTree(resource().path(path)
+                    .queryParam("access_token", context.getActiveUser().getToken()).accept(MediaType.APPLICATION_JSON)
+                    .type(MediaType.APPLICATION_JSON_TYPE).post(String.class, json));
+        } catch (Exception e) {
+
+            //verify
+            //assertNull( node.get( "errors" ) );
+            String doug = node.get("error").asText();
+            assertEquals( node.get("error").asText(), "illegal_argument");
+        }
+
 
         refreshIndex("test-organization", "test-app");
 
@@ -92,9 +275,10 @@ public class GroupResourceIT extends AbstractRestIT {
             }
             assertTrue( failed );
         }
-    }
 
+    }
 
+/*
     @Test
     public void postGroupActivity() {
 
@@ -164,9 +348,12 @@ public class GroupResourceIT extends AbstractRestIT {
         UUID createdId = response.getEntities().get( 0 ).getUuid();
 
         // add Permission
+        String orgName = context.getOrgName();
+        String appName = context.getAppName();
+        String path = "/"+orgName+"/"+appName+"/groups/";
 
         String json = "{\"permission\":\"delete:/test\"}";
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/groups/" + createdId + "/permissions" )
+        JsonNode node = mapper.readTree( resource().path( path + createdId + "/permissions" )
                 .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, json ));
 
@@ -292,4 +479,5 @@ public class GroupResourceIT extends AbstractRestIT {
         assertNull( node.get( "errors" ) );
         assertFalse( node.get( "entities" ).findValuesAsText( "name" ).contains( roleName ) );
     }
-}
+    */
+

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/884bd014/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
index fb9eb70..bb5b934 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
@@ -17,13 +17,16 @@
 package org.apache.usergrid.rest.applications.queries;
 
 
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import com.sun.jersey.api.client.UniformInterfaceException;
 
 import java.io.IOException;
+
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.Results;
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -54,7 +57,7 @@ public class GeoPagingTest extends AbstractRestIT {
     @Test //("Test uses up to many resources to run reliably") // USERGRID-1403
     public void groupQueriesWithGeoPaging() throws IOException {
 
-        CustomCollection groups = context.application().customCollection( "test1groups" );
+        CustomCollection groups = context.application().customCollection("test1groups");
 
         int maxRangeLimit = 2000;
         long[] index = new long[maxRangeLimit];
@@ -93,7 +96,7 @@ public class GeoPagingTest extends AbstractRestIT {
     @Test // USERGRID-1401
     public void groupQueriesWithConsistentResults() throws IOException {
 
-        CustomCollection groups = context.application().customCollection( "test2groups" );
+        CustomCollection groups = context.application().customCollection("test2groups");
 
         int maxRangeLimit = 20;
         JsonNode[] saved = new JsonNode[maxRangeLimit];
@@ -147,8 +150,10 @@ public class GeoPagingTest extends AbstractRestIT {
 
         JsonNode node = null;
         String collectionName = "testFarAwayLocation";
-        Map store1 = entityMapLocationCreator( "usergrid",-33.746369 ,150.952183 );
-        Map store2 = entityMapLocationCreator( "usergrid2",-33.889058, 151.124024  );
+        Map store1 = entityMapLocationCreator( -33.746369 ,150.952183 );
+        store1.put( "name", "usergrid" );
+        Map store2 = entityMapLocationCreator( -33.889058, 151.124024 );
+        store2.put( "name", "usergrid" );
         Point center = new Point( 37.776753, -122.407846 );
         //TODO: make query builder for this
         Query queryClose = locationQuery( 10000 ,center );
@@ -183,11 +188,90 @@ public class GeoPagingTest extends AbstractRestIT {
         // assertEquals(node.get(  ))
     }
 
-    private Map entityMapLocationCreator(String name,Double lat, Double lon){
+
+    /**
+     * Creates two users, then a huge matrix of coordinates, then checks to see if any of the coordinates are near our users
+     * @throws IOException
+     */
+    @Test
+    public void createHugeMatrixOfCoordinates() throws IOException {
+
+
+        JsonNode node = null;
+
+        Map user1Coordinates = entityMapLocationCreator( -33.746369 ,150.952183 );
+        Map user2Coordinates = entityMapLocationCreator( -33.889058, 151.124024 );
+
+        /*Create */
+        try {
+            node = context.users().post("norwest", "norwest@usergrid.com", "norwest", user1Coordinates);
+        }
+        catch ( UniformInterfaceException e ) {
+            JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+            fail( node.get( "error" ).textValue() );
+        }
+
+        /*Create */
+        try {
+            node = context.users().post("ashfield", "ashfield@usergrid.com", "ashfield", user2Coordinates);
+        }
+        catch ( UniformInterfaceException e ) {
+            JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+            fail( node.get( "error" ).textValue() );
+        }
+
+        refreshIndex( context.getOrgName(),context.getAppName() );
+
+        List<Point> points = new ArrayList<Point>();
+        points.add(new Point( 33.746369,-89 ));//Woodland, MS
+        points.add(new Point( 33.746369,-91 ));//Beulah, MS
+        points.add(new Point( -1.000000, 102.000000 ));//Somewhere in Indonesia
+        points.add(new Point( -90.000000, 90.000000 ));//Antarctica
+        points.add(new Point( 90, 90 ));//Santa's house
+        //and the cartesian product...
+        for(int i= -90;i<=90;i++){
+            for(int j= -180;j<=180;j++){
+                points.add(new Point( i, j ));
+            }
+        }
+        Iterator<Point> pointIterator = points.iterator();
+        for(Point p=pointIterator.next();pointIterator.hasNext();p=pointIterator.next()){
+
+            Point center = new Point( p.getLat(),  p.getLon() );
+            Query query = locationQuery( 10000 ,center );
+
+            try {
+               // node = context.users( ).get(  ).withQuery( query );
+            }
+            catch ( UniformInterfaceException e ) {
+                JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+                fail( node.get( "error" ).textValue() );
+            }
+
+/*
+            Query query = Query.fromQL( "select * where location within 10000 of "
+                    + p.getLat() + "," + p.getLon());
+            Results listResults = em.searchCollection( em.getApplicationRef(), "stores", query );
+
+            this.dump( listResults );
+            assertEquals("Results less than 10000m away from center", 0, listResults.size() );
+
+            query = Query.fromQL( "select * where location within 40000000 of "
+                    + p.getLat() + "," + p.getLon());
+            listResults = em.searchCollection( em.getApplicationRef(), "stores", query );
+
+            assertEquals("Results from center point to ridiculously far", 2, listResults.size() );
+*/
+        }
+    }
+
+
+
+
+    private Map entityMapLocationCreator(Double lat, Double lon){
         Map<String, Double> latLon = hashMap( "latitude", lat );
         latLon.put( "longitude", lon );
         Map<String, Object> entityData = new HashMap<String, Object>();
-        entityData.put( "name", name );
         entityData.put( "location", latLon );
 
         return entityData;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/884bd014/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/Connection.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/Connection.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/Connection.java
index e491247..5a87472 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/Connection.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/Connection.java
@@ -19,6 +19,9 @@ package org.apache.usergrid.rest.test.resource;
 
 import java.util.UUID;
 
+import org.apache.usergrid.rest.test.resource.app.UsersCollection;
+import org.apache.usergrid.rest.test.resource.app.GroupsCollection;
+import org.apache.usergrid.rest.test.resource.app.RolesCollection;
 import org.apache.usergrid.rest.test.resource.app.queue.DevicesCollection;
 
 
@@ -45,6 +48,12 @@ public class Connection extends ValueResource {
         return new DevicesCollection( this );
     }
 
+    public UsersCollection users() { return new UsersCollection(this);}
+
+    public GroupsCollection groups() { return new GroupsCollection(this);}
+
+    public RolesCollection roles() { return new RolesCollection(this);}
+
 
     public CustomCollection collection( String name ) {
         return new CustomCollection( name, this );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/884bd014/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestContext.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestContext.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestContext.java
index 2c0531a..f1608b2 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestContext.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestContext.java
@@ -23,6 +23,10 @@ import org.apache.usergrid.rest.test.resource.app.Application;
 import org.apache.usergrid.rest.test.resource.app.Collection;
 import org.apache.usergrid.rest.test.resource.app.User;
 import org.apache.usergrid.rest.test.resource.app.UsersCollection;
+import org.apache.usergrid.rest.test.resource.app.Group;
+import org.apache.usergrid.rest.test.resource.app.GroupsCollection;
+import org.apache.usergrid.rest.test.resource.app.Role;
+import org.apache.usergrid.rest.test.resource.app.RolesCollection;
 import org.apache.usergrid.rest.test.resource.mgmt.Management;
 import org.apache.usergrid.rest.test.security.TestUser;
 
@@ -107,7 +111,7 @@ public class TestContext {
         OrgUserUUIDWrapper ouuw = management().orgs().create( getOrgName(),activeUser );
         testOrganization.setUuid( ouuw.getOrgUUID() );
         activeUser.setUUID( ouuw.getUserUUID() );
-        refreshIndex( getOrgName(), appName );
+        refreshIndex(getOrgName(), appName);
         return this;
     }
 
@@ -139,10 +143,31 @@ public class TestContext {
         return application().users();
     }
 
-
     /** Get the app user resource */
     public User user( String username ) {
-        return application().users().user( username );
+        return application().users().user(username);
+    }
+
+
+    /** Get the users resource for the application */
+    public GroupsCollection groups() {
+        return application().groups();
+    }
+
+    /** Get the app group resource */
+    public Group group( String path ) {
+        return application().groups().group( path );
+    }
+
+
+    /** Get the groups resource for the application */
+    public RolesCollection roles() {
+        return application().roles();
+    }
+
+    /** Get the app role resource */
+    public Role role( String name ) {
+        return application().roles().role( name );
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/884bd014/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Application.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Application.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Application.java
index 9de259d..79e24fd 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Application.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Application.java
@@ -57,6 +57,14 @@ public class Application extends ValueResource {
         return new UsersCollection( this );
     }
 
+    public GroupsCollection groups() {
+        return new GroupsCollection( this );
+    }
+
+    public RolesCollection roles() {
+        return new RolesCollection( this );
+    }
+
 
     public QueuesCollection queues() {
         return new QueuesCollection( this );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/884bd014/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Collection.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Collection.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Collection.java
index 12592b5..ac65a01 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Collection.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Collection.java
@@ -21,6 +21,12 @@ public class Collection extends SetResource {
     }
 
     /** Create the user in a collection using only the username */
+    /**
+     * POST an entity with only a name
+     * @param name
+     * @return JsonNode
+     * @throws IOException
+     */
     public JsonNode post( String name ) throws IOException {
         Map<String, String> data = MapUtils.hashMap( "name", name );
 
@@ -29,11 +35,25 @@ public class Collection extends SetResource {
         return getEntity( response, 0 );
     }
 
+    /**
+     * POST an entity with a name and a Map (e.g. if you want to add in a location sub-object
+     * @param name
+     * @param entityData
+     * @return JsonNode
+     * @throws IOException
+     */
+    public JsonNode post( String name, Map entityData ) throws IOException {
+        Map<String, String> data = MapUtils.hashMap( "name", name );
+        data.putAll(entityData);
+        JsonNode response = this.postInternal( data );
+
+        return getEntity( response, 0 );
+    }
 
     /**
-     * Create the user in a collection using username,email,password
+     * POST an entity with only a Map
      * @param entityData
-     * @return
+     * @return JsonNode
      * @throws IOException
      */
     public JsonNode post(Map entityData) throws IOException{

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/884bd014/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Group.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Group.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Group.java
new file mode 100644
index 0000000..4446bf6
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Group.java
@@ -0,0 +1,56 @@
+/*
+ * 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.test.resource.app;
+
+
+import java.util.UUID;
+
+import org.apache.usergrid.rest.test.resource.EntityResource;
+import org.apache.usergrid.rest.test.resource.NamedResource;
+import org.apache.usergrid.rest.test.resource.app.queue.DevicesCollection;
+
+
+/**
+ * A resource for testing queues
+ *
+ * @author rockerston
+ */
+public class Group
+        extends EntityResource {
+
+    /**
+     * @param entityId
+     * @param parent
+     */
+    public Group( UUID entityId, NamedResource parent ) {
+        super( entityId, parent );
+    }
+
+
+    /**
+     * @param entityName
+     * @param parent
+     */
+    public Group( String entityName, NamedResource parent ) {
+        super( entityName, parent );
+    }
+
+
+    public DevicesCollection devices() {
+        return new DevicesCollection( this );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/884bd014/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/GroupsCollection.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/GroupsCollection.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/GroupsCollection.java
new file mode 100644
index 0000000..0f49dcc
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/GroupsCollection.java
@@ -0,0 +1,66 @@
+/*
+ * 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.test.resource.app;
+
+
+import java.util.Map;
+import java.util.UUID;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import org.apache.usergrid.rest.test.resource.CollectionResource;
+import org.apache.usergrid.rest.test.resource.Me;
+import org.apache.usergrid.rest.test.resource.NamedResource;
+import org.apache.usergrid.utils.MapUtils;
+
+
+/** @author rockerston */
+public class GroupsCollection extends CollectionResource {
+
+
+    public GroupsCollection( NamedResource parent ) {
+        super( "groups", parent );
+    }
+
+
+    public Group group( String username ) {
+        return new Group( username, this );
+    }
+
+
+    public Group group( UUID id ) {
+        return new Group( id, this );
+    }
+
+
+    /** Create the group */
+    public JsonNode create( String path, String title ) throws IOException {
+        Map<String, String> data =
+                MapUtils.hashMap( "path", path ).map( "title", title );
+
+        JsonNode response = this.postInternal( data );
+
+        return getEntity( response, 0 );
+    }
+
+
+
+
+    public Me me() {
+        return new Me( this );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/884bd014/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Role.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Role.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Role.java
new file mode 100644
index 0000000..b60ef56
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Role.java
@@ -0,0 +1,56 @@
+/*
+ * 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.test.resource.app;
+
+
+import java.util.UUID;
+
+import org.apache.usergrid.rest.test.resource.EntityResource;
+import org.apache.usergrid.rest.test.resource.NamedResource;
+import org.apache.usergrid.rest.test.resource.app.queue.DevicesCollection;
+
+
+/**
+ * A resource for testing queues
+ *
+ * @author rockerston
+ */
+public class Role
+        extends EntityResource {
+
+    /**
+     * @param entityId
+     * @param parent
+     */
+    public Role( UUID entityId, NamedResource parent ) {
+        super( entityId, parent );
+    }
+
+
+    /**
+     * @param entityName
+     * @param parent
+     */
+    public Role( String entityName, NamedResource parent ) {
+        super( entityName, parent );
+    }
+
+
+    public DevicesCollection devices() {
+        return new DevicesCollection( this );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/884bd014/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/RolesCollection.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/RolesCollection.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/RolesCollection.java
new file mode 100644
index 0000000..dd3e737
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/RolesCollection.java
@@ -0,0 +1,64 @@
+/*
+ * 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.test.resource.app;
+
+
+import java.util.Map;
+import java.util.UUID;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import org.apache.usergrid.rest.test.resource.CollectionResource;
+import org.apache.usergrid.rest.test.resource.Me;
+import org.apache.usergrid.rest.test.resource.NamedResource;
+import org.apache.usergrid.utils.MapUtils;
+
+
+/** @author rockerston */
+public class RolesCollection extends CollectionResource {
+
+
+    public RolesCollection( NamedResource parent ) {
+        super( "roles", parent );
+    }
+
+
+    public Role role( String name ) {
+        return new Role( name, this );
+    }
+
+
+    public Role role( UUID id ) {
+        return new Role( id, this );
+    }
+
+
+    /** Create the role */
+    public JsonNode create( String name, String title ) throws IOException {
+        Map<String, String> data =
+                MapUtils.hashMap( "name", name ).map( "title", title );
+
+        JsonNode response = this.postInternal( data );
+
+        return getEntity( response, 0 );
+    }
+
+
+    public Me me() {
+        return new Me( this );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/884bd014/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/UsersCollection.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/UsersCollection.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/UsersCollection.java
index da9cccc..d7b4293 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/UsersCollection.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/UsersCollection.java
@@ -58,6 +58,18 @@ public class UsersCollection extends Collection {
     }
 
     /** Create the user */
+    public JsonNode post( String username, String email, String password, Map entityData ) throws IOException {
+        Map<String, String> data =
+                MapUtils.hashMap( "username", username ).map( "email", email ).map( "password", password );
+        data.putAll(entityData);
+
+        JsonNode response = this.postInternal( data );
+
+        return getEntity( response, 0 );
+    }
+
+
+    /** Create the user */
     //TODO: delete create method once rest calls are implemented
     public JsonNode create( String username, String email, String password ) throws IOException {
         Map<String, String> data =