usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [06/17] incubator-usergrid git commit: compile user tests
Date Mon, 05 Jan 2015 19:35:59 GMT
compile user 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/2a5b4c7e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/2a5b4c7e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/2a5b4c7e

Branch: refs/heads/two-dot-o
Commit: 2a5b4c7e2b6337abbaa98b93b7710f5ed35e619d
Parents: 0488a8a
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Tue Dec 23 15:19:16 2014 -0700
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Tue Dec 23 15:19:16 2014 -0700

----------------------------------------------------------------------
 .../applications/assets/AssetResourceIT.java    |  40 +-
 .../collection/users/UserResourceIT.java        | 831 +++++++------------
 .../endpoints/ApplicationsResource.java         |   6 +
 .../endpoints/CollectionEndpoint.java           |  22 +-
 .../endpoints/EntityEndpoint.java               |  17 +-
 .../endpoints/NamedResource.java                |  10 +-
 .../endpoints/OrganizationResource.java         |   1 +
 .../resource2point0/endpoints/RootResource.java |   1 +
 .../endpoints/TokenResource.java                |   4 +
 .../endpoints/mgmt/ApplicationResource.java     |   1 +
 .../endpoints/mgmt/ManagementResource.java      |   1 +
 .../endpoints/mgmt/OrganizationResource.java    |   1 +
 .../endpoints/mgmt/TokenResource.java           |   4 +
 .../resource2point0/model/ActivityEntity.java   |  44 +
 .../test/resource2point0/model/ApiResponse.java |   2 +-
 .../model/ChangePasswordEntity.java             |  30 +
 .../resource2point0/model/QueryParameters.java  |   4 +
 17 files changed, 459 insertions(+), 560 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2a5b4c7e/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
index 6f51122..c1212e2 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
@@ -25,13 +25,13 @@ import java.util.concurrent.TimeoutException;
 import javax.ws.rs.core.MediaType;
 
 import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
 import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.usergrid.cassandra.Concurrent;
-import org.apache.usergrid.rest.AbstractRestIT;
 import org.apache.usergrid.rest.applications.utils.UserRepo;
 import org.apache.usergrid.services.assets.data.AssetUtils;
 
@@ -47,15 +47,20 @@ import static org.apache.usergrid.utils.MapUtils.hashMap;
 @Concurrent()
 public class AssetResourceIT extends AbstractRestIT {
 
+    private final String access_token;
     private Logger LOG = LoggerFactory.getLogger( AssetResourceIT.class );
+    UserRepo userRepo;
+    public AssetResourceIT(){
+        userRepo = new UserRepo(this.clientSetup);
+         access_token = this.getAdminToken().getAccessToken();
+    }
 
 
     /** @Deprecated Tests legacy API */
     @Test
     public void verifyBinaryCrud() throws Exception {
-        UserRepo.INSTANCE.load( resource(), access_token );
 
-        UUID userId = UserRepo.INSTANCE.getByUserName( "user1" );
+        UUID userId = userRepo.getByUserName( "user1" );
         Map<String, String> payload =
                 hashMap( "path", "my/clean/path" ).map( "owner", userId.toString() ).map( "someprop", "somevalue" );
 
@@ -65,8 +70,7 @@ public class AssetResourceIT extends AbstractRestIT {
                         .post( String.class, payload ));
         JsonNode idNode = node.get( "entities" ).get( 0 ).get( "uuid" );
         UUID id = UUID.fromString( idNode.textValue() );
-        assertNotNull( idNode.textValue() );
-        logNode( node );
+        assertNotNull(idNode.textValue());
 
         byte[] data = IOUtils.toByteArray( this.getClass().getResourceAsStream( "/cassandra_eye.jpg" ) );
         resource().path( "/test-organization/test-app/assets/" + id.toString() + "/data" )
@@ -78,7 +82,7 @@ public class AssetResourceIT extends AbstractRestIT {
         byte[] foundData = IOUtils.toByteArray( is );
         assertEquals( 7979, foundData.length );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex();
 
         node = mapper.readTree( resource().path( "/test-organization/test-app/assets/my/clean/path" )
                 .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON_TYPE )
@@ -91,7 +95,6 @@ public class AssetResourceIT extends AbstractRestIT {
 
     @Test
     public void octetStreamOnDynamicEntity() throws Exception {
-        UserRepo.INSTANCE.load( resource(), access_token );
 
         Map<String, String> payload = hashMap( "name", "assetname" );
 
@@ -101,8 +104,7 @@ public class AssetResourceIT extends AbstractRestIT {
 
         JsonNode idNode = node.get( "entities" ).get( 0 ).get( "uuid" );
         String uuid = idNode.textValue();
-        assertNotNull( uuid );
-        logNode( node );
+        assertNotNull(uuid);
 
         byte[] data = IOUtils.toByteArray( this.getClass().getResourceAsStream( "/cassandra_eye.jpg" ) );
         resource().path( "/test-organization/test-app/foos/" + uuid ).queryParam( "access_token", access_token )
@@ -111,7 +113,6 @@ public class AssetResourceIT extends AbstractRestIT {
         // get entity
         node = mapper.readTree( resource().path( "/test-organization/test-app/foos/" + uuid ).queryParam( "access_token", access_token )
                 .accept( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
-        logNode( node );
         Assert.assertEquals( "image/jpeg", node.findValue( AssetUtils.CONTENT_TYPE ).textValue() );
         Assert.assertEquals( 7979, node.findValue( "content-length" ).intValue() );
         idNode = node.get( "entities" ).get( 0 ).get( "uuid" );
@@ -125,7 +126,7 @@ public class AssetResourceIT extends AbstractRestIT {
         byte[] foundData = IOUtils.toByteArray( is );
         assertEquals( 7979, foundData.length );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex();
 
         // get data by name
         is = resource().path( "/test-organization/test-app/foos/assetname" ).queryParam( "access_token", access_token )
@@ -138,7 +139,6 @@ public class AssetResourceIT extends AbstractRestIT {
 
     @Test
     public void multipartPostFormOnDynamicEntity() throws Exception {
-        UserRepo.INSTANCE.load( resource(), access_token );
 
         byte[] data = IOUtils.toByteArray( this.getClass().getResourceAsStream( "/file-bigger-than-5M" ) );
         FormDataMultiPart form = new FormDataMultiPart().field( "file", data, MediaType.MULTIPART_FORM_DATA_TYPE );
@@ -149,13 +149,11 @@ public class AssetResourceIT extends AbstractRestIT {
 
         JsonNode idNode = node.get( "entities" ).get( 0 ).get( "uuid" );
         String uuid = idNode.textValue();
-        assertNotNull( uuid );
-        logNode( node );
+        assertNotNull(uuid);
 
         // get entity
         node = mapper.readTree( resource().path( "/test-organization/test-app/foos/" + uuid ).queryParam( "access_token", access_token )
                 .accept( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
-        logNode( node );
         assertEquals( "application/octet-stream", node.findValue( AssetUtils.CONTENT_TYPE ).textValue() );
         assertEquals( 5324800, node.findValue( AssetUtils.CONTENT_LENGTH ).intValue() );
         idNode = node.get( "entities" ).get( 0 ).get( "uuid" );
@@ -177,7 +175,6 @@ public class AssetResourceIT extends AbstractRestIT {
 
     @Test
     public void multipartPutFormOnDynamicEntity() throws Exception {
-        UserRepo.INSTANCE.load( resource(), access_token );
 
         Map<String, String> payload = hashMap( "foo", "bar" );
 
@@ -187,8 +184,7 @@ public class AssetResourceIT extends AbstractRestIT {
 
         JsonNode idNode = node.get( "entities" ).get( 0 ).get( "uuid" );
         String uuid = idNode.textValue();
-        assertNotNull( uuid );
-        logNode( node );
+        assertNotNull(uuid);
 
         // set file & assetname
         byte[] data = IOUtils.toByteArray( this.getClass().getResourceAsStream( "/cassandra_eye.jpg" ) );
@@ -198,12 +194,10 @@ public class AssetResourceIT extends AbstractRestIT {
         long created = System.currentTimeMillis();
         node = mapper.readTree( resource().path( "/test-organization/test-app/foos/" + uuid ).queryParam( "access_token", access_token )
                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.MULTIPART_FORM_DATA ).put( String.class, form ));
-        logNode( node );
 
         // get entity
         node = mapper.readTree( resource().path( "/test-organization/test-app/foos/" + uuid ).queryParam( "access_token", access_token )
                 .accept( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
-        logNode( node );
         assertEquals( "image/jpeg", node.findValue( AssetUtils.CONTENT_TYPE ).textValue() );
         assertEquals( 7979, node.findValue( AssetUtils.CONTENT_LENGTH ).intValue() );
         idNode = node.get( "entities" ).get( 0 ).get( "uuid" );
@@ -224,7 +218,6 @@ public class AssetResourceIT extends AbstractRestIT {
         // post new data
         node = mapper.readTree( resource().path( "/test-organization/test-app/foos/" + uuid ).queryParam( "access_token", access_token )
                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.MULTIPART_FORM_DATA ).put( String.class, form ));
-        logNode( node );
         Assert.assertTrue( lastModified != node.findValue( AssetUtils.LAST_MODIFIED ).longValue() );
     }
 
@@ -232,7 +225,6 @@ public class AssetResourceIT extends AbstractRestIT {
     @Test
     @Ignore("Just enable and run when testing S3 large file upload specifically")
     public void largeFileInS3() throws Exception {
-        UserRepo.INSTANCE.load( resource(), access_token );
 
         byte[] data = IOUtils.toByteArray( this.getClass().getResourceAsStream( "/file-bigger-than-5M" ) );
         FormDataMultiPart form = new FormDataMultiPart().field( "file", data, MediaType.MULTIPART_FORM_DATA_TYPE );
@@ -241,19 +233,17 @@ public class AssetResourceIT extends AbstractRestIT {
         JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/foos" ).queryParam( "access_token", access_token )
                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.MULTIPART_FORM_DATA )
                 .post( String.class, form ));
-        logNode( node );
         JsonNode idNode = node.get( "entities" ).get( 0 ).get( "uuid" );
         String uuid = idNode.textValue();
 
         // get entity
         long timeout = System.currentTimeMillis() + 60000;
         while ( true ) {
-            LOG.info( "Waiting for upload to finish..." );
+            LOG.info("Waiting for upload to finish...");
             Thread.sleep( 2000 );
             node = mapper.readTree( resource().path( "/test-organization/test-app/foos/" + uuid )
                     .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON_TYPE )
                     .get( String.class ));
-            logNode( node );
 
             // poll for the upload to complete
             if ( node.findValue( AssetUtils.E_TAG ) != null ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2a5b4c7e/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
index a41f86a..1d39bd4 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
@@ -29,10 +29,10 @@ import javax.ws.rs.core.MediaType;
 
 import org.apache.usergrid.rest.test.resource.CollectionResource;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.CollectionEndpoint;
-import org.apache.usergrid.rest.test.resource2point0.model.Collection;
-import org.apache.usergrid.rest.test.resource2point0.model.Entity;
-import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.EntityEndpoint;
+import org.apache.usergrid.rest.test.resource2point0.model.*;
 import org.aspectj.lang.annotation.Before;
+import org.jclouds.rest.annotations.Api;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -69,12 +69,15 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
     private static Logger log = LoggerFactory.getLogger( UserResourceIT.class );
     UserRepo userRepo ;
     CollectionEndpoint usersResource;
+    CollectionEndpoint userResource;
 
     @Before("Before users")
     public void setup(){
         userRepo = new UserRepo(clientSetup);
         userRepo.load();
         usersResource = this.app().collection("users");
+        usersResource = this.app().collection("user");
+
         clientSetup.refreshIndex();
     }
 
@@ -163,26 +166,23 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
         UUID userId = userRepo.getByUserName( "user1" );
 
 
-        Entity activity = new Entity();
-        activity.put("email", "rod@rodsimpson.com");
-        activity.put("verb", "POST");
-        activity.put("content", "Look! more new content");
+        ActivityEntity activity = new ActivityEntity("rod@rodsimpson.com","POST", "Look! more new content");
 
 
-        Entity entity = usersResource.entity(userId.toString()).connection("activities").post(activity);
+        Entity entity = usersResource.entity(userId.toString()).activities().post(activity);
 
 
         UUID activityId =(UUID) entity.get("uuid");
 
         assertNotNull( activityId );
+        Map<String,Object> actor = (Map<String,Object>)entity.get("actor");
 
-        JsonNode actor = getActor( entity );
 
-        UUID actorId = UUIDUtils.tryGetUUID( actor.get( "uuid" ).textValue() );
+        UUID actorId = UUIDUtils.tryGetUUID( actor.get( "uuid" ).toString() );
 
         assertEquals( userId, actorId );
 
-        assertEquals( "user1@apigee.com", actor.get( "email" ).asText() );
+        assertEquals( "user1@apigee.com", actor.get( "email" ).toString() );
     }
 
 
@@ -194,33 +194,30 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
 
         UUID userId = userRepo.getByUserName( "user1" );
 
-        Entity activity = new Entity();
-        activity.put("email", "rod@rodsimpson.com");
-        activity.put("verb", "POST");
-        activity.put("content", "Look! more new content");
+        ActivityEntity activity = new ActivityEntity("rod@rodsimpson.com","POST", "Look! more new content");
 
         // same as above, but with actor partially filled out
 
         Map<String,Object> actorPost = new HashMap<>();
         actorPost.put("displayName","Dino" );
 
-        activity.put("actor", actorPost);
+        activity.putActor(actorPost);
 
 
 
-        Entity entity = usersResource.entity(userId.toString()).connection("activities").post(activity);
+        Entity entity = usersResource.entity(userId.toString()).activities().post(activity);
 
         UUID activityId = entity.getUuid();
 
         assertNotNull( activityId );
 
-        JsonNode actor = getActor( entity );
+        Map<String,Object> actor = (Map<String,Object>)entity.get("actor");
 
-        UUID actorId = UUIDUtils.tryGetUUID( actor.get( "uuid" ).textValue() );
+        UUID actorId = UUIDUtils.tryGetUUID( actor.get( "uuid" ).toString() );
 
         assertEquals( userId, actorId );
 
-        assertEquals( "user1@apigee.com", actor.get( "email" ).asText() );
+        assertEquals( "user1@apigee.com", actor.get( "email" ).toString() );
     }
 
 
@@ -236,10 +233,8 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
         UUID testUUID = UUIDUtils.newTimeUUID();
         String testEmail = "foo@bar.com";
 
-        Entity activity = new Entity();
-        activity.put("email", "rod@rodsimpson.com");
-        activity.put("verb", "POST");
-        activity.put("content", "Look! more new content");
+
+        ActivityEntity activity = new ActivityEntity("rod@rodsimpson.com","POST", "Look! more new content");
 
         // same as above, but with actor partially filled out
 
@@ -247,23 +242,23 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
         actorPost.put("displayName", "Dino");
         actorPost.put("uuid",testUUID);
         actorPost.put("email",testEmail);
-        activity.put("actor", actorPost);
+        activity.putActor(actorPost);
         // same as above, but with actor partially filled out
 
 
-        Entity entity = usersResource.entity(userId.toString()).connection("activities").post(activity);
+        Entity entity = usersResource.entity(userId.toString()).activities().post(activity);
 
         UUID activityId = entity.getUuid();
 
         assertNotNull( activityId );
 
-        JsonNode actor = getActor( entity );
+        Map<String,Object> actor = new ActivityEntity(entity).getActor();
 
-        UUID actorId = UUIDUtils.tryGetUUID( actor.get( "uuid" ).textValue() );
+        UUID actorId = UUIDUtils.tryGetUUID( actor.get( "uuid" ).toString() );
 
         assertEquals( testUUID, actorId );
 
-        assertEquals( testEmail, actor.get( "email" ).asText() );
+        assertEquals( testEmail, actor.get( "email" ).toString() );
     }
 
 
@@ -275,29 +270,23 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
 
         UUID userId = userRepo.getByUserName( "user1" );
 
-        Entity activity = new Entity();
-        activity.put("email", "rod@rodsimpson.com");
-        activity.put("verb", "POST");
-        activity.put("content", "Look! more new content");
+        ActivityEntity activity = new ActivityEntity(  "rod@rodsimpson.com", "POST", "Look! more new content");
 
         // same as above, but with actor partially filled out
 
-        Entity entity = usersResource.entity(userId.toString()).connection("activities").post(activity);
+        Entity entity = usersResource.entity(userId.toString()).activities().post(activity);
         refreshIndex();
 
         UUID firstActivityId = entity.getUuid();
 
-         activity = new Entity();
-        activity.put("email", "rod@rodsimpson.com");
-        activity.put("verb", "POST");
-        activity.put("content", "activity 2");
-        Entity entity = usersResource.entity(userId.toString()).connection("activities").post(activity);
+        activity = new ActivityEntity("rod@rodsimpson.com","POST", "activity 2");
+        entity = usersResource.entity(userId.toString()).activities().post(activity);
 
         refreshIndex();
 
         UUID secondActivityId = entity.getUuid();
 
-        Collection activities = usersResource.entity(userId.toString()).connection("activities").get();
+        Collection activities = usersResource.entity(userId.toString()).activities().get();
 
         entity = (Entity) activities.getResponse().getEntities().get(0);
 
@@ -317,9 +306,7 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
         String name = "name" + id;
         String email = "email" + id + "@usergrid.org";
 
-        Map<String,Object> map = new HashMap<>();
-        map.put("username",username);
-        map.put("name",name);
+        User map = new User(username,name,email,null);
         map.put("email",email);
 
         Entity userEntity = usersResource.post(new Entity(map));
@@ -396,14 +383,14 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
         String username = "username" + id;
         String name = "name" + id;
 
-        Entity entity = new Entity().chainPut("username",username).chainPut("name", name).chainPut("email", id + "@usergrid.org").chainPut("password","password");
+        User user = new User(username, name, id + "@usergrid.org","password");
 
-        entity = usersResource.post(entity);
+        Entity entity = usersResource.post(user);
         UUID createdId = entity.getUuid();
 
         Collection results = usersResource.get(new QueryParameters().setQuery(String.format("name = '%s'", name)));
-        Entity user = (Entity) results.getResponse().getEntities(  ).get( 0 );
-        assertEquals( createdId, user.getUuid() );
+        entity = new User( results.getResponse().getEntities(  ).get( 0 ));
+        assertEquals( createdId, entity.getUuid() );
     }
 
 
@@ -414,28 +401,25 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
 
         String username = "username" + id;
         String name = "name" + id;
+        User entity = new User(username, name, id + "@usergrid.org","password");
 
-        ApiResponse response = client.createUser( username, name, id + "@usergrid.org", "password" );
-        assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        refreshIndex("test-organization", "test-app");
+        entity = new User(usersResource.post(entity));
 
-        UUID createdId = response.getEntities().get( 0 ).getUuid();
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/users/" + createdId )
-                                  .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                                  .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class ));
+        UUID createdId = entity.getUuid();
 
-        assertNull( node.get( "errors" ) );
+        refreshIndex();
 
-        Query results = client.queryUsers( String.format( "username = '%s'", name ) );
-        assertEquals( 0, results.getResponse().getEntities( User.class ).size() );
+       Entity newEntity = usersResource.entity(createdId.toString()).get();
+
+
+        Collection results = usersResource.get(new QueryParameters().setQuery( String.format("username = '%s'", name)));
+        assertEquals(0, results.getResponse().getEntities().size());
 
         // now create that same user again, it should work
-        response = client.createUser( username, name, id + "@usergrid.org", "password" );
-        assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        refreshIndex("test-organization", "test-app");
+        entity = new User( usersResource.post(entity));
 
-        createdId = response.getEntities().get( 0 ).getUuid();
+        createdId = entity.getUuid();
 
         assertNotNull( createdId );
     }
@@ -449,72 +433,57 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
         String name = "name1" + id;
         String email = "email1" + id + "@usergrid.org";
 
-        ApiResponse response = client.createUser( username, name, email, "password" );
-        assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        refreshIndex("test-organization", "test-app");
+        User entity = new User(username, name,email,"password");
 
-        UUID firstCreatedId = response.getEntities().get( 0 ).getUuid();
+        entity = new User( usersResource.post(entity));
+        refreshIndex();
 
+        UUID firstCreatedId = entity.getUuid();
         username = "username2" + id;
         name = "name2" + id;
         email = "email2" + id + "@usergrid.org";
 
-        response = client.createUser( username, name, email, "password" );
-        assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        refreshIndex("test-organization", "test-app");
+        entity = new User(username, name,email,"password");
 
-        UUID secondCreatedId = response.getEntities().get( 0 ).getUuid();
+        entity = new User( usersResource.post(entity));
+        refreshIndex();
+
+        UUID secondCreatedId = entity.getUuid();
 
         // now create a connection of "likes" between the first user and the
         // second using pluralized form
 
         // plural collection name
-        String path = String.format( "/test-organization/test-app/users/%s/conn1/%s", firstCreatedId, secondCreatedId );
-
-        JsonNode node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                          .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
 
-        assertEquals( secondCreatedId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
+        Entity conn1 = usersResource.entity(firstCreatedId.toString()).connection("conn1").entity(secondCreatedId.toString()).post();
 
-        refreshIndex("test-organization", "test-app");
+        assertEquals(secondCreatedId.toString(),conn1.getUuid().toString());
 
-        // singular collection name
-        path = String.format( "/test-organization/test-app/user/%s/conn2/%s", firstCreatedId, secondCreatedId );
-
-        node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                         .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
-
-        assertEquals( secondCreatedId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
+        refreshIndex();
 
-        refreshIndex("test-organization", "test-app");
 
-        path = String.format( "/test-organization/test-app/users/%s/conn1", firstCreatedId );
 
-        node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                         .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
+        Entity conn2 = usersResource.entity(firstCreatedId.toString()).connection("conn2").entity(secondCreatedId.toString()).post();
 
-        assertEquals( secondCreatedId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
+        assertEquals( secondCreatedId.toString(), conn2.getUuid().toString() );
 
-        path = String.format( "/test-organization/test-app/user/%s/conn1", firstCreatedId );
+        refreshIndex();
 
-        node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                         .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
+        Collection conn1Connections = usersResource.entity(firstCreatedId.toString()).connection("conn1").get();
 
-        assertEquals( secondCreatedId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
+        assertEquals( secondCreatedId.toString(),((Entity) conn1Connections.getResponse().getEntities().get(0)).getUuid().toString() );
 
-        path = String.format( "/test-organization/test-app/users/%s/conn2", firstCreatedId );
+        conn1Connections = userResource.entity(firstCreatedId.toString()).connection("conn1").get();
 
-        node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                         .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
+        assertEquals( secondCreatedId.toString(),((Entity) conn1Connections.getResponse().getEntities().get(0)).getUuid().toString() );
 
-        assertEquals( secondCreatedId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
+        Collection conn2Connections = usersResource.entity(firstCreatedId.toString()).connection("conn1").get();
 
-        path = String.format( "/test-organization/test-app/user/%s/conn2", firstCreatedId );
+        assertEquals( secondCreatedId.toString(),((Entity) conn2Connections.getResponse().getEntities().get(0)).getUuid().toString() );
 
-        node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                         .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
+        conn2Connections = userResource.entity(firstCreatedId.toString()).connection("conn1").get();
 
-        assertEquals( secondCreatedId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
+        assertEquals( secondCreatedId.toString(),((Entity) conn2Connections.getResponse().getEntities().get(0)).getUuid().toString() );
     }
 
 
@@ -526,40 +495,36 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
         String name1 = "name1" + id;
         String email1 = "email1" + id + "@usergrid.org";
 
-        ApiResponse response = client.createUser( username1, name1, email1, "password" );
-        assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        refreshIndex("test-organization", "test-app");
+        User entity = new User(username1, name1,email1,"password");
+
+        entity = new User( usersResource.post(entity));
 
-        UUID firstCreatedId = response.getEntities().get( 0 ).getUuid();
+        UUID firstCreatedId = entity.getUuid();
 
         String username2 = "username2" + id;
         String name2 = "name2" + id;
         String email2 = "email2" + id + "@usergrid.org";
 
-        response = client.createUser( username2, name2, email2, "password" );
-        assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        refreshIndex("test-organization", "test-app");
+        entity = new User(username2, name2,email2,"password");
+
+        entity = new User( usersResource.post(entity));
 
-        UUID secondCreatedId = response.getEntities().get( 0 ).getUuid();
+        UUID secondCreatedId = entity.getUuid();
 
         // now create a connection of "likes" between the first user and the
         // second using pluralized form
+        refreshIndex();
 
         // named entity in collection name
-        String path = String.format( "/test-organization/test-app/users/%s/conn1/users/%s", firstCreatedId, username2 );
-
-        JsonNode node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                          .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
+        Entity conn1 = usersResource.entity(firstCreatedId.toString()).connection("conn1").entity(username2.toString()).post();
 
-        assertEquals( secondCreatedId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
+        assertEquals( secondCreatedId.toString(), conn1.getUuid().toString() );
 
         // named entity in collection name
-        path = String.format( "/test-organization/test-app/users/%s/conn2/users/%s", username1, username2 );
 
-        node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                         .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
+        Entity conn2 = usersResource.entity(username1).connection("conn2").entity(username2).post();
 
-        assertEquals( secondCreatedId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
+        assertEquals( secondCreatedId.toString(), conn2.getUuid().toString() );
     }
 
 
@@ -573,131 +538,85 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
         String name = "name1" + id;
         String email = "email1" + id + "@usergrid.org";
 
-        ApiResponse response = client.createUser( email, name, email, "password" );
-        assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        refreshIndex("test-organization", "test-app");
+        User entity = new User(email, name,email,"password");
 
-        UUID userId = response.getEntities().get( 0 ).getUuid();
+        entity =new User( usersResource.post(entity));
 
-        Entity role = new Entity( "role" );
-        role.setProperty( "name", "connectionQuerybyEmail1" );
+        UUID userId = entity.getUuid();
 
-        response = client.createEntity( role );
+        Entity role = new Entity(  );
+        role.put("name", "connectionQuerybyEmail1");
 
-        assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
+        role = this.app().collection("roles").post(role);
 
-        UUID roleId1 = response.getEntities().get( 0 ).getUuid();
+        UUID roleId1 = role.getUuid();
 
         //add permissions to the role
 
-        Map<String, String> perms = new HashMap<String, String>();
+        Map<String, Object> perms = new HashMap<>();
         perms.put( "permission", "get:/stuff/**" );
 
-        String path = String.format( "/test-organization/test-app/roles/%s/permissions", roleId1 );
 
-        JsonNode node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                          .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, perms ));
+        Entity perms1 = this.app().collection("roles").entity(roleId1.toString()).connection("permissions").post(new Entity(perms));
 
 
         //Create the second role
-        role = new Entity( "role" );
-        role.setProperty( "name", "connectionQuerybyEmail2" );
-
-        response = client.createEntity( role );
+        role = new Entity(  );
+        role.put("name", "connectionQuerybyEmail2");
+        role = this.app().collection("roles").post(role);
 
-        assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
 
-        UUID roleId2 = response.getEntities().get( 0 ).getUuid();
+        UUID roleId2 =role.getUuid();
 
         //add permissions to the role
 
-        perms = new HashMap<String, String>();
+        perms = new HashMap<>();
         perms.put( "permission", "get:/stuff/**" );
-
-        path = String.format( "/test-organization/test-app/roles/%s/permissions", roleId2 );
-
-        node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                         .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, perms ));
-
-        refreshIndex("test-organization", "test-app");
-
+        Entity perms2 = this.app().collection("roles").entity(roleId2.toString()).connection("permissions").post(new Entity(perms));
+        refreshIndex();
         //connect the entities where role is the root
-        path = String.format( "/test-organization/test-app/roles/%s/users/%s", roleId1, userId );
-
-        node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                         .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
+        Entity perms3 = this.app().collection("roles").entity(roleId1.toString()).connection("users").entity(userId.toString()).post();
 
         // now create a connection of "likes" between the first user and the
         // second using pluralized form
 
-        assertEquals( userId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
-
-        refreshIndex("test-organization", "test-app");
+        assertEquals( userId.toString(),perms3.getUuid().toString());
 
 
         //connect the second role
-        path = String.format( "/test-organization/test-app/roles/%s/users/%s", roleId2, userId );
-
-        node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                         .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
-
 
-        assertEquals( userId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
+        Entity perms4 = this.app().collection("roles").entity(roleId2).connection("users").entity(userId).post();
 
-        refreshIndex("test-organization", "test-app");
+        assertEquals( userId.toString(),perms4.getUuid().toString() );
 
+        refreshIndex();
         //query the second role, it should work
-        path = String.format( "/test-organization/test-app/roles/%s/users", roleId2 );
-
-        node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token )
-                         .queryParam( "ql", "select%20*%20where%20username%20=%20'" + email + "'" )
-                         .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                         .get( String.class ));
-
-        assertEquals( userId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
+        Collection userRoles = this.app().collection("roles").entity(roleId2).connection("users").get(new QueryParameters().setQuery("select%20*%20where%20username%20=%20'"+ email + "'"));
+        assertEquals( userId.toString(),((Entity)userRoles.iterator().next()).getUuid().toString() );
 
 
         //query the first role, it should work
-        path = String.format( "/test-organization/test-app/roles/%s/users", roleId1 );
-
-        node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token )
-                         .queryParam( "ql", "select%20*%20where%20username%20=%20'" + email + "'" )
-                         .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                         .get( String.class ));
-
-        assertEquals( userId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
+        userRoles = this.app().collection("roles").entity(roleId1).connection("users").get(new QueryParameters().setQuery("select%20*%20where%20username%20=%20'"+ email + "'"));
+        assertEquals( userId.toString(),((Entity)userRoles.iterator().next()).getUuid().toString() );
 
 
         //now delete the first role
-        path = String.format( "/test-organization/test-app/roles/%s", roleId1 );
 
-        node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                         .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class ));
+        Entity roleEntity = this.app().collection("roles").entity(roleId1).get();
 
         //query the first role, it should 404
-        path = String.format( "/test-organization/test-app/roles/%s/users", roleId1 );
-
-        refreshIndex("test-organization", "test-app");
-
         try {
-            node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token )
-                             .queryParam( "ql", "select%20*%20where%20username%20=%20'" + email + "'" )
-                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                             .get( String.class ));
+            userRoles = this.app().collection("roles").entity(roleId1).connection("users").get(new QueryParameters().setQuery("select%20*%20where%20username%20=%20'"+ email + "'"));
+            assertNull(userRoles);
         }
         catch ( UniformInterfaceException e ) {
-            assertEquals( Status.NOT_FOUND, e.getResponse().getClientResponseStatus() );
+            assertEquals( Status.NOT_FOUND, e.getResponse().getStatus() );
         }
 
         //query the second role, it should work
-        path = String.format( "/test-organization/test-app/roles/%s/users", roleId2 );
-
-        node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token )
-                         .queryParam( "ql", "select%20*%20where%20username%20=%20'" + email + "'" )
-                         .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                         .get( String.class ));
+        userRoles = this.app().collection("roles").entity(roleId2).connection("users").get(new QueryParameters().setQuery("select%20*%20where%20username%20=%20'" + email + "'"));
 
-        assertEquals( userId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
+        assertEquals(userId.toString(), userRoles.getResponse().getEntities().get(0).getUuid().toString());
     }
 
 
@@ -708,48 +627,36 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
         String username1 = "username1" + id;
         String name1 = "name1" + id;
         String email1 = "email1" + id + "@usergrid.org";
+        User entity = new User(username1, name1,email1,"password");
 
-        ApiResponse response = client.createUser( username1, name1, email1, "password" );
-        assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        refreshIndex("test-organization", "test-app");
+        entity = new User( usersResource.post(entity));
 
-        UUID firstCreatedId = response.getEntities().get( 0 ).getUuid();
+        UUID firstCreatedId = entity.getUuid();
 
         String name = "pepperoni";
 
         Entity pizza = new Entity();
-        pizza.setProperty( "name", name );
-        pizza.setType( "pizza" );
-
-        response = client.createEntity( pizza );
+        pizza.put("name", name);
+        pizza.put("type", "pizza");
 
-        assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
+        Entity pizzaEntity = this.app().collection("pizzas").post(pizza);
 
-        UUID secondCreatedId = response.getEntities().get( 0 ).getUuid();
-
-        refreshIndex("test-organization", "test-app");
+        UUID secondCreatedId = pizzaEntity.getUuid();
+        refreshIndex();
 
         // now create a connection of "likes" between the first user and the
         // second using pluralized form
 
         // named entity in collection name
-        String path = String.format( "/test-organization/test-app/users/%s/conn1/pizzas/%s", firstCreatedId,
-                secondCreatedId );
-
-        JsonNode node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                          .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
+        Entity conn1 = usersResource.entity(firstCreatedId).connection("conn1").collection("pizzas").entity(secondCreatedId).post();
 
-        assertEquals( secondCreatedId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
-
-        refreshIndex("test-organization", "test-app");
+        assertEquals( secondCreatedId.toString(),conn1.getUuid().toString() );
 
         // named entity in collection name
-        path = String.format( "/test-organization/test-app/users/%s/conn2/pizzas/%s", username1, name );
+        Entity conn2 = usersResource.entity(username1).connection("conn2").collection("pizzas").entity(name).post();
 
-        node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                         .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
 
-        assertEquals( secondCreatedId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
+        assertEquals( secondCreatedId.toString(), conn2.getUuid().toString() );
     }
 
 
@@ -760,59 +667,42 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
         String username = "username" + id;
         String name = "name" + id;
         String email = "email" + id + "@usergrid.org";
+        User entity = new User(username, name,email,"password");
 
-        ApiResponse response = client.createUser( username, name, email, "password" );
-
-        assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        refreshIndex("test-organization", "test-app");
-
-        Entity userEntity = response.getEntities().get( 0 );
+        Entity userEntity = usersResource.post(entity);
 
+        refreshIndex();
         // attempt to log in
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/token" ).queryParam( "username", username )
-                                  .queryParam( "password", "password" ).queryParam( "grant_type", "password" )
-                                  .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                                  .get( String.class ));
+        Token token = this.app().token().post(new Token(username,"password"));
 
-        assertEquals( username, node.get( "user" ).get( "username" ).asText() );
-        assertEquals( name, node.get( "user" ).get( "name" ).asText() );
-        assertEquals( email, node.get( "user" ).get( "email" ).asText() );
+        assertEquals( username, token.getUser().getUsername() );
+        assertEquals( name, token.getUser().getName() );
+        assertEquals( email, token.getUser().getEmail() );
 
         // now update the name and email
         String newName = "newName";
         String newEmail = "newEmail" + UUIDUtils.newTimeUUID() + "@usergrid.org";
 
-        userEntity.setProperty( "name", newName );
-        userEntity.setProperty( "email", newEmail );
-        userEntity.setProperty( "password", "newp2ssword" );
-        userEntity.setProperty( "pin", "newp1n" );
+        userEntity.put("name", newName);
+        userEntity.put("email", newEmail);
+        userEntity.put("password", "newp2ssword");
+        userEntity.put("pin", "newp1n");
 
-        node = mapper.readTree( resource().path( String.format( "/test-organization/test-app/users/%s", username ) )
-                         .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                         .type( MediaType.APPLICATION_JSON_TYPE ).put( String.class, userEntity.getProperties() ));
+        userEntity = usersResource.entity(username).put(userEntity);
 
-        refreshIndex("test-organization", "test-app");
 
+        refreshIndex();
         // now see if we've updated
-        node = mapper.readTree( resource().path( "/test-organization/test-app/token" ).queryParam( "username", username )
-                         .queryParam( "password", "password" ).queryParam( "grant_type", "password" )
-                         .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                         .get( String.class ));
-
-        assertEquals( username, node.get( "user" ).get( "username" ).asText() );
-        assertEquals( newName, node.get( "user" ).get( "name" ).asText() );
-        assertEquals( newEmail, node.get( "user" ).get( "email" ).asText() );
-        assertNull( newEmail, node.get( "user" ).get( "password" ) );
-        assertNull( newEmail, node.get( "user" ).get( "pin" ) );
-    }
 
 
-    /**
-     *
-     * @return
-     */
-    public JsonNode getActor( Entity entity ) {
-        return entity.getProperties().get( "actor" );
+        token = this.app().token().post(new Token(username,"password"));
+
+
+        assertEquals(username, token.getUser().getUsername());
+        assertEquals(newName, token.getUser().getName());
+        assertEquals(newEmail, token.getUser().getEmail());
+        assertNull(token.getUser().get("password"));
+        assertNull(newEmail, token.getUser().get("pin"));
     }
 
 
@@ -821,29 +711,25 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
 
         log.info( "UserResourceIT.test_POST_batch" );
 
-        JsonNode node = null;
 
-        List<Map<String, Object>> batch = new ArrayList<Map<String, Object>>();
+        List<Entity> batch = new ArrayList<>();
 
-        Map<String, Object> properties = new LinkedHashMap<String, Object>();
+        Entity properties = new Entity();
         properties.put( "username", "test_user_1" );
         properties.put( "email", "user1@test.com" );
         batch.add( properties );
 
-        properties = new LinkedHashMap<String, Object>();
+        properties = new Entity();
         properties.put( "username", "test_user_2" );
         batch.add( properties );
 
-        properties = new LinkedHashMap<String, Object>();
+        properties = new Entity();
         properties.put( "username", "test_user_3" );
         batch.add( properties );
 
-        node = mapper.readTree( resource().path( "/test-organization/test-app/users/" ).queryParam( "access_token", access_token )
-                         .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                         .post( String.class, batch ));
+        ApiResponse response = usersResource.post(batch);
 
-        assertNotNull( node );
-        logNode( node );
+        assertNotNull(response);
     }
 
 
@@ -854,34 +740,19 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
 
         String userName = String.format( "test%s", newUserUuid );
 
-        Map<String, String> payload =
-                hashMap( "email", String.format( "%s@anuff.com", newUserUuid ) ).map( "username", userName )
-                                                                                .map( "name", "Ed Anuff" )
-                                                                                .map( "password", "sesame" )
-                                                                                .map( "pin", "1234" );
-
-        resource().path( "/test-organization/test-app/users" ).queryParam( "access_token", access_token )
-                  .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                  .post( String.class, payload );
+        User entity =
+                (User)new User(userName, "Ed Anuff",String.format("%s@anuff.com", newUserUuid),"sesame").chainPut("pin", "1234");
 
-        refreshIndex("test-organization", "test-app");
-
-        JsonNode response = mapper.readTree( resource().path( "/test-organization/test-app/users" ).queryParam( "access_token", access_token )
-                          .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                          .get( String.class ));
+        usersResource.post(entity);
+        refreshIndex();
 
+        Collection response = usersResource.get();
         // disable the user
-
         Map<String, String> data = new HashMap<String, String>();
+        Entity entityConn = usersResource.entity(userName).connection("deactivate").post(new Entity());
 
-        response = mapper.readTree( resource().path( String.format( "/test-organization/test-app/users/%s/deactivate", userName ) )
-                             .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, data ));
-
-        JsonNode entity = getEntity( response, 0 );
-
-        assertFalse( entity.get( "activated" ).asBoolean() );
-        assertNotNull( entity.get( "deactivated" ) );
+        assertFalse( (boolean)entityConn.get( "activated" ) );
+        assertNotNull( entityConn.get( "deactivated" ) );
     }
 
 
@@ -890,8 +761,7 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
 
         boolean fail = false;
         try {
-            ApiResponse changeResponse = client.changePassword( "edanuff", "foo", "bar" );
-            fail = changeResponse.getError() != null;
+            Entity changeResponse = usersResource.entity("edanuff").put(new ChangePasswordEntity("foo","bar"));
         }
         catch ( Exception e ) {
             fail = true;
@@ -904,42 +774,30 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
     public void test_GET_user_ok() throws InterruptedException, IOException {
 
         // TODO figure out what is being overridden? why 400?
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/users" )
-                .queryParam( "access_token", access_token )
-                .accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE )
-                .get( String.class ));
-
-        String uuid = node.get( "entities" ).get( 0 ).get( "uuid" ).textValue();
-        String email = node.get( "entities" ).get( 0 ).get( "email" ).textValue();
-
-        node = mapper.readTree( resource().path( "/test-organization/test-app/users/" + uuid )
-                .queryParam( "access_token", access_token )
-                .accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE )
-                .get( String.class ));
+        Collection users = usersResource.get();
+
+        String uuid =  users.getResponse().getEntities().get(0).getUuid().toString();
+        String email = users.getResponse().getEntities().get( 0 ).get("name").toString();
+
+        Entity user = usersResource.entity(uuid).get();
         
-        logNode( node );
-        assertEquals( email, node.get( "entities" ).get( 0 ).get( "email" ).textValue() );
+        assertEquals( email, user.get("email").toString() );
     }
 
 
     @Test
     public void test_PUT_password_ok() {
 
-        ApiResponse response = client.changePassword( "edanuff", "sesame", "sesame1" );
-
-        assertNull( response.getError() );
 
-        response = client.authorizeAppUser( "ed@anuff.com", "sesame1" );
+        Entity changeResponse = usersResource.entity("edanuff").put(new ChangePasswordEntity("sesame", "sesame1"));
 
-        assertNull( response.getError() );
+        Token token = this.app().token().post(new Token("ed@anuff.com", "sesame1"));
 
         // if this was successful, we need to re-set the password for other
         // tests
-        response = client.changePassword( "edanuff", "sesame1", "sesame" );
+         changeResponse = usersResource.entity("edanuff").put(new ChangePasswordEntity("sesame1","sesame"));
+        assertNotNull(changeResponse);
 
-        assertNull( response.getError() );
     }
 
 
@@ -948,19 +806,15 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
 
         String newPassword = "foo";
 
-        Map<String, String> data = new HashMap<String, String>();
+        Entity data = new Entity();
         data.put( "newpassword", newPassword );
 
         // change the password as admin. The old password isn't required
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/users/edanuff/password" )
-                                  .queryParam( "access_token", adminAccessToken ).accept( MediaType.APPLICATION_JSON )
-                                  .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, data ));
-
-        assertNull( getError( node ) );
-
-        ApiResponse response = client.authorizeAppUser( "ed@anuff.com", newPassword );
+        Entity node = usersResource.entity("edanuff").connection("password").post(data);
+        assertNotNull(node);
 
-        assertNull( response.getError() );
+        Token response = this.app().token().post(new Token("ed@anuff.com", newPassword));
+        assertNotNull(response);
     }
 
 
@@ -969,25 +823,15 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
         String origPassword = "foo";
         String newPassword = "bar";
 
-        Map<String, String> data = new HashMap<String, String>();
-        data.put( "newpassword", origPassword );
-
-        // now change the password, with an incorrect old password
-
-        data.put( "oldpassword", origPassword );
-        data.put( "newpassword", newPassword );
+        ChangePasswordEntity data = new ChangePasswordEntity(origPassword,newPassword);
 
-        Status responseStatus = null;
+        int responseStatus = 0;
         try {
-            resource().path( "/test-organization/test-app/users/edanuff/password" ).accept( MediaType.APPLICATION_JSON )
-                      .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, data );
-        }
-        catch ( UniformInterfaceException uie ) {
-            responseStatus = uie.getResponse().getClientResponseStatus();
+            usersResource.entity("edanuff").connection("password").post(data);
+        } catch ( UniformInterfaceException uie ) {
+            responseStatus = uie.getResponse().getStatus();
         }
 
-        assertNotNull( responseStatus );
-
         assertEquals( Status.BAD_REQUEST, responseStatus );
     }
 
@@ -1003,167 +847,140 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
         String name = "name" + id;
         String email = "email" + id + "@usergrid.org";
 
-        ApiResponse response = client.createUser( username, name, email, "password" );
-        assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        refreshIndex("test-organization", "test-app");
-
-        UUID createdId = response.getEntities().get( 0 ).getUuid();
+        User user = new User(username,name,email,"password");
+        user = new User(usersResource.post(user));
+        UUID createdId = user.getUuid();
 
         // create Role
 
-        String json = "{\"title\":\"" + roleName + "\",\"name\":\"" + roleName + "\"}";
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/roles" )
-            .queryParam( "access_token", access_token )
-            .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-            .post( String.class, json ));
-
+        Entity role = new Entity().chainPut("title",roleName).chainPut("name",roleName);
+        this.app().collection("roles").post(role);
         // check it
-        assertNull( node.get( "errors" ) );
-
-        refreshIndex("test-organization", "test-app");
 
+        refreshIndex();
         // add Role
 
-        node = mapper.readTree( resource().path( "/test-organization/test-app/users/" + createdId + "/roles/" + roleName )
-            .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-            .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
+        role =  usersResource.entity(createdId).collection("roles").entity(roleName).post();
 
+        refreshIndex();
         // check it
-        assertNull( node.get( "errors" ) );
-        assertNotNull( node.get( "entities" ) );
-        assertNotNull( node.get( "entities" ).get( 0 ) );
-        assertNotNull( node.get( "entities" ).get( 0 ).get( "name" ) );
-        assertEquals( node.get( "entities" ).get( 0 ).get( "name" ).asText(), roleName );
+        assertNotNull( role );
+        assertNotNull(role.get("name") );
+        assertEquals( role.get("name").toString(), roleName );
 
-        refreshIndex("test-organization", "test-app");
-
-        node = mapper.readTree( resource().path( "/test-organization/test-app/users/" + createdId + "/roles" )
-            .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-            .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
-        assertNull( node.get( "errors" ) );
-        assertNotNull( node.get( "entities" ) );
-        assertNotNull( node.get( "entities" ).get( 0 ) );
-        assertNotNull( node.get( "entities" ).get( 0 ).get( "name" ) );
-        assertEquals( node.get( "entities" ).get( 0 ).get( "name" ).asText(), roleName );
+        role =  usersResource.entity(createdId).collection("roles").entity(roleName).get();
 
+        assertNotNull( role );
+        assertNotNull(role.get("name") );
+        assertEquals( role.get("name").toString(), roleName );
 
         // remove Role
-
-        node = mapper.readTree( resource().path( "/test-organization/test-app/users/" + createdId + "/roles/" + roleName )
-                         .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                         .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class ));
+        ApiResponse response =  usersResource.entity(createdId).collection("roles").entity(roleName).delete();
 
         // check it
-        assertNull( node.get( "errors" ) );
 
-        refreshIndex("test-organization", "test-app");
+        role =  usersResource.entity(createdId).collection("roles").entity(roleName).get();
 
-        node = mapper.readTree( resource().path( "/test-organization/test-app/users/" + createdId + "/roles" )
-                         .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                         .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
-        assertNull( node.get( "errors" ) );
-        assertTrue( node.get( "entities" ).size() == 0 );
+        assertNull(role);
     }
 
 
     @Test
     public void revokeToken() throws Exception {
 
-        String token1 = super.userToken( "edanuff", "sesame" );
-        String token2 = super.userToken( "edanuff", "sesame" );
-
-        JsonNode response = mapper.readTree( resource().path( "/test-organization/test-app/users/edanuff" ).queryParam( "access_token", token1 )
-                          .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                          .get( String.class ));
+        Token token1 = this.app().token().post(new Token("edanuff", "sesame"));
+        Token token2 = this.app().token().post(new Token("edanuff", "sesame"));
 
-        assertNotNull( getEntity( response, 0 ) );
+        this.app().token().setToken(token1);
+        Entity entity1 = usersResource.entity("edanuff").get();
+        this.app().token().setToken(token2);
+        Entity entity2 = usersResource.entity("edanuff").get();
 
-        response = mapper.readTree( resource().path( "/test-organization/test-app/users/edanuff" ).queryParam( "access_token", token2 )
-                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                             .get( String.class ));
-
-        assertNotNull( getEntity( response, 0 ) );
+        assertNotNull( entity1 );
 
+        assertNotNull( entity2);
+        Token adminToken = this.clientSetup.getRestClient().management().token().post(new Token(clientSetup.getUsername(),clientSetup.getUsername()));
         // now revoke the tokens
-        response = mapper.readTree( resource().path( "/test-organization/test-app/users/edanuff/revoketokens" )
-                             .queryParam( "access_token", adminAccessToken ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
+        this.app().token().setToken(adminToken);
 
+        usersResource.entity("edanuff").connection("revoketokens").post(new Entity().chainPut("token",token1));
+        refreshIndex();
         // the tokens shouldn't work
 
-        Status status = null;
+        int status = 0;
 
         try {
-            response = mapper.readTree( resource().path( "/test-organization/test-app/users/edanuff" ).queryParam( "access_token", token1 )
-                              .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                              .get( String.class ));
+            this.app().token().setToken(token1);
+
+            usersResource.entity("edanuff").get();
+            assertFalse(true);
         }
         catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+            status = uie.getResponse().getStatus();
         }
 
-        assertEquals( Status.UNAUTHORIZED, status );
+        assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
 
-        status = null;
+        status = 0;
 
         try {
-            response = mapper.readTree( resource().path( "/test-organization/test-app/users/edanuff" ).queryParam( "access_token", token2 )
-                              .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                              .get( String.class ));
+            this.app().token().setToken(token2);
+
+            usersResource.entity("edanuff").get();
         }
         catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+            status = uie.getResponse().getStatus();
         }
 
-        assertEquals( Status.UNAUTHORIZED, status );
+        assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
+
+        Token token3 = this.app().token().post(new Token("edanuff", "sesame"));
+        Token token4 = this.app().token().post(new Token("edanuff", "sesame"));
 
-        String token3 = super.userToken( "edanuff", "sesame" );
-        String token4 = super.userToken( "edanuff", "sesame" );
+        this.app().token().setToken(token3);
+        entity1 = usersResource.entity("edanuff").get();
 
-        response = mapper.readTree( resource().path( "/test-organization/test-app/users/edanuff" ).queryParam( "access_token", token3 )
-                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                             .get( String.class ));
 
-        assertNotNull( getEntity( response, 0 ) );
+        assertNotNull(entity1);
 
-        response = mapper.readTree( resource().path( "/test-organization/test-app/users/edanuff" ).queryParam( "access_token", token4 )
-                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                             .get( String.class ));
+        this.app().token().setToken(token3);
+        entity2 = usersResource.entity("edanuff").get();
 
-        assertNotNull( getEntity( response, 0 ) );
+        assertNotNull(entity2);
 
         // now revoke the token3
-        response = mapper.readTree( resource().path( "/test-organization/test-app/users/edanuff/revoketoken" )
-                             .queryParam( "access_token", token3 ).queryParam( "token", token3 )
-                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                             .post( String.class ));
+        adminToken = this.clientSetup.getRestClient().management().token().post(new Token(clientSetup.getUsername(),clientSetup.getUsername()));
+        // now revoke the tokens
+        this.app().token().setToken(adminToken);
+        usersResource.entity("edanuff").connection("revoketokens").post();
+        refreshIndex();
 
         // the token3 shouldn't work
 
-        status = null;
+        status = 0;
 
         try {
-            response = mapper.readTree( resource().path( "/test-organization/test-app/users/edanuff" ).queryParam( "access_token", token3 )
-                              .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                              .get( String.class ));
+            this.app().token().setToken(token3);
+            usersResource.entity("edanuff").get();
+
         }
         catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+            status = uie.getResponse().getStatus();
         }
 
-        assertEquals( Status.UNAUTHORIZED, status );
+        assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
 
-        status = null;
+        status = 0;
 
         try {
-            response = mapper.readTree( resource().path( "/test-organization/test-app/users/edanuff" ).queryParam( "access_token", token4 )
-                              .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                              .get( String.class ));
+            this.app().token().setToken(token4);
+            usersResource.entity("edanuff").get();
+
 
-            status = Status.OK;
+            status = Status.OK.getStatusCode();
         }
         catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+            status = uie.getResponse().getStatus();
         }
 
         assertEquals( Status.OK, status );
@@ -1173,87 +990,76 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
     @Test
     public void getToken() throws Exception {
 
-        createUser( "test_1", "test_1@test.com", "test123", "Test1 User" ); // client.setApiUrl(apiUrl);
-        createUser( "test_2", "test_2@test.com", "test123", "Test2 User" ); // client.setApiUrl(apiUrl);
-        createUser( "test_3", "test_3@test.com", "test123", "Test3 User" ); // client.setApiUrl(apiUrl);
-        refreshIndex("test-organization", "test-app");
+        usersResource.post(new User("test_1","Test1 User", "test_1@test.com", "test123")); // client.setApiUrl(apiUrl);
+        usersResource.post(new User( "test_2", "Test2 User" , "test_2@test.com", "test123")); // client.setApiUrl(apiUrl);
+        usersResource.post(new User( "test_3","Test3 User" , "test_3@test.com", "test123" )); // client.setApiUrl(apiUrl);
+        refreshIndex();
 
         ApplicationInfo appInfo = setup.getMgmtSvc().getApplicationInfo( "test-organization/test-app" );
 
         String clientId = setup.getMgmtSvc().getClientIdForApplication( appInfo.getId() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForApplication( appInfo.getId() );
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/users/test_1/token" ).queryParam( "client_id", clientId )
-                          .queryParam( "client_secret", clientSecret ).accept( MediaType.APPLICATION_JSON )
-                          .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
+        Collection tokens = userResource.entity("test_1").connection("token").get(new QueryParameters().addParam("client_id",clientId).addParam("client_secret", clientSecret ),false);
 
-        String user_token_from_client_credentials = node.get( "access_token" ).asText();
+        Entity token = tokens.getResponse().getEntities().get(0);
+        String user_token_from_client_credentials = token.get( "access_token" ).toString();
 
-        UUID userId = UUID.fromString( node.get( "user" ).get( "uuid" ).asText() );
+        UUID userId = UUID.fromString(((Map<String, Object>) token.get("user")).get("uuid").toString());
         setup.getMgmtSvc().activateAppUser( appInfo.getId(), userId );
 
         String user_token_from_java = setup.getMgmtSvc().getAccessTokenForAppUser( appInfo.getId(), userId, 1000000 );
 
         assertNotNull( user_token_from_client_credentials );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex();
 
-        Status status = null;
+        int status = 0;
 
         // bad access token
         try {
-            resource().path( "/test-organization/test-app/users/test_1/token" ).queryParam( "access_token", "blah" )
-                      .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                      .get( String.class );
+            userResource.entity("test_1").connection("token").get(new QueryParameters().addParam("access_token", "blah"),false);
+            assertTrue(false);
         }
         catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+            status = uie.getResponse().getStatus();
             log.info( "Error Response Body: " + uie.getResponse().getEntity( String.class ) );
         }
 
-        assertEquals( Status.UNAUTHORIZED, status );
+        assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
 
         try {
-            resource().path( "/test-organization/test-app/users/test_2/token" )
-                      .queryParam( "access_token", user_token_from_client_credentials )
-                      .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                      .get( String.class );
+            userResource.entity("test_2").connection("token").get(new QueryParameters().addParam("access_token", user_token_from_client_credentials),false);
+            assertTrue(false);
         }
         catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+            status = uie.getResponse().getStatus();
             log.info( "Error Response Body: " + uie.getResponse().getEntity( String.class ) );
         }
 
-        assertEquals( Status.FORBIDDEN, status );
+        assertEquals( Status.FORBIDDEN.getStatusCode(), status );
+
 
+        tokens = userResource.entity("test_1").connection("token").get(new QueryParameters().addParam("access_token", user_token_from_client_credentials),false);
 
-        JsonNode response = null;
-        response = mapper.readTree( resource().path( "/test-organization/test-app/users/test_1" )
-                             .queryParam( "access_token", user_token_from_client_credentials )
-                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                             .get( String.class ));
 
-        assertNotNull( getEntity( response, 0 ) );
+        assertTrue( tokens.getResponse().getEntities().size()>0 );
 
-        response = mapper.readTree( resource().path( "/test-organization/test-app/users/test_1" )
-                             .queryParam( "access_token", user_token_from_java ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
+        tokens = userResource.entity("test_1").connection("token").get(new QueryParameters().addParam("access_token", user_token_from_java),false);
 
-        assertNotNull( getEntity( response, 0 ) );
+        assertTrue(tokens.getResponse().getEntities().size() > 0);
 
-        setup.getMgmtSvc().deactivateUser( appInfo.getId(), userId );
+        Entity entityConn = usersResource.entity(userId).connection("deactivate").post(new Entity());
 
-        refreshIndex("test-organization", "test-app");
+
+        refreshIndex();
 
         try {
-            resource().path( "/test-organization/test-app/token" ).queryParam( "grant_type", "password" )
-                      .queryParam( "username", "test_1" ).queryParam( "password", "test123" )
-                      .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                      .get( String.class );
+            this.app().token().post(new Token("test_1","test123"));
             fail( "request for deactivated user should fail" );
         }
         catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+            status = uie.getResponse().getStatus();
             JsonNode body = mapper.readTree( uie.getResponse().getEntity( String.class ));
             assertEquals( "user not activated", body.findPath( "error_description" ).textValue() );
         }
@@ -1263,37 +1069,28 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
     @Test
     public void delegatePutOnNotFound() throws Exception {
         String randomName = "user1_" + UUIDUtils.newTimeUUID().toString();
-        createUser( randomName, randomName + "@apigee.com", "password", randomName );
-        refreshIndex("test-organization", "test-app");
+        User user = new User ( randomName,randomName, randomName + "@apigee.com", "password" );
+        usersResource.post(user);
+        refreshIndex();
 
         // should update a field
-        JsonNode response = mapper.readTree( resource().path( "/test-organization/test-app/users/" + randomName )
-                                      .queryParam( "access_token", adminAccessToken )
-                                      .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                                      .get( String.class ));
-        logNode( response );
-        assertNotNull( getEntity( response, 0 ) );
+        Entity response = usersResource.entity(randomName).get();
+        assertNotNull( response );
         // PUT on user
 
         // PUT a new user
         randomName = "user2_" + UUIDUtils.newTimeUUID().toString();
-        Map<String, String> payload =
-                hashMap( "email", randomName + "@apigee.com" ).map( "username", randomName ).map( "name", randomName )
-                                                              .map( "password", "password" ).map( "pin", "1234" );
 
-        response = mapper.readTree( resource().path( "/test-organization/test-app/users" ).queryParam( "access_token", adminAccessToken )
-                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                             .put( String.class, payload ));
+        User user2 =(User) new User ( randomName,randomName, randomName + "@apigee.com", "password" ).chainPut( "pin", "1234" );
 
-        refreshIndex("test-organization", "test-app");
+        response = usersResource.post(user2);
+
+        refreshIndex();
+
+        Entity response2 = usersResource.entity(randomName).get();
 
-        logNode( response );
-        response = mapper.readTree( resource().path( "/test-organization/test-app/users/" + randomName )
-                             .queryParam( "access_token", adminAccessToken ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
 
-        assertNotNull( getEntity( response, 0 ) );
-        logNode( response );
+        assertNotNull(response2);
     }
 
 
@@ -1305,24 +1102,17 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
     public void queryForUuids() throws Exception {
 
         {
-            final JsonNode response = mapper.readTree( resource().path( "/test-organization/test-app/users/" ).queryParam( "ql",
-                    "select *" )               // query for entities
-                    .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
-            assertNotNull( "Entities must exist", response.get( "entities" ) );
-            assertTrue( "Must be some entities", response.get( "entities" ).size() > 0 );
-            assertEquals( "Must be users", "user", response.get( "entities" ).get( 0 ).get( "type" ).asText() );
-            assertNull( "List must not exist", response.get( "list" ) );
+            final Collection response = usersResource.get(new QueryParameters().setQuery("select *"));
+            assertNotNull("Entities must exist", response.getResponse().getEntities());
+            assertTrue("Must be some entities", response.getResponse().getEntities().size() > 0 );
+            assertEquals("Must be users", "user", response.getResponse().getEntities().get(0).get("type").toString());
         }
 
         {
-            final JsonNode response = mapper.readTree( resource().path( "/test-organization/test-app/users/" ).queryParam( "ql",
-                    "select uuid" )            // query for uuid properties
-                    .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
-            assertNotNull( "List must exist", response.get( "list" ) );
-            assertTrue( "Must be some list items", response.get( "list" ).size() > 0 );
-            assertNull( "Entities must not exist", response.get( "entries" ) );
+            final Collection response = usersResource.get(new QueryParameters().setQuery("select uuid"));
+
+            assertNotNull( "List must exist", response.getResponse().getEntities(  ) );
+            assertTrue("Must be some list items", response.getResponse().getEntities(  ).size()>0);
         }
     }
 
@@ -1330,37 +1120,28 @@ public class UserResourceIT extends org.apache.usergrid.rest.test.resource2point
     @Test
     public void queryForUserUuids() throws Exception {
 
-        userRepo.load( resource(), access_token );
-        refreshIndex("test-organization", "test-app");
 
-        Status status = null;
+        int status = 0;
 
 
         String ql = "uuid = " + userRepo.getByUserName( "user1" );
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/users" ).queryParam( "ql", ql )
-                                  .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                                  .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
-
+        usersResource.get(new QueryParameters().setQuery(ql));
 
-        Map<String, String> payload = hashMap( "name", "Austin" ).map( "state", "TX" );
+        Entity payload = new Entity().chainPut( "name", "Austin" ).chainPut("state", "TX");
 
-        node = mapper.readTree( resource().path( "/test-organization/test-app/curts" ).queryParam( "access_token", access_token )
-                         .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                         .post( String.class, payload ));
+        Entity responseEntity = this.app().collection("curts").post(payload);
 
-        UUID userId = UUID.fromString( node.get( "entities" ).get( 0 ).get( "uuid" ).asText() );
+        UUID userId = UUID.fromString( responseEntity.getUuid().toString() );
 
         assertNotNull( userId );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex();
 
         ql = "uuid = " + userId;
 
-        node = mapper.readTree( resource().path( "/test-organization/test-app/curts" ).queryParam( "ql", ql )
-                         .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                         .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
+        Collection response  = this.app().collection("curts").get(new QueryParameters().setQuery(ql));
 
-        assertNotNull( node.get( "entities" ).get( 0 ).get( "uuid" ) );
+        assertEquals(response.getResponse().getEntities().get(0).get("uuid"), userId);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2a5b4c7e/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
index 12b4607..33225ce 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationsResource.java
@@ -20,6 +20,7 @@ package org.apache.usergrid.rest.test.resource2point0.endpoints;
 import org.apache.usergrid.rest.test.resource.app.Collection;
 import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource2point0.model.Application;
+import org.apache.usergrid.rest.test.resource2point0.model.Token;
 import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
 
 import javax.ws.rs.core.MediaType;
@@ -38,8 +39,13 @@ public class ApplicationsResource extends CollectionEndpoint {
     }
 
 
+
     public CollectionEndpoint collection(String name) {
         return new CollectionEndpoint(name,context,this);
     }
 
+    public TokenResource token(){
+        return new TokenResource(context,this);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2a5b4c7e/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionEndpoint.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionEndpoint.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionEndpoint.java
index 8be9a32..6af8431 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionEndpoint.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionEndpoint.java
@@ -17,14 +17,13 @@
 package org.apache.usergrid.rest.test.resource2point0.endpoints;
 
 import com.sun.jersey.api.client.WebResource;
-import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
-import org.apache.usergrid.rest.test.resource2point0.model.Collection;
-import org.apache.usergrid.rest.test.resource2point0.model.Entity;
-import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
+import org.apache.usergrid.rest.test.resource2point0.model.*;
 import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
 import org.apache.usergrid.services.ServiceParameter;
 
 import javax.ws.rs.core.MediaType;
+import java.util.List;
+import java.util.UUID;
 
 
 /**
@@ -44,6 +43,11 @@ public class CollectionEndpoint extends NamedResource {
         return entity(identifier);
     }
 
+    public EntityEndpoint entity(final UUID identifier ){
+        return entity(identifier.toString());
+    }
+
+
     public EntityEndpoint entity(final String identifier ){
         return new EntityEndpoint(identifier, context, this);
     }
@@ -173,6 +177,16 @@ public class CollectionEndpoint extends NamedResource {
         return new Entity(response);
     }
 
+    public Entity post(){
+        ApiResponse response = getResource(true).type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
+                .post(ApiResponse.class);
+        return new Entity(response);
+    }
+
+    public ApiResponse post(List<Entity> entityList){
+        throw new RuntimeException("not implemented");
+    }
+
     /**
      * PUT a payload to a collection
      *

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2a5b4c7e/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/EntityEndpoint.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/EntityEndpoint.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/EntityEndpoint.java
index 4ed8fa2..e70823f 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/EntityEndpoint.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/EntityEndpoint.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import com.sun.jersey.api.client.WebResource;
 import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+import org.apache.usergrid.rest.test.resource2point0.model.Token;
 import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
 
 import javax.ws.rs.core.MediaType;
@@ -56,7 +57,14 @@ public class EntityEndpoint extends NamedResource {
     }
 
     public Entity get(final boolean useToken){
-        WebResource resource  = getResource(useToken);
+        return get(useToken,null);
+    }
+    public Entity get(final Token token){
+        return get(true,token);
+    }
+
+    public Entity get(final boolean useToken, final Token token){
+        WebResource resource  = getResource(useToken,token);
         ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
                 .get(ApiResponse.class);
 
@@ -140,10 +148,15 @@ public class EntityEndpoint extends NamedResource {
     public CollectionEndpoint connection(final String identifier) {
         return new CollectionEndpoint(identifier, context, this);
     }
+    public CollectionEndpoint collection(final String identifier) {
+        return new CollectionEndpoint(identifier, context, this);
+    }
     public CollectionEndpoint connection(){
         return new CollectionEndpoint("", context, this);
     }
 
 
-
+    public CollectionEndpoint activities() {
+        return connection("activities");
+    }
 }


Mime
View raw message