You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2015/01/13 20:15:03 UTC

[01/50] [abbrv] incubator-usergrid git commit: devices test fixed

Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o-import 5d6c4accc -> 6deac1895


devices test fixed


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

Branch: refs/heads/two-dot-o-import
Commit: 3c089f5500023b8fc1846213828ebf801a40e3c4
Parents: 4d86a95
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Jan 5 15:41:02 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Jan 5 15:41:02 2015 -0700

----------------------------------------------------------------------
 .../collection/devices/DevicesResourceIT.java   | 39 ++++++++++----------
 1 file changed, 20 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3c089f55/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/devices/DevicesResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/devices/DevicesResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/devices/DevicesResourceIT.java
index 4010a05..8010c56 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/devices/DevicesResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/devices/DevicesResourceIT.java
@@ -22,9 +22,12 @@ import java.util.Map;
 import java.util.UUID;
 
 import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.CollectionEndpoint;
+import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
 import org.junit.Test;
 import org.apache.usergrid.cassandra.Concurrent;
-import org.apache.usergrid.rest.AbstractRestIT;
 
 import com.sun.jersey.api.client.UniformInterfaceException;
 import java.io.IOException;
@@ -39,34 +42,30 @@ import org.junit.Ignore;
 public class DevicesResourceIT extends AbstractRestIT {
 
     @Test
-    @Ignore("cannot be supported with Core Persistence which requires time based UUIDs")
     public void putWithUUIDShouldCreateAfterDelete() throws IOException {
 
-        Map<String, String> payload = new HashMap<String, String>();
+        Entity payload = new Entity().chainPut("name", "foo");
         UUID uuid = UUID.randomUUID();
-        payload.put( "name", "foo" );
 
-        String path = "devices/" + uuid;
+        refreshIndex();
 
-        refreshIndex("test-organization", "test-app");
-
-        JsonNode response = mapper.readTree( appPath( path ).put( String.class, payload ));
+        CollectionEndpoint devicesResource  =this.app().collection("devices");
+        Entity entity = devicesResource.entity(uuid).put(payload);
 
         // create
-        JsonNode entity = getEntity( response, 0 );
         assertNotNull( entity );
-        String newUuid = entity.get( "uuid" ).textValue();
+        String newUuid = entity.getUuid().toString();
         assertEquals( uuid.toString(), newUuid );
 
         // delete
-        response = mapper.readTree( appPath( path ).delete( String.class ));
-        assertNotNull( getEntity( response, 0 ) );
+        ApiResponse deleteResponse =devicesResource.entity(uuid).delete();
+        assertNotNull(deleteResponse.getEntities().get(0));
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex();
 
         // check deleted
         try {
-            response = mapper.readTree( appPath( path ).get( String.class ));
+            entity = devicesResource.entity(uuid).get();
             fail( "should get 404 error" );
         }
         catch ( UniformInterfaceException e ) {
@@ -74,14 +73,16 @@ public class DevicesResourceIT extends AbstractRestIT {
         }
 
         // create again
-        response = mapper.readTree( appPath( path ).put( String.class, payload ));
-        entity = getEntity( response, 0 );
+        entity = devicesResource.entity(uuid).put(payload);
+
+
         assertNotNull( entity );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex();
 
         // check existence
-        response = mapper.readTree( appPath( path ).get( String.class ));
-        assertNotNull( getEntity( response, 0 ) );
+        entity = devicesResource.entity(uuid).get();
+
+        assertNotNull(entity );
     }
 }


[21/50] [abbrv] incubator-usergrid git commit: Merge remote-tracking branch 'r3b/APIBAAS-1397' into apache_usergrid/two-dot-o

Posted by gr...@apache.org.
Merge remote-tracking branch 'r3b/APIBAAS-1397' into apache_usergrid/two-dot-o


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

Branch: refs/heads/two-dot-o-import
Commit: 323ef9502f4ef553dfb67b4f3c24f850f3cf3160
Parents: adff75f 1216a9c
Author: Rod Simpson <ro...@apigee.com>
Authored: Wed Jan 7 11:27:53 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Wed Jan 7 11:27:53 2015 -0700

----------------------------------------------------------------------
 stack/pom.xml | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/323ef950/stack/pom.xml
----------------------------------------------------------------------


[08/50] [abbrv] incubator-usergrid git commit: Merge branch 'two-dot-o' into Usergrid-310

Posted by gr...@apache.org.
Merge branch 'two-dot-o' into Usergrid-310


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

Branch: refs/heads/two-dot-o-import
Commit: fe7719ab81e7eefc77c4e32839ab7f9686f9699f
Parents: 1404292 acb468c
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Jan 5 21:38:12 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Jan 5 21:38:12 2015 -0700

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



[17/50] [abbrv] incubator-usergrid git commit: Adding editorconfig settings file to help with consistent formatting

Posted by gr...@apache.org.
Adding editorconfig settings file to help with consistent formatting


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

Branch: refs/heads/two-dot-o-import
Commit: 8dc44051b3da0c8c84403b2e132f2c4f483f85b3
Parents: fe7719a
Author: ryan bridges <rb...@apigee.com>
Authored: Fri Dec 5 09:49:09 2014 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Wed Jan 7 13:14:26 2015 -0500

----------------------------------------------------------------------
 stack/.editorconfig | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8dc44051/stack/.editorconfig
----------------------------------------------------------------------
diff --git a/stack/.editorconfig b/stack/.editorconfig
new file mode 100644
index 0000000..21ba8b8
--- /dev/null
+++ b/stack/.editorconfig
@@ -0,0 +1,19 @@
+# top-most EditorConfig file
+root = true
+
+# Unix-style newlines with a newline ending every file
+[*]
+end_of_line = lf
+insert_final_newline = true
+charset = utf-8
+trim_trailing_whitespace = true
+indent_style = space
+indent_size = 4
+continuation_indent_size = 4
+max_line_length = 80
+
+# java
+[*.java]
+curly_bracket_next_line = false
+spaces_around_brackets = both
+spaces_around_operators = true


[45/50] [abbrv] incubator-usergrid git commit: Merge remote-tracking branch 'r3b/editorconfig' into apache_usergrid/two-dot-o

Posted by gr...@apache.org.
Merge remote-tracking branch 'r3b/editorconfig' into apache_usergrid/two-dot-o


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

Branch: refs/heads/two-dot-o-import
Commit: e090acfeb8562144a3125bdd7092d805e8980564
Parents: 8b338b1 f153cda
Author: Rod Simpson <ro...@apigee.com>
Authored: Mon Jan 12 11:25:51 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Mon Jan 12 11:25:51 2015 -0700

----------------------------------------------------------------------

----------------------------------------------------------------------



[13/50] [abbrv] incubator-usergrid git commit: fixed null ref issues

Posted by gr...@apache.org.
fixed null ref issues


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

Branch: refs/heads/two-dot-o-import
Commit: e03108786d6923c51d643ffdcf52c5bc3ab9229d
Parents: 01173d9
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Jan 6 15:51:21 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Jan 6 15:51:21 2015 -0700

----------------------------------------------------------------------
 .../collection/users/PermissionsResourceIT.java | 631 ++++++-------------
 .../rest/test/resource2point0/model/Entity.java |   6 +-
 2 files changed, 209 insertions(+), 428 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e0310878/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
index a07622e..5f196bb 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
@@ -18,6 +18,7 @@ package org.apache.usergrid.rest.applications.collection.users;
 
 
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
@@ -25,13 +26,16 @@ import javax.ws.rs.core.MediaType;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.node.ArrayNode;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.model.*;
+import org.elasticsearch.common.collect.HppcMaps;
+import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.apache.usergrid.cassandra.Concurrent;
 import org.apache.usergrid.java.client.entities.Group;
 import org.apache.usergrid.management.ApplicationInfo;
 import org.apache.usergrid.management.OrganizationOwnerInfo;
-import org.apache.usergrid.rest.AbstractRestIT;
 import org.apache.usergrid.utils.UUIDUtils;
 
 import com.sun.jersey.api.client.ClientResponse;
@@ -39,11 +43,8 @@ import com.sun.jersey.api.client.ClientResponse.Status;
 import com.sun.jersey.api.client.UniformInterfaceException;
 import java.io.IOException;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
 import static org.apache.usergrid.utils.MapUtils.hashMap;
+import static org.junit.Assert.*;
 
 
 /**
@@ -57,59 +58,61 @@ public class PermissionsResourceIT extends AbstractRestIT {
     private static final String ROLE = "permtestrole";
 
     private static final String USER = "edanuff";
+    private User user;
 
 
     public PermissionsResourceIT() throws Exception {
 
     }
+    
+    @Before
+    public void setup(){
+
+        user = new User(USER,USER,USER+"@apigee.com","password");
+        user = new User( this.app().collection("users").post(user));
+        refreshIndex();
+    }
 
 
     @Test
     public void deleteUserFromRole() throws IOException {
-        Map<String, String> data = hashMap( "name", ROLE );
+        Entity data = new Entity().chainPut("name", ROLE);
 
-        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, data ));
-
-        assertNull( node.get( "error" ) );
+        Entity node = this.app().collection("roles").post(data);
 
-        assertEquals( ROLE, getEntity( node, 0 ).get( "name" ).asText() );
+        assertNull(node.get("error"));
 
-        refreshIndex("test-organization", "test-app");
-
-        // add the user to the role
-        node = mapper.readTree( resource().path( "/test-organization/test-app/roles/" + ROLE + "/users/" + USER )
-                .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
+        assertEquals( ROLE, node.get("name").toString() );
 
+        refreshIndex();
+        node = this.app().collection("roles").entity(node).collection("users").entity(USER).post();
         assertNull( node.get( "error" ) );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex();
 
         // now check the user has the role
-        node = mapper.readTree( resource().path( "/test-organization/test-app/users/" + USER + "/roles" )
-                .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
+        node =  this.app().collection("users").entity(USER).collection("roles").entity(ROLE).get();
+
 
         // check if the role was assigned
-        assertEquals( ROLE, getEntity( node, 0 ).get( "name" ).asText() );
+        assertEquals( ROLE, node.get("name").toString() );
 
         // now delete the role
-        node = mapper.readTree( resource().path( "/test-organization/test-app/users/" + USER + "/roles/" + ROLE )
-                .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class ));
+        this.app().collection("users").entity(USER).collection("roles").entity(ROLE).delete();
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex();
 
         // check if the role was deleted
 
-        node = mapper.readTree( resource().path( "/test-organization/test-app/users/" + USER + "/roles" )
-                .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
+        int status = 0;
+        try {
+            node = this.app().collection("users").entity(USER).collection("roles").entity(ROLE).get();
+        }catch (UniformInterfaceException e){
+            status = e.getResponse().getStatus();
+        }
 
         // check if the role was assigned
-        assertNull( getEntity( node, 0 ) );
+        assertEquals(status, 404);
     }
 
 
@@ -118,54 +121,43 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         // don't populate the user, it will use the currently authenticated
         // user.
+        String groupPath = "groupPath" ;
 
-        UUID id = UUIDUtils.newTimeUUID();
-
-        String groupPath = "groupPath" + id;
+        Entity data = new Entity().chainPut("name",groupPath).chainPut("type", "group").chainPut( "path", groupPath );
 
-        Map<String, String> data = hashMap( "type", "group" ).map( "path", groupPath );
-
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/groups" )
-                .queryParam( "access_token", access_token )
-                .accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE )
-                .post( String.class, data ));
+        Entity node = this.app().collection("groups").post(data);
 
         assertNull( node.get( "error" ) );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex();
 
-        node = mapper.readTree( 
-            resource().path( "/test-organization/test-app/groups/" + groupPath + "/users/" + USER )
-                .queryParam( "access_token", access_token )
-                .accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE )
-                .post( String.class ));
+        node = this.app().collection("groups").entity(groupPath).collection("users").entity(USER).post();
 
         assertNull( node.get( "error" ) );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex();
 
-        Map<String, Group> groups = client.getGroupsForUser( USER );
+       Collection groups = this.app().collection("users").entity(USER).collection("groups").get();
 
-        assertNotNull( groups.get( groupPath ) );
+        assertEquals(groups.next().get("name"), groupPath);
 
         // now delete the group
 
-        node = mapper.readTree( 
-            resource().path( "/test-organization/test-app/groups/" + groupPath + "/users/" + USER )
-                .queryParam( "access_token", access_token )
-                .accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE )
-                .delete( String.class ));
+        ApiResponse response = this.app().collection("groups").entity(groupPath).collection("users").entity(USER).delete();
 
-        assertNull( node.get( "error" ) );
+        assertNull( response.getError() );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex();
 
-        groups = client.getGroupsForUser( USER );
+        int status = 0;
+        try {
+            groups = this.app().collection("users").entity(USER).collection("groups").get();
+            assertFalse(groups.hasNext());
+        }catch (UniformInterfaceException e){
+            status=e.getResponse().getStatus();
+            fail();
+        }
 
-        assertNull( groups.get( groupPath ) );
     }
 
 
@@ -183,33 +175,22 @@ public class PermissionsResourceIT extends AbstractRestIT {
         String password = "password";
         String email = String.format( "email%s@usergrid.com", id );
 
-        OrganizationOwnerInfo orgs = setup.getMgmtSvc()
-                                          .createOwnerAndOrganization( orgname, username, "noname", email, password,
-                                                  true, false );
-
-        // create the app
-        ApplicationInfo appInfo =
-                setup.getMgmtSvc().createApplication( orgs.getOrganization().getUuid(), applicationName );
-
-        String adminToken = setup.getMgmtSvc().getAccessTokenForAdminUser( orgs.getOwner().getUuid(), 0 );
 
         // add the perms to the guest to allow users in the role to create roles
         // themselves
-        addPermission( orgname, applicationName, adminToken, "guest", "get,put,post:/roles/**" );
+        addPermission(  "guest", "get,put,post:/roles/**" );
 
-        Map<String, String> data = hashMap( "name", "usercreatedrole" );
+        Entity data = new Entity().chainPut("name", "usercreatedrole");
 
         // create a role as the user
-        JsonNode node = mapper.readTree( resource().path( String.format( "/%s/%s/roles", orgname, applicationName ) )
-                .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                .post( String.class, data ));
+        Entity entity  = this.app().collection("roles").post(data);
 
-        assertNull( getError( node ) );
+        assertNull( entity.getError() );
 
-        refreshIndex(orgname, applicationName);
+        refreshIndex();
 
         // now try to add permission as the user, this should work
-        addPermission( orgname, applicationName, "usercreatedrole", "get,put,post:/foo/**" );
+        addPermission(  "usercreatedrole", "get,put,post:/foo/**" );
     }
 
 
@@ -232,211 +213,154 @@ public class PermissionsResourceIT extends AbstractRestIT {
      */
     @Test
     public void applicationPermissions() throws Exception {
-        UUID id = UUIDUtils.newTimeUUID();
-
-        String applicationName = "test";
-        String orgname = "applicationpermissions";
-        String username = "permissionadmin" + id;
-        String password = "password";
-        String email = String.format( "email%s@usergrid.com", id );
-
-        OrganizationOwnerInfo orgs = setup.getMgmtSvc()
-                                          .createOwnerAndOrganization( orgname, username, "noname", email, password,
-                                                  true, false );
-
-        // create the app
-        ApplicationInfo appInfo =
-                setup.getMgmtSvc().createApplication( orgs.getOrganization().getUuid(), applicationName );
-
         // now create the new role
-        Map<String, String> data = hashMap( "name", "reviewer" );
+        UUID secondUserId = createRoleUser(  "reviewer2", "reviewer2@usergrid.com" );
+        UUID userId = createRoleUser( "reviewer1",  "reviewer1@usergrid.com" );
 
-        String adminToken = setup.getMgmtSvc().getAccessTokenForAdminUser( orgs.getOwner().getUuid(), 0 );
+        Entity  data = new Entity().chainPut("name", "reviewer");
 
-        JsonNode node = mapper.readTree( resource().path( String.format( "/%s/%s/roles", orgname, applicationName ) )
-                .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, data ));
+        Entity node = this.app().collection("roles").post(data);
 
-        assertNull( getError( node ) );
+        assertNull( node.getError() );
 
         // delete the default role to test permissions later
-        node = mapper.readTree( resource().path( String.format( "/%s/%s/roles/default", orgname, applicationName ) )
-                .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class ));
+        refreshIndex();
+
+        ApiResponse response = this.app().collection("roles").entity("default").delete();
 
-        assertNull( getError( node ) );
-        refreshIndex(orgname, applicationName);
+        assertNull( response.getError() );
+        refreshIndex();
 
         // grant the perms to reviewer
-        addPermission( orgname, applicationName, adminToken, "reviewer", "get,put,post:/reviews/**" );
+        addPermission( "reviewer", "get,put,post:/reviews/**" );
 
         // grant get to guest
-        addPermission( orgname, applicationName, adminToken, "guest", "get:/reviews/**" );
+        addPermission(  "guest", "get:/reviews/**" );
 
-        UUID userId = createRoleUser( orgs.getOrganization().getUuid(), appInfo.getId(), adminToken, "reviewer1",
-                "reviewer1@usergrid.com" );
+        Entity group = new Entity().chainPut( "path", "reviewergroup" ).chainPut("name","reviewergroup");
 
-        refreshIndex(orgname, applicationName);
+        // now create the group
+        this.app().collection("groups").post(group);
 
-        // grant this user the "reviewer" role
-        node = mapper.readTree( resource().path( String.format( "/%s/%s/users/reviewer1/roles/reviewer", orgname, applicationName ) )
-                .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
+        refreshIndex();
 
-        assertNull( getError( node ) );
+        this.app().collection("groups").entity("reviewergroup").collection("roles").entity("reviewer").post();
 
-        refreshIndex(orgname, applicationName);
+        refreshIndex();
 
-        String reviewer1Token = setup.getMgmtSvc().getAccessTokenForAppUser( appInfo.getId(), userId, 0 );
+        // add the user to the group
+        this.app().collection("users").entity("reviewer2").collection("groups").entity("reviewergroup").post();
 
-        Map<String, String> review =
-                hashMap( "rating", "4" ).map( "name", "noca" ).map( "review", "Excellent service and food" );
+        refreshIndex();
 
-        // post a review as the reviewer1 user
-        resource().path( String.format( "/%s/%s/reviews", orgname, applicationName ) )
-                .queryParam( "access_token", reviewer1Token ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, review );
+        Entity userRole = this.app().collection("users").entity("reviewer1").collection("roles").entity("reviewer").post();
+        // grant this user the "reviewer" role
 
-        review = hashMap( "rating", "4" ).map( "name", "4peaks" ).map( "review", "Huge beer selection" );
+        refreshIndex();
 
-        refreshIndex(orgname, applicationName);
+        this.app().token().post(new Token("reviewer1","password"));
 
-        // put a review as the reviewer1 user
-        resource().path( String.format( "/%s/%s/reviews", orgname, applicationName ) )
-                .queryParam( "access_token", reviewer1Token ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).put( String.class, review );
+        Entity review =
+                new Entity().chainPut("rating", "4").chainPut("name", "noca").chainPut("review", "Excellent service and food");
 
-        refreshIndex(orgname, applicationName);
+        this.app().collection("reviews").post(review);
+        refreshIndex();
 
-        // get the reviews
+        // post a review as the reviewer1 user
+        review = new Entity().chainPut ("rating", "4").chainPut( "name", "4peaks").chainPut("review", "Huge beer selection" );
+        this.app().collection("reviews").post(review);
 
-        node = mapper.readTree( resource().path( String.format( "/%s/%s/reviews", orgname, applicationName ) )
-                .queryParam( "access_token", reviewer1Token ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
+        refreshIndex();
 
-        assertEquals( "noca", getEntity( node, 0 ).get( "name" ).asText() );
-        assertEquals( "4peaks", getEntity( node, 1 ).get( "name" ).asText() );
+        // get the reviews
+        Collection reviews = this.app().collection("reviews").get();
 
-        // can't delete, not in the grants
+        assertEquals( "noca",reviews.next().get("name") );
+        assertEquals("4peaks", reviews.next().get("name").toString());
 
-        ClientResponse.Status status = null;
+        // can't delete, not in the grants
 
+        int status = 0;
         try {
-            resource().path( String.format( "/%s/%s/reviews/noca", orgname, applicationName ) )
-                    .queryParam( "access_token", reviewer1Token ).accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class );
+            this.app().collection("reviews").entity("noca").delete();
         }
         catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+            status = uie.getResponse().getStatus();
         }
 
-        assertEquals( Status.UNAUTHORIZED, status );
+        assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
 
-        refreshIndex(orgname, applicationName);
+        refreshIndex();
 
-        status = null;
+        status = 0;
 
         try {
-            resource().path( String.format( "/%s/%s/reviews/4peaks", orgname, applicationName ) )
-                    .queryParam( "access_token", reviewer1Token ).accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class );
+            this.app().collection("reviews").entity("4peaks").delete();
         }
         catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+            status = uie.getResponse().getStatus();
         }
 
-        assertEquals( Status.UNAUTHORIZED, status );
+        assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
 
-        refreshIndex(orgname, applicationName);
+        refreshIndex();
 
         // now test some groups
-        UUID secondUserId = createRoleUser( orgs.getOrganization().getUuid(), appInfo.getId(), adminToken, "reviewer2",
-                "reviewer2@usergrid.com" );
-
-        Map<String, String> group = hashMap( "path", "reviewergroup" );
-
-        // /now create the group
-        resource().path( String.format( "/%s/%s/groups", orgname, applicationName ) )
-                .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, group );
-
-        refreshIndex(orgname, applicationName);
-
-        // link the group to the role
-        resource().path( String.format( "/%s/%s/groups/reviewergroup/roles/reviewer", orgname, applicationName ) )
-                .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, group );
-
-        refreshIndex(orgname, applicationName);
-
-        // add the user to the group
-        resource().path( String.format( "/%s/%s/users/reviewer2/groups/reviewergroup", orgname, applicationName ) )
-                .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class );
-
-        refreshIndex(orgname, applicationName);
 
         // post 2 reviews. Should get permissions from the group
 
-        String secondUserToken = setup.getMgmtSvc().getAccessTokenForAppUser( appInfo.getId(), secondUserId, 0 );
+        Token secondUserToken = this.app().token().post(new Token("reviewer2", "password"));
 
-        review = hashMap( "rating", "4" ).map( "name", "cowboyciao" ).map( "review", "Great atmosphoere" );
+        review = new Entity().chainPut("rating", "4").chainPut("name", "cowboyciao").chainPut("review", "Great atmosphoere");
 
         // post a review as the reviewer2 user
-        resource().path( String.format( "/%s/%s/reviews", orgname, applicationName ) )
-                .queryParam( "access_token", secondUserToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, review );
-
-        review = hashMap( "rating", "4" ).map( "name", "currycorner" ).map( "review", "Authentic" );
+        this.app().collection("reviews").post(review);
 
-        refreshIndex(orgname, applicationName);
+        refreshIndex();
+        review = new Entity().chainPut( "rating", "4" ).chainPut("name", "currycorner").chainPut( "review", "Authentic" );
 
         // post a review as the reviewer2 user
-        resource().path( String.format( "/%s/%s/reviews", orgname, applicationName ) )
-                .queryParam( "access_token", secondUserToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, review );
+        this.app().collection("reviews").post(review);
+
+        refreshIndex();
 
-        refreshIndex(orgname, applicationName);
+        reviews =  this.app().collection("reviews").get();
 
         // get all reviews as a user
-        node = mapper.readTree( resource().path( String.format( "/%s/%s/reviews", orgname, applicationName ) )
-                .queryParam( "access_token", secondUserToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
 
-        assertEquals( "noca", getEntity( node, 0 ).get( "name" ).asText() );
-        assertEquals( "4peaks", getEntity( node, 1 ).get( "name" ).asText() );
-        assertEquals( "cowboyciao", getEntity( node, 2 ).get( "name" ).asText() );
-        assertEquals( "currycorner", getEntity( node, 3 ).get( "name" ).asText() );
+
+        assertEquals("noca", reviews.next().get("name").toString());
+        assertEquals("4peaks", reviews.next().get("name").toString());
+        assertEquals("cowboyciao", reviews.next().get("name").toString());
+        assertEquals("currycorner", reviews.next().get("name").toString());
 
         // issue a delete, it shouldn't work, no permissions
 
-        status = null;
+        status = 0;
 
         try {
-            resource().path( String.format( "/%s/%s/reviews/cowboyciao", orgname, applicationName ) )
-                    .queryParam( "access_token", secondUserToken ).accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class );
+            this.app().collection("reviews").entity("cowboyciao").delete();
+      
         }
         catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+            status = uie.getResponse().getStatus();
         }
 
-        assertEquals( Status.UNAUTHORIZED, status );
+        assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
 
-        refreshIndex(orgname, applicationName);
+        refreshIndex();
 
-        status = null;
+        status = 0;
 
         try {
-            resource().path( String.format( "/%s/%s/reviews/currycorner", orgname, applicationName ) )
-                    .queryParam( "access_token", secondUserToken ).accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class );
+            this.app().collection("reviews").entity("currycorner").delete();
+
         }
         catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+            status = uie.getResponse().getStatus();
         }
 
-        assertEquals( Status.UNAUTHORIZED, status );
+        assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
     }
 
 
@@ -454,148 +378,99 @@ public class PermissionsResourceIT extends AbstractRestIT {
     @Test
     public void wildcardMiddlePermission() throws Exception {
 
-         Map<String, String> params = buildOrgAppParams();
-        String orgname =params.get( "orgName" ) ;
-        String applicationName = params.get( "appName" ) ;
-        
-        OrganizationOwnerInfo orgs = setup.getMgmtSvc().createOwnerAndOrganization( params.get( "orgName" ),
-                params.get( "username" ), "noname", params.get( "email" ), params.get( "password" ), true, false );
-
-        // create the app
-        ApplicationInfo appInfo =
-                setup.getMgmtSvc().createApplication( orgs.getOrganization().getUuid(), params.get( "appName" ) );
-        assertNotNull( appInfo );
-
-        String adminToken = setup.getMgmtSvc().getAccessTokenForAdminUser( orgs.getOwner().getUuid(), 0 );
-
-        JsonNode node = mapper.readTree( resource()
-                .path( String.format( "/%s/%s/roles/default", params.get( "orgName" ), params.get( "appName" ) ) )
-                .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class ));
-        Map<String, String> data = hashMap( "name", "reviewer" );
+        this.app().collection("roles").entity("default").delete();
+        Entity data = new Entity().chainPut("name", "reviewer");
 
-        node = mapper.readTree( resource().path( String.format( "/%s/%s/roles", params.get( "orgName" ), params.get( "appName" ) ) )
-                .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, data ));
-        assertNull( getError( node ) );
+        this.app().collection("roles").post(data);
 
-        refreshIndex(orgname, applicationName);
+        refreshIndex();
 
         // allow access to reviews
-        addPermission( params.get( "orgName" ), params.get( "appName" ), adminToken, "reviewer",
+        addPermission( "reviewer",
                 "get,put,post:/reviews/**" );
         // allow access to all user's connections
-        addPermission( params.get( "orgName" ), params.get( "appName" ), adminToken, "reviewer",
+        addPermission( "reviewer",
                 "get,put,post:/users/${user}/**" );
         // allow access to the review relationship
-        addPermission( params.get( "orgName" ), params.get( "appName" ), adminToken, "reviewer",
+        addPermission( "reviewer",
                 "get,put,post:/books/*/review/*" );
 
-        assertNull( getError( node ) );
         // create userOne
         UUID userOneId =
-                createRoleUser( orgs.getOrganization().getUuid(), appInfo.getId(), adminToken, "wildcardpermuserone",
+                createRoleUser( "wildcardpermuserone",
                         "wildcardpermuserone@apigee.com" );
         assertNotNull( userOneId );
 
         // create userTwo
         UUID userTwoId =
-                createRoleUser( orgs.getOrganization().getUuid(), appInfo.getId(), adminToken, "wildcardpermusertwo",
+                createRoleUser( "wildcardpermusertwo",
                         "wildcardpermusertwo@apigee.com" );
         assertNotNull( userTwoId );
 
-        refreshIndex(orgname, applicationName);
-
-        // assign userOne the reviewer role
-        node = mapper.readTree( resource().path( String
-                .format( "/%s/%s/users/%s/roles/reviewer", params.get( "orgName" ), params.get( "appName" ),
-                        userOneId.toString() ) ).queryParam( "access_token", adminToken )
-                .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
+        refreshIndex();
+        
+        this.app().collection("users").entity(userOneId).collection("roles").entity("reviewer").post();
 
-        refreshIndex(orgname, applicationName);
+       
+        refreshIndex();
 
-        Map<String, String> book = hashMap( "title", "Ready Player One" ).map( "author", "Earnest Cline" );
+        Entity book = new Entity().chainPut( "title", "Ready Player One" ).chainPut("author", "Earnest Cline");
 
+        book = this.app().collection("books").post(book);
         // create a book as admin
-        node = mapper.readTree( resource().path( String.format( "/%s/%s/books", params.get( "orgName" ), params.get( "appName" ) ) )
-                .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, book ));
+       
 
-        logNode( node );
-        assertEquals( "Ready Player One", getEntity( node, 0 ).get( "title" ).textValue() );
-        String bookId = getEntity( node, 0 ).get( "uuid" ).textValue();
+        assertEquals( "Ready Player One", book.get("title").toString() );
+        String bookId = book.get("uuid").toString();
 
-        refreshIndex(orgname, applicationName);
+        refreshIndex();
 
-        String userOneToken = setup.getMgmtSvc().getAccessTokenForAppUser( appInfo.getId(), userOneId, 0 );
+        this.app().token().post(new Token("wildcardpermuserone","password"));
         // post a review of the book as user1
         // POST https://api.usergrid.com/my-org/my-app/users/$user1/reviewed/books/$uuid
-        Map<String, String> review =
-                hashMap( "heading", "Loved It" ).map( "body", "80s Awesomeness set in the future" );
-        node = mapper.readTree( resource().path( String.format( "/%s/%s/reviews", params.get( "orgName" ), params.get( "appName" ) ) )
-                .queryParam( "access_token", userOneToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, review ));
-        String reviewId = getEntity( node, 0 ).get( "uuid" ).textValue();
+        Entity review =
+                new Entity().chainPut( "heading", "Loved It" ).chainPut( "body", "80s Awesomeness set in the future" );
+        review = this.app().collection("reviews").post(review);
+        String reviewId = review.get("uuid").toString();
 
-        refreshIndex(orgname, applicationName);
+        refreshIndex();
 
         // POST https://api.usergrid.com/my-org/my-app/users/me/wrote/review/${reviewId}
-        node = mapper.readTree( resource().path( String
-                .format( "/%s/%s/users/me/wrote/review/%s", params.get( "orgName" ), params.get( "appName" ),
-                        reviewId ) ).queryParam( "access_token", userOneToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
+        this.app().collection("users").entity("me").connection("wrote").collection("review").entity(reviewId).post();
+
+
+        refreshIndex();
+        this.app().collection("users").entity("me").connection("reviewed").collection("books").entity(bookId).post();
 
-        refreshIndex(orgname, applicationName);
 
-        node = mapper.readTree( resource().path( String
-                .format( "/%s/%s/users/me/reviewed/books/%s", params.get( "orgName" ), params.get( "appName" ),
-                        bookId ) ).queryParam( "access_token", userOneToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
-        logNode( node );
+        refreshIndex();
+
 
-        refreshIndex(orgname, applicationName);
 
         // POST https://api.usergrid.com/my-org/my-app/books/${bookId}/review/${reviewId}
-        node = mapper.readTree( resource().path( String
-                .format( "/%s/%s/books/%s/review/%s", params.get( "orgName" ), params.get( "appName" ), bookId,
-                        reviewId ) ).queryParam( "access_token", userOneToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
-        logNode( node );
+        this.app().collection("books").entity(bookId).collection("review").entity(reviewId).post();
+
 
-        refreshIndex(orgname, applicationName);
+        refreshIndex();
 
         // now try to post the same thing to books to verify as userOne the failure
-        Status status = null;
+        int status = 0;
         try {
-            node = mapper.readTree( resource().path( String.format( "/%s/%s/books", params.get( "orgName" ), params.get( "appName" ) ) )
-                    .queryParam( "access_token", userOneToken ).accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
-            logNode( node );
+            this.app().collection("books").post();
+
         }
         catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+            status = uie.getResponse().getStatus();
         }
-        assertEquals( Status.UNAUTHORIZED, status );
-
-        refreshIndex(orgname, applicationName);
-
-        node = mapper.readTree( resource().path( String
-                .format( "/%s/%s/users/me/reviewed/books", params.get( "orgName" ), params.get( "appName" ) ) )
-                .queryParam( "access_token", userOneToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
-        logNode( node );
-
-        node = mapper.readTree( resource().path( String
-                .format( "/%s/%s/reviews/%s", params.get( "orgName" ), params.get( "appName" ), reviewId ) )
-                .queryParam( "access_token", userOneToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
-        logNode( node );
-
-        node = mapper.readTree( resource()
-                .path( String.format( "/%s/%s/users/me/wrote", params.get( "orgName" ), params.get( "appName" ) ) )
-                .queryParam( "access_token", userOneToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
-        logNode( node );
+        assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
+
+        refreshIndex();
+        this.app().collection("users").entity("me").connection("reviewed").collection("books").get();
+
+        this.app().collection("reviews").entity(reviewId).get();
+
+        this.app().collection("users").entity("me").connection("wrote").get();
+
     }
 
 
@@ -610,127 +485,59 @@ public class PermissionsResourceIT extends AbstractRestIT {
      * examplepatient add himself to exampledoctor following list
      */
     @Test
-    @Ignore("Why is this ignored?")
     public void wildcardFollowingPermission() throws Exception {
-        UUID id = UUIDUtils.newTimeUUID();
+        app().collection("roles").entity("default").delete();
+        Entity data = new Entity().chainPut( "name", "patient" );
+        app().collection("roles").post(data);
 
-        String applicationName = "test";
-        String orgname = "followingpermissions";
-        String username = "permissionadmin" + id;
-        String password = "password";
-        String email = String.format( "email%s@usergrid.com", id );
-
-        OrganizationOwnerInfo orgs = setup.getMgmtSvc()
-                                          .createOwnerAndOrganization( orgname, username, "noname", email, password,
-                                                  true, false );
-
-        // create the app
-        ApplicationInfo appInfo =
-                setup.getMgmtSvc().createApplication( orgs.getOrganization().getUuid(), applicationName );
-        assertNotNull( appInfo );
-
-        String adminToken = setup.getMgmtSvc().getAccessTokenForAdminUser( orgs.getOwner().getUuid(), 0 );
-
-        JsonNode node = mapper.readTree( resource().path( String.format( "/%s/%s/roles/default", orgname, applicationName ) )
-                .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class ));
-        Map<String, String> data = hashMap( "name", "patient" );
-
-        node = mapper.readTree( resource().path( String.format( "/%s/%s/roles", orgname, applicationName ) )
-                .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, data ));
-        assertNull( getError( node ) );
         //allow patients to add doctors as their followers
-        addPermission( orgname, applicationName, adminToken, "patient",
-                "delete,post:/users/*/following/users/${user}" );
-
-        assertNull( getError( node ) );
+        addPermission(  "patient", "delete,post:/users/*/following/users/${user}" );
+        refreshIndex();
         // create examplepatient
-        UUID patientId =
-                createRoleUser( orgs.getOrganization().getUuid(), appInfo.getId(), adminToken, "examplepatient",
-                        "examplepatient@apigee.com" );
+        UUID patientId =  createRoleUser( "examplepatient",  "examplepatient@apigee.com" );
         assertNotNull( patientId );
 
         // create exampledoctor
-        UUID doctorId = createRoleUser( orgs.getOrganization().getUuid(), appInfo.getId(), adminToken, "exampledoctor",
-                "exampledoctor@apigee.com" );
+        UUID doctorId = createRoleUser( "exampledoctor",  "exampledoctor@apigee.com" );
         assertNotNull( doctorId );
-
-
+        refreshIndex();
         // assign examplepatient the patient role
-        node = mapper.readTree( resource().path( String
-                .format( "/%s/%s/users/%s/roles/patient", orgname, applicationName, patientId.toString() ) )
-                .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
-
-        String patientToken = setup.getMgmtSvc().getAccessTokenForAppUser( appInfo.getId(), patientId, 0 );
-
-        node = mapper.readTree( resource().path( String
-                .format( "/%s/%s/users/%s/following/users/%s", orgname, applicationName, "exampledoctor",
-                        "examplepatient" ) ).queryParam( "access_token", patientToken )
-                .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
-        logNode( node );
+        this.app().collection("users").entity(patientId).collection("roles").entity("patient").post();
+        refreshIndex();
+        this.app().token().post(new Token("examplepatient","password"));
+        refreshIndex();
+        //not working yet, used to be ignored
+//        this.app().collection("users").entity("exampledoctor").connection("following").collection("users").entity("examplepatient").post();
     }
 
-
-    private Map<String, String> buildOrgAppParams() {
-        UUID id = UUIDUtils.newTimeUUID();
-        Map<String, String> props =
-                hashMap( "username", "wcpermadmin" ).map( "orgName", "orgnamewcperm" ).map( "appName", "test" )
-                        .map( "password", "password" )
-                        .map( "email", String.format( "email%s@apigee.com", id.toString() ) );
-
-        return props;
-    }
-
-
     /**
      * Create the user, check there are no errors
      *
      * @return the userid
      */
-    private UUID createRoleUser( UUID orgId, UUID appId, String adminToken, String username, String email )
+    private UUID createRoleUser(String username, String email)
             throws Exception {
 
-        Map<String, String> props = hashMap( "email", email ).map( "username", username ).map( "name", username )
-                .map( "password", "password" );
-
-        JsonNode node = mapper.readTree( resource().path( String.format( "/%s/%s/users", orgId, appId ) )
-                .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).put( String.class, props ));
-
-        assertNull( getError( node ) );
+        User props = new User(username, username, email, "password");
 
-        UUID userId = UUID.fromString( getEntity( node, 0 ).get( "uuid" ).asText() );
+        Entity entity = this.app().collection("users").post(props);
 
-        // manually activate user
-        setup.getMgmtSvc().activateAppUser( appId, userId );
-
-        return userId;
+        return entity.getUuid();
     }
 
 
     /** Test adding the permission to the role */
-    private void addPermission( String orgname, String appname, String adminToken, String rolename, String grant ) throws IOException {
-        Map<String, String> props = hashMap( "permission", grant );
-
-        String rolePath = String.format( "/%s/%s/roles/%s/permissions", orgname, appname, rolename );
-
-        JsonNode node = mapper.readTree( resource().path( rolePath ).queryParam( "access_token", adminToken )
-                .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                .put( String.class, props ));
+    private void addPermission(  String rolename, String grant ) throws IOException {
+        Entity props = new Entity().chainPut("permission", grant);
 
-        assertNull( getError( node ) );
+        this.app().collection("roles").entity(rolename).collection("permissions").post(props);
 
-        node = mapper.readTree( resource().path( rolePath ).queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
+        Collection node = this.app().collection("roles").entity(rolename).collection("permissions").get();
 
-        ArrayNode data = ( ArrayNode ) node.get( "data" );
+        List<Object> data =(List) node.getResponse().getData();
 
-        Iterator<JsonNode> iterator = data.elements();
-
-        while ( iterator.hasNext() ) {
-            if ( grant.equals( iterator.next().asText() ) ) {
+        for(Object o : data){
+            if(grant.equals(o.toString())){
                 return;
             }
         }
@@ -739,30 +546,4 @@ public class PermissionsResourceIT extends AbstractRestIT {
     }
 
 
-    /** Test adding the permission to the role */
-    private void addPermission( String orgname, String appname, String rolename, String grant ) throws IOException {
-        Map<String, String> props = hashMap( "permission", grant );
-
-        String rolePath = String.format( "/%s/%s/roles/%s/permissions", orgname, appname, rolename );
-
-        JsonNode node = mapper.readTree( resource().path( rolePath ).accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                        .put( String.class, props ));
-
-        assertNull( getError( node ) );
-
-        node = mapper.readTree( resource().path( rolePath ).accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                .get( String.class ));
-
-        ArrayNode data = ( ArrayNode ) node.get( "data" );
-
-        Iterator<JsonNode> iterator = data.elements();
-
-        while ( iterator.hasNext() ) {
-            if ( grant.equals( iterator.next().asText() ) ) {
-                return;
-            }
-        }
-
-        fail( String.format( "didn't find grant %s in the results", grant ) );
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e0310878/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
index b70f90c..5b74215 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
@@ -124,15 +124,15 @@ public class Entity implements Serializable, Map<String,Object> {
     }
 
     public String getError () {
-        return (String) this.get("error").toString();
+        return (String) this.get("error");
     }
 
     public String getErrorCode () {
-        return (String) this.get("errorCode").toString();
+        return (String)this.get("errorCode");
     }
 
     public String getErrorDescription () {
-        return (String) this.get("errorDescription").toString();
+        return (String) this.get("errorDescription");
     }
 
     @Override


[19/50] [abbrv] incubator-usergrid git commit: Merge remote-tracking branch 'GERey/USERGRID-304_Fix-paging-tests' into apache_usergrid/two-dot-o

Posted by gr...@apache.org.
Merge remote-tracking branch 'GERey/USERGRID-304_Fix-paging-tests' into apache_usergrid/two-dot-o


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

Branch: refs/heads/two-dot-o-import
Commit: 28d19f2f7c0b3036179f17ab1823f411e719e1c2
Parents: 1e3a16e f9927a7
Author: Rod Simpson <ro...@apigee.com>
Authored: Wed Jan 7 11:23:32 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Wed Jan 7 11:23:32 2015 -0700

----------------------------------------------------------------------
 .../collection/paging/PagingEntitiesTest.java   | 132 ------
 .../collection/paging/PagingResourceIT.java     | 442 +++++++++++--------
 .../endpoints/CollectionEndpoint.java           |  10 +-
 .../endpoints/EntityEndpoint.java               |  11 +
 .../test/resource2point0/model/Collection.java  |  11 +-
 5 files changed, 276 insertions(+), 330 deletions(-)
----------------------------------------------------------------------



[07/50] [abbrv] incubator-usergrid git commit: updated cast

Posted by gr...@apache.org.
updated cast


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

Branch: refs/heads/two-dot-o-import
Commit: acb468ceccc2be55f02bb5153cb26285f21bb775
Parents: ac4e0ae
Author: Rod Simpson <ro...@apigee.com>
Authored: Mon Jan 5 21:30:42 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Mon Jan 5 21:30:42 2015 -0700

----------------------------------------------------------------------
 .../apache/usergrid/rest/test/resource2point0/model/Entity.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


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


[23/50] [abbrv] incubator-usergrid git commit: Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into USERGRID-313

Posted by gr...@apache.org.
Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into USERGRID-313

# By grey (5) and ryan bridges (5)
# Via Rod Simpson (4) and grey (2)
* 'two-dot-o' of github.com:apache/incubator-usergrid:
  Removed test duplicated test. Fixed logic issue with helper method.
  Added a helper method to collections. Changed the test to use this new helper method.
  Removed test that was never properly implemented. Cleaned up all the tests with helper methods. Added comments detailing what each test does.
  Removed different PagingEntitiesTest and just consolidated tests into PagingResourceIT. Added helper methods and removed a lot of duplicated code. Added queryParameters to getNextPage method since we can do queryGets. Added a note to have the collection remember its own name
  Fixed PagingEntities and PagingResourceTest. Fixed bug where proper resource wasn't being used in the delete call. Added a queryParameter get call to the Entity method for testing purposes. Added a way to get the response from Collection
  [USERGRID-288]Updated GeoPagingTests
  Added comments to configuration options. removed 'root' declaration
  Adding editorconfig settings file to help with consistent formatting
  fixed formatting
  Adding excludes to rat


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

Branch: refs/heads/two-dot-o-import
Commit: 421a1d9d855d95cfadb481036cd3a13ec023c684
Parents: e031087 323ef95
Author: grey <gr...@apigee.com>
Authored: Wed Jan 7 11:01:42 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Wed Jan 7 11:01:42 2015 -0800

----------------------------------------------------------------------
 stack/.editorconfig                             |  26 +
 stack/pom.xml                                   |   2 +
 .../collection/paging/PagingEntitiesTest.java   | 132 -----
 .../collection/paging/PagingResourceIT.java     | 442 ++++++++-------
 .../applications/queries/GeoPagingTest.java     | 563 +++++++++----------
 .../endpoints/CollectionEndpoint.java           |  10 +-
 .../endpoints/EntityEndpoint.java               |  11 +
 .../test/resource2point0/model/Collection.java  |  11 +-
 8 files changed, 566 insertions(+), 631 deletions(-)
----------------------------------------------------------------------



[03/50] [abbrv] incubator-usergrid git commit: add clear token

Posted by gr...@apache.org.
add clear token


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

Branch: refs/heads/two-dot-o-import
Commit: 1404292b9e9656d43848bea683cea3b650dec80a
Parents: 80b093f
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Jan 5 19:01:18 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Jan 5 19:01:18 2015 -0700

----------------------------------------------------------------------
 .../rest/test/resource2point0/endpoints/TokenResource.java       | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1404292b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
index 22224ed..c7c5367 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
@@ -53,5 +53,9 @@ public class TokenResource extends NamedResource {
         this.context.setToken(token);
         return this;
     }
+    public TokenResource clearToken() {
+        this.context.setToken(null);
+        return this;
+    }
 
 }


[37/50] [abbrv] incubator-usergrid git commit: Revert "Made the styles path relative so they will no longer go to the root and get 401 errors."

Posted by gr...@apache.org.
Revert "Made the styles path relative so they will no longer go to the root and get 401 errors."

This reverts commit 97d47af408f754df576e1b16b8e17ad4e359d034.


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

Branch: refs/heads/two-dot-o-import
Commit: c8a05a13bdaa27d3b92f5daa7761ba4bac236041
Parents: 5178b22
Author: grey <gr...@apigee.com>
Authored: Thu Jan 8 16:06:41 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Thu Jan 8 16:06:41 2015 -0800

----------------------------------------------------------------------
 .../WEB-INF/jsp/org/apache/usergrid/rest/TestResource/error.jsp    | 2 +-
 .../WEB-INF/jsp/org/apache/usergrid/rest/TestResource/test.jsp     | 2 +-
 .../rest/applications/ApplicationResource/authorize_form.jsp       | 2 +-
 .../usergrid/rest/applications/ApplicationResource/error.jsp       | 2 +-
 .../usergrid/rest/applications/users/UserResource/activate.jsp     | 2 +-
 .../usergrid/rest/applications/users/UserResource/confirm.jsp      | 2 +-
 .../apache/usergrid/rest/applications/users/UserResource/error.jsp | 2 +-
 .../rest/applications/users/UserResource/resetpw_email_form.jsp    | 2 +-
 .../rest/applications/users/UserResource/resetpw_email_success.jsp | 2 +-
 .../rest/applications/users/UserResource/resetpw_set_form.jsp      | 2 +-
 .../rest/applications/users/UserResource/resetpw_set_success.jsp   | 2 +-
 .../usergrid/rest/applications/users/UsersResource/error.jsp       | 2 +-
 .../rest/applications/users/UsersResource/resetpw_email_form.jsp   | 2 +-
 .../applications/users/UsersResource/resetpw_email_success.jsp     | 2 +-
 .../usergrid/rest/management/ManagementResource/authorize_form.jsp | 2 +-
 .../apache/usergrid/rest/management/ManagementResource/error.jsp   | 2 +-
 .../management/organizations/OrganizationResource/activate.jsp     | 2 +-
 .../rest/management/organizations/OrganizationResource/confirm.jsp | 2 +-
 .../rest/management/organizations/OrganizationResource/error.jsp   | 2 +-
 .../usergrid/rest/management/users/UserResource/activate.jsp       | 2 +-
 .../apache/usergrid/rest/management/users/UserResource/confirm.jsp | 2 +-
 .../apache/usergrid/rest/management/users/UserResource/error.jsp   | 2 +-
 .../rest/management/users/UserResource/resetpw_email_form.jsp      | 2 +-
 .../rest/management/users/UserResource/resetpw_email_success.jsp   | 2 +-
 .../rest/management/users/UserResource/resetpw_set_form.jsp        | 2 +-
 .../rest/management/users/UserResource/resetpw_set_success.jsp     | 2 +-
 .../apache/usergrid/rest/management/users/UsersResource/error.jsp  | 2 +-
 .../rest/management/users/UsersResource/resetpw_email_form.jsp     | 2 +-
 .../rest/management/users/UsersResource/resetpw_email_success.jsp  | 2 +-
 29 files changed, 29 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/TestResource/error.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/TestResource/error.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/TestResource/error.jsp
index 1f2466d..be184b1 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/TestResource/error.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/TestResource/error.jsp
@@ -23,7 +23,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Error</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/TestResource/test.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/TestResource/test.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/TestResource/test.jsp
index a3399c1..83a6ad1 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/TestResource/test.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/TestResource/test.jsp
@@ -21,7 +21,7 @@ limitations under the License.
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 <title>Test Viewable</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 <h1>${it.foo}</h1> 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/ApplicationResource/authorize_form.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/ApplicationResource/authorize_form.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/ApplicationResource/authorize_form.jsp
index 99bf6bc..6b1b8b2 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/ApplicationResource/authorize_form.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/ApplicationResource/authorize_form.jsp
@@ -23,7 +23,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Sign In</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/ApplicationResource/error.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/ApplicationResource/error.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/ApplicationResource/error.jsp
index 1f2466d..be184b1 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/ApplicationResource/error.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/ApplicationResource/error.jsp
@@ -23,7 +23,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Error</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/activate.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/activate.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/activate.jsp
index e13a3f1..dfcf3b7 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/activate.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/activate.jsp
@@ -22,7 +22,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Activate User</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/confirm.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/confirm.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/confirm.jsp
index 5d4f392..02e9ee3 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/confirm.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/confirm.jsp
@@ -22,7 +22,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Confirm User</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/error.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/error.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/error.jsp
index 1f2466d..be184b1 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/error.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/error.jsp
@@ -23,7 +23,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Error</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_email_form.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_email_form.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_email_form.jsp
index 023df87..0f53bfc 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_email_form.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_email_form.jsp
@@ -22,7 +22,7 @@ limitations under the License.
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 <title>Reset Password</title>
-<link rel="stylesheet" type="text/css" href="css/styles.css" />
+<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 	<div class="dialog-area">

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_email_success.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_email_success.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_email_success.jsp
index 79a598b..23f8508 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_email_success.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_email_success.jsp
@@ -25,7 +25,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Reset Password</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_set_form.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_set_form.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_set_form.jsp
index e8940e7..a83d80d 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_set_form.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_set_form.jsp
@@ -25,7 +25,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Reset Password</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_set_success.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_set_success.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_set_success.jsp
index 41ababa..9de90ba 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_set_success.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UserResource/resetpw_set_success.jsp
@@ -25,7 +25,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Reset Password</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UsersResource/error.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UsersResource/error.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UsersResource/error.jsp
index 1f2466d..be184b1 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UsersResource/error.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UsersResource/error.jsp
@@ -23,7 +23,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Error</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UsersResource/resetpw_email_form.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UsersResource/resetpw_email_form.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UsersResource/resetpw_email_form.jsp
index 58b5aa6..3211a3a 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UsersResource/resetpw_email_form.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UsersResource/resetpw_email_form.jsp
@@ -22,7 +22,7 @@ limitations under the License.
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 <title>Reset Password</title>
-<link rel="stylesheet" type="text/css" href="css/styles.css" />
+<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UsersResource/resetpw_email_success.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UsersResource/resetpw_email_success.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UsersResource/resetpw_email_success.jsp
index 79a598b..23f8508 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UsersResource/resetpw_email_success.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/applications/users/UsersResource/resetpw_email_success.jsp
@@ -25,7 +25,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Reset Password</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/ManagementResource/authorize_form.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/ManagementResource/authorize_form.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/ManagementResource/authorize_form.jsp
index 99bf6bc..6b1b8b2 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/ManagementResource/authorize_form.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/ManagementResource/authorize_form.jsp
@@ -23,7 +23,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Sign In</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/ManagementResource/error.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/ManagementResource/error.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/ManagementResource/error.jsp
index 1f2466d..be184b1 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/ManagementResource/error.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/ManagementResource/error.jsp
@@ -23,7 +23,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Error</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/organizations/OrganizationResource/activate.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/organizations/OrganizationResource/activate.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/organizations/OrganizationResource/activate.jsp
index d6387a3..85114cd 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/organizations/OrganizationResource/activate.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/organizations/OrganizationResource/activate.jsp
@@ -22,7 +22,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Activate Organization</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/organizations/OrganizationResource/confirm.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/organizations/OrganizationResource/confirm.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/organizations/OrganizationResource/confirm.jsp
index 8c862bc..f4307b7 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/organizations/OrganizationResource/confirm.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/organizations/OrganizationResource/confirm.jsp
@@ -22,7 +22,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Confirm Organization</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/organizations/OrganizationResource/error.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/organizations/OrganizationResource/error.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/organizations/OrganizationResource/error.jsp
index 1f2466d..be184b1 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/organizations/OrganizationResource/error.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/organizations/OrganizationResource/error.jsp
@@ -23,7 +23,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Error</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/activate.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/activate.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/activate.jsp
index e13a3f1..dfcf3b7 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/activate.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/activate.jsp
@@ -22,7 +22,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Activate User</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/confirm.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/confirm.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/confirm.jsp
index 5d4f392..02e9ee3 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/confirm.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/confirm.jsp
@@ -22,7 +22,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Confirm User</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/error.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/error.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/error.jsp
index 1f2466d..be184b1 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/error.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/error.jsp
@@ -23,7 +23,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Error</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_email_form.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_email_form.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_email_form.jsp
index b699b11..3e56cd1 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_email_form.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_email_form.jsp
@@ -22,7 +22,7 @@ limitations under the License.
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 <title>Reset Password</title>
-<link rel="stylesheet" type="text/css" href="css/styles.css" />
+<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 	<div class="dialog-area password-reset-form">

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_email_success.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_email_success.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_email_success.jsp
index 79a598b..23f8508 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_email_success.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_email_success.jsp
@@ -25,7 +25,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Reset Password</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_set_form.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_set_form.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_set_form.jsp
index e8940e7..a83d80d 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_set_form.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_set_form.jsp
@@ -25,7 +25,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Reset Password</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_set_success.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_set_success.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_set_success.jsp
index 41ababa..9de90ba 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_set_success.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UserResource/resetpw_set_success.jsp
@@ -25,7 +25,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Reset Password</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UsersResource/error.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UsersResource/error.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UsersResource/error.jsp
index 1f2466d..be184b1 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UsersResource/error.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UsersResource/error.jsp
@@ -23,7 +23,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Error</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UsersResource/resetpw_email_form.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UsersResource/resetpw_email_form.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UsersResource/resetpw_email_form.jsp
index 969ccef..8643016 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UsersResource/resetpw_email_form.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UsersResource/resetpw_email_form.jsp
@@ -22,7 +22,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Reset Password</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8a05a13/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UsersResource/resetpw_email_success.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UsersResource/resetpw_email_success.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UsersResource/resetpw_email_success.jsp
index 79a598b..23f8508 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UsersResource/resetpw_email_success.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/apache/usergrid/rest/management/users/UsersResource/resetpw_email_success.jsp
@@ -25,7 +25,7 @@ limitations under the License.
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 	<title>Reset Password</title>
-	<link rel="stylesheet" type="text/css" href="css/styles.css" />
+	<link rel="stylesheet" type="text/css" href="/css/styles.css" />
 </head>
 <body>
 


[28/50] [abbrv] incubator-usergrid git commit: [USERGRID-303]Code formatting and updates for query tests

Posted by gr...@apache.org.
[USERGRID-303]Code formatting and updates for query 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/72533903
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/72533903
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/72533903

Branch: refs/heads/two-dot-o-import
Commit: 725339039d2574a12943de689f7a5717e297fadc
Parents: 309fc19
Author: ryan bridges <rb...@apigee.com>
Authored: Wed Jan 7 10:11:40 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Wed Jan 7 14:44:29 2015 -0500

----------------------------------------------------------------------
 .../applications/queries/AndOrQueryTest.java    |  33 ++--
 .../queries/BadGrammarQueryTest.java            |  78 ++++----
 .../applications/queries/MatrixQueryTests.java  | 181 ++++++++-----------
 .../rest/applications/queries/OrderByTest.java  |   3 +-
 4 files changed, 126 insertions(+), 169 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72533903/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
index ab1bc78..5e619be 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
@@ -17,14 +17,11 @@
 package org.apache.usergrid.rest.applications.queries;
 
 
-import org.apache.commons.lang.RandomStringUtils;
 import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
 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.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.LinkedHashMap;
@@ -41,23 +38,22 @@ import static org.junit.Assert.assertTrue;
  * @since 4.0
  */
 public class AndOrQueryTest extends AbstractRestIT {
-  private static Logger log = LoggerFactory.getLogger(AndOrQueryTest.class);
-
   /**
    * Ensure limit is respected in queries
    * 1. Insert a number of entities
    * 2. Set half the entities to have a 'madeup' property of 'true'
-   *  and set the other half to 'false'
+   * and set the other half to 'false'
    * 3. Query all entities where "madeup = true"
    * 4. Limit the query to half of the number of entities
    * 5. Ensure the correct entities are returned
+   *
    * @throws IOException
    */
   @Test //USERGRID-900
   public void queriesWithAndPastLimit() throws IOException {
     int numValuesTested = 40;
     long created = 0;
-    
+
     Entity actor = new Entity();
     actor.put("displayName", "Erin");
     Entity props = new Entity();
@@ -90,7 +86,7 @@ public class AndOrQueryTest extends AbstractRestIT {
     Collection activities = this.app().collection("activities").get(params);
     //5. Ensure the correct entities are returned
     assertEquals(numValuesTested / 2, activities.response.getEntityCount());
-    while(activities.hasNext()){
+    while (activities.hasNext()) {
       assertTrue(Boolean.parseBoolean(activities.next().get("madeup").toString()));
     }
   }
@@ -100,10 +96,11 @@ public class AndOrQueryTest extends AbstractRestIT {
    * Test negated query
    * 1. Insert a number of entities
    * 2. Set half the entities to have a 'verb' property of 'go'
-   *  and set the other half to 'stop'
+   * and set the other half to 'stop'
    * 3. Query all entities where "NOT verb = 'go'"
    * 4. Limit the query to half of the number of entities
    * 5. Ensure the returned entities have "verb = 'stop'"
+   *
    * @throws IOException
    */
   @Test //USERGRID-1475
@@ -139,7 +136,7 @@ public class AndOrQueryTest extends AbstractRestIT {
     Collection activities = this.app().collection("activities").get(params);
     //5. Ensure the returned entities have "verb = 'stop'"
     assertEquals(numValuesTested / 2, activities.response.getEntityCount());
-    while(activities.hasNext()){
+    while (activities.hasNext()) {
       assertEquals("stop", activities.next().get("verb").toString());
     }
 
@@ -151,6 +148,7 @@ public class AndOrQueryTest extends AbstractRestIT {
    * 1. Insert a number of entities
    * 2. Query for a subset of the entities
    * 3. Validate that the correct entities are returned
+   *
    * @throws Exception
    */
   @Test //USERGRID-1615
@@ -163,11 +161,10 @@ public class AndOrQueryTest extends AbstractRestIT {
     props.put("actor", actor);
     props.put("verb", "go");
     props.put("content", "bragh");
-    Entity[] correctValues = new Entity[numValuesTested];
     //1. Insert a number of entities
     for (int i = 0; i < numValuesTested; i++) {
       props.put("ordinal", i);
-      correctValues[i] = this.app().collection("activities").post(props);
+      this.app().collection("activities").post(props);
     }
     this.refreshIndex();
     //2. Query for a subset of the entities
@@ -189,6 +186,7 @@ public class AndOrQueryTest extends AbstractRestIT {
    * 1. Insert entities
    * 2. Use AND/OR query to retrieve entities
    * 3. Verify the order of results
+   *
    * @throws Exception
    */
   @Test
@@ -196,13 +194,12 @@ public class AndOrQueryTest extends AbstractRestIT {
     int numOfEntities = 20;
     String collectionName = "imagination";
 
-    Entity[] correctValues = new Entity[numOfEntities];
     Entity props = new Entity();
     props.put("WhoHelpedYou", "Ruff");
     //1. Insert entities
     for (int i = 0; i < numOfEntities; i++) {
       props.put("ordinal", i);
-      correctValues[i] = this.app().collection(collectionName).post(props);
+      this.app().collection(collectionName).post(props);
     }
 
     this.refreshIndex();
@@ -227,6 +224,7 @@ public class AndOrQueryTest extends AbstractRestIT {
    * 1. Insert a number of entities
    * 2. Issue a query
    * 3. validate that a full page of (10) entities is returned
+   *
    * @throws Exception
    */
   @Test
@@ -234,13 +232,12 @@ public class AndOrQueryTest extends AbstractRestIT {
     int numOfEntities = 20;
     String collectionName = "imagination";
 
-    Entity[] correctValues = new Entity[numOfEntities];
     Entity props = new Entity();
     props.put("WhoHelpedYou", "Ruff");
     //1. Insert a number of entities
     for (int i = 0; i < numOfEntities; i++) {
       props.put("ordinal", i);
-      correctValues[i] = this.app().collection(collectionName).post(props);
+      this.app().collection(collectionName).post(props);
     }
 
     this.refreshIndex();
@@ -263,6 +260,7 @@ public class AndOrQueryTest extends AbstractRestIT {
    * 1. Insert a number of entities
    * 2. Issue a query using alphanumeric operators
    * 3. validate that a full page of (10) entities is returned
+   *
    * @throws Exception
    */
   @Test
@@ -270,13 +268,12 @@ public class AndOrQueryTest extends AbstractRestIT {
     int numOfEntities = 10;
     String collectionName = "imagination";
 
-    Entity[] correctValues = new Entity[numOfEntities];
     Entity props = new Entity();
     props.put("WhoHelpedYou", "Ruff");
     //1. Insert a number of entities
     for (int i = 0; i < numOfEntities; i++) {
       props.put("ordinal", i);
-      correctValues[i] = this.app().collection(collectionName).post(props);
+      this.app().collection(collectionName).post(props);
     }
 
     this.refreshIndex();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72533903/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java
index a6eb831..00b90dc 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java
@@ -17,63 +17,49 @@
 package org.apache.usergrid.rest.applications.queries;
 
 
-import java.util.HashMap;
-import java.util.Map;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.junit.Rule;
+import com.sun.jersey.api.client.UniformInterfaceException;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
 import org.junit.Test;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.rest.TestContextSetup;
-import org.apache.usergrid.rest.test.resource.CustomCollection;
 
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.UniformInterfaceException;
 import java.io.IOException;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
-import static org.apache.usergrid.utils.MapUtils.hashMap;
 
 
 /**
- * @author tnine
+ * Test for an exception with incorrect query grammar
+ * 1. Insert an entity
+ * 2. Issue an invalid query
+ * 3. Check for an exception
  */
 public class BadGrammarQueryTest extends AbstractRestIT {
 
-    @Rule
-    public TestContextSetup context = new TestContextSetup( this );
-
-
-    @Test
-    public void catchBadQueryGrammar() throws IOException {
-
-        CustomCollection things = context.customCollection( "things" );
-
-        Map actor = hashMap( "displayName", "Erin" );
-        Map props = new HashMap();
-        props.put( "actor", actor );
-        props.put( "content", "bragh" );
-
-        JsonNode activity = things.create( props );
-
-        refreshIndex(context.getOrgName(), context.getAppName());
-
-        String query = "select * where name != 'go'";
-
-        ClientResponse.Status status = null;
-
-        try {
-
-            JsonNode incorrectNode = things.query( query, "limit", Integer.toString( 10 ) );
-            fail( "This should throw an exception" );
-        }
-        catch ( UniformInterfaceException uie ) {
-             status = uie.getResponse().getClientResponseStatus();
-
-
-        }
-
-        assertEquals( 400, status.getStatusCode() );
+  @Test
+  public void catchBadQueryGrammar() throws IOException {
+
+    //1. Insert an entity
+    Entity actor = new Entity();
+    actor.put("displayName", "Erin");
+    Entity props = new Entity();
+    props.put("actor", actor);
+    props.put("content", "bragh");
+
+    this.app().collection("things").post(props);
+    refreshIndex();
+
+    //2. Issue an invalid query
+    String query = "select * where name != 'go'";
+    try {
+
+      QueryParameters params = new QueryParameters().setQuery(query);
+      this.app().collection("things").get(params);
+      fail("This should throw an exception");
+    } catch (UniformInterfaceException uie) {
+      //3. Check for an exception
+      assertEquals(400, uie.getResponse().getStatus());
     }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72533903/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/MatrixQueryTests.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/MatrixQueryTests.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/MatrixQueryTests.java
index 9531a14..184e1c0 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/MatrixQueryTests.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/MatrixQueryTests.java
@@ -16,114 +16,89 @@
  */
 package org.apache.usergrid.rest.applications.queries;
 
-import java.util.Map;
-import java.util.UUID;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.rest.TestContextSetup;
-import org.apache.usergrid.rest.test.resource.CustomCollection;
-import org.apache.usergrid.rest.test.resource.app.UsersCollection;
-import static org.apache.usergrid.utils.MapUtils.hashMap;
-import org.junit.Rule;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.model.Collection;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
 import org.junit.Test;
 
-
-public class MatrixQueryTests extends AbstractRestIT {
-
-    @Rule
-    public TestContextSetup context = new TestContextSetup( this );
-
-
-    @Test
-    public void simpleMatrix() throws Exception {
-
-        /**
-         * Create 3 users which we will use for sub searching
-         */
-        UsersCollection users = context.users();
-
-        Map user1 =
-                hashMap( "username", "user1" ).map( "email", "testuser1@usergrid.com" ).map( "fullname", "Bob Smith" );
-
-        users.create( user1 );
-
-
-        Map user2 =
-                hashMap( "username", "user2" ).map( "email", "testuser2@usergrid.com" ).map( "fullname", "Fred Smith" );
-
-        users.create( user2 );
-
-
-        Map user3 = hashMap( "username", "user3" ).map( "email", "testuser3@usergrid.com" )
-                .map( "fullname", "Frank Grimes" );
-
-        users.create( user3 );
-
-
-        //now create 4 restaurants
-
-        CustomCollection restaurants = context.customCollection( "restaurants" );
-
-
-        Map restaurant1 = hashMap( "name", "Old Major" );
-
-        UUID restaurant1Id = getEntityId( restaurants.create( restaurant1 ), 0 );
-
-        Map restaurant2 = hashMap( "name", "tag" );
-
-        UUID restaurant2Id = getEntityId( restaurants.create( restaurant2 ), 0 );
-
-        Map restaurant3 = hashMap( "name", "Squeaky Bean" );
-
-        UUID restaurant3Id = getEntityId( restaurants.create( restaurant3 ), 0 );
-
-        Map restaurant4 = hashMap( "name", "Lola" );
-
-        UUID restaurant4Id = getEntityId( restaurants.create( restaurant4 ), 0 );
-
-
-        //now like our 3 users
+import static org.junit.Assert.assertEquals;
 
 
-        //user 1 likes old major
-        users.user( "user1" ).connection( "likes" ).entity( restaurant1Id ).post();
-
-        users.user( "user1" ).connection( "likes" ).entity( restaurant2Id ).post();
-
-
-        //user 2 likes tag and squeaky bean
-        users.user( "user2" ).connection( "likes" ).entity( restaurant2Id ).post();
-
-        users.user( "user2" ).connection( "likes" ).entity( restaurant3Id ).post();
-
-        //user 3 likes  Lola (it shouldn't appear in the results)
-
-        users.user( "user3" ).connection( "likes" ).entity( restaurant4Id ).post();
-
-
-        //now query with matrix params
-
-
-//        JsonNode testGetUsers = context.collection( "users" ).get().get( "entities" );
-//
-//        JsonNode likesNode =
-//                context.collection( "users" ).entity( "user1" ).connection( "likes" ).get().get( "entities" );
-//
-//
-//        JsonNode queryResponse = context.collection( "users" ).withMatrix(
-//                hashMap( "ql", "where fullname contains 'Smith'" ).map( "limit", "1000" ) ).connection( "likes" ).get();
-//
-//        assertEquals( "Old Major", getEntityName( queryResponse, 0 ) );
-//
-//        assertEquals( "tag", getEntityName( queryResponse, 1 ) );
-//
-//        assertEquals( "Squeaky Bean", getEntityName( queryResponse, 2 ) );
-//
-//        /**
-//         * No additional elements in the response
-//         */
-//        assertNull( getEntity( queryResponse, 3 ) );
-    }
+public class MatrixQueryTests extends AbstractRestIT {
 
+  /**
+   * Test standard connection queries
+   * 1. Insert a number of users
+   * 2. Insert a number of restaurants
+   * 3. Create "likes" connections between users and restaurants
+   * 4. Retrieve "likes" connections per user and ensure the correct restaurants are returned
+   *
+   * @throws Exception
+   */
+  @Test
+  public void connectionsTest() throws Exception {
+
+    //1. Insert a number of users
+    Entity user1 = new Entity();
+    user1.put("username", "user1");
+    user1.put("email", "testuser1@usergrid.com");
+    user1.put("fullname", "Bob Smith");
+
+    Entity user2 = new Entity();
+    user2.put("username", "user2");
+    user2.put("email", "testuser2@usergrid.com");
+    user2.put("fullname", "Fred Smith");
+
+    Entity user3 = new Entity();
+    user3.put("username", "user3");
+    user3.put("email", "testuser3@usergrid.com");
+    user3.put("fullname", "Frank Grimes");
+
+    user1 = this.app().collection("users").post(user1);
+    user2 = this.app().collection("users").post(user2);
+    user3 = this.app().collection("users").post(user3);
+
+    //2. Insert a number of restaurants
+
+    Entity restaurant1 = new Entity();
+    restaurant1.put("name", "Old Major");
+    Entity restaurant2 = new Entity();
+    restaurant2.put("name", "tag");
+    Entity restaurant3 = new Entity();
+    restaurant3.put("name", "Squeaky Bean");
+    Entity restaurant4 = new Entity();
+    restaurant4.put("name", "Lola");
+    restaurant1 = this.app().collection("restaurants").post(restaurant1);
+    restaurant2 = this.app().collection("restaurants").post(restaurant2);
+    restaurant3 = this.app().collection("restaurants").post(restaurant3);
+    restaurant4 = this.app().collection("restaurants").post(restaurant4);
+    this.refreshIndex();
+
+    //3. Create "likes" connections between users and restaurants
+    //user 1 likes old major
+    this.app().collection("users").entity(user1).connection("likes").collection("restaurants").entity(restaurant1).post();
+    this.app().collection("users").entity(user1).connection("likes").collection("restaurants").entity(restaurant2).post();
+
+    //user 2 likes tag and squeaky bean
+    this.app().collection("users").entity(user2).connection("likes").collection("restaurants").entity(restaurant2).post();
+    this.app().collection("users").entity(user2).connection("likes").collection("restaurants").entity(restaurant3).post();
+
+    //user 3 likes  Lola (it shouldn't appear in the results)
+    this.app().collection("users").entity(user3).connection("likes").collection("restaurants").entity(restaurant4).post();
+    this.refreshIndex();
+
+    //4. Retrieve "likes" connections per user and ensure the correct restaurants are returned
+    Collection user1likes = this.app().collection("users").entity(user1).connection("likes").get();
+    assertEquals(2, user1likes.response.getEntityCount());
+
+    Collection user2likes = this.app().collection("users").entity(user2).connection("likes").get();
+    assertEquals(2, user2likes.response.getEntityCount());
+
+    Collection user3likes = this.app().collection("users").entity(user3).connection("likes").get();
+    assertEquals(1, user3likes.response.getEntityCount());
+  }
+
+  //TODO implement matrix parameters and tests!!!
 
 //    @Test
 //    public void largeRootElements() {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72533903/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
index 3ba5787..5f78c5e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
@@ -161,7 +161,6 @@ public class OrderByTest extends AbstractRestIT {
     long lastCreated = Long.parseLong(activities[0].get("created").toString());
     //2. Query for the entities in descending order
     String errorQuery = String.format("select * where created <= %d order by created desc", lastCreated);
-    String cursor = null;
     int index = size - 1;
 
     QueryParameters params = new QueryParameters().setQuery(errorQuery);
@@ -172,7 +171,7 @@ public class OrderByTest extends AbstractRestIT {
       //loop through the current page of results
       for (int i = 0; i < returnSize; i++, index--) {
         assertEquals(((LinkedHashMap<String, Object>) activitiesResponse.response.getEntities().get(i)).get("uuid").toString(),
-            ((Entity) activities[index]).get("uuid").toString());
+            (activities[index]).get("uuid").toString());
       }
       //grab the next page of results
       activitiesResponse = this.app().getNextPage(activitiesResponse, true);


[34/50] [abbrv] incubator-usergrid git commit: Finished adding comments for OwnershipResourceIT

Posted by gr...@apache.org.
Finished adding comments for OwnershipResourceIT


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

Branch: refs/heads/two-dot-o-import
Commit: 0b894415b97308cd4eb9da240ae04eb65cc62581
Parents: fac2e05
Author: grey <gr...@apigee.com>
Authored: Thu Jan 8 10:37:58 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Thu Jan 8 10:37:58 2015 -0800

----------------------------------------------------------------------
 .../collection/users/OwnershipResourceIT.java   | 33 +++++++++++---------
 1 file changed, 19 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0b894415/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
index f562ccd..30b12f1 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
@@ -218,7 +218,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
 
     /**
-     * 
+     *
      * @throws IOException
      */
     @Test
@@ -261,12 +261,12 @@ public class OwnershipResourceIT extends AbstractRestIT {
         //Setting the token to be in a user1 context.
         this.app().token().post(new Token(user1.getUsername(),"password"));
 
-        //Setup the connection between user1 and the restaurant collection.
+        //Gets the connection between user1 and the their restaurants. In this case gets 4peaks
         CollectionEndpoint likeRestaurants =
                 usersResource.entity( "me" ).connection( "likes" )
                        .collection( "restaurants" );
 
-        //Check that we can get the restaurant by using its uuid
+        //Check that we can get the 4peaks restaurant by using its uuid
         String peaksId = data.getUuid().toString();
         data = likeRestaurants.entity(peaksId).get();
         assertNotNull( data );
@@ -280,7 +280,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         // check we can't see arrogantbutcher by name or id from user1
         int status = 200;
         try {
-            data = likeRestaurants.entity("arrogantbutcher").get();
+            likeRestaurants.entity("arrogantbutcher").get();
         }catch (UniformInterfaceException e){
             status = e.getResponse().getStatus();
         }
@@ -288,7 +288,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
         status = 200;
         try {
-            data = likeRestaurants.entity( arrogantButcherId ).get();
+            likeRestaurants.entity( arrogantButcherId ).get();
         }catch (UniformInterfaceException e){
             status = e.getResponse().getStatus();
         }
@@ -327,11 +327,13 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
         status = 200;
         try {
-            data = likeRestaurants.entity( peaksId ).get();
+            likeRestaurants.entity( peaksId ).get();
 
         }catch (UniformInterfaceException e){
             status = e.getResponse().getStatus();
         }
+        assertEquals( status,404 );
+
 
         // do a collection load, make sure we're not loading device 1
         collectionData = likeRestaurants.get();
@@ -370,6 +372,10 @@ public class OwnershipResourceIT extends AbstractRestIT {
     }
 
 
+    /**
+     *
+     * @throws IOException
+     */
     @Test
     public void contextualConnectionOwnershipGuestAccess() throws IOException {
 
@@ -378,25 +384,24 @@ public class OwnershipResourceIT extends AbstractRestIT {
                 .post(new Entity().chainPut("permission", "get,put,post,delete:/**"));
 
 
-
+        //Sets up the cities collection with the city tempe
         Entity city = this.app().collection("cities").post(new Entity().chainPut("name", "tempe"));
 
         refreshIndex();
 
-        String cityId = city.get("uuid").toString();
-
-        // create a 4peaks restaurant
+        // create a 4peaks restaurant that is connected by a like to tempe.
         Entity data = this.app().collection("cities").entity( "tempe" ).connection( "likes" )
                                .collection( "restaurants" ).post(new Entity().chainPut("name", "4peaks"));
 
         String peaksId = data.get("uuid").toString();
 
+        // create the arrogantbutcher restaurant that is connected by a like to tempe.
         data = this.app().collection("cities").entity( "tempe" ).connection( "likes" )
                       .collection( "restaurants" ).post(new Entity().chainPut("name", "arrogantbutcher"));
 
         String arrogantButcherId = data.get("uuid").toString();
 
-        // now query on user 1.
+        //Set the user to user1 and get the collection cities
         this.app().token().post(new Token(user1.getUsername(),"password"));
 
         CollectionEndpoint likeRestaurants =
@@ -404,7 +409,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
         refreshIndex();
 
-        // check we can get it via id with no collection name
+        // check we can get the resturant entities back via uuid without a collection name
         data = likeRestaurants.entity( peaksId ).get();
         assertNotNull( data );
         assertEquals( "4peaks", data.get("name").toString() );
@@ -412,7 +417,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         data = likeRestaurants.entity( arrogantButcherId ).get();
         assertEquals( "arrogantbutcher", data.get("name").toString() );
 
-        // check we can get it via id with a collection name
+        // check we can get the restaurant via uuid with a collection name
         data = likeRestaurants.collection( "restaurants" ).entity( peaksId ).get();
         assertNotNull( data );
         assertEquals( "4peaks", data.get("name").toString() );
@@ -420,7 +425,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         data = likeRestaurants.collection( "restaurants" ).entity( arrogantButcherId ).get();
         assertEquals( "arrogantbutcher", data.get("name").toString() );
 
-        // do a delete either token should work
+        // Delete the restaurants, either token should work for deletion
         ApiResponse deleteResponse = likeRestaurants.collection( "restaurants" ).entity( peaksId ).delete();
 
         assertNotNull( deleteResponse );


[11/50] [abbrv] incubator-usergrid git commit: finished test

Posted by gr...@apache.org.
finished test


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

Branch: refs/heads/two-dot-o-import
Commit: 01173d9a00b1d013edf1d3fb047ec4b5f1c2852f
Parents: e964551
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Jan 6 09:29:10 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Jan 6 09:29:10 2015 -0700

----------------------------------------------------------------------
 .../collection/users/OwnershipResourceIT.java   | 67 +++++++++++++++-----
 1 file changed, 50 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/01173d9a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
index 3e4e94d..fc85ca0 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
@@ -20,6 +20,7 @@ package org.apache.usergrid.rest.applications.collection.users;
 import com.fasterxml.jackson.databind.JsonNode;
 import java.io.IOException;
 
+import com.sun.jersey.api.client.UniformInterfaceException;
 import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.CollectionEndpoint;
 import org.apache.usergrid.rest.test.resource2point0.model.*;
@@ -53,7 +54,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         String email = "testuser1@usergrid.org";
         String email2 = "testuser2@usergrid.org";
 
-        user2 = new User("testuser2","testuser2", email, "password" );
+        user2 = new User("testuser2","testuser2", email2, "password" );
 
         user1 = new User("testuser1","testuser1", email, "password" );
         user1 = new User(this.usersResource.post(user1));
@@ -127,8 +128,13 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertEquals("device1", data.get("name").toString());
 
         // check we can't see device2
-        data = devices.entity("device2").get();
-        assertNull( data );
+        int status = 0;
+        try {
+            data = devices.entity("device2").get();
+        }catch (UniformInterfaceException e){
+            status = e.getResponse().getStatus();
+        }
+        assertEquals( status,404 );
 
         // do a collection load, make sure we're not loading device 2
         Collection devicesData = devices.get();
@@ -146,8 +152,13 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertEquals( "device2", data.get("name").toString() );
 
         // check we can't see device1
+        status = 0;
+        try{
         data = devices.entity("device1").get();
-        assertNull( data );
+        }catch (UniformInterfaceException e){
+            status = e.getResponse().getStatus();
+        }
+        assertEquals( status,404 );
 
         // do a collection load, make sure we're not loading device 1
         devicesData = devices.get();
@@ -157,15 +168,14 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
         // we should see both devices when loaded from the root application
 
+        devices  = this.app().collection("devices");
         // test for user 1
         token = this.app().token().post(new Token(user1.getUsername(),"password"));
 
-        devices = usersResource.entity(user1).collection("devices");
         data = devices.entity("device1").get();
 
         assertNotNull( data );
         assertEquals( "device1", data.get("name").toString() );
-
         data = devices.entity("device2").get();
 
         assertNotNull( data );
@@ -174,7 +184,8 @@ public class OwnershipResourceIT extends AbstractRestIT {
         // test for user 2
         token = this.app().token().post(new Token(user2.getUsername(),"password"));
 
-        data =usersResource.entity(user2).collection("devices").entity( "device1" ).get();
+
+        data = devices.entity( "device1" ).get();
 
         assertNotNull( data );
         assertEquals( "device1",data.get( "name" ).toString() );
@@ -242,17 +253,27 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertEquals( "4peaks", data.get("name").toString() );
 
         // check we can't see arrogantbutcher by name or id
-        data = likeRestaurants.entity( "arrogantbutcher" ).get();
-        assertNull( data );
+        int status = 200;
+        try {
+            data = likeRestaurants.entity("arrogantbutcher").get();
+        }catch (UniformInterfaceException e){
+            status = e.getResponse().getStatus();
+        }
+        assertEquals(status, 404);
 
-        data = likeRestaurants.entity( arrogantButcherId ).get();
-        assertNull( data );
+        status = 200;
+        try {
+            data = likeRestaurants.entity( arrogantButcherId ).get();
+        }catch (UniformInterfaceException e){
+            status = e.getResponse().getStatus();
+        }
+        assertEquals(status, 404);
 
         // do a collection load, make sure we're not entities we shouldn't see
         Collection collectionData = likeRestaurants.get();
 
         assertEquals("4peaks", collectionData.next().get("name").toString());
-        assertNull( collectionData.next() );
+        assertTrue( !collectionData.hasNext() );
 
         // log in as user 2 and check it
         this.app().token().post(new Token(user2.getUsername(),"password"));
@@ -269,17 +290,29 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertEquals( "arrogantbutcher", data.get("name").toString() );
 
         // check we can't see 4peaks
-        data = likeRestaurants.entity( "4peaks" ).get();
-        assertNull( data );
+         status = 200;
+        try {
+            data = likeRestaurants.entity( "4peaks" ).get();
+        }catch (UniformInterfaceException e){
+            status = e.getResponse().getStatus();
+        }
+        assertEquals( status,404 );
 
-        data = likeRestaurants.entity( peaksId ).get();
-        assertNull( data );
+
+
+        status = 200;
+        try {
+            data = likeRestaurants.entity( peaksId ).get();
+
+        }catch (UniformInterfaceException e){
+            status = e.getResponse().getStatus();
+        }
 
         // do a collection load, make sure we're not loading device 1
         collectionData = likeRestaurants.get();
 
         assertEquals("arrogantbutcher", collectionData.next().get("name").toString());
-        assertNull( collectionData.next() );
+        assertTrue( !collectionData.hasNext() );
 
         // we should see both devices when loaded from the root application
 


[41/50] [abbrv] incubator-usergrid git commit: Added fix for entity class and array list casting.

Posted by gr...@apache.org.
Added fix for entity class and array list casting.


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

Branch: refs/heads/two-dot-o-import
Commit: 4a17e5f5a1cacf19745bd38ae7e65be77753df3f
Parents: 5ae01ef
Author: grey <gr...@apigee.com>
Authored: Fri Jan 9 10:26:09 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Fri Jan 9 10:26:09 2015 -0800

----------------------------------------------------------------------
 .../rest/management/OrganizationsIT.java        |  2 +-
 .../rest/test/resource2point0/model/Entity.java | 30 +++++++++++---------
 2 files changed, 17 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4a17e5f5/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
index 239fe7d..8cb079e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
@@ -368,7 +368,7 @@ public class OrganizationsIT extends AbstractRestIT {
         assertEquals( 6, orgResponse.getProperties().get( "puppies" ));
 
     }
-    
+
     /**
      * Create an organization payload with almost the same value for everyfield.
      * @param baseName

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4a17e5f5/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
index 346a4b0..1c37697 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
@@ -61,20 +61,22 @@ public class Entity implements Serializable, Map<String,Object> {
             this.putAll(entity);
         }
         else if (response.getData() != null){
-            LinkedHashMap dataResponse = ( LinkedHashMap ) response.getData();
 
-            //covers case for admin users
-            if(dataResponse.get( "user" )!=null){
-                //Entity entity = new Entity();
-                //entity.put( "data", dataResponse.get( "user" ) );
-                this.putAll( ( Map<? extends String, ?> ) dataResponse.get( "user" ) );
+            if(response.getData() instanceof  LinkedHashMap) {
+                LinkedHashMap dataResponse = ( LinkedHashMap ) response.getData();
+
+                if(dataResponse.get( "user" )!=null){
+                    this.putAll( ( Map<? extends String, ?> ) dataResponse.get( "user" ) );
+                }
+                else{
+                    this.putAll( dataResponse );
+                }
             }
-            else {
-                //Doesn't always type correct below.
-                //ArrayList<String> data = ( ArrayList<String> ) response.getData();
-                //Entity entity = new Entity();
-               // entity.put( "data", data.get( 0 ) );
-                this.putAll( dataResponse );
+            else if (response.getData() instanceof ArrayList){
+                ArrayList<String> data = ( ArrayList<String> ) response.getData();
+                Entity entity = new Entity();
+                entity.put( "data", data.get( 0 ) );
+                this.putAll( entity );
             }
         }
     }
@@ -131,7 +133,7 @@ public class Entity implements Serializable, Map<String,Object> {
     }
 
     public String getError () {
-        return (String) this.get("error").toString();
+        return (String) this.get( "error" ).toString();
     }
 
     public String getErrorCode () {
@@ -184,7 +186,7 @@ public class Entity implements Serializable, Map<String,Object> {
     }
 
     public UUID getUuid(){
-        return UUID.fromString((String) get("uuid"));
+        return UUID.fromString( ( String ) get( "uuid" ) );
     }
 
     public Entity chainPut(final String key, final Object value){


[32/50] [abbrv] incubator-usergrid git commit: Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into USERGRID-313

Posted by gr...@apache.org.
Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into USERGRID-313

# By ryan bridges
# Via ryan bridges
* 'two-dot-o' of github.com:apache/incubator-usergrid:
  [USERGRID-303]Fixed paging issue in orderByReturnCorrectResults
  [USERGRID-303]fixed tests after framework update
  [USERGRID-303]Code formatting and updates for query tests
  [USERGRID-303]Updated AND/OR query tests to work with new test framework
  [USERGRID-303]Updated 'order by' tests to work with new test framework
  [USERGRID-303]Updates to AndOrQueryTest


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

Branch: refs/heads/two-dot-o-import
Commit: f789821a6a44e8b195bb90b1a2650b7e0d74ed30
Parents: 421a1d9 231a449
Author: grey <gr...@apigee.com>
Authored: Wed Jan 7 14:36:14 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Wed Jan 7 14:36:14 2015 -0800

----------------------------------------------------------------------
 .../applications/queries/AndOrQueryTest.java    | 390 ++++++++++++-------
 .../queries/BadGrammarQueryTest.java            |  78 ++--
 .../applications/queries/GeoPagingTest.java     |  19 +-
 .../applications/queries/MatrixQueryTests.java  | 181 ++++-----
 .../rest/applications/queries/OrderByTest.java  | 269 ++++++-------
 5 files changed, 498 insertions(+), 439 deletions(-)
----------------------------------------------------------------------



[31/50] [abbrv] incubator-usergrid git commit: Fixes and comments while looking over the tests

Posted by gr...@apache.org.
Fixes and comments while looking over the 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/5178b22c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5178b22c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5178b22c

Branch: refs/heads/two-dot-o-import
Commit: 5178b22cb8e1e2de25b6020f6e673a7052d49906
Parents: 1830fc7
Author: grey <gr...@apigee.com>
Authored: Wed Jan 7 14:29:06 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Wed Jan 7 14:29:06 2015 -0800

----------------------------------------------------------------------
 .../rest/management/OrganizationsIT.java        | 35 +++++++++-----------
 1 file changed, 16 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5178b22c/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
index dd2bbe9..2c2ad52 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
@@ -52,6 +52,7 @@ import static org.junit.Assert.fail;
 public class OrganizationsIT extends AbstractRestIT {
     private static final Logger LOG = LoggerFactory.getLogger( OrganizationsIT.class );
 
+    //TODO: make enum?
     String duplicateUniquePropertyExistsErrorMessage = "duplicate_unique_property_exists";
     String invalidGrantErrorMessage = "invalid_grant";
 
@@ -68,7 +69,6 @@ public class OrganizationsIT extends AbstractRestIT {
         String orgName = username;
         String email = username + "@usergrid.com";
 
-        //TODO:seperate entity properties from organization properties.
         Map<String, Object> userProperties = new HashMap<String, Object>();
         userProperties.put( "company", "Apigee" );
 
@@ -94,6 +94,7 @@ public class OrganizationsIT extends AbstractRestIT {
         User returnedUser = returnedOrg.getOwner();
 
         //Assert that the property was retained in the owner of the organization.
+        assertNotNull( returnedUser );
         assertEquals( "Apigee", returnedUser.getProperties().get( "company" ) );
     }
 
@@ -118,14 +119,14 @@ public class OrganizationsIT extends AbstractRestIT {
         Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post( orgPayload );
         this.refreshIndex();
 
+        assertNotNull( orgCreatedResponse );
+
         //Ensure that the token from the newly created organization works.
         Token tokenPayload = new Token( "password", username, password );
         Token tokenReturned = clientSetup.getRestClient().management().token().post( tokenPayload );
 
         assertNotNull( tokenReturned );
 
-        assertNotNull( orgCreatedResponse );
-
         //Try to create a organization with the same name as an organization that already exists, ensure that it fails
         Organization orgTestDuplicatePayload =
                 new Organization( orgName, username + "test", email + "test", name + "test", password, null );
@@ -179,6 +180,12 @@ public class OrganizationsIT extends AbstractRestIT {
 
         assertNotNull( orgCreatedResponse );
 
+        //get token from organization that was created to verify it exists.
+        Token tokenPayload = new Token( "password", username, password );
+        Token tokenReturned = clientSetup.getRestClient().management().token().post( tokenPayload );
+
+        assertNotNull( tokenReturned );
+
         //recreate a new payload using a duplicate email
         orgPayload = new Organization( orgName+"test", username+"test", email, name+"test", password+"test", null );
 
@@ -192,24 +199,18 @@ public class OrganizationsIT extends AbstractRestIT {
         }
 
         //try to get the token from the organization that failed to be created to verify it was not made.
-        Token tokenPayload = new Token( "password", username + "test", password );
+        tokenPayload = new Token( "password", username + "test", password );
         Token tokenError = null;
         try {
             tokenError = clientSetup.getRestClient().management().token().post( tokenPayload );
             fail( "Should not have created organization" );
         }
         catch ( UniformInterfaceException ex ) {
-            //TODO: Should throw a 404 not a 400?
             errorParse( 400,invalidGrantErrorMessage,ex );
         }
 
         assertNull( tokenError );
 
-        //get token from organization that was created to verify it exists.
-        tokenPayload = new Token( "password", username, password );
-        Token tokenReturned = clientSetup.getRestClient().management().token().post( tokenPayload );
-
-        assertNotNull( tokenReturned );
     }
 
 
@@ -239,8 +240,6 @@ public class OrganizationsIT extends AbstractRestIT {
         //Post the organization and verify it worked
         Organization organization = clientSetup.getRestClient().management().orgs().post( queryParameters );
 
-        this.refreshIndex();
-
         assertNotNull( organization );
         assertEquals( orgName,organization.getName() );
     }
@@ -266,8 +265,6 @@ public class OrganizationsIT extends AbstractRestIT {
         //Post the organization and verify it worked.
         Organization organization = clientSetup.getRestClient().management().orgs().post( form );
 
-        this.refreshIndex();
-
         assertNotNull( organization );
         assertEquals( "testOrgPOSTForm" + timeUuid ,organization.getName() );
     }
@@ -286,7 +283,7 @@ public class OrganizationsIT extends AbstractRestIT {
             fail( "Delete is not implemented yet" );
         }catch(UniformInterfaceException uie){
             assertEquals(500,uie.getResponse().getStatus());
-            //TODO: I think the below is what it should return,but instead it expects the above
+            //TODO: I think the below is what it should return (501 not implemented ) ,but instead it expects the above
            // assertEquals( ClientResponse.Status.NOT_IMPLEMENTED ,uie.getResponse().getStatus());
         }
     }
@@ -339,7 +336,7 @@ public class OrganizationsIT extends AbstractRestIT {
 
         //Setup what will be interested into the organization
         Map<String, Object> properties = new HashMap<String, Object>();
-        properties.put( "securityLevel", 5 );
+        properties.put( "puppies", 5 );
 
         Organization orgPayload = clientSetup.getOrganization();
         orgPayload.put( "properties", properties );
@@ -352,10 +349,10 @@ public class OrganizationsIT extends AbstractRestIT {
         //retrieve the organization
         Organization orgResponse = restClient.management().orgs().organization( clientSetup.getOrganizationName() ).get();
 
-        assertEquals( 5, orgResponse.getProperties().get( "securityLevel" ));
+        assertEquals( 5, orgResponse.getProperties().get( "puppies" ));
 
         //update the value added to the organization
-        properties.put( "securityLevel", 6 );
+        properties.put( "puppies", 6 );
         orgPayload.put( "properties", properties );
 
         //update the organization.
@@ -365,7 +362,7 @@ public class OrganizationsIT extends AbstractRestIT {
 
         orgResponse = restClient.management().orgs().organization( clientSetup.getOrganizationName() ).get();
 
-        assertEquals( 6, orgResponse.getProperties().get( "securityLevel" ));
+        assertEquals( 6, orgResponse.getProperties().get( "puppies" ));
 
     }
 }


[30/50] [abbrv] incubator-usergrid git commit: Merge branch 'two-dot-o' of https://github.com/GERey/incubator-usergrid into USERGRID-278_org-management-tests-fix

Posted by gr...@apache.org.
Merge branch 'two-dot-o' of https://github.com/GERey/incubator-usergrid into USERGRID-278_org-management-tests-fix

* 'two-dot-o' of https://github.com/GERey/incubator-usergrid:
  Made the styles path relative so they will no longer go to the root and get 401 errors.


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

Branch: refs/heads/two-dot-o-import
Commit: 1830fc7946606aa08f3bfe4010679b679a648142
Parents: 6f1685d 16ef7e7
Author: grey <gr...@apigee.com>
Authored: Wed Jan 7 13:55:06 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Wed Jan 7 13:55:06 2015 -0800

----------------------------------------------------------------------
 .../WEB-INF/jsp/org/apache/usergrid/rest/TestResource/error.jsp    | 2 +-
 .../WEB-INF/jsp/org/apache/usergrid/rest/TestResource/test.jsp     | 2 +-
 .../rest/applications/ApplicationResource/authorize_form.jsp       | 2 +-
 .../usergrid/rest/applications/ApplicationResource/error.jsp       | 2 +-
 .../usergrid/rest/applications/users/UserResource/activate.jsp     | 2 +-
 .../usergrid/rest/applications/users/UserResource/confirm.jsp      | 2 +-
 .../apache/usergrid/rest/applications/users/UserResource/error.jsp | 2 +-
 .../rest/applications/users/UserResource/resetpw_email_form.jsp    | 2 +-
 .../rest/applications/users/UserResource/resetpw_email_success.jsp | 2 +-
 .../rest/applications/users/UserResource/resetpw_set_form.jsp      | 2 +-
 .../rest/applications/users/UserResource/resetpw_set_success.jsp   | 2 +-
 .../usergrid/rest/applications/users/UsersResource/error.jsp       | 2 +-
 .../rest/applications/users/UsersResource/resetpw_email_form.jsp   | 2 +-
 .../applications/users/UsersResource/resetpw_email_success.jsp     | 2 +-
 .../usergrid/rest/management/ManagementResource/authorize_form.jsp | 2 +-
 .../apache/usergrid/rest/management/ManagementResource/error.jsp   | 2 +-
 .../management/organizations/OrganizationResource/activate.jsp     | 2 +-
 .../rest/management/organizations/OrganizationResource/confirm.jsp | 2 +-
 .../rest/management/organizations/OrganizationResource/error.jsp   | 2 +-
 .../usergrid/rest/management/users/UserResource/activate.jsp       | 2 +-
 .../apache/usergrid/rest/management/users/UserResource/confirm.jsp | 2 +-
 .../apache/usergrid/rest/management/users/UserResource/error.jsp   | 2 +-
 .../rest/management/users/UserResource/resetpw_email_form.jsp      | 2 +-
 .../rest/management/users/UserResource/resetpw_email_success.jsp   | 2 +-
 .../rest/management/users/UserResource/resetpw_set_form.jsp        | 2 +-
 .../rest/management/users/UserResource/resetpw_set_success.jsp     | 2 +-
 .../apache/usergrid/rest/management/users/UsersResource/error.jsp  | 2 +-
 .../rest/management/users/UsersResource/resetpw_email_form.jsp     | 2 +-
 .../rest/management/users/UsersResource/resetpw_email_success.jsp  | 2 +-
 29 files changed, 29 insertions(+), 29 deletions(-)
----------------------------------------------------------------------



[22/50] [abbrv] incubator-usergrid git commit: Cleared up and added some comments to the tests in organizationIt Added comment to one of the methods in AbstractRestIt.

Posted by gr...@apache.org.
Cleared up and added some comments to the tests in organizationIt
Added comment to one of the methods in AbstractRestIt.


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

Branch: refs/heads/two-dot-o-import
Commit: 6f1685dd13d5097b876ed94671600fb80cd43084
Parents: 860de10
Author: grey <gr...@apigee.com>
Authored: Wed Jan 7 10:56:57 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Wed Jan 7 10:56:57 2015 -0800

----------------------------------------------------------------------
 .../rest/management/OrganizationsIT.java        | 37 +++++++++++---------
 .../test/resource2point0/AbstractRestIT.java    | 11 ++++--
 .../endpoints/mgmt/OrganizationResource.java    |  4 +--
 3 files changed, 32 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6f1685dd/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
index 0a7a82b..dd2bbe9 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
@@ -61,6 +61,7 @@ public class OrganizationsIT extends AbstractRestIT {
     @Test
     public void createOrgAndOwner() throws Exception {
 
+        //Created a uuid username because I am creating a organization
         String username = "createOrgAndOwner" + UUIDUtils.newTimeUUID();
         String name = username;
         String password = "password";
@@ -85,8 +86,6 @@ public class OrganizationsIT extends AbstractRestIT {
 
         assertNotNull( token );
 
-        assertNotNull( clientSetup.getRestClient().getContext().getToken() );
-
         //Assert that the get returns the correct org and owner.
         Organization returnedOrg = clientSetup.getRestClient().management().orgs().organization( orgName ).get();
 
@@ -94,6 +93,7 @@ public class OrganizationsIT extends AbstractRestIT {
 
         User returnedUser = returnedOrg.getOwner();
 
+        //Assert that the property was retained in the owner of the organization.
         assertEquals( "Apigee", returnedUser.getProperties().get( "company" ) );
     }
 
@@ -118,23 +118,28 @@ public class OrganizationsIT extends AbstractRestIT {
         Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post( orgPayload );
         this.refreshIndex();
 
-        assertNotNull( orgCreatedResponse );
+        //Ensure that the token from the newly created organization works.
+        Token tokenPayload = new Token( "password", username, password );
+        Token tokenReturned = clientSetup.getRestClient().management().token().post( tokenPayload );
+
+        assertNotNull( tokenReturned );
 
+        assertNotNull( orgCreatedResponse );
 
+        //Try to create a organization with the same name as an organization that already exists, ensure that it fails
         Organization orgTestDuplicatePayload =
                 new Organization( orgName, username + "test", email + "test", name + "test", password, null );
         try {
-            Organization orgTestDuplicateResponse = clientSetup.getRestClient()
-                                                               .management().orgs().post( orgTestDuplicatePayload );
+            clientSetup.getRestClient().management().orgs().post( orgTestDuplicatePayload );
             fail("Should not have been able to create duplicate organization");
         }
         catch ( UniformInterfaceException ex ) {
             errorParse( 400,duplicateUniquePropertyExistsErrorMessage, ex );
         }
 
-        // Post to get token of what should be a non existent user.
+        // Post to get token of what should be a non existent user due to the failure of creation above
 
-        Token tokenPayload = new Token( "password", username + "test", password );
+        tokenPayload = new Token( "password", username + "test", password );
         Token tokenError = null;
         try {
             tokenError = clientSetup.getRestClient().management().token().post( tokenPayload );
@@ -146,11 +151,6 @@ public class OrganizationsIT extends AbstractRestIT {
         }
 
         assertNull( tokenError );
-
-        tokenPayload = new Token( "password", username, password );
-        Token tokenReturned = clientSetup.getRestClient().management().token().post( tokenPayload );
-
-        assertNotNull( tokenReturned );
     }
 
 
@@ -199,7 +199,7 @@ public class OrganizationsIT extends AbstractRestIT {
             fail( "Should not have created organization" );
         }
         catch ( UniformInterfaceException ex ) {
-            //TODO: Should throw a 404 not a 400.
+            //TODO: Should throw a 404 not a 400?
             errorParse( 400,invalidGrantErrorMessage,ex );
         }
 
@@ -220,12 +220,14 @@ public class OrganizationsIT extends AbstractRestIT {
     @Test
     public void testOrgPOSTParams() throws IOException {
 
+        //Create organization defaults
         String username = "testCreateDuplicateOrgEmail" + UUIDUtils.newTimeUUID();
         String name = username;
         String password = "password";
         String orgName = username;
         String email = username + "@usergrid.com";
 
+        //Append them to the end as query parameters
         QueryParameters queryParameters = new QueryParameters();
         queryParameters.setKeyValue( "organization",orgName );
         queryParameters.setKeyValue( "username",username );
@@ -234,6 +236,7 @@ public class OrganizationsIT extends AbstractRestIT {
         queryParameters.setKeyValue( "name",name );
         queryParameters.setKeyValue( "password",password );
 
+        //Post the organization and verify it worked
         Organization organization = clientSetup.getRestClient().management().orgs().post( queryParameters );
 
         this.refreshIndex();
@@ -260,6 +263,7 @@ public class OrganizationsIT extends AbstractRestIT {
         form.add( "name", "testOrgPOSTForm" );
         form.add( "password", "password" );
 
+        //Post the organization and verify it worked.
         Organization organization = clientSetup.getRestClient().management().orgs().post( form );
 
         this.refreshIndex();
@@ -270,17 +274,19 @@ public class OrganizationsIT extends AbstractRestIT {
 
 
     /**
-     * Returns error from unimplemented delete method
+     * Returns error from unimplemented delete method by trying to call the delete organization endpoint
      * @throws IOException
      */
     @Test
     public void noOrgDelete() throws IOException {
 
         try {
+            //Delete default organization
             clientSetup.getRestClient().management().orgs().organization( clientSetup.getOrganizationName() ).delete();
             fail( "Delete is not implemented yet" );
         }catch(UniformInterfaceException uie){
             assertEquals(500,uie.getResponse().getStatus());
+            //TODO: I think the below is what it should return,but instead it expects the above
            // assertEquals( ClientResponse.Status.NOT_IMPLEMENTED ,uie.getResponse().getStatus());
         }
     }
@@ -292,12 +298,11 @@ public class OrganizationsIT extends AbstractRestIT {
      */
     @Test
     public void testCreateOrgUserAndReturnCorrectUsername() throws Exception {
-        String username = "testCreateOrgUserAndReturnCorrectUsername"+UUIDUtils.newTimeUUID();
-
         RestClient restClient = clientSetup.getRestClient();
 
         //Create adminUser values
         Entity adminUserPayload = new Entity();
+        String username = "testCreateOrgUserAndReturnCorrectUsername"+UUIDUtils.newTimeUUID();
         adminUserPayload.put( "username", username );
         adminUserPayload.put( "name", username );
         adminUserPayload.put( "email", username+"@usergrid.com" );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6f1685dd/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
index 370823d..102fb12 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
@@ -130,8 +130,15 @@ public class AbstractRestIT extends JerseyTest {
     }
 
 
-    public void errorParse(Integer expectedStatus, String expectedErrorMessage, UniformInterfaceException uie){
-        assertEquals((Integer)400,expectedStatus);
+    /**
+     * Takes in the expectedStatus message and the expectedErrorMessage then compares it to the UniformInterfaceException
+     * to make sure that we got what we expected.
+     * @param expectedStatus
+     * @param expectedErrorMessage
+     * @param uie
+     */
+    public void errorParse(int expectedStatus, String expectedErrorMessage, UniformInterfaceException uie){
+        assertEquals(expectedStatus,uie.getResponse().getStatus());
         JsonNode errorJson = uie.getResponse().getEntity( JsonNode.class );
         assertEquals( expectedErrorMessage, errorJson.get( "error" ).asText() );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6f1685dd/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
index 85451bd..a436358 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
@@ -67,14 +67,14 @@ public class OrganizationResource extends NamedResource {
         return org;
     }
 
-    //Doesn't return anything useful.
+    //Doesn't return anything useful server side so this was made as a void. .
     public void put( Organization organization ){
         Map<String,Object> response = getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
                                                        .accept(MediaType.APPLICATION_JSON).put( Organization.class,
                         organization );
 
     }
-
+    
     public ApplicationResource app(){
         return new ApplicationResource(  context ,this );
     }


[04/50] [abbrv] incubator-usergrid git commit: removed UpdateGroupIT, merged test into GroupResourceIT

Posted by gr...@apache.org.
removed UpdateGroupIT, merged test into GroupResourceIT


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

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

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


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

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/132b6304/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java
deleted file mode 100644
index 7bbd95b..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.rest.applications.collection.groups;
-
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.junit.Rule;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.rest.TestContextSetup;
-
-import org.apache.commons.io.IOUtils;
-
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.WebResource;
-
-import junit.framework.Assert;
-
-import static org.junit.Assert.fail;
-
-
-public class UpdateGroupIT extends AbstractRestIT {
-    private static final Logger logger = LoggerFactory.getLogger( UpdateGroupIT.class );
-
-    @Rule
-    public TestContextSetup context = new TestContextSetup( this );
-
-
-    @Test // USERGRID-1729
-    public void updateGroupWithSameNameAsApp() throws IOException {
-
-        // create groupMap with same name as app
-        String groupId = null;
-        String groupPath = context.getAppName();
-        try {
-            Map<String, Object> groupMap = new HashMap<String, Object>();
-            groupMap.put( "title", "Old Title" );
-            groupMap.put( "path", groupPath );
-            String path = context.getOrgName() + "/" + context.getAppName() + "/groups";
-            JsonNode groupJson = mapper.readTree( webResourceBuilder( path ).post( String.class, groupMap ));
-            groupId = groupJson.get( "entities" ).get( 0 ).get( "uuid" ).textValue();
-        }
-        catch ( UniformInterfaceException e ) {
-            fail( "Error creating group: " + IOUtils.toString( e.getResponse().getEntityInputStream() ) );
-        }
-
-        assertTitle( groupId, "Old Title" );
-
-        refreshIndex(context.getOrgName(), context.getAppName());
-
-        // update that group by giving it a new title and using group path in URL
-        try {
-            Map<String, Object> group = new HashMap<String, Object>();
-            group.put( "title", "New Title" );
-            String path = context.getOrgName() + "/" + context.getAppName() + "/groups/" + groupPath;
-            webResourceBuilder( path ).put( String.class, group );
-        }
-        catch ( UniformInterfaceException e ) {
-            fail( "Error updating group: " + IOUtils.toString( e.getResponse().getEntityInputStream() ) );
-        }
-
-        assertTitle( groupId, "New Title" );
-
-        refreshIndex(context.getOrgName(), context.getAppName());
-
-        // update that group by giving it a new title and using UUID in URL
-        try {
-            Map<String, Object> group = new HashMap<String, Object>();
-            group.put( "title", "Even Newer Title" );
-            String path = context.getOrgName() + "/" + context.getAppName() + "/groups/" + groupId;
-            webResourceBuilder( path ).put( String.class, group );
-        }
-        catch ( UniformInterfaceException e ) {
-            fail( "Error updating group: " + IOUtils.toString( e.getResponse().getEntityInputStream() ) );
-        }
-
-        assertTitle( groupId, "Even Newer Title" );
-    }
-
-
-    private WebResource.Builder webResourceBuilder( String path ) {
-        return resource().path( path ).queryParam( "access_token", context.getActiveUser().getToken() )
-                .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE );
-    }
-
-
-    private void assertTitle( String groupId, String title ) throws IOException {
-        String path = context.getOrgName() + "/" + context.getAppName() + "/groups/" + groupId;
-        JsonNode groupJson = mapper.readTree( webResourceBuilder( path ).get( String.class ));
-        Assert.assertEquals( title, groupJson.get( "entities" ).get( 0 ).get( "title" ).textValue() );
-    }
-}

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


[43/50] [abbrv] incubator-usergrid git commit: Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-278_org-management-tests-fix

Posted by gr...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-278_org-management-tests-fix

# By ryan bridges (11) and others
# Via Rod Simpson (4) and others
* 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid: (24 commits)
  [USERGRID-303]Fixed paging issue in orderByReturnCorrectResults
  [USERGRID-303]fixed tests after framework update
  [USERGRID-303]Code formatting and updates for query tests
  [USERGRID-303]Updated AND/OR query tests to work with new test framework
  [USERGRID-303]Updated 'order by' tests to work with new test framework
  [USERGRID-303]Updates to AndOrQueryTest
  Removed test duplicated test. Fixed logic issue with helper method.
  Added a helper method to collections. Changed the test to use this new helper method.
  updated cast
  fixed app level user token method
  removed UpdateGroupIT, merged test into GroupResourceIT
  add clear token
  fixed retrieve users
  devices test fixed
  fix put test
  activities test replaced
  Removed test that was never properly implemented. Cleaned up all the tests with helper methods. Added comments detailing what each test does.
  Removed different PagingEntitiesTest and just consolidated tests into PagingResourceIT. Added helper methods and removed a lot of duplicated code. Added queryParameters to getNextPage method since we can do queryGets. Added a note to have the collection remember its own name
  Fixed PagingEntities and PagingResourceTest. Fixed bug where proper resource wasn't being used in the delete call. Added a queryParameter get call to the Entity method for testing purposes. Added a way to get the response from Collection
  [USERGRID-288]Updated GeoPagingTests
  ...


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

Branch: refs/heads/two-dot-o-import
Commit: 1ef432545b4ee8a052a0e3419a507b375af1443f
Parents: a66eeb9 231a449
Author: grey <gr...@apigee.com>
Authored: Fri Jan 9 10:38:08 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Fri Jan 9 10:38:08 2015 -0800

----------------------------------------------------------------------
 stack/.editorconfig                             |  26 +
 stack/pom.xml                                   |   2 +
 .../activities/ActivityResourceIT.java          | 133 ++---
 .../collection/activities/PutTest.java          |  33 +-
 .../collection/devices/DevicesResourceIT.java   |  39 +-
 .../collection/groups/GroupResourceIT.java      |  32 ++
 .../collection/groups/UpdateGroupIT.java        | 114 ----
 .../collection/paging/PagingEntitiesTest.java   | 132 -----
 .../collection/paging/PagingResourceIT.java     | 442 ++++++++-------
 .../collection/users/RetrieveUsersTest.java     |  40 +-
 .../applications/queries/AndOrQueryTest.java    | 390 ++++++++-----
 .../queries/BadGrammarQueryTest.java            |  78 ++-
 .../applications/queries/GeoPagingTest.java     | 562 +++++++++----------
 .../applications/queries/MatrixQueryTests.java  | 181 +++---
 .../rest/applications/queries/OrderByTest.java  | 269 ++++-----
 .../test/resource2point0/AbstractRestIT.java    |   2 +-
 .../endpoints/CollectionEndpoint.java           |  10 +-
 .../endpoints/EntityEndpoint.java               |  11 +
 .../endpoints/TokenResource.java                |   4 +
 .../resource2point0/model/ActivityEntity.java   |   5 +
 .../test/resource2point0/model/Collection.java  |  11 +-
 .../rest/test/resource2point0/model/Entity.java |   4 +
 22 files changed, 1208 insertions(+), 1312 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1ef43254/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1ef43254/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1ef43254/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
index 1c37697,b70f90c..6ef0f80
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
@@@ -131,9 -118,13 +131,13 @@@ public class Entity implements Serializ
          //All values are strings , so doing the cast here saves doing the cast elsewhere
          return getDynamicProperties().get( key );
      }
+     public String getString( final Object key ) {
+         //All values are strings , so doing the cast here saves doing the cast elsewhere
+         return (String) getDynamicProperties().get( key );
+     }
  
      public String getError () {
 -        return (String) this.get("error").toString();
 +        return (String) this.get( "error" ).toString();
      }
  
      public String getErrorCode () {


[46/50] [abbrv] incubator-usergrid git commit: Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into rodsimpson_usergrid/two_dot_o

Posted by gr...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into rodsimpson_usergrid/two_dot_o


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

Branch: refs/heads/two-dot-o-import
Commit: b2436c6ee942d3ef66628f45dbe8b08e34c42fc5
Parents: 49508e4 e090acf
Author: Rod Simpson <ro...@apigee.com>
Authored: Mon Jan 12 11:29:20 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Mon Jan 12 11:29:20 2015 -0700

----------------------------------------------------------------------
 portal/Gruntfile.js                             |  194 ++-
 portal/build.sh                                 |    2 -
 portal/config.js                                |   94 +-
 stack/.editorconfig                             |   26 +
 stack/awscluster/gatling-cluster-cf.json        |  387 ++++++
 stack/awscluster/pom.xml                        |    2 +-
 .../main/dist/init_instance/init_rest_server.sh |   18 +-
 .../main/dist/init_instance/install_yourkit.sh  |    6 +-
 .../src/main/groovy/NodeRegistry.groovy         |  195 ++-
 .../main/groovy/configure_elasticsearch.groovy  |   31 +-
 .../src/main/groovy/registry_list.groovy        |   36 -
 stack/awscluster/ugcluster-cf.json              |    7 +-
 stack/core/.test-tdoe-5thread.log.swp           |  Bin 0 -> 28672 bytes
 stack/core/pom.xml                              |   15 +-
 .../corepersistence/CpEntityDeleteListener.java |  101 --
 .../CpEntityIndexDeleteListener.java            |   98 --
 .../corepersistence/CpEntityManager.java        |  354 +++--
 .../corepersistence/CpEntityManagerFactory.java |    7 +
 .../corepersistence/CpRelationManager.java      |   35 +-
 .../usergrid/corepersistence/CpSetup.java       |   16 +-
 .../usergrid/corepersistence/GuiceModule.java   |   43 +-
 .../HybridEntityManagerFactory.java             |    9 +
 .../events/EntityDeletedHandler.java            |   68 +
 .../events/EntityVersionCreatedHandler.java     |   69 +
 .../events/EntityVersionDeletedHandler.java     |  102 ++
 .../results/FilteringLoader.java                |    7 +-
 .../corepersistence/util/CpEntityMapUtils.java  |   32 +-
 .../persistence/EntityManagerFactory.java       |   10 +
 .../cassandra/EntityManagerFactoryImpl.java     |    5 +
 .../org/apache/usergrid/AbstractCoreIT.java     |   12 +-
 .../apache/usergrid/ConcurrentCoreITSuite.java  |   51 -
 .../usergrid/ConcurrentCoreIteratorITSuite.java |   83 --
 .../usergrid/ConcurrentCoreTestSuite.java       |   46 -
 .../java/org/apache/usergrid/CoreITSuite.java   |   58 -
 .../java/org/apache/usergrid/CoreTestSuite.java |   45 -
 .../apache/usergrid/batch/SchedulerITSuite.java |   50 -
 .../usergrid/batch/SchedulerTestSuite.java      |   34 -
 .../batch/job/AbstractSchedulerRuntimeIT.java   |   18 +-
 .../batch/job/SchedulerRuntimeIntervalIT.java   |   49 +-
 .../CpEntityDeleteListenerTest.java             |   91 --
 .../CpEntityIndexDeleteListenerTest.java        |  111 --
 .../corepersistence/StaleIndexCleanupTest.java  |  219 ++-
 .../corepersistence/TestGuiceModule.java        |    9 +-
 .../migration/EntityDataMigrationIT.java        |  139 +-
 .../migration/EntityTypeMappingMigrationIT.java |   89 +-
 .../migration/GraphShardVersionMigrationIT.java |    5 +-
 .../usergrid/persistence/CollectionIT.java      |   15 +-
 .../apache/usergrid/persistence/CounterIT.java  |   93 +-
 .../usergrid/persistence/CountingMutatorIT.java |    4 +-
 .../persistence/EntityDictionaryIT.java         |   11 +-
 .../usergrid/persistence/EntityManagerIT.java   |   47 +-
 .../org/apache/usergrid/persistence/GeoIT.java  |  844 ++++++------
 .../persistence/GeoQueryBooleanTest.java        |    7 +-
 .../apache/usergrid/persistence/IndexIT.java    |   35 +-
 .../usergrid/persistence/PathQueryIT.java       |   10 +-
 .../PerformanceEntityRebuildIndexTest.java      |    6 +-
 .../usergrid/persistence/PermissionsIT.java     |    5 +-
 .../cassandra/EntityManagerFactoryImplIT.java   |   24 +-
 .../query/AbstractIteratingQueryIT.java         |   16 +-
 .../system/UsergridSystemMonitorIT.java         |   14 +-
 stack/core/src/test/resources/log4j.properties  |    5 +-
 .../resources/usergrid-custom-test.properties   |    3 +
 .../collection/EntityCollectionManager.java     |   13 +-
 .../collection/EntityDeletedFactory.java        |   34 +
 .../persistence/collection/EntitySet.java       |    4 +-
 .../collection/EntityVersionCleanupFactory.java |   35 +
 .../collection/EntityVersionCreatedFactory.java |   31 +
 .../persistence/collection/VersionSet.java      |   22 +-
 .../collection/event/EntityDeleted.java         |    5 +-
 .../collection/event/EntityVersionCreated.java  |   14 +-
 .../collection/event/EntityVersionDeleted.java  |   11 +-
 .../collection/guice/CollectionModule.java      |   24 +-
 .../collection/impl/CollectionScopeImpl.java    |    4 +-
 .../impl/EntityCollectionManagerImpl.java       |   86 +-
 .../collection/impl/EntityDeletedTask.java      |  148 ++
 .../impl/EntityVersionCleanupTask.java          |  224 ++--
 .../impl/EntityVersionCreatedTask.java          |  122 ++
 .../mvcc/stage/delete/MarkCommit.java           |  137 +-
 .../impl/EntityVersionSerializer.java           |    3 -
 .../MvccEntitySerializationStrategyImpl.java    |    2 +-
 .../collection/guice/TestCollectionModule.java  |    4 -
 .../impl/EntityVersionCleanupTaskTest.java      |  450 ++++---
 .../impl/EntityVersionCreatedTaskTest.java      |  244 ++++
 .../core/astyanax/BucketScopedRowKey.java       |    3 +-
 .../core/astyanax/CassandraConfig.java          |   18 +
 .../core/astyanax/ColumnNameIterator.java       |    1 -
 .../persistence/core/astyanax/ColumnSearch.java |   30 +-
 .../persistence/core/astyanax/ColumnTypes.java  |   19 +-
 .../core/astyanax/FieldBufferBuilder.java       |    1 -
 .../astyanax/MultiKeyColumnNameIterator.java    |    2 -
 .../core/astyanax/MultiRowColumnIterator.java   |    4 -
 .../core/astyanax/MultiTennantColumnFamily.java |    1 -
 .../persistence/core/astyanax/ScopedRowKey.java |    1 -
 .../astyanax/StringRowCompositeSerializer.java  |   35 +-
 .../core/hystrix/HystrixCassandra.java          |    3 -
 .../core/migration/data/DataMigration.java      |   31 +-
 .../migration/data/DataMigrationException.java  |   30 +-
 .../migration/data/DataMigrationManager.java    |   30 +-
 .../data/DataMigrationManagerImpl.java          |   32 +-
 .../data/MigrationInfoSerialization.java        |   31 +-
 .../data/MigrationInfoSerializationImpl.java    |   31 +-
 .../migration/schema/MigrationManagerFig.java   |   18 +
 .../migration/schema/MigrationManagerImpl.java  |   18 +
 .../core/shard/ExpandingShardLocator.java       |   23 +-
 .../persistence/core/shard/StringHashUtils.java |   22 +-
 .../core/task/NamedTaskExecutorImpl.java        |  141 +-
 .../usergrid/persistence/core/task/Task.java    |   19 +-
 .../persistence/core/task/TaskExecutor.java     |   18 +
 .../core/task/NamedTaskExecutorImplTest.java    |   56 +-
 .../persistence/model/field/LocationField.java  |    8 +
 .../persistence/index/AliasedEntityIndex.java   |   48 +
 .../usergrid/persistence/index/EntityIndex.java |   31 +-
 .../persistence/index/EntityIndexBatch.java     |    7 +-
 .../usergrid/persistence/index/IndexFig.java    |    9 +
 .../persistence/index/IndexIdentifier.java      |   92 ++
 .../index/impl/EsEntityIndexBatchImpl.java      |   55 +-
 .../index/impl/EsEntityIndexImpl.java           |  336 +++--
 .../persistence/index/impl/EsIndexCache.java    |  114 ++
 .../persistence/index/impl/IndexingUtils.java   |  129 +-
 .../persistence/index/impl/EntityIndexTest.java |  124 +-
 .../persistence/queue/DefaultQueueManager.java  |   68 +
 stack/loadtests/README.md                       |   19 +
 stack/loadtests/pom.xml                         |    4 +-
 stack/loadtests/runtests.sh                     |  120 ++
 .../apache/usergrid/helpers/Extractors.scala    |   84 ++
 .../org/apache/usergrid/helpers/Setup.scala     |   30 +-
 .../usergrid/scenarios/DeviceScenarios.scala    |    2 +-
 .../usergrid/scenarios/UserScenarios.scala      |  197 ++-
 .../org/apache/usergrid/settings/Headers.scala  |    6 +-
 .../org/apache/usergrid/settings/Settings.scala |    2 +-
 .../simulations/DeleteUsersSimulation.scala     |   56 +
 .../simulations/GetUserPagesSimulation.scala    |   51 +
 .../simulations/GetUsersSimulation.scala        |   51 +
 .../simulations/PostUsersSimulation.scala       |   49 +-
 .../simulations/PutUsersSimulation.scala        |   56 +
 .../usergrid/simulations/SetupSimulation.scala  |    4 +-
 stack/loadtests/src/test/scala/Engine.scala     |    4 +-
 stack/pom.xml                                   |    3 +
 .../org/apache/usergrid/rest/IndexResource.java |  227 ++++
 .../apache/usergrid/rest/SystemResource.java    |  151 +--
 .../rest/management/ManagementResource.java     |    2 +
 .../apache/usergrid/rest/AbstractRestIT.java    |    2 +-
 .../apache/usergrid/rest/IndexResourceIT.java   |   80 ++
 .../apache/usergrid/rest/TestContextSetup.java  |    6 +-
 .../applications/assets/AssetResourceIT.java    |   43 +-
 .../collection/DuplicateNameIT.java             |    2 +-
 .../activities/ActivityResourceIT.java          |  133 +-
 .../collection/activities/PutTest.java          |   33 +-
 .../collection/devices/DevicesResourceIT.java   |   39 +-
 .../collection/groups/GroupResourceIT.java      |  592 +++++---
 .../collection/groups/UpdateGroupIT.java        |  114 --
 .../collection/paging/PagingEntitiesTest.java   |  141 --
 .../collection/paging/PagingResourceIT.java     |  442 +++---
 .../users/ConnectionResourceTest.java           |  282 ++--
 .../collection/users/OwnershipResourceIT.java   |  424 +++---
 .../collection/users/PermissionsResourceIT.java |  723 ++++------
 .../collection/users/RetrieveUsersTest.java     |   40 +-
 .../collection/users/UserResourceIT.java        | 1260 +++++++-----------
 .../applications/queries/AndOrQueryTest.java    |  390 +++---
 .../queries/BadGrammarQueryTest.java            |   78 +-
 .../applications/queries/GeoPagingTest.java     |  562 ++++----
 .../applications/queries/MatrixQueryTests.java  |  181 ++-
 .../rest/applications/queries/OrderByTest.java  |  269 ++--
 .../rest/applications/utils/TestUtils.java      |   19 +
 .../rest/applications/utils/UserRepo.java       |   51 +-
 .../rest/management/OrganizationsIT.java        |  471 +++----
 .../rest/test/resource/TestContext.java         |    3 +-
 .../test/resource2point0/AbstractRestIT.java    |  159 +++
 .../rest/test/resource2point0/ClientSetup.java  |  113 ++
 .../rest/test/resource2point0/DumbClient.java   |   58 +
 .../rest/test/resource2point0/RestClient.java   |  114 ++
 .../endpoints/ApplicationsResource.java         |   48 +
 .../endpoints/CollectionEndpoint.java           |  221 +++
 .../endpoints/EntityEndpoint.java               |  176 +++
 .../endpoints/NamedResource.java                |  109 ++
 .../endpoints/OrganizationResource.java         |   55 +
 .../resource2point0/endpoints/RootResource.java |   85 ++
 .../endpoints/TokenResource.java                |   61 +
 .../resource2point0/endpoints/UrlResource.java  |   44 +
 .../endpoints/mgmt/ApplicationResource.java     |   48 +
 .../endpoints/mgmt/ManagementResource.java      |   44 +
 .../endpoints/mgmt/OrgResource.java             |  114 ++
 .../endpoints/mgmt/OrganizationResource.java    |   83 ++
 .../endpoints/mgmt/TokenResource.java           |   54 +
 .../endpoints/mgmt/UsersResource.java           |   61 +
 .../resource2point0/model/ActivityEntity.java   |   49 +
 .../test/resource2point0/model/ApiResponse.java |  219 +++
 .../test/resource2point0/model/Application.java |   39 +
 .../model/ChangePasswordEntity.java             |   33 +
 .../test/resource2point0/model/Collection.java  |   98 ++
 .../rest/test/resource2point0/model/Entity.java |  204 +++
 .../resource2point0/model/Organization.java     |  117 ++
 .../resource2point0/model/QueryParameters.java  |   93 ++
 .../rest/test/resource2point0/model/Token.java  |   72 +
 .../rest/test/resource2point0/model/User.java   |  101 ++
 .../resource2point0/state/ClientContext.java    |   39 +
 .../resources/usergrid-custom-test.properties   |    2 +
 stack/services/pom.xml                          |  268 +---
 .../cassandra/ManagementServiceImpl.java        |    2 -
 .../notifications/apns/APNsAdapter.java         |    4 +-
 .../notifications/apns/EntityPushManager.java   |    3 +-
 .../usergrid/ConcurrentServiceITSuite.java      |   60 -
 .../org/apache/usergrid/NewOrgAppAdminRule.java |  159 +++
 .../org/apache/usergrid/ServiceITSuite.java     |   64 -
 .../apache/usergrid/management/EmailFlowIT.java |  124 +-
 .../usergrid/management/OrganizationIT.java     |   36 +-
 .../org/apache/usergrid/management/RoleIT.java  |   12 +-
 .../cassandra/ApplicationCreatorIT.java         |   46 +-
 .../management/cassandra/ExportServiceIT.java   |   63 +-
 .../cassandra/ManagementServiceIT.java          |   94 +-
 .../security/providers/FacebookProviderIT.java  |   21 +-
 .../providers/PingIdentityProviderIT.java       |   12 +-
 .../security/tokens/TokenServiceIT.java         |   55 +-
 .../usergrid/services/AbstractServiceIT.java    |   13 +-
 .../usergrid/services/ServiceFactoryIT.java     |    4 +-
 .../usergrid/services/ServiceRequestIT.java     |   14 +-
 .../usergrid/services/TestQueueManager.java     |   65 -
 .../AbstractServiceNotificationIT.java          |   16 +-
 .../apns/NotificationsServiceIT.java            |   12 +-
 .../gcm/NotificationsServiceIT.java             |   15 +-
 .../java/org/apache/usergrid/TestHelper.java    |   75 ++
 221 files changed, 11971 insertions(+), 6950 deletions(-)
----------------------------------------------------------------------



[02/50] [abbrv] incubator-usergrid git commit: fixed retrieve users

Posted by gr...@apache.org.
fixed retrieve users


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

Branch: refs/heads/two-dot-o-import
Commit: 80b093f57b5129e0eed5f6c8c230ac98167a4404
Parents: 3c089f5
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Jan 5 19:00:47 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Jan 5 19:00:47 2015 -0700

----------------------------------------------------------------------
 .../collection/users/RetrieveUsersTest.java     | 40 ++++++++++----------
 1 file changed, 20 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/80b093f5/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/RetrieveUsersTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/RetrieveUsersTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/RetrieveUsersTest.java
index 5a8d363..f85cd5a 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/RetrieveUsersTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/RetrieveUsersTest.java
@@ -22,14 +22,17 @@ import java.util.Map;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import java.io.IOException;
+
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.CollectionEndpoint;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.EntityEndpoint;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
 import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.rest.TestContextSetup;
-import org.apache.usergrid.rest.test.resource.CustomCollection;
 
 import static org.junit.Assert.assertEquals;
 
@@ -43,45 +46,42 @@ import static org.junit.Assert.assertEquals;
 public class RetrieveUsersTest extends AbstractRestIT {
     private static final Logger log = LoggerFactory.getLogger( RetrieveUsersTest.class );
 
-    @Rule
-    public TestContextSetup context = new TestContextSetup( this );
 
 
     @Test // USERGRID-1222
     public void queryForUsername() throws IOException {
-        CustomCollection users = context.customCollection( "users" );
+        CollectionEndpoint users =this.app().collection( "users" );
 
-        Map props = new HashMap();
+        Entity props = new Entity();
 
         props.put( "username", "Alica" );
-        users.create( props );
+        users.post(props);
 
         props.put( "username", "Bob" );
-        users.create( props );
+        users.post(props);
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
         String query = "select *";
         String incorrectQuery = "select * where username = 'Alica'";
 
-        assertEquals( users.entityValue( query, "username", 0 ), users.entityValue( incorrectQuery, "username", 0 ) );
+        assertEquals( users.get(new QueryParameters().setQuery( query) ).next().get( "username").toString(), users.get(new QueryParameters().setQuery( incorrectQuery)).next().get( "username").toString() );
     }
 
 
     @Test // USERGRID-1727
     public void userEntityDictionaryHasRoles() throws IOException {
-        CustomCollection users = context.customCollection( "users" );
+        CollectionEndpoint users = this.app().collection("users");
 
-        Map props = new HashMap();
+        Entity props = new Entity();
         props.put( "username", "Nina" );
 
-        JsonNode response = users.create( props );
-        refreshIndex(context.getOrgName(), context.getAppName());
+        Entity entity = users.post(props);
+        refreshIndex();
 
-        JsonNode entity = response.get( "entities" ).get( 0 );
-        JsonNode metadata = entity.get( "metadata" );
-        JsonNode sets = metadata.get( "sets" );
-        JsonNode rolenames = sets.get( "rolenames" );
-        Assert.assertTrue( "rolenames URL ends with /roles", rolenames.asText().endsWith( "/roles" ) );
+        Map<String,Object> metadata = (Map)entity.get( "metadata" );
+        Map<String,Object> sets = (Map)metadata.get( "sets" );
+        Map<String,Object> rolenames =(Map) sets.get( "rolenames" );
+        Assert.assertTrue( "rolenames URL ends with /roles", rolenames.toString().endsWith( "/roles" ) );
     }
 }


[06/50] [abbrv] incubator-usergrid git commit: fixing ownershipResourceIT

Posted by gr...@apache.org.
fixing ownershipResourceIT


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

Branch: refs/heads/two-dot-o-import
Commit: d2faf43eae7ba8d41d73d953205c9258061a98a6
Parents: 1404292
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Jan 5 21:19:09 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Jan 5 21:19:09 2015 -0700

----------------------------------------------------------------------
 .../users/ConnectionResourceTest.java           | 125 ++++-----
 .../collection/users/OwnershipResourceIT.java   | 275 +++++++++----------
 2 files changed, 196 insertions(+), 204 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d2faf43e/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
index 21b30d3..0e18b13 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
@@ -24,11 +24,13 @@ import java.util.UUID;
 import javax.ws.rs.core.MediaType;
 
 import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.CollectionEndpoint;
+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.junit.Rule;
 import org.junit.Test;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.rest.TestContextSetup;
-import org.apache.usergrid.rest.test.resource.CustomCollection;
 
 import com.sun.jersey.api.client.ClientResponse;
 import com.sun.jersey.api.client.UniformInterfaceException;
@@ -47,61 +49,53 @@ import static org.apache.usergrid.utils.MapUtils.hashMap;
  * @since 4.0
  */
 public class ConnectionResourceTest extends AbstractRestIT {
-    @Rule
-    public TestContextSetup context = new TestContextSetup( this );
+   
 
 
     @Test
     public void connectionsQueryTest() throws IOException {
 
 
-        CustomCollection activities = context.customCollection( "peeps" );
+        CollectionEndpoint activities = this.app().collection("peeps");
 
-        Map stuff = hashMap( "type", "chicken" );
+        Entity stuff = new Entity().chainPut("type", "chicken");
 
-        activities.create( stuff );
+        activities.post(stuff);
 
 
-        Map<String, Object> payload = new LinkedHashMap<String, Object>();
+        Entity payload = new Entity();
         payload.put( "username", "todd" );
 
-        Map<String, Object> objectOfDesire = new LinkedHashMap<String, Object>();
+        Entity objectOfDesire = new Entity();
         objectOfDesire.put( "codingmunchies", "doritoes" );
 
-        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 );
+        Entity entity = this.app().collection("users").post(payload);
+
 
         payload.put( "username", "scott" );
 
+         entity = this.app().collection("users").post(payload);
+        refreshIndex();
+
 
-        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 );
     /*finish setting up the two users */
 
 
-        refreshIndex("test-organization", "test-app");
 
-        ClientResponse toddWant = resource().path( "/test-organization/test-app/users/todd/likes/peeps" )
-                .queryParam( "access_token", access_token ).accept( MediaType.TEXT_HTML )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( ClientResponse.class, objectOfDesire );
+        entity = this.app().collection("users").entity("todd").connection("likes").entity("peeps").post();
 
-        assertEquals( 200, toddWant.getStatus() );
+        assertNotNull(entity);
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex();
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/peeps" ).queryParam( "access_token", access_token )
-                        .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                        .get( String.class ));
+        Collection collection = this.app().collection("peeps").get();
 
-        String uuid = node.get( "entities" ).get( 0 ).get( "uuid" ).textValue();
+        String uuid = collection.next().get("uuid").toString();
 
 
         try {
-            node = mapper.readTree( resource().path( "/test-organization/test-app/users/scott/likes/" + uuid )
-                    .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
+            entity = this.app().collection("users").entity("scott").connection("likes").entity(uuid).get();
+
             assert ( false );
         }
         catch ( UniformInterfaceException uie ) {
@@ -113,26 +107,26 @@ public class ConnectionResourceTest extends AbstractRestIT {
     @Test
     public void connectionsLoopbackTest() throws IOException {
 
-        CustomCollection things = context.customCollection( "things" );
+        CollectionEndpoint things = this.app().collection("things");
 
-        UUID thing1Id = getEntityId( things.create( hashMap( "name", "thing1" ) ), 0 );
+        UUID thing1Id =  things.post( new Entity().chainPut("name", "thing1") ).getUuid();
 
-        UUID thing2Id = getEntityId( things.create( hashMap( "name", "thing2" ) ), 0 );
+        UUID thing2Id = things.post( new Entity().chainPut("name", "thing2") ).getUuid();
 
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
         //create the connection
         things.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
 
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
         //test we have the "likes" in our connection meta data response
 
-        JsonNode response = things.entity( "thing1" ).get();
+        Entity response = things.entity( "thing1" ).get();
 
-        String url = getEntity( response, 0 ).get( "metadata" ).get( "connections" ).get( "likes" ).asText();
+        String url =((Map) ((Map)response.get( "metadata" )).get( "connections" )).get( "likes" ).toString();
 
 
         assertNotNull( "Connection url returned in entity", url );
@@ -143,16 +137,17 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
         //now that we know the URl is correct, follow it
 
-        response = context.customCollection( url ).get();
+        Collection collection = this.app().collection(url).get();
 
-        UUID returnedUUID = getEntityId( response, 0 );
+        Entity entity  =collection.next();
+        UUID returnedUUID = entity.getUuid();
 
         assertEquals( thing2Id, returnedUUID );
 
 
         //now follow the loopback, which should be pointers to the other entity
 
-        url = getEntity( response, 0 ).get( "metadata" ).get( "connecting" ).get( "likes" ).asText();
+        url = ((Map) ((Map)entity.get( "metadata" )).get( "connections" )).get("likes").toString();
 
         assertNotNull( "Incoming edge URL provited", url );
 
@@ -161,9 +156,9 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
         //now we should get thing1 from the loopback url
 
-        response = context.customCollection( url ).get();
+        collection = this.app().collection(url).get();
 
-        UUID returned = getEntityId( response, 0 );
+        UUID returned = collection.next().getUuid();
 
         assertEquals( "Should point to thing1 as an incoming entity connection", thing1Id, returned );
     }
@@ -172,26 +167,26 @@ public class ConnectionResourceTest extends AbstractRestIT {
     @Test
     public void connectionsUUIDTest() throws IOException {
 
-        CustomCollection things = context.customCollection( "things" );
+        CollectionEndpoint things = this.app().collection("things");
 
-        UUID thing1Id = getEntityId( things.create( hashMap( "name", "thing1" ) ), 0 );
+        UUID thing1Id =   things.post( new Entity().chainPut("name", "thing1") ).getUuid();
 
-        UUID thing2Id = getEntityId( things.create( hashMap( "name", "thing2" ) ), 0 );
+        UUID thing2Id =  things.post( new Entity().chainPut("name", "thing2") ).getUuid();
 
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
         //create the connection
         things.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
 
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
         //test we have the "likes" in our connection meta data response
 
-        JsonNode response = things.entity( "thing1" ).get();
+        Entity response = things.entity( "thing1" ).get();
 
-        String url = getEntity( response, 0 ).get( "metadata" ).get( "connections" ).get( "likes" ).asText();
+        String url =((Map) ((Map)response.get( "metadata" )).get( "connections" )).get( "likes" ).toString();
 
 
         assertNotNull( "Connection url returned in entity", url );
@@ -202,9 +197,9 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
         //now that we know the URl is correct, follow it
 
-        response = context.customCollection( url ).get();
+        Collection collection = this.app().collection(url).get();
 
-        UUID returnedUUID = getEntityId( response, 0 );
+        UUID returnedUUID =collection.next().getUuid();
 
         assertEquals( thing2Id, returnedUUID );
 
@@ -214,7 +209,7 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
         response = things.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).get();
 
-        UUID returned = getEntityId( response, 0 );
+        UUID returned = response.getUuid();
 
         assertEquals( "Should point to thing2 as an entity connection", thing2Id, returned );
     }
@@ -222,22 +217,22 @@ public class ConnectionResourceTest extends AbstractRestIT {
     @Test //USERGRID-3011
     public void connectionsDeleteSecondEntityInConnectionTest() throws IOException {
 
-        CustomCollection things = context.customCollection( "things" );
+        CollectionEndpoint things = this.app().collection("things");
 
-        UUID thing1Id = getEntityId( things.create( hashMap( "name", "thing1" ) ), 0 );
+        UUID thing1Id =  things.post( new Entity().chainPut("name", "thing1") ).getUuid();
 
-        UUID thing2Id = getEntityId( things.create( hashMap( "name", "thing2" ) ), 0 );
+        UUID thing2Id = things.post( new Entity().chainPut("name", "thing2") ).getUuid();
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
         //create the connection
         things.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
 
-        JsonNode response = things.entity( "thing2" ).delete();
+        ApiResponse response = things.entity( "thing2" ).delete();
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
-        JsonNode node = things.entity ( "thing2" ).get();
+        Entity node = things.entity ( "thing2" ).get();
 
         assertNull(node);
 
@@ -246,22 +241,22 @@ public class ConnectionResourceTest extends AbstractRestIT {
     @Test //USERGRID-3011
     public void connectionsDeleteFirstEntityInConnectionTest() throws IOException {
 
-        CustomCollection things = context.customCollection( "things" );
+        CollectionEndpoint things = this.app().collection("things");
 
-        UUID thing1Id = getEntityId( things.create( hashMap( "name", "thing1" ) ), 0 );
+        UUID thing1Id =   things.post( new Entity().chainPut("name", "thing1") ).getUuid();
 
-        UUID thing2Id = getEntityId( things.create( hashMap( "name", "thing2" ) ), 0 );
+        UUID thing2Id =   things.post( new Entity().chainPut("name", "thing2") ).getUuid();
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
         //create the connection
         things.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
 
-        JsonNode response = things.entity( "thing1" ).delete();
+        ApiResponse response = things.entity( "thing1" ).delete();
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
-        JsonNode node = things.entity ( "thing1" ).get();
+        Entity node = things.entity ( "thing1" ).get();
 
         assertNull(node);
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d2faf43e/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
index 17d99ec..3e4e94d 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
@@ -19,16 +19,15 @@ package org.apache.usergrid.rest.applications.collection.users;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import java.io.IOException;
+
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.CollectionEndpoint;
+import org.apache.usergrid.rest.test.resource2point0.model.*;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.apache.usergrid.cassandra.Concurrent;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.rest.TestContextSetup;
-import org.apache.usergrid.rest.test.resource.Connection;
-import org.apache.usergrid.rest.test.resource.CustomCollection;
-import org.apache.usergrid.rest.test.resource.app.queue.DevicesCollection;
-import org.apache.usergrid.rest.test.security.TestAppUser;
-import org.apache.usergrid.rest.test.security.TestUser;
+
 import org.apache.usergrid.utils.MapUtils;
 
 import static org.junit.Assert.assertEquals;
@@ -44,35 +43,46 @@ import static org.junit.Assert.fail;
 @Concurrent()
 public class OwnershipResourceIT extends AbstractRestIT {
 
-    @Rule
-    public TestContextSetup context = new TestContextSetup( this );
+    private CollectionEndpoint usersResource;
+    private User user1;
+    private User user2;
+
+    @Before
+    public void setup(){
+        this.usersResource =  this.app().collection("users");
+        String email = "testuser1@usergrid.org";
+        String email2 = "testuser2@usergrid.org";
+
+        user2 = new User("testuser2","testuser2", email, "password" );
 
+        user1 = new User("testuser1","testuser1", email, "password" );
+        user1 = new User(this.usersResource.post(user1));
+        user2 = new User(this.usersResource.post(user2));
+
+        refreshIndex();
+    }
 
     @Test
     public void meVerify() throws Exception {
 
-        context.clearUser();
+        this.app().token().clearToken();
 
-        String email = "testuser1@usergrid.org";
-        TestUser user1 = new TestAppUser( email, "password", email ).create( context );
-        refreshIndex(context.getOrgName(), context.getAppName());
-        user1.login( context ).makeActive( context );
+        Token token = this.app().token().post(new Token(user1.getUsername(),"password"));
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        Entity userNode = usersResource.entity("me").get();
 
-        String token = user1.getToken();
-        JsonNode userNode = context.application().users().user( "me" ).get();
         assertNotNull( userNode );
 
-        String uuid = userNode.get( "entities" ).get( 0 ).get( "uuid" ).textValue();
+        String uuid = userNode.getUuid().toString();
         assertNotNull( uuid );
 
-        setup.getMgmtSvc().revokeAccessTokenForAppUser( token );
+        usersResource.entity(user1).connection("revoketokens").post(new Entity().chainPut("token", token.getAccessToken()));
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
         try {
-            context.application().users().user( "me" ).get();
+             userNode = usersResource.entity("me").get();
+
             fail();
         }
         catch ( Exception ex ) {
@@ -86,98 +96,93 @@ public class OwnershipResourceIT extends AbstractRestIT {
     public void contextualPathOwnership() throws IOException {
 
         // anonymous user
-        context.clearUser();
+        this.app().token().clearToken();
 
-        refreshIndex(context.getOrgName(), context.getAppName());
 
-        TestUser user1 = new TestAppUser( "testuser1@usergrid.org", "password", "testuser1@usergrid.org" ).create( context );
-        refreshIndex(context.getOrgName(), context.getAppName());
-        user1.login( context );
-        user1.makeActive( context );
+        Token token = this.app().token().post(new Token(user1.getUsername(),"password"));
 
-        refreshIndex(context.getOrgName(), context.getAppName());
 
         // create device 1 on user1 devices
-        context.application().users().user( "me" ).devices()
-               .create( MapUtils.hashMap( "name", "device1" ).map( "number", "5551112222" ) );
+        usersResource.entity("me").collection("devices")
+               .post(new Entity( ).chainPut("name", "device1").chainPut("number", "5551112222"));
+        refreshIndex();
 
         // anonymous user
-        context.clearUser();
-        refreshIndex(context.getOrgName(), context.getAppName());
+        this.app().token().clearToken();
 
         // create device 2 on user 2
-        TestUser user2 = new TestAppUser( "testuser2@usergrid.org", "password", "testuser2@usergrid.org" ).create( context );
-        refreshIndex(context.getOrgName(), context.getAppName());
-        user2.login( context );
-        user2.makeActive( context );
-
-        refreshIndex(context.getOrgName(), context.getAppName());
-
-        context.application().users().user( "me" ).devices()
-               .create( MapUtils.hashMap( "name", "device2" ).map( "number", "5552223333" ) );
+         token = this.app().token().post(new Token(user2.getUsername(),"password"));
+        usersResource.entity("me").collection("devices")
+                .post(new Entity( ).chainPut("name", "device2").chainPut("number", "5552223333"));
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
         // now query on user 1.
+        token = this.app().token().post(new Token(user1.getUsername(),"password"));
 
-        DevicesCollection devices = context.withUser( user1 ).application().users().user( "me" ).devices();
+        CollectionEndpoint devices = usersResource.entity( user1 ).collection("devices");
 
-        JsonNode data = devices.device( "device1" ).get();
+        Entity data = devices.entity("device1").get();
         assertNotNull( data );
-        assertEquals( "device1", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals("device1", data.get("name").toString());
 
         // check we can't see device2
-        data = devices.device( "device2" ).get();
+        data = devices.entity("device2").get();
         assertNull( data );
 
         // do a collection load, make sure we're not loading device 2
-        data = devices.get();
+        Collection devicesData = devices.get();
 
-        assertEquals( "device1", getEntity( data, 0 ).get( "name" ).asText() );
-        assertNull( getEntity( data, 1 ) );
+        assertEquals("device1", devicesData.next().get("name").toString());
+        assertTrue(!devicesData.hasNext());
 
         // log in as user 2 and check it
-        devices = context.withUser( user2 ).application().users().user( "me" ).devices();
+        token = this.app().token().post(new Token(user2.getUsername(),"password"));
 
-        data = devices.device( "device2" ).get();
+        devices =  usersResource.entity("me").collection("devices");
+
+        data = devices.entity("device2").get();
         assertNotNull( data );
-        assertEquals( "device2", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "device2", data.get("name").toString() );
 
         // check we can't see device1
-        data = devices.device( "device1" ).get();
+        data = devices.entity("device1").get();
         assertNull( data );
 
         // do a collection load, make sure we're not loading device 1
-        data = devices.get();
+        devicesData = devices.get();
 
-        assertEquals( "device2", getEntity( data, 0 ).get( "name" ).asText() );
-        assertNull( getEntity( data, 1 ) );
+        assertEquals("device2", devicesData.next().get("name").toString());
+        assertTrue(!devicesData.hasNext());
 
         // we should see both devices when loaded from the root application
 
         // test for user 1
+        token = this.app().token().post(new Token(user1.getUsername(),"password"));
 
-        devices = context.withUser( user1 ).application().devices();
-        data = devices.device( "device1" ).get();
+        devices = usersResource.entity(user1).collection("devices");
+        data = devices.entity("device1").get();
 
         assertNotNull( data );
-        assertEquals( "device1", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "device1", data.get("name").toString() );
 
-        data = devices.device( "device2" ).get();
+        data = devices.entity("device2").get();
 
         assertNotNull( data );
-        assertEquals( "device2", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "device2", data.get("name").toString() );
 
         // test for user 2
-        data = context.withUser( user2 ).application().devices().device( "device1" ).get();
+        token = this.app().token().post(new Token(user2.getUsername(),"password"));
+
+        data =usersResource.entity(user2).collection("devices").entity( "device1" ).get();
 
         assertNotNull( data );
-        assertEquals( "device1", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "device1",data.get( "name" ).toString() );
 
-        data = devices.device( "device2" ).get();
+        data = devices.entity( "device2" ).get();
 
         assertNotNull( data );
-        assertEquals( "device2", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "device2",data.get( "name" ).toString() );
     }
 
 
@@ -185,66 +190,56 @@ public class OwnershipResourceIT extends AbstractRestIT {
     public void contextualConnectionOwnership() throws IOException {
 
         // anonymous user
-        context.clearUser();
+        this.app().token().clearToken();
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+         this.app().token().post(new Token(user1.getUsername(),"password"));
 
-        String email = "testuser1@usergrid.org";
-        TestUser user1 = new TestAppUser( email, "password", email ).create( context );
-        refreshIndex(context.getOrgName(), context.getAppName());
-        user1.login( context ).makeActive( context );
 
         // create a 4peaks restaurant
-        JsonNode data = context.application()
-                .customCollection( "restaurants" ).create( MapUtils.hashMap( "name", "4peaks" ) );
+        Entity data = this.app().collection("restaurants").post(new Entity().chainPut("name", "4peaks"));
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
         // create our connection
-        data = context.application().users().user( "me" )
-                .connection( "likes" ).collection( "restaurants" ).entity( "4peaks" ).post();
+        data = usersResource.entity("me")
+                .connection("likes").collection( "restaurants" ).entity( "4peaks" ).post();
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
-       String peaksId = getEntity( data, 0 ).get( "uuid" ).asText();
+       String peaksId = data.getUuid().toString();
 
         // anonymous user
-        context.clearUser();
+        this.app().token().clearToken();
 
         // create a restaurant and link it to user 2
-        email = "testuser2@usergrid.org";
-        TestUser user2 = new TestAppUser( email, "password", email ).create( context );
-        refreshIndex(context.getOrgName(), context.getAppName());
+        this.app().token().post(new Token(user2.getUsername(),"password"));
 
-        user2.login( context ).makeActive( context );
-        refreshIndex(context.getOrgName(), context.getAppName());
+        data = this.app().collection("restaurants")
+                      .post(new Entity().chainPut("name", "arrogantbutcher"));
+        refreshIndex();
 
-        data = context.application().customCollection( "restaurants" )
-                      .create( MapUtils.hashMap( "name", "arrogantbutcher" ) );
-        refreshIndex(context.getOrgName(), context.getAppName());
-
-        data = context.application().users().user( "me" ).connection( "likes" ).collection( "restaurants" )
+        data = usersResource.entity("me").connection( "likes" ).collection( "restaurants" )
                       .entity( "arrogantbutcher" ).post();
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
-        String arrogantButcherId = getEntity( data, 0 ).get( "uuid" ).asText();
+        String arrogantButcherId = data.getUuid().toString();
 
         // now query on user 1.
+        this.app().token().post(new Token(user1.getUsername(),"password"));
 
-        CustomCollection likeRestaurants =
-                context.withUser( user1 ).application().users().user( "me" ).connection( "likes" )
+        CollectionEndpoint likeRestaurants =
+                usersResource.entity( "me" ).connection( "likes" )
                        .collection( "restaurants" );
-        refreshIndex(context.getOrgName(), context.getAppName());
 
         // check we can get it via id
-        data = likeRestaurants.entity( peaksId ).get();
+        data = likeRestaurants.entity(peaksId).get();
         assertNotNull( data );
-        assertEquals( "4peaks", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals("4peaks", data.get("name").toString());
 
         // check we can get it by name
         data = likeRestaurants.entity( "4peaks" ).get();
         assertNotNull( data );
-        assertEquals( "4peaks", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "4peaks", data.get("name").toString() );
 
         // check we can't see arrogantbutcher by name or id
         data = likeRestaurants.entity( "arrogantbutcher" ).get();
@@ -254,22 +249,24 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertNull( data );
 
         // do a collection load, make sure we're not entities we shouldn't see
-        data = likeRestaurants.get();
+        Collection collectionData = likeRestaurants.get();
 
-        assertEquals( "4peaks", getEntity( data, 0 ).get( "name" ).asText() );
-        assertNull( getEntity( data, 1 ) );
+        assertEquals("4peaks", collectionData.next().get("name").toString());
+        assertNull( collectionData.next() );
 
         // log in as user 2 and check it
-        likeRestaurants = context.withUser( user2 ).application().users().user( "me" ).connection( "likes" )
+        this.app().token().post(new Token(user2.getUsername(),"password"));
+
+        likeRestaurants = usersResource.entity("me").connection( "likes" )
                                  .collection( "restaurants" );
 
         data = likeRestaurants.entity( arrogantButcherId ).get();
         assertNotNull( data );
-        assertEquals( "arrogantbutcher", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "arrogantbutcher", data.get("name").toString() );
 
         data = likeRestaurants.entity( "arrogantbutcher" ).get();
         assertNotNull( data );
-        assertEquals( "arrogantbutcher", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "arrogantbutcher", data.get("name").toString() );
 
         // check we can't see 4peaks
         data = likeRestaurants.entity( "4peaks" ).get();
@@ -279,37 +276,39 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertNull( data );
 
         // do a collection load, make sure we're not loading device 1
-        data = likeRestaurants.get();
+        collectionData = likeRestaurants.get();
 
-        assertEquals( "arrogantbutcher", getEntity( data, 0 ).get( "name" ).asText() );
-        assertNull( getEntity( data, 1 ) );
+        assertEquals("arrogantbutcher", collectionData.next().get("name").toString());
+        assertNull( collectionData.next() );
 
         // we should see both devices when loaded from the root application
 
         // test for user 1
+        this.app().token().post(new Token(user1.getUsername(),"password"));
 
-        CustomCollection restaurants = context.withUser( user1 ).application().customCollection( "restaurants" );
+        CollectionEndpoint restaurants = this.app().collection( "restaurants" );
         data = restaurants.entity( "4peaks" ).get();
 
         assertNotNull( data );
-        assertEquals( "4peaks", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "4peaks", data.get("name").toString() );
 
         data = restaurants.entity( "arrogantbutcher" ).get();
 
         assertNotNull( data );
-        assertEquals( "arrogantbutcher", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "arrogantbutcher", data.get("name").toString() );
 
         // test for user 2
-        restaurants = context.withUser( user1 ).application().customCollection( "restaurants" );
+        this.app().token().post(new Token(user2.getUsername(),"password"));
+        restaurants = this.app().collection("restaurants");
         data = restaurants.entity( "4peaks" ).get();
 
         assertNotNull( data );
-        assertEquals( "4peaks", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "4peaks",data.get("name").toString() );
 
         data = restaurants.entity( "arrogantbutcher" ).get();
 
         assertNotNull( data );
-        assertEquals( "arrogantbutcher", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "arrogantbutcher",data.get("name").toString() );
     }
 
 
@@ -317,63 +316,61 @@ public class OwnershipResourceIT extends AbstractRestIT {
     public void contextualConnectionOwnershipGuestAccess() throws IOException {
 
         //set up full GET,PUT,POST,DELETE access for guests
-        context.application().customCollection( "roles" ).entity( "guest" ).collection( "permissions" )
-               .create( MapUtils.hashMap( "permission", "get,put,post,delete:/**" ) );
-
+        this.app().collection("roles").entity( "guest" ).collection( "permissions" )
+                .post(new Entity().chainPut("permission", "get,put,post,delete:/**"));
 
-        // anonymous user
-        context.clearUser();
 
 
-        JsonNode city = context.application().customCollection( "cities" ).create( MapUtils.hashMap( "name", "tempe" ) );
+        Entity city = this.app().collection("cities").post(new Entity().chainPut("name", "tempe"));
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
-        String cityId = getEntity( city, 0 ).get( "uuid" ).asText();
+        String cityId = city.get("uuid").toString();
 
         // create a 4peaks restaurant
-        JsonNode data = context.application().customCollection( "cities" ).entity( "tempe" ).connection( "likes" )
-                               .collection( "restaurants" ).create( MapUtils.hashMap( "name", "4peaks" ) );
+        Entity data = this.app().collection("cities").entity( "tempe" ).connection( "likes" )
+                               .collection( "restaurants" ).post(new Entity().chainPut("name", "4peaks"));
 
-        String peaksId = getEntity( data, 0 ).get( "uuid" ).asText();
+        String peaksId = data.get("uuid").toString();
 
-        data = context.application().customCollection( "cities" ).entity( "tempe" ).connection( "likes" )
-                      .collection( "restaurants" ).create( MapUtils.hashMap( "name", "arrogantbutcher" ) );
+        data = this.app().collection("cities").entity( "tempe" ).connection( "likes" )
+                      .collection( "restaurants" ).post(new Entity().chainPut("name", "arrogantbutcher"));
 
-        String arrogantButcherId = getEntity( data, 0 ).get( "uuid" ).asText();
+        String arrogantButcherId = data.get("uuid").toString();
 
         // now query on user 1.
+        this.app().token().post(new Token(user1.getUsername(),"password"));
 
-        Connection likeRestaurants =
-                context.application().customCollection( "cities" ).entity( "tempe" ).connection( "likes" );
+        CollectionEndpoint likeRestaurants =
+                this.app().collection("cities").entity( "tempe" ).connection( "likes" );
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
         // check we can get it via id with no collection name
         data = likeRestaurants.entity( peaksId ).get();
         assertNotNull( data );
-        assertEquals( "4peaks", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "4peaks", data.get("name").toString() );
 
         data = likeRestaurants.entity( arrogantButcherId ).get();
-        assertEquals( "arrogantbutcher", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "arrogantbutcher", data.get("name").toString() );
 
         // check we can get it via id with a collection name
         data = likeRestaurants.collection( "restaurants" ).entity( peaksId ).get();
         assertNotNull( data );
-        assertEquals( "4peaks", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "4peaks", data.get("name").toString() );
 
         data = likeRestaurants.collection( "restaurants" ).entity( arrogantButcherId ).get();
-        assertEquals( "arrogantbutcher", getEntity( data, 0 ).get( "name" ).asText() );
+        assertEquals( "arrogantbutcher", data.get("name").toString() );
 
         // do a delete either token should work
-        data = likeRestaurants.collection( "restaurants" ).entity( peaksId ).delete();
+        ApiResponse deleteResponse = likeRestaurants.collection( "restaurants" ).entity( peaksId ).delete();
 
-        assertNotNull( data );
-        assertEquals( "4peaks", getEntity( data, 0 ).get( "name" ).asText() );
+        assertNotNull( deleteResponse );
+        assertEquals( "4peaks", deleteResponse.getEntities().get(0).get("name").toString() );
 
-        data = likeRestaurants.collection( "restaurants" ).entity( arrogantButcherId ).delete();
+        deleteResponse = likeRestaurants.collection( "restaurants" ).entity( arrogantButcherId ).delete();
 
-        assertNotNull( data );
-        assertEquals( "arrogantbutcher", getEntity( data, 0 ).get( "name" ).asText() );
+        assertNotNull( deleteResponse );
+        assertEquals( "arrogantbutcher", deleteResponse.getEntities().get(0).get("name").toString() );
     }
 }


[29/50] [abbrv] incubator-usergrid git commit: [USERGRID-303]Fixed paging issue in orderByReturnCorrectResults

Posted by gr...@apache.org.
[USERGRID-303]Fixed paging issue in orderByReturnCorrectResults


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

Branch: refs/heads/two-dot-o-import
Commit: 231a449a62885727229b6977b6e7e8c7d19e392c
Parents: 0141aad
Author: ryan bridges <rb...@apigee.com>
Authored: Wed Jan 7 14:54:26 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Wed Jan 7 14:54:26 2015 -0500

----------------------------------------------------------------------
 .../apache/usergrid/rest/applications/queries/OrderByTest.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/231a449a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
index 8edf698..6d5f39b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
@@ -171,10 +171,10 @@ public class OrderByTest extends AbstractRestIT {
       //loop through the current page of results
       for (int i = 0; i < returnSize; i++, index--) {
         assertEquals(activitiesResponse.getResponse().getEntities().get(i).get("uuid").toString(),
-            (activities[index]).get("uuid").toString());
+            (activities[i]).get("uuid").toString());
       }
       //grab the next page of results
-      activitiesResponse = this.app().getNextPage(activitiesResponse, true);
+      activitiesResponse = this.app().getNextPage(activitiesResponse, params, true);
     }
     while (activitiesResponse.getCursor() != null);
   }


[26/50] [abbrv] incubator-usergrid git commit: [USERGRID-303]fixed tests after framework update

Posted by gr...@apache.org.
[USERGRID-303]fixed tests after framework update


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

Branch: refs/heads/two-dot-o-import
Commit: 0141aad4dc3ddcb8ac1440ab06c9279e68704713
Parents: 7253390
Author: ryan bridges <rb...@apigee.com>
Authored: Wed Jan 7 14:42:45 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Wed Jan 7 14:44:29 2015 -0500

----------------------------------------------------------------------
 .../applications/queries/AndOrQueryTest.java    | 28 ++++++++++----------
 .../applications/queries/GeoPagingTest.java     | 18 ++++++-------
 .../applications/queries/MatrixQueryTests.java  |  6 ++---
 .../rest/applications/queries/OrderByTest.java  | 10 +++----
 4 files changed, 31 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0141aad4/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
index 5e619be..59329bc 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
@@ -85,7 +85,7 @@ public class AndOrQueryTest extends AbstractRestIT {
         .setLimit(numValuesTested / 2);//4. Limit the query to half of the number of entities
     Collection activities = this.app().collection("activities").get(params);
     //5. Ensure the correct entities are returned
-    assertEquals(numValuesTested / 2, activities.response.getEntityCount());
+    assertEquals(numValuesTested / 2, activities.getResponse().getEntityCount());
     while (activities.hasNext()) {
       assertTrue(Boolean.parseBoolean(activities.next().get("madeup").toString()));
     }
@@ -135,7 +135,7 @@ public class AndOrQueryTest extends AbstractRestIT {
     QueryParameters params = new QueryParameters().setQuery(query).setLimit(numValuesTested / 2);
     Collection activities = this.app().collection("activities").get(params);
     //5. Ensure the returned entities have "verb = 'stop'"
-    assertEquals(numValuesTested / 2, activities.response.getEntityCount());
+    assertEquals(numValuesTested / 2, activities.getResponse().getEntityCount());
     while (activities.hasNext()) {
       assertEquals("stop", activities.next().get("verb").toString());
     }
@@ -172,11 +172,11 @@ public class AndOrQueryTest extends AbstractRestIT {
     QueryParameters params = new QueryParameters().setQuery(inCorrectQuery).setLimit(numValuesTested / 2);
     Collection activities = this.app().collection("activities").get(params);
     //3. Validate that the correct entities are returned
-    assertEquals(numValuesTested / 2, activities.response.getEntityCount());
+    assertEquals(numValuesTested / 2, activities.getResponse().getEntityCount());
 
-    List entities = activities.response.getEntities();
+    List<Entity> entities = activities.getResponse().getEntities();
     for (int i = 0; i < numValuesTested / 2; i++) {
-      assertEquals(numValuesTested / 2 + i, Integer.parseInt(((LinkedHashMap<String, Object>) entities.get(i)).get("ordinal").toString()));
+      assertEquals(numValuesTested / 2 + i, Integer.parseInt(entities.get(i).get("ordinal").toString()));
     }
 
   }
@@ -211,10 +211,10 @@ public class AndOrQueryTest extends AbstractRestIT {
     Collection activities = this.app().collection(collectionName).get(params);
 
     //3. Verify the order of results
-    assertEquals(numOfEntities / 2, activities.response.getEntityCount());
-    List entities = activities.response.getEntities();
+    assertEquals(numOfEntities / 2, activities.getResponse().getEntityCount());
+    List<Entity> entities = activities.getResponse().getEntities();
     for (int i = 0; i < numOfEntities / 2; i++) {
-      assertEquals(i, Integer.parseInt(((LinkedHashMap<String, Object>) entities.get(i)).get("ordinal").toString()));
+      assertEquals(i, Integer.parseInt(entities.get(i).get("ordinal").toString()));
     }
   }
 
@@ -248,10 +248,10 @@ public class AndOrQueryTest extends AbstractRestIT {
     Collection activities = this.app().collection(collectionName).get(params);
 
     //3. validate that a full page of (10) entities is returned
-    assertEquals(10, activities.response.getEntityCount());
-    List entities = activities.response.getEntities();
+    assertEquals(10, activities.getResponse().getEntityCount());
+    List<Entity> entities = activities.getResponse().getEntities();
     for (int i = 0; i < 10; i++) {
-      assertEquals(i, Integer.parseInt(((LinkedHashMap<String, Object>) entities.get(i)).get("ordinal").toString()));
+      assertEquals(i, Integer.parseInt(entities.get(i).get("ordinal").toString()));
     }
   }
 
@@ -284,10 +284,10 @@ public class AndOrQueryTest extends AbstractRestIT {
     Collection activities = this.app().collection(collectionName).get(params);
 
     //3. validate that a full page of (10) entities is returned
-    assertEquals(10, activities.response.getEntityCount());
-    List entities = activities.response.getEntities();
+    assertEquals(10, activities.getResponse().getEntityCount());
+    List<Entity> entities = activities.getResponse().getEntities();
     for (int i = 0; i < 10; i++) {
-      assertEquals(i, Integer.parseInt(((LinkedHashMap<String, Object>) entities.get(i)).get("ordinal").toString()));
+      assertEquals(i, Integer.parseInt(entities.get(i).get("ordinal").toString()));
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0141aad4/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 4a3ff80..044a249 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
@@ -94,7 +94,7 @@ public class GeoPagingTest extends AbstractRestIT {
     QueryParameters params = new QueryParameters();
     params.setQuery(query);
     Collection collection = this.app().collection("groups").get(params);
-    assertEquals("Query should have returned 1 entity", 1, collection.response.getEntityCount());
+    assertEquals("Query should have returned 1 entity", 1, collection.getResponse().getEntityCount());
     Entity entity = collection.next();
     // 3. Verify that the desired entity i, and only the desired entity, is returned
     assertNotNull("Query should have returned 1 entity", entity);
@@ -142,13 +142,13 @@ public class GeoPagingTest extends AbstractRestIT {
     this.refreshIndex();
 
     Collection collection = this.app().collection(collectionType).get();
-    assertEquals("Should return both entities", 2, collection.response.getEntityCount());
+    assertEquals("Should return both entities", 2, collection.getResponse().getEntityCount());
     // 2. Query within a short distance of the center point to ensure that none are returned
     collection = this.app().collection(collectionType).get(queryClose);
-    assertEquals("Results from nearby, should return nothing", 0, collection.response.getEntityCount());
+    assertEquals("Results from nearby, should return nothing", 0, collection.getResponse().getEntityCount());
     // 3. Query within a huge distance of the center point to ensure that both are returned
     collection = this.app().collection(collectionType).get(queryFar);
-    assertEquals("Results from center point to ridiculously far", 2, collection.response.getEntityCount());
+    assertEquals("Results from center point to ridiculously far", 2, collection.getResponse().getEntityCount());
   }
 
   /**
@@ -193,8 +193,8 @@ public class GeoPagingTest extends AbstractRestIT {
       params.setQuery(query);
       Collection collection = this.app().collection("groups").get(params);
 
-      assertEquals(3, collection.response.getEntityCount());
-      List entities = collection.response.getEntities();
+      assertEquals(3, collection.getResponse().getEntityCount());
+      List entities = collection.getResponse().getEntities();
       // 3. Test that the entities were returned in the order expected
       for (int i = 0; i < 3; i++) {
         // shouldn't start at 10 since you're excluding it above in the query, it should return 9,8,7
@@ -240,11 +240,11 @@ public class GeoPagingTest extends AbstractRestIT {
 
     // 2. Query from the center point to ensure that one is returned
     Collection collection = this.app().collection(collectionType).get(queryClose);
-    assertEquals("Results from nearby, should return 1 store", 1, collection.response.getEntityCount());
+    assertEquals("Results from nearby, should return 1 store", 1, collection.getResponse().getEntityCount());
 
     // 3. Query within a huge distance of the center point to ensure that both are returned
     collection = this.app().collection(collectionType).get(queryFar);
-    assertEquals("Results from center point to ridiculously far", 2, collection.response.getEntityCount());
+    assertEquals("Results from center point to ridiculously far", 2, collection.getResponse().getEntityCount());
   }
 
 
@@ -294,7 +294,7 @@ public class GeoPagingTest extends AbstractRestIT {
       QueryParameters params = new QueryParameters();
       params.setQuery(query);
       Collection collection = this.app().collection("users").get(params);
-      assertEquals("Expected 0 results", 0, collection.response.getEntityCount());
+      assertEquals("Expected 0 results", 0, collection.getResponse().getEntityCount());
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0141aad4/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/MatrixQueryTests.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/MatrixQueryTests.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/MatrixQueryTests.java
index 184e1c0..5b5b21b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/MatrixQueryTests.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/MatrixQueryTests.java
@@ -89,13 +89,13 @@ public class MatrixQueryTests extends AbstractRestIT {
 
     //4. Retrieve "likes" connections per user and ensure the correct restaurants are returned
     Collection user1likes = this.app().collection("users").entity(user1).connection("likes").get();
-    assertEquals(2, user1likes.response.getEntityCount());
+    assertEquals(2, user1likes.getResponse().getEntityCount());
 
     Collection user2likes = this.app().collection("users").entity(user2).connection("likes").get();
-    assertEquals(2, user2likes.response.getEntityCount());
+    assertEquals(2, user2likes.getResponse().getEntityCount());
 
     Collection user3likes = this.app().collection("users").entity(user3).connection("likes").get();
-    assertEquals(1, user3likes.response.getEntityCount());
+    assertEquals(1, user3likes.getResponse().getEntityCount());
   }
 
   //TODO implement matrix parameters and tests!!!

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0141aad4/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
index 5f78c5e..8edf698 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
@@ -77,12 +77,12 @@ public class OrderByTest extends AbstractRestIT {
     String query = "select * where created > " + created;
     QueryParameters params = new QueryParameters().setQuery(query);
     Collection activitiesWithoutOrderBy = this.app().collection("activities").get(params);
-    assertEquals(10, activitiesWithoutOrderBy.response.getEntityCount());
+    assertEquals(10, activitiesWithoutOrderBy.getResponse().getEntityCount());
     //3. Query with 'order by'
     query = query + " order by created desc";
     params.setQuery(query);
     Collection activitiesWithOrderBy = this.app().collection("activities").get(params);
-    assertEquals(10, activitiesWithOrderBy.response.getEntityCount());
+    assertEquals(10, activitiesWithOrderBy.getResponse().getEntityCount());
     //4. Ensure the same entities are returned
     while(activitiesWithoutOrderBy.hasNext() && activitiesWithOrderBy.hasNext()) {
       Entity activityWithoutOrderBy = activitiesWithoutOrderBy.next();
@@ -121,7 +121,7 @@ public class OrderByTest extends AbstractRestIT {
     QueryParameters params = new QueryParameters().setQuery(query).setLimit(5);
     Collection activities = this.app().collection("activities").get(params);
     //3. Ensure the correct number of results are returned
-    assertEquals(5, activities.response.getEntityCount());
+    assertEquals(5, activities.getResponse().getEntityCount());
 
   }
 
@@ -167,10 +167,10 @@ public class OrderByTest extends AbstractRestIT {
     Collection activitiesResponse = this.app().collection("activities").get(params);
     //3. Validate that the order is correct
     do {
-      int returnSize = activitiesResponse.response.getEntityCount();
+      int returnSize = activitiesResponse.getResponse().getEntityCount();
       //loop through the current page of results
       for (int i = 0; i < returnSize; i++, index--) {
-        assertEquals(((LinkedHashMap<String, Object>) activitiesResponse.response.getEntities().get(i)).get("uuid").toString(),
+        assertEquals(activitiesResponse.getResponse().getEntities().get(i).get("uuid").toString(),
             (activities[index]).get("uuid").toString());
       }
       //grab the next page of results


[36/50] [abbrv] incubator-usergrid git commit: Added in a bunch of comments to clarify what was going on in PermissionsResourceIT

Posted by gr...@apache.org.
Added in a bunch of comments to clarify what was going on in PermissionsResourceIT


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

Branch: refs/heads/two-dot-o-import
Commit: d567dd1af9d0a530e7cefa7b057cb2383fb4a787
Parents: 944bcf9
Author: grey <gr...@apigee.com>
Authored: Thu Jan 8 13:02:04 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Thu Jan 8 13:02:04 2015 -0800

----------------------------------------------------------------------
 .../collection/users/OwnershipResourceIT.java   |   2 +-
 .../collection/users/PermissionsResourceIT.java | 166 ++++++++++---------
 2 files changed, 88 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d567dd1a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
index 52e27c7..b335a1f 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
@@ -219,7 +219,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
     /**
      * Tests that we can have our own personal connections without being seen by other users, but are still visible
-     * from a root context. 
+     * from a root context.
      * @throws IOException
      */
     @Test

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d567dd1a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
index 5f196bb..c72d906 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
@@ -50,7 +50,6 @@ import static org.junit.Assert.*;
 /**
  * Tests permissions of adding and removing users from roles as well as groups
  *
- * @author tnine
  */
 @Concurrent()
 public class PermissionsResourceIT extends AbstractRestIT {
@@ -64,7 +63,11 @@ public class PermissionsResourceIT extends AbstractRestIT {
     public PermissionsResourceIT() throws Exception {
 
     }
-    
+
+
+    /**
+     * Creates a user in the default org/app combo for use by all of the tests
+     */
     @Before
     public void setup(){
 
@@ -74,8 +77,14 @@ public class PermissionsResourceIT extends AbstractRestIT {
     }
 
 
+    /**
+     * Tests that we can delete a role that is in use by a user.
+     * @throws IOException
+     */
     @Test
     public void deleteUserFromRole() throws IOException {
+
+        //Create a role and check the response
         Entity data = new Entity().chainPut("name", ROLE);
 
         Entity node = this.app().collection("roles").post(data);
@@ -85,6 +94,8 @@ public class PermissionsResourceIT extends AbstractRestIT {
         assertEquals( ROLE, node.get("name").toString() );
 
         refreshIndex();
+
+        //Post the user with a specific role into the users collection
         node = this.app().collection("roles").entity(node).collection("users").entity(USER).post();
         assertNull( node.get( "error" ) );
 
@@ -116,13 +127,16 @@ public class PermissionsResourceIT extends AbstractRestIT {
     }
 
 
+    /**
+     * Deletes a user from the group.
+     * @throws IOException
+     */
     @Test
     public void deleteUserGroup() throws IOException {
 
-        // don't populate the user, it will use the currently authenticated
-        // user.
         String groupPath = "groupPath" ;
 
+        //Creates and posts a group.
         Entity data = new Entity().chainPut("name",groupPath).chainPut("type", "group").chainPut( "path", groupPath );
 
         Entity node = this.app().collection("groups").post(data);
@@ -131,13 +145,15 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         refreshIndex();
 
+        //Create a user that is in the group.
         node = this.app().collection("groups").entity(groupPath).collection("users").entity(USER).post();
 
         assertNull( node.get( "error" ) );
 
         refreshIndex();
 
-       Collection groups = this.app().collection("users").entity(USER).collection("groups").get();
+        //Get the user and make sure that they are part of the group
+        Collection groups = this.app().collection("users").entity(USER).collection("groups").get();
 
         assertEquals(groups.next().get("name"), groupPath);
 
@@ -149,6 +165,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         refreshIndex();
 
+        //Check that the user no longer exists in the group
         int status = 0;
         try {
             groups = this.app().collection("users").entity(USER).collection("groups").get();
@@ -164,17 +181,11 @@ public class PermissionsResourceIT extends AbstractRestIT {
     /**
      * For the record, you should NEVER allow the guest role to add roles. This is a gaping security hole and a VERY BAD
      * IDEA! That being said, this should technically work, and needs testing.
+     *
+     * Tests that you can allow a guest role to add additional roles.
      */
     @Test
     public void dictionaryPermissions() throws Exception {
-        UUID id = UUIDUtils.newTimeUUID();
-
-        String applicationName = "testapp";
-        String orgname = "dictionaryPermissions";
-        String username = "permissionadmin" + id;
-        String password = "password";
-        String email = String.format( "email%s@usergrid.com", id );
-
 
         // add the perms to the guest to allow users in the role to create roles
         // themselves
@@ -195,94 +206,82 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
 
     /**
-     * Tests a real world example with the following steps. Creates an application.
-     * <p/>
-     * Creates a new role "reviewer"
-     * <p/>
-     * Grants a permission to GET, POST, and PUT the reviews url for the reviewer role
-     * <p/>
-     * Grants a permission GET on the reviewer for the
-     * <p/>
-     * Create a user reviewer1 and add them to the reviewer role
-     * <p/>
-     * Test access with reviewer1
-     * <p/>
-     * Create a group reviewergroup and add the "reviewer" group to it
-     * <p/>
-     * Create a user reviewer 2 and add them to the "reveiwergroup"
+     * Test application permissions by posting entities different users and making sure we work within
+     * the permissions given.
      */
     @Test
     public void applicationPermissions() throws Exception {
-        // now create the new role
-        UUID secondUserId = createRoleUser(  "reviewer2", "reviewer2@usergrid.com" );
-        UUID userId = createRoleUser( "reviewer1",  "reviewer1@usergrid.com" );
+        //Creates two new roles: reviewer1 and reviewer2
+        createRoleUser( "reviewer1",  "reviewer1@usergrid.com" );
+        createRoleUser(  "reviewer2", "reviewer2@usergrid.com" );
 
         Entity  data = new Entity().chainPut("name", "reviewer");
 
+        //Creates a new role "reviewer"
         Entity node = this.app().collection("roles").post(data);
 
         assertNull( node.getError() );
 
-        // delete the default role to test permissions later
         refreshIndex();
 
+        // delete the default role to test permissions later
         ApiResponse response = this.app().collection("roles").entity("default").delete();
 
         assertNull( response.getError() );
         refreshIndex();
 
-        // grant the perms to reviewer
+        // Grants a permission to GET, POST, and PUT the reviews url for the reviewer role
         addPermission( "reviewer", "get,put,post:/reviews/**" );
 
-        // grant get to guest
+        // Grants a permission GET on the guests for the reviews url
         addPermission(  "guest", "get:/reviews/**" );
 
+        //Creates a reviewer group
         Entity group = new Entity().chainPut( "path", "reviewergroup" ).chainPut("name","reviewergroup");
 
-        // now create the group
         this.app().collection("groups").post(group);
 
         refreshIndex();
 
+        //Adds the reviewer to the reviewerGroup
         this.app().collection("groups").entity("reviewergroup").collection("roles").entity("reviewer").post();
 
         refreshIndex();
 
-        // add the user to the group
+        //Adds reviewer2 user to the reviewergroup
         this.app().collection("users").entity("reviewer2").collection("groups").entity("reviewergroup").post();
 
         refreshIndex();
 
-        Entity userRole = this.app().collection("users").entity("reviewer1").collection("roles").entity("reviewer").post();
-        // grant this user the "reviewer" role
+        //Adds reviewer1 to the reviewer role
+        this.app().collection("users").entity("reviewer1").collection("roles").entity("reviewer").post();
 
         refreshIndex();
 
+        //Set the current context to reviewer1
         this.app().token().post(new Token("reviewer1","password"));
 
+        //Post reviews to the reviews collection as reviewer1
         Entity review =
                 new Entity().chainPut("rating", "4").chainPut("name", "noca").chainPut("review", "Excellent service and food");
+        this.app().collection("reviews").post( review );
 
-        this.app().collection("reviews").post(review);
-        refreshIndex();
-
-        // post a review as the reviewer1 user
         review = new Entity().chainPut ("rating", "4").chainPut( "name", "4peaks").chainPut("review", "Huge beer selection" );
         this.app().collection("reviews").post(review);
 
         refreshIndex();
 
-        // get the reviews
+        // get the reviews and assert they were created
         Collection reviews = this.app().collection("reviews").get();
 
         assertEquals( "noca",reviews.next().get("name") );
-        assertEquals("4peaks", reviews.next().get("name").toString());
-
-        // can't delete, not in the grants
+        assertEquals("4peaks", reviews.next().get( "name" ));
 
+        //Try to delete the reviews, but it should fail due to have having delete permission in the grants.
         int status = 0;
         try {
             this.app().collection("reviews").entity("noca").delete();
+            fail( "this should have failed due to having insufficient permissions" );
         }
         catch ( UniformInterfaceException uie ) {
             status = uie.getResponse().getStatus();
@@ -290,12 +289,12 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
 
-        refreshIndex();
-
         status = 0;
 
+        //Try to delete the reviews, but it should fail due to have having delete permission in the grants.
         try {
             this.app().collection("reviews").entity("4peaks").delete();
+            fail( "this should have failed due to having insufficient permissions" );
         }
         catch ( UniformInterfaceException uie ) {
             status = uie.getResponse().getStatus();
@@ -305,30 +304,23 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         refreshIndex();
 
-        // now test some groups
-
-        // post 2 reviews. Should get permissions from the group
+        //TODO: maybe make this into two different tests?
 
-        Token secondUserToken = this.app().token().post(new Token("reviewer2", "password"));
+        //Change context to reviewer2
+        this.app().token().post(new Token("reviewer2", "password"));
 
+        // post 2 reviews as reviewer2
         review = new Entity().chainPut("rating", "4").chainPut("name", "cowboyciao").chainPut("review", "Great atmosphoere");
-
-        // post a review as the reviewer2 user
         this.app().collection("reviews").post(review);
 
-        refreshIndex();
         review = new Entity().chainPut( "rating", "4" ).chainPut("name", "currycorner").chainPut( "review", "Authentic" );
-
-        // post a review as the reviewer2 user
         this.app().collection("reviews").post(review);
 
         refreshIndex();
 
+        // get all reviews as reviewer2
         reviews =  this.app().collection("reviews").get();
 
-        // get all reviews as a user
-
-
         assertEquals("noca", reviews.next().get("name").toString());
         assertEquals("4peaks", reviews.next().get("name").toString());
         assertEquals("cowboyciao", reviews.next().get("name").toString());
@@ -340,7 +332,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         try {
             this.app().collection("reviews").entity("cowboyciao").delete();
-      
+            fail( "this should have failed due to having insufficient permissions" );
         }
         catch ( UniformInterfaceException uie ) {
             status = uie.getResponse().getStatus();
@@ -354,7 +346,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         try {
             this.app().collection("reviews").entity("currycorner").delete();
-
+            fail( "this should have failed due to having insufficient permissions" );
         }
         catch ( UniformInterfaceException uie ) {
             status = uie.getResponse().getStatus();
@@ -378,20 +370,22 @@ public class PermissionsResourceIT extends AbstractRestIT {
     @Test
     public void wildcardMiddlePermission() throws Exception {
 
+        //Deletes the default role
         this.app().collection("roles").entity("default").delete();
-        Entity data = new Entity().chainPut("name", "reviewer");
 
+        //Creates a reviewer role
+        Entity data = new Entity().chainPut("name", "reviewer");
         this.app().collection("roles").post(data);
 
         refreshIndex();
 
-        // allow access to reviews
+        // allow access to reviews excluding delete
         addPermission( "reviewer",
                 "get,put,post:/reviews/**" );
-        // allow access to all user's connections
+        // allow access to all user's connections excluding delete
         addPermission( "reviewer",
                 "get,put,post:/users/${user}/**" );
-        // allow access to the review relationship
+        // allow access to the review relationship excluding delete
         addPermission( "reviewer",
                 "get,put,post:/books/*/review/*" );
 
@@ -408,24 +402,26 @@ public class PermissionsResourceIT extends AbstractRestIT {
         assertNotNull( userTwoId );
 
         refreshIndex();
-        
+
+        //Add user1 to the reviewer role
         this.app().collection("users").entity(userOneId).collection("roles").entity("reviewer").post();
 
-       
+
         refreshIndex();
 
+        //Add a book to the books collection
         Entity book = new Entity().chainPut( "title", "Ready Player One" ).chainPut("author", "Earnest Cline");
 
         book = this.app().collection("books").post(book);
-        // create a book as admin
-       
 
         assertEquals( "Ready Player One", book.get("title").toString() );
         String bookId = book.get("uuid").toString();
 
         refreshIndex();
 
+        //Switch the contex to be that of user1
         this.app().token().post(new Token("wildcardpermuserone","password"));
+
         // post a review of the book as user1
         // POST https://api.usergrid.com/my-org/my-app/users/$user1/reviewed/books/$uuid
         Entity review =
@@ -438,25 +434,21 @@ public class PermissionsResourceIT extends AbstractRestIT {
         // POST https://api.usergrid.com/my-org/my-app/users/me/wrote/review/${reviewId}
         this.app().collection("users").entity("me").connection("wrote").collection("review").entity(reviewId).post();
 
-
-        refreshIndex();
+        // POST https://api.usergrid.com/my-org/my-app/users/me/reviewed/review/${reviewId}
         this.app().collection("users").entity("me").connection("reviewed").collection("books").entity(bookId).post();
 
-
         refreshIndex();
 
-
-
         // POST https://api.usergrid.com/my-org/my-app/books/${bookId}/review/${reviewId}
         this.app().collection("books").entity(bookId).collection("review").entity(reviewId).post();
 
 
         refreshIndex();
 
-        // now try to post the same thing to books to verify as userOne the failure
+        // now try to post the same thing to books to verify as userOne does not have correct permissions
         int status = 0;
         try {
-            this.app().collection("books").post();
+            this.app().collection("books").post(book);
 
         }
         catch ( UniformInterfaceException uie ) {
@@ -464,11 +456,13 @@ public class PermissionsResourceIT extends AbstractRestIT {
         }
         assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
 
-        refreshIndex();
+        //Gets all books that user1 reviewed\
         this.app().collection("users").entity("me").connection("reviewed").collection("books").get();
 
+        //Gets a specific review
         this.app().collection("reviews").entity(reviewId).get();
 
+        //Gets all the reviews that user1 wrote
         this.app().collection("users").entity("me").connection("wrote").get();
 
     }
@@ -484,15 +478,20 @@ public class PermissionsResourceIT extends AbstractRestIT {
      * <p/>
      * examplepatient add himself to exampledoctor following list
      */
+    //TODO: get this test working.
     @Test
     public void wildcardFollowingPermission() throws Exception {
+        //Delete default role
         app().collection("roles").entity("default").delete();
+
+        //Create new role named patient
         Entity data = new Entity().chainPut( "name", "patient" );
         app().collection("roles").post(data);
 
         //allow patients to add doctors as their followers
         addPermission(  "patient", "delete,post:/users/*/following/users/${user}" );
         refreshIndex();
+
         // create examplepatient
         UUID patientId =  createRoleUser( "examplepatient",  "examplepatient@apigee.com" );
         assertNotNull( patientId );
@@ -522,16 +521,25 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         Entity entity = this.app().collection("users").post(props);
 
+        assertNotNull( entity );
+
         return entity.getUuid();
     }
 
 
-    /** Test adding the permission to the role */
+    /**
+     * Adds the permission in grant to the rolename role, and tests that they were added correctly
+     * @param rolename
+     * @param grant
+     * @throws IOException
+     */
     private void addPermission(  String rolename, String grant ) throws IOException {
+        //Create and post the permissions
         Entity props = new Entity().chainPut("permission", grant);
 
         this.app().collection("roles").entity(rolename).collection("permissions").post(props);
 
+        //Checks that the permissions were added correctly
         Collection node = this.app().collection("roles").entity(rolename).collection("permissions").get();
 
         List<Object> data =(List) node.getResponse().getData();


[25/50] [abbrv] incubator-usergrid git commit: [USERGRID-303]Updates to AndOrQueryTest

Posted by gr...@apache.org.
[USERGRID-303]Updates to AndOrQueryTest


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

Branch: refs/heads/two-dot-o-import
Commit: dc625ac9d4dc24e5ccdf19a42f3a507d959e7df3
Parents: 323ef95
Author: ryan bridges <rb...@apigee.com>
Authored: Mon Jan 5 12:01:47 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Wed Jan 7 14:44:29 2015 -0500

----------------------------------------------------------------------
 .../applications/queries/AndOrQueryTest.java    | 233 ++++++++++++-------
 .../applications/queries/GeoPagingTest.java     |   1 -
 2 files changed, 154 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/dc625ac9/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
index 2003faf..ae7083f 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
@@ -18,15 +18,23 @@ package org.apache.usergrid.rest.applications.queries;
 
 
 import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import java.io.IOException;
+
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.RandomStringUtils;
+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.utils.MapUtils;
 import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
-import org.apache.usergrid.rest.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
 import org.apache.usergrid.rest.TestContextSetup;
 import org.apache.usergrid.rest.test.resource.CustomCollection;
 
@@ -42,26 +50,21 @@ import static org.apache.usergrid.utils.MapUtils.hashMap;
  */
 public class AndOrQueryTest extends AbstractRestIT {
 
-    @Rule
-    public TestContextSetup context = new TestContextSetup( this );
-
-
     @Test //USERGRID-900
     public void queriesWithAndPastLimit() throws IOException {
 
-        CustomCollection activities = context.customCollection( "activities" );
 
         long created = 0;
-        Map actor = hashMap( "displayName", "Erin" );
-        Map props = new HashMap();
-
+      Entity actor = new Entity();
+      actor.put("displayName", "Erin");
+      Entity props = new Entity();
         props.put( "actor", actor );
         props.put( "verb", "go" );
         props.put( "content", "bragh" );
 
 
-        for ( int i = 0; i < 2000; i++ ) {
-            if ( i < 1000 ) {
+        for ( int i = 0; i < 20; i++ ) {
+            if ( i < 10 ) {
                 props.put( "madeup", false );
             }
             else {
@@ -69,136 +72,208 @@ public class AndOrQueryTest extends AbstractRestIT {
             }
 
             props.put( "ordinal", i );
-            JsonNode activity = activities.create( props );
+            Entity activity = this.app().collection("activities").post(props);
             if ( i == 0 ) {
-                created = activity.findValue( "created" ).longValue();
+                created = Long.parseLong(activity.get("created").toString());
             }
         }
 
-        this.refreshIndex( context.getAppUuid() );
+        this.refreshIndex();
 
         String errorQuery = "select * where created >= " + created + "AND madeup = true";
-        JsonNode incorrectNode = activities.withQuery( errorQuery ).get();
+      QueryParameters params= new QueryParameters();
+      params.setQuery(errorQuery);
+       Collection activities=this.app().collection("activities").get(params);
 
-        assertEquals( 10, incorrectNode.get( "entities" ).size() );
+        assertEquals( 10, activities.response.getEntityCount() );
     }
 
 
     @Test //USERGRID-1475
     public void displayFullQueriesInLimit() throws IOException {
 
-        CustomCollection activities = context.customCollection( "activities" );
+      int numValuesTested = 20;
+      Entity actor = new Entity();
+      actor.put("displayName", "Erin");
+      Entity props = new Entity();
+      props.put( "actor", actor );
+      props.put( "verb", "go" );
+      props.put( "content", "bragh" );
 
-        Map actor = hashMap( "displayName", "Erin" );
-        Map props = new HashMap();
-        props.put( "actor", actor );
-        props.put( "content", "bragh" );
 
-        for ( int i = 0; i < 20; i++ ) {
+      for ( int i = 0; i < numValuesTested; i++ ) {
+        if ( i < numValuesTested/2 ) {
+          props.put( "verb", "go" );
+        }
+        else {
+          props.put( "verb", "stop" );
+        }
 
-            if ( i < 10 ) {
-                props.put( "verb", "go" );
-            }
-            else {
-                props.put( "verb", "stop" );
-            }
+        props.put( "ordinal", i );
+        this.app().collection("activities").post(props);
+      }
 
-            props.put( "ordinal", i );
-            JsonNode activity = activities.create( props );
-        }
 
-        this.refreshIndex( context.getAppUuid() );
+        this.refreshIndex();
 
         String query = "select * where not verb = 'go'";
-        JsonNode incorrectNode = activities.query( query, "limit", Integer.toString( 10 ) );
+      QueryParameters params= new QueryParameters();
+      params.setQuery(query);
+      Collection activities=this.app().collection("activities").get(params);
 
-        assertEquals( 10, incorrectNode.get( "entities" ).size() );
+      assertEquals( numValuesTested/2, activities.response.getEntityCount() );
+      List entities = activities.response.getEntities();
 
-        for ( int i = 0; i < 10; i++ ) {
-            assertEquals( 19 - i, incorrectNode.get( "entities" ).get( i ).get( "ordinal" ).intValue() );
-            assertEquals( "stop", incorrectNode.get( "entities" ).get( i ).get( "verb" ).textValue() );
+        for ( int i = 0; i < numValuesTested/2; i++ ) {
+            assertEquals(numValuesTested - i, Integer.parseInt(((LinkedHashMap<String, Object>) entities.get(i)).get("ordinal").toString()));
+            assertEquals( "stop", ((LinkedHashMap<String, Object>) entities.get(i)).get("verb").toString() );
         }
     }
-
+  
 
     @Test //USERGRID-1615
     public void queryReturnCount() throws Exception {
 
-        CustomCollection activities = context.customCollection( "activities" );
-
-        Map actor = hashMap( "displayName", "Erin" );
-        Map props = new HashMap();
 
         int numValuesTested = 20;
 
+      Entity actor = new Entity();
+      actor.put("displayName", "Erin");
+      Entity props = new Entity();
+      props.put( "actor", actor );
+      props.put( "verb", "go" );
+      props.put( "content", "bragh" );
+      Entity[] correctValues = new Entity[numValuesTested];
+      for(int i=0; i< numValuesTested; i++){
+        props.put("ordinal", i);
+        correctValues[i] = this.app().collection("activities").post(props);
+      }
+      this.refreshIndex();
+
+      String inCorrectQuery = "select * where ordinal >= 10 order by ordinal asc";
+      QueryParameters params = new QueryParameters();
+      params.setQuery(inCorrectQuery);
+      Collection activities=this.app().collection("activities").get(params);
+
+      assertEquals( 10, activities.response.getEntityCount() );
+
+//      verificationOfQueryResults( "activities", (Entity[])ArrayUtils.subarray(correctValues, 10, 19), false, inCorrectQuery );
+      List entities = activities.response.getEntities();
+
+      for ( int i = 0; i < 10; i++ ) {
+        assertEquals(10+i, Integer.parseInt(((LinkedHashMap<String, Object>) entities.get(i)).get("ordinal").toString()));
+//        assertEquals( "stop", ((LinkedHashMap<String, Object>) entities.get(i)).get("verb").toString() );
+      }
 
-        props.put( "actor", actor );
-        props.put( "verb", "go" );
-        props.put( "content", "bragh" );
-
-        JsonNode[] correctValues = activities.createEntitiesWithOrdinal( props, numValuesTested );
-
-        this.refreshIndex( context.getAppUuid() );
-
-        String inCorrectQuery = "select * where verb = 'go' and ordinal >= 10 ";
-
-        activities.verificationOfQueryResults( correctValues, true, inCorrectQuery );
     }
 
 
     @Test //Check to make sure that asc works
     public void queryCheckAsc() throws Exception {
+      int numOfEntities = 10;
+        String collectionName = "imagination" + RandomStringUtils.randomAlphabetic( 5 );
 
-        CustomCollection madeupStuff = context.customCollection(
-                "imagination" + RandomStringUtils.randomAlphabetic( 5 ) );
-        Map character = hashMap( "WhoHelpedYou", "Ruff" );
+      Entity[] correctValues = new Entity[numOfEntities];
+      Entity props = new Entity();
+      props.put( "WhoHelpedYou", "Ruff" );
+      for(int i=0; i< numOfEntities; i++){
+        props.put("ordinal", i);
+        correctValues[i] = this.app().collection(collectionName).post(props);
+      }
 
-        JsonNode[] correctValues;
-        correctValues = madeupStuff.createEntitiesWithOrdinal( character, 10 );
-
-        this.refreshIndex( context.getAppUuid() );
+        this.refreshIndex(  );
 
         String inquisitiveQuery = "select * where Ordinal gte 0 and Ordinal lte 10 "
                 + "or WhoHelpedYou eq 'Ruff' ORDER BY Ordinal asc";
 
-        int totalEntitiesContained = madeupStuff.verificationOfQueryResults( correctValues, false, inquisitiveQuery );
+        int totalEntitiesContained = verificationOfQueryResults( collectionName, correctValues, false, inquisitiveQuery );
 
-        assertEquals( 10, totalEntitiesContained );
+        assertEquals( numOfEntities, totalEntitiesContained );
     }
 
 
-    @Ignore("Test to make sure all 1000 exist with a regular query")
+//    @Ignore("Test to make sure all 1000 exist with a regular query")
+    @Test
     public void queryReturnCheck() throws Exception {
-        CustomCollection madeupStuff = context.customCollection( "imagination" );
-        Map character = hashMap( "WhoHelpedYou", "Ruff" );
+        int numOfEntities = 20;
 
-        int numOfEntities = 1000;
+      String collectionName = "imagination" + RandomStringUtils.randomAlphabetic( 5 );
 
-        JsonNode[] correctValues = madeupStuff.createEntitiesWithOrdinal( character, numOfEntities );
+      Entity[] correctValues = new Entity[numOfEntities];
+      Entity props = new Entity();
+      props.put( "WhoHelpedYou", "Ruff" );
+      for(int i=0; i< numOfEntities; i++){
+        props.put("ordinal", i);
+        correctValues[i] = this.app().collection(collectionName).post(props);
+      }
 
-        this.refreshIndex( context.getAppUuid() );
+      this.refreshIndex(  );
 
-        String inquisitiveQuery = "select * where Ordinal >= 0 and Ordinal <= 2000 or WhoHelpedYou = 'Ruff'";
+        String inquisitiveQuery = "select * where ordinal >= 0 and ordinal <= 2000 or WhoHelpedYou = 'Ruff'";
 
-        int totalEntitiesContained = madeupStuff.verificationOfQueryResults( correctValues, true, inquisitiveQuery );
+        int totalEntitiesContained = verificationOfQueryResults( collectionName, correctValues, true, inquisitiveQuery );
 
         assertEquals( numOfEntities, totalEntitiesContained );
     }
 
 
-    @Ignore
-    public void queryReturnCheckWithShortHand() throws IOException {
-        CustomCollection madeupStuff = context.customCollection( "imagination" );
-        Map character = hashMap( "WhoHelpedYou", "Ruff" );
+    @Test
+    public void queryReturnCheckWithShortHand() throws Exception {
+      int numOfEntities = 20;
 
-        madeupStuff.createEntitiesWithOrdinal( character, 1000 );
+      String collectionName = "imagination" + RandomStringUtils.randomAlphabetic( 5 );
 
-        this.refreshIndex( context.getAppUuid() );
+      Entity[] correctValues = new Entity[numOfEntities];
+      Entity props = new Entity();
+      props.put( "WhoHelpedYou", "Ruff" );
+      for(int i=0; i< numOfEntities; i++){
+        props.put("ordinal", i);
+        correctValues[i] = this.app().collection(collectionName).post(props);
+      }
 
-        String inquisitiveQuery = "select * where Ordinal gte 0 and Ordinal lte 2000 or WhoHelpedYou eq 'Ruff'";
+      this.refreshIndex(  );
 
-        int totalEntitiesContained = madeupStuff.countEntities( inquisitiveQuery );
+      String inquisitiveQuery = "select * where Ordinal gte 0 and Ordinal lte 2000 or WhoHelpedYou eq 'Ruff'";
+
+      int totalEntitiesContained = verificationOfQueryResults( collectionName, correctValues, true, inquisitiveQuery );
+
+      assertEquals( numOfEntities, totalEntitiesContained );
 
-        assertEquals( 1000, totalEntitiesContained );
     }
+
+  public int verificationOfQueryResults( String collectionName, Entity[] correctValues, boolean reverse, String checkedQuery )
+      throws Exception {
+
+    int totalEntitiesContained = 0;
+    QueryParameters params = new QueryParameters();
+    params.setQuery(checkedQuery);
+    Collection checkedNodes = this.app().collection(collectionName).get(params);
+
+    while ( correctValues.length != totalEntitiesContained )//correctNode.get("entities") != null)
+    {
+      totalEntitiesContained += checkedNodes.response.getEntityCount();
+      if ( !reverse ) {
+        for ( int index = 0; index < checkedNodes.response.getEntityCount(); index++ ) {
+          assertEquals( correctValues[index].get("uuid"),
+              ((LinkedHashMap)checkedNodes.response.getEntities().get( index )).get("uuid") );
+        }
+      }
+      else {
+        for ( int index = 0; index < checkedNodes.response.getEntityCount(); index++ ) {
+          assertEquals( correctValues[correctValues.length - 1 - index].get("uuid"),
+              ((LinkedHashMap)checkedNodes.response.getEntities().get( index )).get("uuid") );
+        }
+      }
+
+      if ( checkedNodes.getCursor() != null ) {
+        checkedNodes = this.app().getNextPage(checkedNodes,true);
+      }
+
+      else {
+        break;
+      }
+    }
+    return totalEntitiesContained;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/dc625ac9/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 babbb56..4a3ff80 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
@@ -250,7 +250,6 @@ public class GeoPagingTest extends AbstractRestIT {
 
   /**
    * Creates two users, then a matrix of coordinates, then checks to see if any of the coordinates are near our users
-   * <p/>
    * 1. Create 2 users
    * 2. Create a list of geo points
    * 3. Test each to ensure it is not within 10000 meters of our users


[14/50] [abbrv] incubator-usergrid git commit: Cleanup of imports and spaces. Fixed OrganizationsIT and added comments. Added users to the end of ManagementResource to emulate AdminUser calls. Added put to organizationResource so we can update organizati

Posted by gr...@apache.org.
Cleanup of imports and spaces.
Fixed OrganizationsIT and added comments.
Added users to the end of ManagementResource to emulate AdminUser calls.
Added put to organizationResource so we can update organizations.
Added Additional case to entities that puts any data from a entity into the entity itself.
Added ability to get Organization properties without needing to go through dynamic properties.
Removed cruft from ClientContext.


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

Branch: refs/heads/two-dot-o-import
Commit: 860de10b31f1135ca0622a70713ad01cdee6075b
Parents: f6c1a0e
Author: grey <gr...@apigee.com>
Authored: Tue Jan 6 15:02:37 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Tue Jan 6 15:02:37 2015 -0800

----------------------------------------------------------------------
 .../collection/groups/GroupResourceIT.java      |   1 -
 .../rest/management/OrganizationsIT.java        | 137 ++++++++-----------
 .../rest/test/resource2point0/RestClient.java   |   1 -
 .../endpoints/mgmt/ManagementResource.java      |   4 +
 .../endpoints/mgmt/OrganizationResource.java    |   8 ++
 .../rest/test/resource2point0/model/Entity.java |  23 +++-
 .../resource2point0/model/Organization.java     |   3 +
 .../resource2point0/state/ClientContext.java    |  21 ---
 8 files changed, 91 insertions(+), 107 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/860de10b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
index e7acf4b..8f3fbcc 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
@@ -347,7 +347,6 @@ public class GroupResourceIT extends AbstractRestIT {
 
         //8. log user in, should then be using the app user's token not the admin token
         this.getAppUserToken(username, password);
-
         //9. create a cat - permissions should allow this
         String catName = "fluffy";
         payload = new Entity();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/860de10b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
index aae2735..0a7a82b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
@@ -163,6 +163,7 @@ public class OrganizationsIT extends AbstractRestIT {
     @Test
     public void testCreateDuplicateOrgEmail() throws Exception {
 
+        //Setup the org/owner combo
         String username = "testCreateDuplicateOrgEmail" + UUIDUtils.newTimeUUID();
         String name = username;
         String password = "password";
@@ -171,14 +172,17 @@ public class OrganizationsIT extends AbstractRestIT {
 
         Organization orgPayload = new Organization( orgName, username, email, name, password, null );
 
+        //create the org/owner
         Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post( orgPayload );
 
         this.refreshIndex();
 
         assertNotNull( orgCreatedResponse );
 
+        //recreate a new payload using a duplicate email
         orgPayload = new Organization( orgName+"test", username+"test", email, name+"test", password+"test", null );
 
+        //verify that we cannot create an organization that shares a email with another preexisting organization.
         try {
             clientSetup.getRestClient().management().orgs().post( orgPayload );
             fail( "Should not have created organization" );
@@ -187,6 +191,7 @@ public class OrganizationsIT extends AbstractRestIT {
             errorParse( 400,duplicateUniquePropertyExistsErrorMessage,ex);
         }
 
+        //try to get the token from the organization that failed to be created to verify it was not made.
         Token tokenPayload = new Token( "password", username + "test", password );
         Token tokenError = null;
         try {
@@ -200,6 +205,7 @@ public class OrganizationsIT extends AbstractRestIT {
 
         assertNull( tokenError );
 
+        //get token from organization that was created to verify it exists.
         tokenPayload = new Token( "password", username, password );
         Token tokenReturned = clientSetup.getRestClient().management().token().post( tokenPayload );
 
@@ -244,6 +250,7 @@ public class OrganizationsIT extends AbstractRestIT {
     @Test
     public void testOrgPOSTForm() throws IOException {
 
+        //create the form to hold the organization
         UUID timeUuid = UUIDUtils.newTimeUUID();
         Form form = new Form();
         form.add( "organization", "testOrgPOSTForm" + timeUuid );
@@ -285,105 +292,75 @@ public class OrganizationsIT extends AbstractRestIT {
      */
     @Test
     public void testCreateOrgUserAndReturnCorrectUsername() throws Exception {
-
-
         String username = "testCreateOrgUserAndReturnCorrectUsername"+UUIDUtils.newTimeUUID();
 
         RestClient restClient = clientSetup.getRestClient();
 
+        //Create adminUser values
         Entity adminUserPayload = new Entity();
         adminUserPayload.put( "username", username );
         adminUserPayload.put( "name", username );
         adminUserPayload.put( "email", username+"@usergrid.com" );
         adminUserPayload.put( "password", username );
 
+        //create adminUser
         Entity adminUserResponse = restClient.management().orgs().organization( clientSetup.getOrganizationName() )
                                            .users().post( adminUserPayload );
 
+        //verify that the response contains the correct data
         assertNotNull( adminUserResponse );
         assertEquals( username, adminUserResponse.get( "username" ) );
 
-        adminUserResponse = restClient.management().orgs().organization( clientSetup.getOrganizationName() )
-                                                .users().entity( username ).get();
+        //fetch the stored response
+        adminUserResponse = restClient.management().users().entity( username ).get(this.getAdminToken(username,username));
 
+        //verify that values match stored response
         assertNotNull( adminUserResponse );
         assertEquals( username , adminUserResponse.get( "username" ) );
         assertEquals( username, adminUserResponse.get( "name" ) );
-        assertEquals( username, adminUserResponse.get( "email" ));
-
-//        Map<String, String> payload = hashMap( "username", "test-user-2" ).map( "name", "Test User 2" )
-//                                                                          .map( "email", "test-user-2@mockserver.com" )
-//                                                                          .map( "password", "password" );
-//
-//        JsonNode node = mapper.readTree(
-//                resource().path( "/management/organizations/" + context.getOrgName() + "/users" )
-//                          .queryParam( "access_token", mgmtToken ).accept( MediaType.APPLICATION_JSON )
-//                          .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ) );
-//
-//        clientSetup.getRestClient().management().orgs()
-//
-//        logNode( node );
-//        assertNotNull( node );
-//
-//        String username = node.get( "data" ).get( "user" ).get( "username" ).asText();
-//        String name = node.get( "data" ).get( "user" ).get( "name" ).asText();
-//        String email = node.get( "data" ).get( "user" ).get( "email" ).asText();
-//
-//        assertNotNull( username );
-//        assertNotNull( name );
-//        assertNotNull( email );
-//
-//        assertEquals( "test-user-2", username );
-//        assertEquals( "Test User 2", name );
-//        assertEquals( "test-user-2@mockserver.com", email );
+        assertEquals( username+"@usergrid.com", adminUserResponse.get( "email" ));
+
+    }
+
+
+    /**
+     * Inserts a value into the default organization then update that value and see if the value persists.
+     * @throws Exception
+     */
+    @Test
+    public void testOrganizationUpdate() throws Exception {
+
+        RestClient restClient = clientSetup.getRestClient();
+
+        //Setup what will be interested into the organization
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put( "securityLevel", 5 );
+
+        Organization orgPayload = clientSetup.getOrganization();
+        orgPayload.put( "properties", properties );
+
+        //update the organization.
+        restClient.management().orgs().organization( clientSetup.getOrganizationName() ).put(orgPayload);
+
+        this.refreshIndex();
+
+        //retrieve the organization
+        Organization orgResponse = restClient.management().orgs().organization( clientSetup.getOrganizationName() ).get();
+
+        assertEquals( 5, orgResponse.getProperties().get( "securityLevel" ));
+
+        //update the value added to the organization
+        properties.put( "securityLevel", 6 );
+        orgPayload.put( "properties", properties );
+
+        //update the organization.
+        restClient.management().orgs().organization( clientSetup.getOrganizationName() ).put(orgPayload);
+
+        this.refreshIndex();
+
+        orgResponse = restClient.management().orgs().organization( clientSetup.getOrganizationName() ).get();
+
+        assertEquals( 6, orgResponse.getProperties().get( "securityLevel" ));
+
     }
-//
-//
-//    @Test
-//    public void testOrganizationUpdate() throws Exception {
-//        String accessToken = context.getActiveUser().getToken();
-//        Map<String, Object> properties = new HashMap<String, Object>();
-//        properties.put( "securityLevel", 5 );
-//        Map payload = new HashMap();
-//        payload.put( OrganizationsResource.ORGANIZATION_PROPERTIES, properties );
-//
-//
-//        //update the organizations
-//        mapper.readTree( resource().path( "/management/organizations/" + context.getOrgName() )
-//                                   .queryParam( "access_token", accessToken ).accept( MediaType.APPLICATION_JSON )
-//                                   .type( MediaType.APPLICATION_JSON_TYPE ).put( String.class, payload ) );
-//
-//
-//        refreshIndex( context.getOrgName(), context.getAppName() );
-//
-//        //get the organization
-//        JsonNode node = mapper.readTree( resource().path( "/management/organizations/" + context.getOrgName() )
-//                                                   .queryParam( "access_token", accessToken )
-//                                                   .accept( MediaType.APPLICATION_JSON )
-//                                                   .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ) );
-//
-//        assertEquals( 5L, node.get( "organization" ).get( "properties" ).get( "securityLevel" )
-//                              .asLong() );//orgInfo.getProperties().get( "securityLevel" ) );
-//
-//        payload = new HashMap();
-//        properties.put( "securityLevel", 6 );
-//        payload.put( OrganizationsResource.ORGANIZATION_PROPERTIES, properties );
-//
-//        node = mapper.readTree( resource().path( "/management/organizations/" + context.getOrgName() )
-//                                          .queryParam( "access_token", accessToken )
-//                                          .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-//                                          .put( String.class, payload ) );
-//        logNode( node );
-//
-//        refreshIndex( context.getOrgName(), context.getAppName() );
-//
-//        node = mapper.readTree( resource().path( "/management/organizations/" + context.getOrgName() )
-//                                          .queryParam( "access_token", accessToken )
-//                                          .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-//                                          .get( String.class ) );
-//        logNode( node );
-//        Assert.assertEquals( 6,
-//                node.get( "organization" ).get( OrganizationsResource.ORGANIZATION_PROPERTIES ).get( "securityLevel" )
-//                    .asInt() );
-//    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/860de10b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
index 52e4262..ebd1e35 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
@@ -20,7 +20,6 @@ import org.apache.usergrid.rest.test.resource2point0.endpoints.TokenResource;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.ManagementResource;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.UrlResource;
-import org.apache.usergrid.rest.test.resource2point0.model.Organization;
 import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
 
 import com.sun.jersey.api.client.Client;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/860de10b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
index 78631bb..0443695 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
@@ -37,4 +37,8 @@ public class ManagementResource extends NamedResource {
     public OrgResource orgs() {
         return new OrgResource( context, this );
     }
+
+    public UsersResource users() {
+        return new UsersResource( context, this );
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/860de10b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
index 95797f5..85451bd 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
@@ -67,6 +67,14 @@ public class OrganizationResource extends NamedResource {
         return org;
     }
 
+    //Doesn't return anything useful.
+    public void put( Organization organization ){
+        Map<String,Object> response = getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
+                                                       .accept(MediaType.APPLICATION_JSON).put( Organization.class,
+                        organization );
+
+    }
+
     public ApplicationResource app(){
         return new ApplicationResource(  context ,this );
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/860de10b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
index 3a4b2b0..346a4b0 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
@@ -61,10 +61,21 @@ public class Entity implements Serializable, Map<String,Object> {
             this.putAll(entity);
         }
         else if (response.getData() != null){
-            ArrayList<String> data = (ArrayList <String>) response.getData();
-            Entity entity = new Entity();
-            entity.put("data", data.get(0));
-            this.putAll(entity);
+            LinkedHashMap dataResponse = ( LinkedHashMap ) response.getData();
+
+            //covers case for admin users
+            if(dataResponse.get( "user" )!=null){
+                //Entity entity = new Entity();
+                //entity.put( "data", dataResponse.get( "user" ) );
+                this.putAll( ( Map<? extends String, ?> ) dataResponse.get( "user" ) );
+            }
+            else {
+                //Doesn't always type correct below.
+                //ArrayList<String> data = ( ArrayList<String> ) response.getData();
+                //Entity entity = new Entity();
+               // entity.put( "data", data.get( 0 ) );
+                this.putAll( dataResponse );
+            }
         }
     }
 
@@ -180,4 +191,8 @@ public class Entity implements Serializable, Map<String,Object> {
         put(key,value);
         return this;
     }
+
+    public ApiResponse getResponse(){
+        return response;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/860de10b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Organization.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Organization.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Organization.java
index 4e28844..5487bda 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Organization.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Organization.java
@@ -94,6 +94,9 @@ public class Organization extends Entity {
         this.user = new User( response, nameOverride);
     }
 
+    public Map<String,Object> getProperties(){
+        return (Map) this.get( "properties" );
+    }
 
     /**
      * Created specifically so that we could set the organization owner to the Organization model from a get Organization

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/860de10b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/state/ClientContext.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/state/ClientContext.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/state/ClientContext.java
index 6ebbeca..3a0e280 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/state/ClientContext.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/state/ClientContext.java
@@ -26,10 +26,6 @@ import org.apache.usergrid.rest.test.resource2point0.model.Token;
  */
 public class ClientContext {
     private Token token;
-//    private Organization organization;
-//    private User user;
-
-
 
     public Token getToken() {
         return token;
@@ -40,21 +36,4 @@ public class ClientContext {
         this.token = token;
     }
 
-//    public Organization getOrganization() {
-//        return organization;
-//    }
-//
-//
-//    public void setOrganization( final Organization organization ) {
-//        this.organization = organization;
-//    }
-//
-//    public User getUser() {
-//        return user;
-//    }
-//
-//
-//    public void setUser( final User user ) {
-//        this.user = user;
-//    }
 }


[09/50] [abbrv] incubator-usergrid git commit: Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-313

Posted by gr...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-313


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

Branch: refs/heads/two-dot-o-import
Commit: 389fb9d77999d63833057f9af26d532a69a7fac1
Parents: d2faf43 fe7719a
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Jan 6 08:38:00 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Jan 6 08:38:00 2015 -0700

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



[44/50] [abbrv] incubator-usergrid git commit: Merge branch 'USERGRID-313' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into apache_usergrid/two-dot-o

Posted by gr...@apache.org.
Merge branch 'USERGRID-313' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into apache_usergrid/two-dot-o

Conflicts:
	stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java


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

Branch: refs/heads/two-dot-o-import
Commit: 8b338b184d07932c4cfdb72e81ceffb84843185f
Parents: 1ef4325 9fcb150
Author: Rod Simpson <ro...@apigee.com>
Authored: Mon Jan 12 11:18:58 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Mon Jan 12 11:18:58 2015 -0700

----------------------------------------------------------------------
 .../users/ConnectionResourceTest.java           | 282 ++++----
 .../collection/users/OwnershipResourceIT.java   | 424 ++++++-----
 .../collection/users/PermissionsResourceIT.java | 723 +++++++------------
 .../endpoints/TokenResource.java                |   2 +-
 .../rest/test/resource2point0/model/Entity.java |   6 +-
 5 files changed, 635 insertions(+), 802 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8b338b18/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------


[49/50] [abbrv] incubator-usergrid git commit: Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o-import

Posted by gr...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6deac189/stack/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6deac189/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
index fb4260c,c48c7f6..6eae9ef
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
@@@ -17,9 -17,33 +17,11 @@@
  package org.apache.usergrid.rest.management.organizations;
  
  
 -import java.util.HashMap;
 -import java.util.Map;
 -import java.util.UUID;
 -
 -import javax.ws.rs.Consumes;
 -import javax.ws.rs.DefaultValue;
 -import javax.ws.rs.GET;
 -import javax.ws.rs.POST;
 -import javax.ws.rs.PUT;
 -import javax.ws.rs.Path;
 -import javax.ws.rs.PathParam;
 -import javax.ws.rs.Produces;
 -import javax.ws.rs.QueryParam;
 -import javax.ws.rs.core.Context;
 -import javax.ws.rs.core.MediaType;
 -import javax.ws.rs.core.Response;
 -import javax.ws.rs.core.UriInfo;
 -
 -import org.slf4j.Logger;
 -import org.slf4j.LoggerFactory;
 -import org.springframework.beans.factory.annotation.Autowired;
 -import org.springframework.context.annotation.Scope;
 -import org.springframework.stereotype.Component;
 -
 +import com.sun.jersey.api.json.JSONWithPadding;
 +import com.sun.jersey.api.view.Viewable;
  import org.apache.amber.oauth2.common.exception.OAuthSystemException;
 -import org.apache.amber.oauth2.common.message.OAuthResponse;
+ 
++import org.apache.usergrid.corepersistence.util.CpNamingUtils;
  import org.apache.usergrid.management.ActivationState;
  import org.apache.usergrid.management.OrganizationInfo;
  import org.apache.usergrid.management.export.ExportService;
@@@ -36,27 -59,15 +38,26 @@@ import org.apache.usergrid.rest.utils.J
  import org.apache.usergrid.security.oauth.ClientCredentialsInfo;
  import org.apache.usergrid.security.tokens.exceptions.TokenException;
  import org.apache.usergrid.services.ServiceResults;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +import org.springframework.beans.factory.annotation.Autowired;
 +import org.springframework.context.annotation.Scope;
 +import org.springframework.stereotype.Component;
  
 -import com.sun.jersey.api.json.JSONWithPadding;
 -import com.sun.jersey.api.view.Viewable;
 +import javax.ws.rs.*;
 +import javax.ws.rs.core.Context;
 +import javax.ws.rs.core.MediaType;
 +import javax.ws.rs.core.Response;
 +import javax.ws.rs.core.UriInfo;
 +import java.util.HashMap;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.UUID;
  
 -import static javax.servlet.http.HttpServletResponse.SC_ACCEPTED;
 -import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
 -import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
 -import static javax.servlet.http.HttpServletResponse.SC_OK;
 +import static javax.servlet.http.HttpServletResponse.*;
  import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
- import static org.apache.usergrid.corepersistence.CpEntityManagerFactory.MANAGEMENT_APPLICATION_ID;
 +import org.apache.usergrid.persistence.Entity;
 +import org.apache.usergrid.persistence.index.query.Query.Level;
  
  
  @Component("org.apache.usergrid.rest.management.organizations.OrganizationResource")
@@@ -353,111 -362,4 +354,111 @@@ public class OrganizationResource exten
  
          return Response.status( SC_OK ).entity( entity).build();
      }
 +
 +    @POST
 +    @Path("import")
 +    @Consumes(APPLICATION_JSON)
 +    @RequireOrganizationAccess
 +    public Response importPostJson( @Context UriInfo ui,Map<String, Object> json,
 +                                    @QueryParam("callback") @DefaultValue("") String callback )
 +            throws OAuthSystemException {
 +
 +        UUID jobUUID = null;
 +        Map<String, String> uuidRet = new HashMap<String, String>();
 +
 +        Map<String,Object> properties;
 +        Map<String, Object> storage_info;
 +
 +        try {
 +            if((properties = ( Map<String, Object> )  json.get( "properties" )) == null){
 +                throw new NullPointerException("Could not find 'properties'");
 +            }
 +            storage_info = ( Map<String, Object> ) properties.get( "storage_info" );
 +            String storage_provider = ( String ) properties.get( "storage_provider" );
 +            if(storage_provider == null) {
 +                throw new NullPointerException( "Could not find field 'storage_provider'" );
 +            }
 +            if(storage_info == null) {
 +                throw new NullPointerException( "Could not find field 'storage_info'" );
 +            }
 +
 +
 +            String bucketName = ( String ) storage_info.get( "bucket_location" );
 +            String accessId = ( String ) storage_info.get( "s3_access_id" );
 +            String secretKey = ( String ) storage_info.get( "s3_key" );
 +
 +            if(bucketName == null) {
 +                throw new NullPointerException( "Could not find field 'bucketName'" );
 +            }
 +            if(accessId == null) {
 +                throw new NullPointerException( "Could not find field 's3_access_id'" );
 +            }
 +            if(secretKey == null) {
 +                throw new NullPointerException( "Could not find field 's3_key'" );
 +            }
 +
 +            json.put( "organizationId",organization.getUuid());
 +
 +            jobUUID = importService.schedule( json );
 +            uuidRet.put( "Import Entity", jobUUID.toString() );
 +        }
 +        catch ( NullPointerException e ) {
 +            return Response.status( SC_BAD_REQUEST ).type( JSONPUtils.jsonMediaType( callback ) )
 +                    .entity( ServiceResource.wrapWithCallback( e.getMessage(), callback ) ).build();
 +        }
 +        catch ( Exception e ) {
 +            //TODO:throw descriptive error message and or include on in the response
 +            //TODO:fix below, it doesn't work if there is an exception. Make it look like the OauthResponse.
 +            return Response.status( SC_INTERNAL_SERVER_ERROR ).type( JSONPUtils.jsonMediaType( callback ) )
 +                    .entity( ServiceResource.wrapWithCallback( e.getMessage(), callback ) ).build();
 +        }
 +        return Response.status( SC_ACCEPTED ).entity( uuidRet ).build();
 +    }
 +
 +    @GET
 +    @RequireOrganizationAccess
 +    @Path("import/{importEntity: [A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}}")
 +    public Response importGetJson( @Context UriInfo ui, @PathParam("importEntity") UUID importEntityUUIDStr,
 +                                   @QueryParam("callback") @DefaultValue("") String callback ) throws Exception {
 +
 +        Import entity;
 +        try {
-             entity = smf.getServiceManager( MANAGEMENT_APPLICATION_ID ).getEntityManager()
++            entity = smf.getServiceManager( CpNamingUtils.MANAGEMENT_APPLICATION_ID ).getEntityManager()
 +                    .get( importEntityUUIDStr, Import.class );
 +        }
 +        catch ( Exception e ) { //this might not be a bad request and needs better error checking
 +            return Response.status( SC_BAD_REQUEST ).type( JSONPUtils.jsonMediaType( callback ) )
 +                    .entity( ServiceResource.wrapWithCallback( e.getMessage(), callback ) ).build();
 +        }
 +
 +        if ( entity == null ) {
 +            return Response.status( SC_BAD_REQUEST ).build();
 +        }
 +
 +        return Response.status( SC_OK ).entity( entity).build();
 +    }
 +
 +
 +    @GET
 +    @RequireOrganizationAccess
 +    @Path("import/{importEntity: [A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}}/includes")
 +    public Response importFileGetJson( @Context UriInfo ui, @PathParam("importEntity") UUID importEntityUUIDStr,
 +                                   @QueryParam("callback") @DefaultValue("") String callback ) throws Exception {
- 
-         List<Entity> entity;
++        //TODO: fix the below as that method no longer exists.
++        List<Entity> entity = null;
 +        try {
-             entity = smf.getServiceManager( MANAGEMENT_APPLICATION_ID ).getEntityManager()
-                     .getConnectedEntities(importEntityUUIDStr ,"includes", null, Level.ALL_PROPERTIES).getEntities();
++//            entity = smf.getServiceManager( CpNamingUtils.MANAGEMENT_APPLICATION_ID  ).getEntityManager()
++//                    .get(importEntityUUIDStr ,"includes", null, Level.ALL_PROPERTIES).getEntities();
 +        }
 +        catch ( Exception e ) { //this might not be a bad request and needs better error checking
 +            return Response.status( SC_BAD_REQUEST ).type( JSONPUtils.jsonMediaType( callback ) )
 +                    .entity( ServiceResource.wrapWithCallback( e.getMessage(), callback ) ).build();
 +        }
 +
 +        if ( entity == null ) {
 +            return Response.status( SC_BAD_REQUEST ).build();
 +        }
 +
 +        return Response.status( SC_OK ).entity( entity).build();
 +    }
  }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6deac189/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
index e054739,7bfd895..7343268
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
@@@ -35,28 -55,29 +35,38 @@@ import org.apache.usergrid.security.oau
  import org.apache.usergrid.security.providers.SignInAsProvider;
  import org.apache.usergrid.security.providers.SignInProviderFactory;
  import org.apache.usergrid.services.ServiceManager;
 +import org.springframework.beans.factory.annotation.Autowired;
 +import org.springframework.context.annotation.Scope;
 +import org.springframework.stereotype.Component;
  
 -import com.google.common.base.Preconditions;
 -import com.sun.jersey.api.json.JSONWithPadding;
 +import javax.ws.rs.*;
 +import javax.ws.rs.core.Context;
 +import javax.ws.rs.core.MediaType;
 +import javax.ws.rs.core.Response;
 +import javax.ws.rs.core.UriInfo;
 +import java.util.HashMap;
 +import java.util.Map;
 +import java.util.UUID;
  
- import static javax.servlet.http.HttpServletResponse.*;
+ import static javax.servlet.http.HttpServletResponse.SC_ACCEPTED;
+ import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
+ import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
+ import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
+ import static javax.servlet.http.HttpServletResponse.SC_OK;
  import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+ import org.apache.usergrid.persistence.EntityManager;
+ import org.apache.usergrid.persistence.core.util.Health;
  
  
  @Component("org.apache.usergrid.rest.management.organizations.applications.ApplicationResource")
  @Scope("prototype")
  @Produces({
-         MediaType.APPLICATION_JSON, "application/javascript", "application/x-javascript", "text/ecmascript",
-         "application/ecmascript", "text/jscript"
 -    MediaType.APPLICATION_JSON, 
 -    "application/javascript", 
 -    "application/x-javascript", 
++    MediaType.APPLICATION_JSON,
++    "application/javascript",
++    "application/x-javascript",
+     "text/ecmascript",
 -    "application/ecmascript", 
++    "application/ecmascript",
+     "text/jscript"
  })
  public class ApplicationResource extends AbstractContextResource {
  
@@@ -95,10 -112,9 +105,9 @@@
  
      @RequireOrganizationAccess
      @DELETE
-     public JSONWithPadding deleteApplicationFromOrganizationByApplicationId( @Context UriInfo ui,
-                                                                              @QueryParam("callback")
-                                                                              @DefaultValue("callback") String callback )
-             throws Exception {
 -    public JSONWithPadding deleteApplicationFromOrganizationByApplicationId( 
++    public JSONWithPadding deleteApplicationFromOrganizationByApplicationId(
+             @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback )
+         throws Exception {
  
          ApiResponse response = createApiResponse();
          response.setAction( "delete application from organization" );
@@@ -111,9 -127,9 +120,9 @@@
  
      @RequireOrganizationAccess
      @GET
-     public JSONWithPadding getApplication( @Context UriInfo ui,
-                                            @QueryParam("callback") @DefaultValue("callback") String callback )
-             throws Exception {
 -    public JSONWithPadding getApplication( 
++    public JSONWithPadding getApplication(
+             @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback )
+         throws Exception {
  
          ApiResponse response = createApiResponse();
          ServiceManager sm = smf.getServiceManager( applicationId );
@@@ -128,9 -144,9 +137,9 @@@
      @RequireOrganizationAccess
      @GET
      @Path("credentials")
-     public JSONWithPadding getCredentials( @Context UriInfo ui,
-                                            @QueryParam("callback") @DefaultValue("callback") String callback )
-             throws Exception {
 -    public JSONWithPadding getCredentials( 
++    public JSONWithPadding getCredentials(
+             @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback )
+         throws Exception {
  
          ApiResponse response = createApiResponse();
          response.setAction( "get application client credentials" );
@@@ -147,9 -163,9 +156,9 @@@
      @RequireOrganizationAccess
      @POST
      @Path("credentials")
 -    public JSONWithPadding generateCredentials( @Context UriInfo ui, 
 +    public JSONWithPadding generateCredentials( @Context UriInfo ui,
-                                                 @QueryParam("callback") @DefaultValue("callback") String callback )
-             throws Exception {
+             @QueryParam("callback") @DefaultValue("callback") String callback )
+         throws Exception {
  
          ApiResponse response = createApiResponse();
          response.setAction( "generate application client credentials" );
@@@ -167,10 -183,13 +176,13 @@@
      @Path("sia-provider")
      @Consumes(APPLICATION_JSON)
      @RequireOrganizationAccess
-     public JSONWithPadding configureProvider( @Context UriInfo ui, @QueryParam("provider_key") String siaProvider,
-                                               Map<String, Object> json,
-                                               @QueryParam("callback") @DefaultValue("") String callback )
-             throws Exception {
 -    public JSONWithPadding configureProvider( 
 -            @Context UriInfo ui, 
++    public JSONWithPadding configureProvider(
++            @Context UriInfo ui,
+             @QueryParam("provider_key") String siaProvider,
 -            Map<String, Object> json, 
 -            @QueryParam("callback") 
++            Map<String, Object> json,
++            @QueryParam("callback")
+             @DefaultValue("") String callback )
+         throws Exception {
  
          ApiResponse response = createApiResponse();
          response.setAction( "post signin provider configuration" );
@@@ -179,20 -198,20 +191,20 @@@
  
          SignInAsProvider signInAsProvider = null;
          if ( StringUtils.equalsIgnoreCase( siaProvider, "facebook" ) ) {
-             signInAsProvider =
-                     signInProviderFactory.facebook( smf.getServiceManager( applicationId ).getApplication() );
 -            signInAsProvider = signInProviderFactory.facebook( 
++            signInAsProvider = signInProviderFactory.facebook(
+                     smf.getServiceManager( applicationId ).getApplication() );
          }
          else if ( StringUtils.equalsIgnoreCase( siaProvider, "pingident" ) ) {
-             signInAsProvider =
-                     signInProviderFactory.pingident( smf.getServiceManager( applicationId ).getApplication() );
 -            signInAsProvider = signInProviderFactory.pingident( 
++            signInAsProvider = signInProviderFactory.pingident(
+                     smf.getServiceManager( applicationId ).getApplication() );
          }
          else if ( StringUtils.equalsIgnoreCase( siaProvider, "foursquare" ) ) {
-             signInAsProvider =
-                     signInProviderFactory.foursquare( smf.getServiceManager( applicationId ).getApplication() );
 -            signInAsProvider = signInProviderFactory.foursquare( 
++            signInAsProvider = signInProviderFactory.foursquare(
+                     smf.getServiceManager( applicationId ).getApplication() );
          }
  
-         Preconditions
-                 .checkArgument( signInAsProvider != null, "No signin provider found by that name: " + siaProvider );
 -        Preconditions.checkArgument( signInAsProvider != null, 
++        Preconditions.checkArgument( signInAsProvider != null,
+                 "No signin provider found by that name: " + siaProvider );
  
          signInAsProvider.saveToConfiguration( json );
  
@@@ -249,14 -271,17 +261,17 @@@
              uuidRet.put( "Export Entity", jobUUID.toString() );
          }
          catch ( NullPointerException e ) {
-             return Response.status( SC_BAD_REQUEST ).type( JSONPUtils.jsonMediaType( callback ) )
-                            .entity( ServiceResource.wrapWithCallback( e.getMessage(), callback ) ).build();
+             return Response.status( SC_BAD_REQUEST )
+                 .type( JSONPUtils.jsonMediaType( callback ) )
+                 .entity( ServiceResource.wrapWithCallback( e.getMessage(), callback ) ).build();
          }
          catch ( Exception e ) {
-             //TODO:throw descriptive error message and or include on in the response
-             //TODO:fix below, it doesn't work if there is an exception. Make it look like the OauthResponse.
-             return Response.status( SC_INTERNAL_SERVER_ERROR ).type( JSONPUtils.jsonMediaType( callback ) )
-                                        .entity( ServiceResource.wrapWithCallback( e.getMessage(), callback ) ).build();
+             // TODO: throw descriptive error message and or include on in the response
 -            // TODO: fix below, it doesn't work if there is an exception. 
++            // TODO: fix below, it doesn't work if there is an exception.
+             // Make it look like the OauthResponse.
+             return Response.status( SC_INTERNAL_SERVER_ERROR )
+                 .type( JSONPUtils.jsonMediaType( callback ) )
+                 .entity( ServiceResource.wrapWithCallback( e.getMessage(), callback ) ).build();
          }
  
          return Response.status( SC_ACCEPTED ).entity( uuidRet ).build();
@@@ -266,10 -291,13 +281,11 @@@
      @Path("collection/{collection_name}/export")
      @Consumes(APPLICATION_JSON)
      @RequireOrganizationAccess
-     public Response exportPostJson( @Context UriInfo ui,@PathParam( "collection_name" ) String collection_name ,Map<String, Object> json,
-                                     @QueryParam("callback") @DefaultValue("") String callback )
+     public Response exportPostJson( @Context UriInfo ui,
+             @PathParam( "collection_name" ) String collection_name ,Map<String, Object> json,
+             @QueryParam("callback") @DefaultValue("") String callback )
              throws OAuthSystemException {
  
 -
 -        OAuthResponse response = null;
          UUID jobUUID = null;
          String colExport = collection_name;
          Map<String, String> uuidRet = new HashMap<String, String>();
@@@ -313,148 -341,53 +329,181 @@@
              uuidRet.put( "Export Entity", jobUUID.toString() );
          }
          catch ( NullPointerException e ) {
-             return Response.status( SC_BAD_REQUEST ).type( JSONPUtils.jsonMediaType( callback ) )
-                            .entity( ServiceResource.wrapWithCallback( e.getMessage(), callback ) ).build();
+             return Response.status( SC_BAD_REQUEST )
+                 .type( JSONPUtils.jsonMediaType( callback ) )
+                 .entity( ServiceResource.wrapWithCallback( e.getMessage(), callback ) )
+                 .build();
          }
          catch ( Exception e ) {
-             //TODO:throw descriptive error message and or include on in the response
-             //TODO:fix below, it doesn't work if there is an exception. Make it look like the OauthResponse.
-             OAuthResponse errorMsg =
-                     OAuthResponse.errorResponse( SC_INTERNAL_SERVER_ERROR ).setErrorDescription( e.getMessage() )
-                                  .buildJSONMessage();
-             return Response.status( errorMsg.getResponseStatus() ).type( JSONPUtils.jsonMediaType( callback ) )
-                            .entity( ServiceResource.wrapWithCallback( errorMsg.getBody(), callback ) ).build();
+ 
+             // TODO: throw descriptive error message and or include on in the response
 -            // TODO: fix below, it doesn't work if there is an exception.  
++            // TODO: fix below, it doesn't work if there is an exception.
+             // Make it look like the OauthResponse.
+ 
+             OAuthResponse errorMsg = OAuthResponse.errorResponse( SC_INTERNAL_SERVER_ERROR )
+                 .setErrorDescription( e.getMessage() )
+                 .buildJSONMessage();
+ 
+             return Response.status( errorMsg.getResponseStatus() )
+                 .type( JSONPUtils.jsonMediaType( callback ) )
+                 .entity( ServiceResource.wrapWithCallback( errorMsg.getBody(), callback ) )
+                 .build();
          }
  
          return Response.status( SC_ACCEPTED ).entity( uuidRet ).build();
      }
  
 +    @POST
 +    @Path("import")
 +    @Consumes(APPLICATION_JSON)
 +    @RequireOrganizationAccess
 +    public Response importPostJson( @Context UriInfo ui,Map<String, Object> json,
 +                                    @QueryParam("callback") @DefaultValue("") String callback )
 +            throws OAuthSystemException {
 +
 +        UUID jobUUID = null;
 +        Map<String, String> uuidRet = new HashMap<String, String>();
 +
 +        Map<String,Object> properties;
 +        Map<String, Object> storage_info;
 +
 +        try {
 +            if((properties = ( Map<String, Object> )  json.get( "properties" )) == null){
 +                throw new NullPointerException("Could not find 'properties'");
 +            }
 +            storage_info = ( Map<String, Object> ) properties.get( "storage_info" );
 +            String storage_provider = ( String ) properties.get( "storage_provider" );
 +            if(storage_provider == null) {
 +                throw new NullPointerException( "Could not find field 'storage_provider'" );
 +            }
 +            if(storage_info == null) {
 +                throw new NullPointerException( "Could not find field 'storage_info'" );
 +            }
 +
 +
 +            String bucketName = ( String ) storage_info.get( "bucket_location" );
 +            String accessId = ( String ) storage_info.get( "s3_access_id" );
 +            String secretKey = ( String ) storage_info.get( "s3_key" );
 +
 +            if(bucketName == null) {
 +                throw new NullPointerException( "Could not find field 'bucketName'" );
 +            }
 +            if(accessId == null) {
 +                throw new NullPointerException( "Could not find field 's3_access_id'" );
 +            }
 +            if(secretKey == null) {
 +                throw new NullPointerException( "Could not find field 's3_key'" );
 +            }
 +
 +            json.put( "organizationId",organization.getUuid());
 +            json.put( "applicationId",applicationId);
 +
 +            jobUUID = importService.schedule( json );
 +            uuidRet.put( "Import Entity", jobUUID.toString() );
 +        }
 +        catch ( NullPointerException e ) {
 +            return Response.status( SC_BAD_REQUEST ).type( JSONPUtils.jsonMediaType( callback ) )
 +                    .entity( ServiceResource.wrapWithCallback( e.getMessage(), callback ) ).build();
 +        }
 +        catch ( Exception e ) {
 +            //TODO:throw descriptive error message and or include on in the response
 +            //TODO:fix below, it doesn't work if there is an exception. Make it look like the OauthResponse.
 +            return Response.status( SC_INTERNAL_SERVER_ERROR ).type( JSONPUtils.jsonMediaType( callback ) )
 +                    .entity( ServiceResource.wrapWithCallback( e.getMessage(), callback ) ).build();
 +        }
 +
 +        return Response.status( SC_ACCEPTED ).entity( uuidRet ).build();
 +    }
 +
 +    @POST
 +    @Path("collection/{collection_name}/import")
 +    @Consumes(APPLICATION_JSON)
 +    @RequireOrganizationAccess
 +    public Response importPostJson( @Context UriInfo ui,@PathParam( "collection_name" ) String collection_name ,Map<String, Object> json,
 +                                    @QueryParam("callback") @DefaultValue("") String callback )
 +            throws OAuthSystemException {
 +
 +        UUID jobUUID = null;
 +        String colImport = collection_name;
 +        Map<String, String> uuidRet = new HashMap<String, String>();
 +
-         Map<String,Object> properties;
++        Map<String, Object> properties;
 +        Map<String, Object> storage_info;
 +
 +        try {
 +            //checkJsonExportProperties(json);
-             if((properties = ( Map<String, Object> )  json.get( "properties" )) == null){
-                 throw new NullPointerException("Could not find 'properties'");
++            if ( ( properties = ( Map<String, Object> ) json.get( "properties" ) ) == null ) {
++                throw new NullPointerException( "Could not find 'properties'" );
 +            }
 +            storage_info = ( Map<String, Object> ) properties.get( "storage_info" );
 +            String storage_provider = ( String ) properties.get( "storage_provider" );
-             if(storage_provider == null) {
++            if ( storage_provider == null ) {
 +                throw new NullPointerException( "Could not find field 'storage_provider'" );
 +            }
-             if(storage_info == null) {
++            if ( storage_info == null ) {
 +                throw new NullPointerException( "Could not find field 'storage_info'" );
 +            }
 +
 +
 +            String bucketName = ( String ) storage_info.get( "bucket_location" );
 +            String accessId = ( String ) storage_info.get( "s3_access_id" );
 +            String secretKey = ( String ) storage_info.get( "s3_key" );
 +
-             if(bucketName == null) {
++            if ( bucketName == null ) {
 +                throw new NullPointerException( "Could not find field 'bucketName'" );
 +            }
-             if(accessId == null) {
++            if ( accessId == null ) {
 +                throw new NullPointerException( "Could not find field 's3_access_id'" );
 +            }
-             if(secretKey == null) {
++            if ( secretKey == null ) {
 +                throw new NullPointerException( "Could not find field 's3_key'" );
 +            }
-             json.put( "organizationId",organization.getUuid() );
-             json.put( "applicationId", applicationId);
-             json.put( "collectionName", colImport);
++            json.put( "organizationId", organization.getUuid() );
++            json.put( "applicationId", applicationId );
++            json.put( "collectionName", colImport );
 +
 +            jobUUID = importService.schedule( json );
 +            uuidRet.put( "Import Entity", jobUUID.toString() );
 +        }
 +        catch ( NullPointerException e ) {
 +            return Response.status( SC_BAD_REQUEST ).type( JSONPUtils.jsonMediaType( callback ) )
-                     .entity( ServiceResource.wrapWithCallback( e.getMessage(), callback ) ).build();
++                           .entity( ServiceResource.wrapWithCallback( e.getMessage(), callback ) ).build();
 +        }
 +        catch ( Exception e ) {
 +            //TODO:throw descriptive error message and or include on in the response
 +            //TODO:fix below, it doesn't work if there is an exception. Make it look like the OauthResponse.
-             OAuthResponse errorMsg =
-                     OAuthResponse.errorResponse( SC_INTERNAL_SERVER_ERROR ).setErrorDescription( e.getMessage() )
-                             .buildJSONMessage();
++            OAuthResponse errorMsg = OAuthResponse.errorResponse( SC_INTERNAL_SERVER_ERROR ).setErrorDescription( e.getMessage() )
++                                                  .buildJSONMessage();
 +            return Response.status( errorMsg.getResponseStatus() ).type( JSONPUtils.jsonMediaType( callback ) )
-                     .entity( ServiceResource.wrapWithCallback( errorMsg.getBody(), callback ) ).build();
++                           .entity( ServiceResource.wrapWithCallback( errorMsg.getBody(), callback ) ).build();
 +        }
 +
 +        return Response.status( SC_ACCEPTED ).entity( uuidRet ).build();
 +    }
++
+     @GET
+     @Path("/status")
+     public Response getStatus() {
+ 
+         Map<String, Object> statusMap = new HashMap<String, Object>();
+ 
+         EntityManager em = emf.getEntityManager( applicationId );
+         if ( !em.getIndexHealth().equals( Health.RED ) ) {
+             statusMap.put("message", "Index Health Status RED for application " + applicationId );
+             return Response.status( SC_INTERNAL_SERVER_ERROR ).entity( statusMap ).build();
+         }
+ 
+         try {
+             if ( em.getApplication() == null ) {
 -                statusMap.put("message", "Appliction " + applicationId + " not found");
++                statusMap.put("message", "Application " + applicationId + " not found");
+                 return Response.status( SC_NOT_FOUND ).entity( statusMap ).build();
+             }
+ 
+         } catch (Exception ex) {
 -            statusMap.put("message", "Error looking up appliction " + applicationId );
++            statusMap.put("message", "Error looking up application " + applicationId );
+             return Response.status( SC_INTERNAL_SERVER_ERROR ).entity( statusMap ).build();
+         }
 -            
++
+         return Response.status( SC_OK ).entity( null ).build();
+     }
  }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6deac189/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6deac189/stack/services/src/main/java/org/apache/usergrid/management/importer/FileImportJob.java
----------------------------------------------------------------------
diff --cc stack/services/src/main/java/org/apache/usergrid/management/importer/FileImportJob.java
index f5f8ac0,0000000..e6d81c9
mode 100644,000000..100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/importer/FileImportJob.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/importer/FileImportJob.java
@@@ -1,109 -1,0 +1,109 @@@
 +/*
 + * 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.management.importer;
 +
 +import org.apache.usergrid.batch.JobExecution;
 +import org.apache.usergrid.batch.job.OnlyOnceJob;
++import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 +import org.apache.usergrid.persistence.Entity;
 +import org.apache.usergrid.persistence.EntityManager;
 +import org.apache.usergrid.persistence.EntityManagerFactory;
 +import org.apache.usergrid.persistence.Results;
 +import org.apache.usergrid.persistence.entities.FileImport;
 +import org.apache.usergrid.persistence.entities.Import;
 +import org.apache.usergrid.persistence.entities.JobData;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +import org.springframework.beans.factory.annotation.Autowired;
 +import org.springframework.stereotype.Component;
 +import java.util.List;
 +import java.util.UUID;
- import static org.apache.usergrid.corepersistence.CpEntityManagerFactory.MANAGEMENT_APPLICATION_ID;
 +import org.apache.usergrid.persistence.index.query.Query.Level;
 +
 +
 +@Component("fileImportJob")
 +public class FileImportJob extends OnlyOnceJob {
 +
 +    public static final String FILE_IMPORT_ID = "fileImportId";
 +    private static final Logger logger = LoggerFactory.getLogger(FileImportJob.class);
 +
 +    // injected the Entity Manager Factory
 +    protected EntityManagerFactory emf;
 +
 +    @Autowired
 +    ImportService importService;
 +
 +    public FileImportJob() {
 +        logger.info( "FileImportJob created " + this );
 +    }
 +
 +    @Override
 +    protected void doJob(JobExecution jobExecution) throws Exception {
 +        logger.info( "execute FileImportJob {}", jobExecution );
 +
 +        JobData jobData = jobExecution.getJobData();
 +        if ( jobData == null ) {
 +            logger.error( "jobData cannot be null" );
 +            return;
 +        }
 +
 +        // heartbeat to indicate job has started
 +        jobExecution.heartbeat();
 +
 +        // call the File Parser for the file set in job execution
 +        importService.FileParser( jobExecution );
 +
 +        logger.error("File Import Service completed job");
 +    }
 +
 +    @Override
 +    protected long getDelay(JobExecution execution) throws Exception {
 +        return 100;
 +    }
 +
 +    @Autowired
 +    public void setImportService( final ImportService importService ) {
 +        this.importService = importService;
 +    }
 +
 +    /**
 +     * This method is called when the job is retried maximum times by the scheduler but still fails.
 +     * Thus the scheduler marks it as DEAD.
 +     */
 +    @Override
 +    public void dead( final JobExecution execution ) throws Exception {
 +
 +        // Get the root entity manager
-         EntityManager rootEm = emf.getEntityManager(MANAGEMENT_APPLICATION_ID);
++        EntityManager rootEm = emf.getEntityManager( CpNamingUtils.MANAGEMENT_APPLICATION_ID);
 +
 +        // Mark the sub-job i.e. File Import Job as Failed
 +        FileImport fileImport = importService.getFileImportEntity(execution);
 +        fileImport.setErrorMessage("The Job has been tried maximum times but still failed");
 +        fileImport.setState(FileImport.State.FAILED);
 +        rootEm.update(fileImport);
 +
 +        // If one file Job fails, mark the main import Job also as failed
-         Results ImportJobResults = rootEm.getConnectingEntities( 
++        Results ImportJobResults = rootEm.getConnectingEntities(
 +                fileImport, "includes", null, Level.ALL_PROPERTIES);
 +        List<Entity> importEntity = ImportJobResults.getEntities();
 +        UUID importId = importEntity.get(0).getUuid();
 +        Import importUG = rootEm.get(importId, Import.class);
 +        importUG.setState(Import.State.FAILED);
 +        rootEm.update(importUG);
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6deac189/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportJob.java
----------------------------------------------------------------------
diff --cc stack/services/src/main/java/org/apache/usergrid/management/importer/ImportJob.java
index cab6a37,0000000..77fdc56
mode 100644,000000..100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportJob.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportJob.java
@@@ -1,91 -1,0 +1,92 @@@
 +/*
 + * 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.management.importer;
 +
 +import org.apache.usergrid.batch.JobExecution;
 +import org.apache.usergrid.batch.job.OnlyOnceJob;
- import static org.apache.usergrid.corepersistence.CpEntityManagerFactory.MANAGEMENT_APPLICATION_ID;
++
++import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 +import org.apache.usergrid.persistence.EntityManager;
 +import org.apache.usergrid.persistence.EntityManagerFactory;
 +import org.apache.usergrid.persistence.entities.Import;
 +import org.apache.usergrid.persistence.entities.JobData;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +import org.springframework.beans.factory.annotation.Autowired;
 +import org.springframework.stereotype.Component;
 +
 +
 +@Component("importJob")
 +public class ImportJob extends OnlyOnceJob {
 +
 +    public static final String IMPORT_ID = "importId";
 +    private static final Logger logger = LoggerFactory.getLogger(ImportJob.class);
 +
 +    //injected the Entity Manager Factory
 +    protected EntityManagerFactory emf;
 +    @Autowired
 +    ImportService importService;
 +
 +    public ImportJob() {
 +        logger.info( "ImportJob created " + this );
 +    }
 +
 +    @Override
 +    protected void doJob(JobExecution jobExecution) throws Exception {
 +        logger.info( "execute ImportJob {}", jobExecution );
 +
 +        JobData jobData = jobExecution.getJobData();
 +        if ( jobData == null ) {
 +            logger.error( "jobData cannot be null" );
 +            return;
 +        }
 +
 +        // heartbeat to indicate job has started
 +        jobExecution.heartbeat();
 +
 +        // call the doImport method from import service which schedules the sub-jobs i.e. parsing of files to FileImport Job
 +        importService.doImport( jobExecution );
 +
 +        logger.error("Import Service completed job");
 +    }
 +
 +    @Override
 +    protected long getDelay(JobExecution execution) throws Exception {
 +        return 100;
 +    }
 +
 +    @Autowired
 +    public void setImportService( final ImportService importService ) {
 +        this.importService = importService;
 +    }
 +
 +    /*
 +    This method is called when the job is retried maximum times by the scheduler but still fails. Thus the scheduler marks it as DEAD.
 +     */
 +    @Override
 +    public void dead( final JobExecution execution ) throws Exception {
 +
 +        // marks the job as failed as it will not be retried by the scheduler.
-         EntityManager rootEm = emf.getEntityManager(MANAGEMENT_APPLICATION_ID);
++        EntityManager rootEm = emf.getEntityManager( CpNamingUtils.MANAGEMENT_APPLICATION_ID);
 +        Import importUG = importService.getImportEntity(execution);
 +        importUG.setErrorMessage("The Job has been tried maximum times but still failed");
 +        importUG.setState(Import.State.FAILED);
 +        rootEm.update(importUG);
 +
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6deac189/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
----------------------------------------------------------------------
diff --cc stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
index 400439a,0000000..44bdd06
mode 100644,000000..100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
@@@ -1,977 -1,0 +1,977 @@@
 +/*
 + * 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.management.importer;
 +
 +import org.apache.usergrid.batch.JobExecution;
 +import org.apache.usergrid.batch.service.SchedulerService;
++import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 +import org.apache.usergrid.management.ApplicationInfo;
 +import org.apache.usergrid.management.ManagementService;
 +import org.apache.usergrid.management.OrganizationInfo;
 +import org.apache.usergrid.persistence.*;
 +import org.apache.usergrid.persistence.entities.FileImport;
 +import org.apache.usergrid.persistence.entities.Import;
 +import org.apache.usergrid.persistence.entities.JobData;
 +import org.codehaus.jackson.JsonFactory;
 +import org.codehaus.jackson.JsonParseException;
 +import org.codehaus.jackson.JsonParser;
 +import org.codehaus.jackson.JsonToken;
 +import org.codehaus.jackson.map.ObjectMapper;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +import rx.Observable;
 +import rx.Subscriber;
 +import rx.functions.Action1;
 +import rx.functions.Func1;
 +import rx.schedulers.Schedulers;
 +
 +import java.io.File;
 +import java.io.IOException;
 +import java.util.*;
 +import java.util.concurrent.atomic.AtomicLong;
- import static org.apache.usergrid.corepersistence.CpEntityManagerFactory.MANAGEMENT_APPLICATION_ID;
 +import org.apache.usergrid.persistence.index.query.Query.Level;
 +
 +
 +public class ImportServiceImpl implements ImportService {
 +
 +    public static final String IMPORT_ID = "importId";
 +    public static final String IMPORT_JOB_NAME = "importJob";
 +    public static final String FILE_IMPORT_ID = "fileImportId";
 +    public static final String FILE_IMPORT_JOB_NAME = "fileImportJob";
 +
 +    //Amount of time that has passed before sending another heart beat in millis
 +    public static final int TIMESTAMP_DELTA = 5000;
 +
 +    private static final Logger logger = LoggerFactory.getLogger(ImportServiceImpl.class);
 +
 +    //injected the Entity Manager Factory
 +    protected EntityManagerFactory emf;
 +    private ArrayList<File> files;
 +
 +    //dependency injection
 +    private SchedulerService sch;
 +
 +    //inject Management Service to access Organization Data
 +    private ManagementService managementService;
 +    private JsonFactory jsonFactory = new JsonFactory();
 +
 +    private int entityCount = 0;
 +
 +    /**
 +     * This schedules the main import Job
 +     *
 +     * @param config configuration of the job to be scheduled
 +     * @return it returns the UUID of the scheduled job
 +     * @throws Exception
 +     */
 +    @Override
 +    public UUID schedule(Map<String, Object> config) throws Exception {
 +
 +        if (config == null) {
 +            logger.error("import information cannot be null");
 +            return null;
 +        }
 +
 +        EntityManager rootEm = null;
 +        try {
-             rootEm = emf.getEntityManager(MANAGEMENT_APPLICATION_ID);
++            rootEm = emf.getEntityManager( CpNamingUtils.MANAGEMENT_APPLICATION_ID);
 +            Set<String> collections = rootEm.getApplicationCollections();
 +            if (!collections.contains("imports")) {
 +                rootEm.createApplicationCollection("imports");
 +            }
 +        } catch (Exception e) {
 +            logger.error("application doesn't exist within the current context");
 +            return null;
 +        }
 +
 +        Import importUG = new Import();
 +
 +        // create the import entity to store all metadata about the import job
 +        try {
 +            importUG = rootEm.create(importUG);
 +        } catch (Exception e) {
 +            logger.error("Import entity creation failed");
 +            return null;
 +        }
 +
 +        // update state for import job to created
 +        importUG.setState(Import.State.CREATED);
 +        rootEm.update(importUG);
 +
 +        // set data to be transferred to importInfo
 +        JobData jobData = new JobData();
 +        jobData.setProperty("importInfo", config);
 +        jobData.setProperty(IMPORT_ID, importUG.getUuid());
 +
 +        long soonestPossible = System.currentTimeMillis() + 250; //sch grace period
 +
 +        // schedule import job
 +        sch.createJob(IMPORT_JOB_NAME, soonestPossible, jobData);
 +
 +        // update state for import job to created
 +        importUG.setState(Import.State.SCHEDULED);
 +        rootEm.update(importUG);
 +
 +        return importUG.getUuid();
 +    }
 +
 +    /**
 +     * This schedules the sub  FileImport Job
 +     *
 +     * @param file file to be scheduled
 +     * @return it returns the UUID of the scheduled job
 +     * @throws Exception
 +     */
 +    public UUID scheduleFile(String file, EntityRef importRef) throws Exception {
 +
 +        EntityManager rootEm = null;
 +
 +        try {
-             rootEm = emf.getEntityManager(MANAGEMENT_APPLICATION_ID);
++            rootEm = emf.getEntityManager(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
 +        } catch (Exception e) {
 +            logger.error("application doesn't exist within the current context");
 +            return null;
 +        }
 +
 +        // create a FileImport entity to store metadata about the fileImport job
 +        FileImport fileImport = new FileImport();
 +
 +        fileImport.setFileName(file);
 +        fileImport.setCompleted(false);
 +        fileImport.setLastUpdatedUUID(" ");
 +        fileImport.setErrorMessage(" ");
 +        fileImport.setState(FileImport.State.CREATED);
 +        fileImport = rootEm.create(fileImport);
 +
 +        Import importUG = rootEm.get(importRef, Import.class);
 +
 +        try {
 +            // create a connection between the main import job and the sub FileImport Job
 +            rootEm.createConnection(importUG, "includes", fileImport);
 +        } catch (Exception e) {
 +            logger.error(e.getMessage());
 +            return null;
 +        }
 +
 +        // mark the File Import Job as created
 +        fileImport.setState(FileImport.State.CREATED);
 +        rootEm.update(fileImport);
 +
 +        //set data to be transferred to the FileImport Job
 +        JobData jobData = new JobData();
 +        jobData.setProperty("File", file);
 +        jobData.setProperty(FILE_IMPORT_ID, fileImport.getUuid());
 +
 +        long soonestPossible = System.currentTimeMillis() + 250; //sch grace period
 +
 +        //schedule file import job
 +        sch.createJob(FILE_IMPORT_JOB_NAME, soonestPossible, jobData);
 +
 +        //update state of the job to Scheduled
 +        fileImport.setState(FileImport.State.SCHEDULED);
 +        rootEm.update(fileImport);
 +
 +        return fileImport.getUuid();
 +    }
 +
 +    /**
 +     * Query Entity Manager for the state of the Import Entity. This corresponds to the GET /import
 +     *
 +     * @return String
 +     */
 +    @Override
 +    public String getState(UUID uuid) throws Exception {
 +        if (uuid == null) {
 +            logger.error("UUID passed in cannot be null.");
 +            return "UUID passed in cannot be null";
 +        }
 +
-         EntityManager rootEm = emf.getEntityManager(MANAGEMENT_APPLICATION_ID);
++        EntityManager rootEm = emf.getEntityManager(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
 +
 +        //retrieve the import entity.
 +        Import importUG = rootEm.get(uuid, Import.class);
 +
 +        if (importUG == null) {
 +            logger.error("no entity with that uuid was found");
 +            return "No Such Element found";
 +        }
 +        return importUG.getState().toString();
 +    }
 +
 +    /**
 +     * Query Entity Manager for the error message generated for an import job.
 +     *
 +     * @return String
 +     */
 +    @Override
 +    public String getErrorMessage(final UUID uuid) throws Exception {
 +
 +        //get application entity manager
 +
 +        if (uuid == null) {
 +            logger.error("UUID passed in cannot be null.");
 +            return "UUID passed in cannot be null";
 +        }
 +
-         EntityManager rootEm = emf.getEntityManager(MANAGEMENT_APPLICATION_ID);
++        EntityManager rootEm = emf.getEntityManager(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
 +
 +        //retrieve the import entity.
 +        Import importUG = rootEm.get(uuid, Import.class);
 +
 +        if (importUG == null) {
 +            logger.error("no entity with that uuid was found");
 +            return "No Such Element found";
 +        }
 +        return importUG.getErrorMessage().toString();
 +    }
 +
 +    /**
 +     * Returns the Import Entity that stores all meta-data for the particular import Job
 +     * @param jobExecution the import job details
 +     * @return Import Entity
 +     * @throws Exception
 +     */
 +    @Override
 +    public Import getImportEntity(final JobExecution jobExecution) throws Exception {
 +
 +        UUID importId = (UUID) jobExecution.getJobData().getProperty(IMPORT_ID);
-         EntityManager importManager = emf.getEntityManager(MANAGEMENT_APPLICATION_ID);
++        EntityManager importManager = emf.getEntityManager(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
 +
 +        return importManager.get(importId, Import.class);
 +    }
 +
 +
 +    /**
 +     * Returns the File Import Entity that stores all meta-data for the particular sub File import Job
 +     * @param jobExecution the file import job details
 +     * @return File Import Entity
 +     * @throws Exception
 +     */
 +    @Override
 +    public FileImport getFileImportEntity(final JobExecution jobExecution) throws Exception {
 +
 +        UUID fileImportId = (UUID) jobExecution.getJobData().getProperty(FILE_IMPORT_ID);
-         EntityManager em = emf.getEntityManager(MANAGEMENT_APPLICATION_ID);
++        EntityManager em = emf.getEntityManager(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
 +
 +        return em.get(fileImportId, FileImport.class);
 +    }
 +
 +    /**
 +     * This returns the temporary files downloaded form s3
 +     */
 +    @Override
 +    public ArrayList<File> getEphemeralFile() {
 +        return files;
 +    }
 +
 +    public SchedulerService getSch() {
 +        return sch;
 +    }
 +
 +
 +    public void setSch(final SchedulerService sch) {
 +        this.sch = sch;
 +    }
 +
 +
 +    public EntityManagerFactory getEmf() {
 +        return emf;
 +    }
 +
 +
 +    public void setEmf(final EntityManagerFactory emf) {
 +        this.emf = emf;
 +    }
 +
 +
 +    public ManagementService getManagementService() {
 +
 +        return managementService;
 +    }
 +
 +
 +    public void setManagementService(final ManagementService managementService) {
 +        this.managementService = managementService;
 +    }
 +
 +    /**
 +     * This method gets the files from s3 and also creates sub-jobs for each file i.e. File Import Jobs
 +     * @param jobExecution the job created by the scheduler with all the required config data
 +     * @throws Exception
 +     */
 +    @Override
 +    public void doImport(JobExecution jobExecution) throws Exception {
 +
 +        Map<String, Object> config = (Map<String, Object>) jobExecution.getJobData().getProperty("importInfo");
 +        Object s3PlaceHolder = jobExecution.getJobData().getProperty("s3Import");
 +        S3Import s3Import = null;
 +
 +        if (config == null) {
 +            logger.error("Import Information passed through is null");
 +            return;
 +        }
 +
 +        //get the entity manager for the application, and the entity that this Import corresponds to.
 +        UUID importId = (UUID) jobExecution.getJobData().getProperty(IMPORT_ID);
 +
-         EntityManager rooteEm = emf.getEntityManager(MANAGEMENT_APPLICATION_ID);
++        EntityManager rooteEm = emf.getEntityManager(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
 +        Import importUG = rooteEm.get(importId, Import.class);
 +
 +        //update the entity state to show that the job has officially started.
 +        importUG.setState(Import.State.STARTED);
 +        importUG.setStarted(System.currentTimeMillis());
 +        importUG.setErrorMessage(" ");
 +        rooteEm.update(importUG);
 +        try {
 +            if (s3PlaceHolder != null) {
 +                s3Import = (S3Import) s3PlaceHolder;
 +            } else {
 +                s3Import = new S3ImportImpl();
 +            }
 +        } catch (Exception e) {
 +            logger.error("S3Import doesn't exist");
 +            importUG.setErrorMessage(e.getMessage());
 +            importUG.setState(Import.State.FAILED);
 +            rooteEm.update(importUG);
 +            return;
 +        }
 +
 +        try {
 +
 +            if (config.get("organizationId") == null) {
 +                logger.error("No organization could be found");
 +                importUG.setErrorMessage("No organization could be found");
 +                importUG.setState(Import.State.FAILED);
 +                rooteEm.update(importUG);
 +                return;
 +            } else if (config.get("applicationId") == null) {
 +                //import All the applications from an organization
 +                importApplicationsFromOrg((UUID) config.get("organizationId"), config, jobExecution, s3Import);
 +            } else if (config.get("collectionName") == null) {
 +                //imports an Application from a single organization
 +                importApplicationFromOrg((UUID) config.get("organizationId"), (UUID) config.get("applicationId"), config, jobExecution, s3Import);
 +            } else {
 +                //imports a single collection from an app org combo
 +                importCollectionFromOrgApp((UUID) config.get("applicationId"), config, jobExecution, s3Import);
 +            }
 +
 +        } catch (OrganizationNotFoundException e) {
 +            importUG.setErrorMessage(e.getMessage());
 +            importUG.setState(Import.State.FINISHED);
 +            rooteEm.update(importUG);
 +            return;
 +        } catch (ApplicationNotFoundException e) {
 +            importUG.setErrorMessage(e.getMessage());
 +            importUG.setState(Import.State.FINISHED);
 +            rooteEm.update(importUG);
 +            return;
 +        }
 +
 +        if (files.size() == 0) {
 +
 +            importUG.setState(Import.State.FINISHED);
 +            importUG.setErrorMessage("no files found in the bucket with the relevant context");
 +            rooteEm.update(importUG);
 +
 +        } else {
 +
 +            Map<String, Object> fileMetadata = new HashMap<String, Object>();
 +
 +            ArrayList<Map<String, Object>> value = new ArrayList<Map<String, Object>>();
 +
 +            // schedule each file as a separate job
 +            for (File eachfile : files) {
 +
 +                UUID jobID = scheduleFile(eachfile.getPath(), importUG);
 +                Map<String, Object> fileJobID = new HashMap<String, Object>();
 +                fileJobID.put("FileName", eachfile.getName());
 +                fileJobID.put("JobID", jobID.toString());
 +                value.add(fileJobID);
 +            }
 +
 +            fileMetadata.put("files", value);
 +            importUG.addProperties(fileMetadata);
 +            rooteEm.update(importUG);
 +        }
 +        return;
 +    }
 +
 +    /**
 +     * Imports a specific collection from an org-app combo.
 +     */
 +    private void importCollectionFromOrgApp(UUID applicationUUID, final Map<String, Object> config,
 +                                            final JobExecution jobExecution, S3Import s3Import) throws Exception {
 +
 +        //retrieves import entity
 +        Import importUG = getImportEntity(jobExecution);
 +        ApplicationInfo application = managementService.getApplicationInfo(applicationUUID);
 +
 +        if (application == null) {
 +            throw new ApplicationNotFoundException("Application Not Found");
 +        }
 +
 +        String collectionName = config.get("collectionName").toString();
 +
 +        // prepares the prefix path for the files to be imported depending on the endpoint being hit
 +        String appFileName = prepareInputFileName("application", application.getName(), collectionName);
 +
 +        files = fileTransfer(importUG, appFileName, config, s3Import, 0);
 +
 +    }
 +
 +    /**
 +     * Imports a specific applications from an organization
 +     */
 +    private void importApplicationFromOrg(UUID organizationUUID, UUID applicationId, final Map<String, Object> config,
 +                                          final JobExecution jobExecution, S3Import s3Import) throws Exception {
 +
 +        //retrieves import entity
 +        Import importUG = getImportEntity(jobExecution);
 +
 +        ApplicationInfo application = managementService.getApplicationInfo(applicationId);
 +
 +        if (application == null) {
 +            throw new ApplicationNotFoundException("Application Not Found");
 +        }
 +
 +        // prepares the prefix path for the files to be imported depending on the endpoint being hit
 +        String appFileName = prepareInputFileName("application", application.getName(), null);
 +
 +        files = fileTransfer(importUG, appFileName, config, s3Import, 1);
 +
 +    }
 +
 +    /**
 +     * Imports All Applications from an Organization
 +     */
 +    private void importApplicationsFromOrg(UUID organizationUUID, final Map<String, Object> config,
 +                                           final JobExecution jobExecution, S3Import s3Import) throws Exception {
 +
 +        // retrieves import entity
 +        Import importUG = getImportEntity(jobExecution);
 +        String appFileName = null;
 +
 +        OrganizationInfo organizationInfo = managementService.getOrganizationByUuid(organizationUUID);
 +        if (organizationInfo == null) {
 +            throw new OrganizationNotFoundException("Organization Not Found");
 +        }
 +
 +        // prepares the prefix path for the files to be imported depending on the endpoint being hit
 +        appFileName = prepareInputFileName("organization", organizationInfo.getName(), null);
 +
 +        files = fileTransfer(importUG, appFileName, config, s3Import, 2);
 +
 +    }
 +
 +    /**
 +     * prepares the prefix path for the files to be imported depending on the endpoint being hit
 +     * @param type just a label such us: organization, application.
 +     * @return the file name concatenated with the type and the name of the collection
 +     */
 +    protected String prepareInputFileName(String type, String name, String CollectionName) {
 +        StringBuilder str = new StringBuilder();
 +
 +        // in case of type organization --> the file name will be "<org_name>/"
 +        if (type.equals("organization")) {
 +
 +            str.append(name);
 +            str.append("/");
 +
 +        } else if (type.equals("application")) {
 +
 +            // in case of type application --> the file name will be "<org_name>/<app_name>."
 +            str.append(name);
 +            str.append(".");
 +
 +            if (CollectionName != null) {
 +
 +                // in case of type application and collection import --> the file name will be "<org_name>/<app_name>.<collection_name>."
 +                str.append(CollectionName);
 +                str.append(".");
 +
 +            }
 +        }
 +
 +        String inputFileName = str.toString();
 +
 +        return inputFileName;
 +    }
 +
 +    /**
 +     * @param importUG    Import instance
 +     * @param appFileName the base file name for the files to be downloaded
 +     * @param config      the config information for the import job
 +     * @param s3Import    s3import instance
 +     * @param type        it indicates the type of import. 0 - Collection , 1 - Application and 2 - Organization
 +     * @return
 +     */
 +    public ArrayList<File> fileTransfer(Import importUG, String appFileName, Map<String, Object> config,
 +                                        S3Import s3Import, int type) throws Exception {
 +
-         EntityManager rootEm = emf.getEntityManager(MANAGEMENT_APPLICATION_ID);
++        EntityManager rootEm = emf.getEntityManager(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
 +        ArrayList<File> files = new ArrayList<File>();
 +
 +        try {
 +            files = s3Import.copyFromS3(config, appFileName, type);
 +        } catch (Exception e) {
 +            importUG.setErrorMessage(e.getMessage());
 +            importUG.setState(Import.State.FAILED);
 +            rootEm.update(importUG);
 +        }
 +        return files;
 +    }
 +
 +    /**
 +     * The loops through each temp file and parses it to store the entities from the json back into usergrid
 +     *
 +     * @throws Exception
 +     */
 +    @Override
 +    public void FileParser(JobExecution jobExecution) throws Exception {
 +
 +        // add properties to the import entity
 +        FileImport fileImport = getFileImportEntity(jobExecution);
 +
 +        File file = new File(jobExecution.getJobData().getProperty("File").toString());
 +
-         EntityManager rootEm = emf.getEntityManager(MANAGEMENT_APPLICATION_ID);
++        EntityManager rootEm = emf.getEntityManager(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
 +        rootEm.update(fileImport);
 +
 +        boolean completed = fileImport.getCompleted();
 +
 +        // on resume, completed files will not be traversed again
 +        if (!completed) {
 +
 +            // validates the JSON structure
 +            if (isValidJSON(file, rootEm, fileImport)) {
 +
 +                // mark the File import job as started
 +                fileImport.setState(FileImport.State.STARTED);
 +                rootEm.update(fileImport);
 +
 +                // gets the application anme from the filename
 +                String applicationName = file.getPath().split("\\.")[0];
 +
 +                ApplicationInfo application = managementService.getApplicationInfo(applicationName);
 +
 +                JsonParser jp = getJsonParserForFile(file);
 +
 +                // incase of resume, retrieve the last updated UUID for this file
 +                String lastUpdatedUUID = fileImport.getLastUpdatedUUID();
 +
 +                // this handles partially completed files by updating entities from the point of failure
 +                if (!lastUpdatedUUID.equals(" ")) {
 +
 +                    // go till the last updated entity
 +                    while (!jp.getText().equals(lastUpdatedUUID)) {
 +                        jp.nextToken();
 +                    }
 +
 +                    // skip the last one and start from the next one
 +                    while (!(jp.getCurrentToken() == JsonToken.END_OBJECT && jp.nextToken() == JsonToken.START_OBJECT)) {
 +                        jp.nextToken();
 +                    }
 +                }
 +
 +                // get to start of an object i.e next entity.
 +                while (jp.getCurrentToken() != JsonToken.START_OBJECT) {
 +                    jp.nextToken();
 +                }
 +
 +                // get entity manager for the application
 +                EntityManager em = emf.getEntityManager(application.getId());
 +
 +                while (jp.nextToken() != JsonToken.END_ARRAY) {
 +                    // import the entities in this file
 +                    importEntityStuff(jp, em, rootEm, fileImport, jobExecution);
 +                }
 +                jp.close();
 +
 +                // Updates the state of file import job
 +                if (!fileImport.getState().equals("FAILED")) {
 +
 +                    // mark file as completed
 +                    fileImport.setCompleted(true);
 +                    fileImport.setState(FileImport.State.FINISHED);
 +                    rootEm.update(fileImport);
 +
 +                    //check other files status and mark the status of import Job as Finished if all others are finished
 +                    Results ImportJobResults = rootEm.getConnectingEntities(fileImport, "includes", null, Level.ALL_PROPERTIES);
 +                    List<Entity> importEntity = ImportJobResults.getEntities();
 +                    UUID importId = importEntity.get(0).getUuid();
 +                    Import importUG = rootEm.get(importId, Import.class);
 +
 +                    Results entities = rootEm.getConnectedEntities( importUG, "includes", null, Level.ALL_PROPERTIES);
 +                    List<Entity> importFile = entities.getEntities();
 +
 +                    int count = 0;
 +                    for (Entity eachEntity : importFile) {
 +                        FileImport fi = rootEm.get(eachEntity.getUuid(), FileImport.class);
 +                        if (fi.getState().toString().equals("FINISHED")) {
 +                            count++;
 +                        } else if (fi.getState().toString().equals("FAILED")) {
 +                            importUG.setState(Import.State.FAILED);
 +                            rootEm.update(importUG);
 +                            break;
 +                        }
 +                    }
 +                    if (count == importFile.size()) {
 +                        importUG.setState(Import.State.FINISHED);
 +                        rootEm.update(importUG);
 +                    }
 +                }
 +            }
 +        }
 +    }
 +
 +    /**
 +     * Checks if a file is a valid JSON
 +     * @param collectionFile the file being validated
 +     * @param rootEm    the Entity Manager for the Management application
 +     * @param fileImport the file import entity
 +     * @return
 +     * @throws Exception
 +     */
 +    private boolean isValidJSON(File collectionFile, EntityManager rootEm, FileImport fileImport) throws Exception {
 +
 +        boolean valid = false;
 +        try {
 +            final JsonParser jp = jsonFactory.createJsonParser(collectionFile);
 +            while (jp.nextToken() != null) {
 +            }
 +            valid = true;
 +        } catch (JsonParseException e) {
 +            e.printStackTrace();
 +            fileImport.setErrorMessage(e.getMessage());
 +            rootEm.update(fileImport);
 +        } catch (IOException e) {
 +            fileImport.setErrorMessage(e.getMessage());
 +            rootEm.update(fileImport);
 +        }
 +        return valid;
 +    }
 +
 +
 +    /**
 +     * Gets the JSON parser for given file
 +     * @param collectionFile the file for which JSON parser is required
 +     * @return
 +     * @throws Exception
 +     */
 +    private JsonParser getJsonParserForFile(File collectionFile) throws Exception {
 +        JsonParser jp = jsonFactory.createJsonParser(collectionFile);
 +        jp.setCodec(new ObjectMapper());
 +        return jp;
 +    }
 +
 +
 +
 +    /**
 +     * Imports the entity's connecting references (collections, connections and dictionaries)
 +     * @param jp  JsonParser pointing to the beginning of the object.
 +     * @param em Entity Manager for the application being imported
 +     * @param rootEm Entity manager for the root applicaition
 +     * @param fileImport the file import entity
 +     * @param jobExecution  execution details for the import jbo
 +     * @throws Exception
 +     */
 +    private void importEntityStuff(final JsonParser jp, final EntityManager em, final EntityManager rootEm, final FileImport fileImport, final JobExecution jobExecution) throws Exception {
 +
 +        final JsonParserObservable subscribe = new JsonParserObservable(jp, em, rootEm, fileImport);
 +
 +        final Observable<WriteEvent> observable = Observable.create(subscribe);
 +
 +        /**
 +         * This is the action we want to perform for every UUID we receive
 +         */
 +        final Action1<WriteEvent> doWork = new Action1<WriteEvent>() {
 +            @Override
 +            public void call(WriteEvent writeEvent) {
 +                writeEvent.doWrite(em, jobExecution, fileImport);
 +            }
 +
 +        };
 +
 +
 +        final AtomicLong entityCounter = new AtomicLong();
 +        final AtomicLong eventCounter = new AtomicLong();
 +        /**
 +         * This is boilerplate glue code.  We have to follow this for the parallel operation.  In the "call"
 +         * method we want to simply return the input observable + the chain of operations we want to invoke
 +         */
 +        observable.parallel(new Func1<Observable<WriteEvent>, Observable<WriteEvent>>() {
 +            @Override
 +            public Observable<WriteEvent> call(Observable<WriteEvent> entityWrapperObservable) {
 +
 +                /* TODO:
 +                 * need to fixed so that number of entities created can be counted correctly
 +                 * and also update the last updated UUID for the fileImport which is a must for resumability
 +                 */
 +//                return entityWrapperObservable.doOnNext(doWork).doOnNext(new Action1<WriteEvent>() {
 +//
 +//                         @Override
 +//                         public void call(WriteEvent writeEvent) {
 +//                             if (!(writeEvent instanceof EntityEvent)) {
 +//                                 final long val = eventCounter.incrementAndGet();
 +//                                 if(val % 50 == 0) {
 +//                                     jobExecution.heartbeat();
 +//                                 }
 +//                                 return;
 +//                             }
 +//
 +//                             final long value = entityCounter.incrementAndGet();
 +//                             if (value % 2000 == 0) {
 +//                                 try {
 +//                                     logger.error("UUID = " +((EntityEvent) writeEvent).getEntityUuid().toString() + " value = " + value +"");
 +//                                     fileImport.setLastUpdatedUUID(((EntityEvent) writeEvent).getEntityUuid().toString());
 +//                                     //checkpoint the UUID here.
 +//                                     rootEm.update(fileImport);
 +//                                 } catch(Exception ex) {}
 +//                             }
 +//                             if(value % 100 == 0) {
 +//                                 logger.error("heartbeat sent by " + fileImport.getFileName());
 +//                                 jobExecution.heartbeat();
 +//                             }
 +//                         }
 +//                     }
 +//                );
 +
 +                return entityWrapperObservable.doOnNext(doWork);
 +            }
 +        }, Schedulers.io()).toBlocking().last();
 +    }
 +
 +    private interface WriteEvent {
 +        public void doWrite(EntityManager em, JobExecution jobExecution, FileImport fileImport);
 +    }
 +
 +    private final class EntityEvent implements WriteEvent {
 +        UUID entityUuid;
 +        String entityType;
 +        Map<String, Object> properties;
 +
 +        EntityEvent(UUID entityUuid, String entityType, Map<String, Object> properties) {
 +            this.entityUuid = entityUuid;
 +            this.entityType = entityType;
 +            this.properties = properties;
 +        }
 +
 +        public UUID getEntityUuid() {
 +            return entityUuid;
 +        }
 +
 +        // Creates entities
 +        @Override
 +        public void doWrite(EntityManager em, JobExecution jobExecution, FileImport fileImport) {
-             EntityManager rootEm = emf.getEntityManager(MANAGEMENT_APPLICATION_ID);
++            EntityManager rootEm = emf.getEntityManager(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
 +
 +            try {
 +                em.create(entityUuid, entityType, properties);
 +            } catch (Exception e) {
 +                fileImport.setErrorMessage(e.getMessage());
 +                try {
 +                    rootEm.update(fileImport);
 +                } catch (Exception ex) {
 +                }
 +            }
 +        }
 +    }
 +
 +    private final class ConnectionEvent implements WriteEvent {
 +        EntityRef ownerEntityRef;
 +        String connectionType;
 +        EntityRef entryRef;
 +
 +        ConnectionEvent(EntityRef ownerEntityRef, String connectionType, EntityRef entryRef) {
 +            this.ownerEntityRef = ownerEntityRef;
 +            this.connectionType = connectionType;
 +            this.entryRef = entryRef;
 +
 +        }
 +
 +        // creates connections between entities
 +        @Override
 +        public void doWrite(EntityManager em, JobExecution jobExecution, FileImport fileImport) {
-             EntityManager rootEm = emf.getEntityManager(MANAGEMENT_APPLICATION_ID);
++            EntityManager rootEm = emf.getEntityManager(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
 +
 +            try {
 +                em.createConnection(ownerEntityRef, connectionType, entryRef);
 +            } catch (Exception e) {
 +                fileImport.setErrorMessage(e.getMessage());
 +                try {
 +                    rootEm.update(fileImport);
 +                } catch (Exception ex) {
 +                }
 +            }
 +        }
 +    }
 +
 +    private final class DictionaryEvent implements WriteEvent {
 +
 +        EntityRef ownerEntityRef;
 +        String dictionaryName;
 +        Map<String, Object> dictionary;
 +
 +        DictionaryEvent(EntityRef ownerEntityRef, String dictionaryName, Map<String, Object> dictionary) {
 +            this.ownerEntityRef = ownerEntityRef;
 +            this.dictionaryName = dictionaryName;
 +            this.dictionary = dictionary;
 +        }
 +
 +        // adds map to the dictionary
 +        @Override
 +        public void doWrite(EntityManager em, JobExecution jobExecution, FileImport fileImport) {
-             EntityManager rootEm = emf.getEntityManager(MANAGEMENT_APPLICATION_ID);
++            EntityManager rootEm = emf.getEntityManager(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
 +            try {
 +                em.addMapToDictionary(ownerEntityRef, dictionaryName, dictionary);
 +            } catch (Exception e) {
 +                fileImport.setErrorMessage(e.getMessage());
 +                try {
 +                    rootEm.update(fileImport);
 +                } catch (Exception ex) {
 +                }
 +            }
 +        }
 +    }
 +
 +
 +    private final class JsonParserObservable implements Observable.OnSubscribe<WriteEvent> {
 +        private final JsonParser jp;
 +        EntityManager em;
 +        EntityManager rootEm;
 +        FileImport fileImport;
 +
 +
 +        JsonParserObservable(JsonParser parser, EntityManager em, EntityManager rootEm, FileImport fileImport) {
 +            this.jp = parser;
 +            this.em = em;
 +            this.rootEm = rootEm;
 +            this.fileImport = fileImport;
 +        }
 +
 +        @Override
 +        public void call(final Subscriber<? super WriteEvent> subscriber) {
 +
 +            WriteEvent entityWrapper = null;
 +            EntityRef ownerEntityRef = null;
 +            String entityUuid = "";
 +            String entityType = "";
 +            try {
 +                while (!subscriber.isUnsubscribed() && jp.nextToken() != JsonToken.END_OBJECT) {
 +                    String collectionName = jp.getCurrentName();
 +
 +                    // create the  wrapper for connections
 +                    if (collectionName.equals("connections")) {
 +
 +                        jp.nextToken(); // START_OBJECT
 +                        while (jp.nextToken() != JsonToken.END_OBJECT) {
 +                            String connectionType = jp.getCurrentName();
 +
 +                            jp.nextToken(); // START_ARRAY
 +                            while (jp.nextToken() != JsonToken.END_ARRAY) {
 +                                String entryId = jp.getText();
 +
 +                                EntityRef entryRef = new SimpleEntityRef(UUID.fromString(entryId));
 +                                entityWrapper = new ConnectionEvent(ownerEntityRef, connectionType, entryRef);
 +
 +                                // Creates a new subscriber to the observer with the given connection wrapper
 +                                subscriber.onNext(entityWrapper);
 +                            }
 +                        }
 +
 +                    }
 +                    // create the  wrapper for dictionaries
 +                    else if (collectionName.equals("dictionaries")) {
 +
 +                        jp.nextToken(); // START_OBJECT
 +                        while (jp.nextToken() != JsonToken.END_OBJECT) {
 +
 +                            String dictionaryName = jp.getCurrentName();
 +
 +                            jp.nextToken();
 +
 +                            Map<String, Object> dictionary = jp.readValueAs(HashMap.class);
 +                            entityWrapper = new DictionaryEvent(ownerEntityRef, dictionaryName, dictionary);
 +
 +                            // Creates a new subscriber to the observer with the given dictionary wrapper
 +                            subscriber.onNext(entityWrapper);
 +                        }
 +                        subscriber.onCompleted();
 +
 +                    } else {
 +
 +                        // Regular collections
 +                        jp.nextToken(); // START_OBJECT
 +
 +                        Map<String, Object> properties = new HashMap<String, Object>();
 +                        JsonToken token = jp.nextToken();
 +
 +                        while (token != JsonToken.END_OBJECT) {
 +                            if (token == JsonToken.VALUE_STRING || token == JsonToken.VALUE_NUMBER_INT) {
 +                                String key = jp.getCurrentName();
 +                                if (key.equals("uuid")) {
 +                                    entityUuid = jp.getText();
 +
 +                                } else if (key.equals("type")) {
 +                                    entityType = jp.getText();
 +                                } else if (key.length() != 0 && jp.getText().length() != 0) {
 +                                    String value = jp.getText();
 +                                    properties.put(key, value);
 +                                }
 +                            }
 +                            token = jp.nextToken();
 +                        }
 +
 +                        ownerEntityRef = new SimpleEntityRef(entityType, UUID.fromString(entityUuid));
 +                        entityWrapper = new EntityEvent(UUID.fromString(entityUuid), entityType, properties);
 +
 +                        // Creates a new subscriber to the observer with the given dictionary wrapper
 +                        subscriber.onNext(entityWrapper);
 +
 +                    }
 +                }
 +            } catch (Exception e) {
 +                // skip illegal entity UUID and go to next one
 +                fileImport.setErrorMessage(e.getMessage());
 +                try {
 +                    rootEm.update(fileImport);
 +                } catch (Exception ex) {
 +                }
 +                subscriber.onError(e);
 +            }
 +        }
 +    }
 +}
 +
 +/**
 + * Custom Exception class for Organization Not Found
 + */
 +class OrganizationNotFoundException extends Exception {
 +    OrganizationNotFoundException(String s) {
 +        super(s);
 +    }
 +}
 +
 +/**
 + * Custom Exception class for Application Not Found
 + */
 +class ApplicationNotFoundException extends Exception {
 +    ApplicationNotFoundException(String s) {
 +        super(s);
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6deac189/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
----------------------------------------------------------------------
diff --cc stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
index 8cafa68,216e0a6..cd8b691
--- a/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
+++ b/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
@@@ -21,8 -28,8 +21,9 @@@ import org.apache.usergrid.cassandra.Ca
  import org.apache.usergrid.management.ApplicationCreator;
  import org.apache.usergrid.management.ManagementService;
  import org.apache.usergrid.management.export.ExportService;
 +import org.apache.usergrid.management.importer.ImportService;
  import org.apache.usergrid.persistence.cassandra.CassandraService;
+ import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
  import org.apache.usergrid.security.providers.SignInProviderFactory;
  import org.apache.usergrid.security.tokens.TokenService;
  import org.apache.usergrid.services.ServiceManagerFactory;


[47/50] [abbrv] incubator-usergrid git commit: added apache header to editor config

Posted by gr...@apache.org.
added apache header to editor config


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

Branch: refs/heads/two-dot-o-import
Commit: bcabda26c426fef01c88c8bb761640cd409d50cf
Parents: b2436c6
Author: Rod Simpson <ro...@apigee.com>
Authored: Mon Jan 12 11:34:42 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Mon Jan 12 11:34:42 2015 -0700

----------------------------------------------------------------------
 stack/.editorconfig | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bcabda26/stack/.editorconfig
----------------------------------------------------------------------
diff --git a/stack/.editorconfig b/stack/.editorconfig
index cc4e3a0..0de5e12 100644
--- a/stack/.editorconfig
+++ b/stack/.editorconfig
@@ -1,3 +1,19 @@
+#
+# 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.
+#
 [*]
 # Unix-style newlines with a newline ending every file
 end_of_line = lf


[27/50] [abbrv] incubator-usergrid git commit: [USERGRID-303]Updated AND/OR query tests to work with new test framework

Posted by gr...@apache.org.
[USERGRID-303]Updated AND/OR query tests to work with new test framework


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

Branch: refs/heads/two-dot-o-import
Commit: 309fc197e4d3d3d03215db0acac95def3feddd08
Parents: 2811728
Author: ryan bridges <rb...@apigee.com>
Authored: Wed Jan 7 09:55:44 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Wed Jan 7 14:44:29 2015 -0500

----------------------------------------------------------------------
 .../applications/queries/AndOrQueryTest.java    | 436 ++++++++++---------
 1 file changed, 227 insertions(+), 209 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/309fc197/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
index ae7083f..ab1bc78 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
@@ -17,29 +17,21 @@
 package org.apache.usergrid.rest.applications.queries;
 
 
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import java.io.IOException;
-
-import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.RandomStringUtils;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
 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.utils.MapUtils;
-import org.junit.Ignore;
-import org.junit.Rule;
 import org.junit.Test;
-import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
-import org.apache.usergrid.rest.TestContextSetup;
-import org.apache.usergrid.rest.test.resource.CustomCollection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.List;
 
 import static org.junit.Assert.assertEquals;
-import static org.apache.usergrid.utils.MapUtils.hashMap;
+import static org.junit.Assert.assertTrue;
 
 
 /**
@@ -49,231 +41,257 @@ import static org.apache.usergrid.utils.MapUtils.hashMap;
  * @since 4.0
  */
 public class AndOrQueryTest extends AbstractRestIT {
-
-    @Test //USERGRID-900
-    public void queriesWithAndPastLimit() throws IOException {
-
-
-        long created = 0;
-      Entity actor = new Entity();
-      actor.put("displayName", "Erin");
-      Entity props = new Entity();
-        props.put( "actor", actor );
-        props.put( "verb", "go" );
-        props.put( "content", "bragh" );
-
-
-        for ( int i = 0; i < 20; i++ ) {
-            if ( i < 10 ) {
-                props.put( "madeup", false );
-            }
-            else {
-                props.put( "madeup", true );
-            }
-
-            props.put( "ordinal", i );
-            Entity activity = this.app().collection("activities").post(props);
-            if ( i == 0 ) {
-                created = Long.parseLong(activity.get("created").toString());
-            }
-        }
-
-        this.refreshIndex();
-
-        String errorQuery = "select * where created >= " + created + "AND madeup = true";
-      QueryParameters params= new QueryParameters();
-      params.setQuery(errorQuery);
-       Collection activities=this.app().collection("activities").get(params);
-
-        assertEquals( 10, activities.response.getEntityCount() );
-    }
-
-
-    @Test //USERGRID-1475
-    public void displayFullQueriesInLimit() throws IOException {
-
-      int numValuesTested = 20;
-      Entity actor = new Entity();
-      actor.put("displayName", "Erin");
-      Entity props = new Entity();
-      props.put( "actor", actor );
-      props.put( "verb", "go" );
-      props.put( "content", "bragh" );
-
-
-      for ( int i = 0; i < numValuesTested; i++ ) {
-        if ( i < numValuesTested/2 ) {
-          props.put( "verb", "go" );
-        }
-        else {
-          props.put( "verb", "stop" );
-        }
-
-        props.put( "ordinal", i );
-        this.app().collection("activities").post(props);
-      }
-
-
-        this.refreshIndex();
-
-        String query = "select * where not verb = 'go'";
-      QueryParameters params= new QueryParameters();
-      params.setQuery(query);
-      Collection activities=this.app().collection("activities").get(params);
-
-      assertEquals( numValuesTested/2, activities.response.getEntityCount() );
-      List entities = activities.response.getEntities();
-
-        for ( int i = 0; i < numValuesTested/2; i++ ) {
-            assertEquals(numValuesTested - i, Integer.parseInt(((LinkedHashMap<String, Object>) entities.get(i)).get("ordinal").toString()));
-            assertEquals( "stop", ((LinkedHashMap<String, Object>) entities.get(i)).get("verb").toString() );
-        }
-    }
-  
-
-    @Test //USERGRID-1615
-    public void queryReturnCount() throws Exception {
-
-
-        int numValuesTested = 20;
-
-      Entity actor = new Entity();
-      actor.put("displayName", "Erin");
-      Entity props = new Entity();
-      props.put( "actor", actor );
-      props.put( "verb", "go" );
-      props.put( "content", "bragh" );
-      Entity[] correctValues = new Entity[numValuesTested];
-      for(int i=0; i< numValuesTested; i++){
-        props.put("ordinal", i);
-        correctValues[i] = this.app().collection("activities").post(props);
+  private static Logger log = LoggerFactory.getLogger(AndOrQueryTest.class);
+
+  /**
+   * Ensure limit is respected in queries
+   * 1. Insert a number of entities
+   * 2. Set half the entities to have a 'madeup' property of 'true'
+   *  and set the other half to 'false'
+   * 3. Query all entities where "madeup = true"
+   * 4. Limit the query to half of the number of entities
+   * 5. Ensure the correct entities are returned
+   * @throws IOException
+   */
+  @Test //USERGRID-900
+  public void queriesWithAndPastLimit() throws IOException {
+    int numValuesTested = 40;
+    long created = 0;
+    
+    Entity actor = new Entity();
+    actor.put("displayName", "Erin");
+    Entity props = new Entity();
+    props.put("actor", actor);
+    props.put("verb", "go");
+    props.put("content", "bragh");
+    //1. Insert a number of entities
+    for (int i = 0; i < numValuesTested; i++) {
+      //2. Set half the entities to have a 'madeup' property of 'true'
+      // and set the other half to 'false'
+      if (i < numValuesTested / 2) {
+        props.put("madeup", false);
+      } else {
+        props.put("madeup", true);
       }
-      this.refreshIndex();
-
-      String inCorrectQuery = "select * where ordinal >= 10 order by ordinal asc";
-      QueryParameters params = new QueryParameters();
-      params.setQuery(inCorrectQuery);
-      Collection activities=this.app().collection("activities").get(params);
-
-      assertEquals( 10, activities.response.getEntityCount() );
 
-//      verificationOfQueryResults( "activities", (Entity[])ArrayUtils.subarray(correctValues, 10, 19), false, inCorrectQuery );
-      List entities = activities.response.getEntities();
-
-      for ( int i = 0; i < 10; i++ ) {
-        assertEquals(10+i, Integer.parseInt(((LinkedHashMap<String, Object>) entities.get(i)).get("ordinal").toString()));
-//        assertEquals( "stop", ((LinkedHashMap<String, Object>) entities.get(i)).get("verb").toString() );
+      props.put("ordinal", i);
+      Entity activity = this.app().collection("activities").post(props);
+      if (i == 0) {
+        created = Long.parseLong(activity.get("created").toString());
       }
-
     }
 
+    this.refreshIndex();
+    //3. Query all entities where "madeup = true"
+    String errorQuery = "select * where created >= " + created + "AND madeup = true";
+    QueryParameters params = new QueryParameters()
+        .setQuery(errorQuery)
+        .setLimit(numValuesTested / 2);//4. Limit the query to half of the number of entities
+    Collection activities = this.app().collection("activities").get(params);
+    //5. Ensure the correct entities are returned
+    assertEquals(numValuesTested / 2, activities.response.getEntityCount());
+    while(activities.hasNext()){
+      assertTrue(Boolean.parseBoolean(activities.next().get("madeup").toString()));
+    }
+  }
 
-    @Test //Check to make sure that asc works
-    public void queryCheckAsc() throws Exception {
-      int numOfEntities = 10;
-        String collectionName = "imagination" + RandomStringUtils.randomAlphabetic( 5 );
 
-      Entity[] correctValues = new Entity[numOfEntities];
-      Entity props = new Entity();
-      props.put( "WhoHelpedYou", "Ruff" );
-      for(int i=0; i< numOfEntities; i++){
-        props.put("ordinal", i);
-        correctValues[i] = this.app().collection(collectionName).post(props);
+  /**
+   * Test negated query
+   * 1. Insert a number of entities
+   * 2. Set half the entities to have a 'verb' property of 'go'
+   *  and set the other half to 'stop'
+   * 3. Query all entities where "NOT verb = 'go'"
+   * 4. Limit the query to half of the number of entities
+   * 5. Ensure the returned entities have "verb = 'stop'"
+   * @throws IOException
+   */
+  @Test //USERGRID-1475
+  public void negatedQuery() throws IOException {
+    int numValuesTested = 20;
+
+    Entity actor = new Entity();
+    actor.put("displayName", "Erin");
+    Entity props = new Entity();
+    props.put("actor", actor);
+    props.put("verb", "go");
+    props.put("content", "bragh");
+    //1. Insert a number of entities
+    for (int i = 0; i < numValuesTested; i++) {
+      //2. Set half the entities to have a 'verb' property of 'go'
+      // and set the other half to 'stop'
+      if (i % 2 == 0) {
+        props.put("verb", "go");
+      } else {
+        props.put("verb", "stop");
       }
 
-        this.refreshIndex(  );
-
-        String inquisitiveQuery = "select * where Ordinal gte 0 and Ordinal lte 10 "
-                + "or WhoHelpedYou eq 'Ruff' ORDER BY Ordinal asc";
-
-        int totalEntitiesContained = verificationOfQueryResults( collectionName, correctValues, false, inquisitiveQuery );
-
-        assertEquals( numOfEntities, totalEntitiesContained );
+      props.put("ordinal", i);
+      this.app().collection("activities").post(props);
     }
 
 
-//    @Ignore("Test to make sure all 1000 exist with a regular query")
-    @Test
-    public void queryReturnCheck() throws Exception {
-        int numOfEntities = 20;
-
-      String collectionName = "imagination" + RandomStringUtils.randomAlphabetic( 5 );
+    this.refreshIndex();
+    //3. Query all entities where "NOT verb = 'go'"
+    String query = "select * where not verb = 'go'";
+    //4. Limit the query to half of the number of entities
+    QueryParameters params = new QueryParameters().setQuery(query).setLimit(numValuesTested / 2);
+    Collection activities = this.app().collection("activities").get(params);
+    //5. Ensure the returned entities have "verb = 'stop'"
+    assertEquals(numValuesTested / 2, activities.response.getEntityCount());
+    while(activities.hasNext()){
+      assertEquals("stop", activities.next().get("verb").toString());
+    }
 
-      Entity[] correctValues = new Entity[numOfEntities];
-      Entity props = new Entity();
-      props.put( "WhoHelpedYou", "Ruff" );
-      for(int i=0; i< numOfEntities; i++){
-        props.put("ordinal", i);
-        correctValues[i] = this.app().collection(collectionName).post(props);
-      }
 
-      this.refreshIndex(  );
+  }
 
-        String inquisitiveQuery = "select * where ordinal >= 0 and ordinal <= 2000 or WhoHelpedYou = 'Ruff'";
+  /**
+   * Ensure queries return a subset of entities in the correct order
+   * 1. Insert a number of entities
+   * 2. Query for a subset of the entities
+   * 3. Validate that the correct entities are returned
+   * @throws Exception
+   */
+  @Test //USERGRID-1615
+  public void queryReturnCount() throws Exception {
+    int numValuesTested = 20;
+
+    Entity actor = new Entity();
+    actor.put("displayName", "Erin");
+    Entity props = new Entity();
+    props.put("actor", actor);
+    props.put("verb", "go");
+    props.put("content", "bragh");
+    Entity[] correctValues = new Entity[numValuesTested];
+    //1. Insert a number of entities
+    for (int i = 0; i < numValuesTested; i++) {
+      props.put("ordinal", i);
+      correctValues[i] = this.app().collection("activities").post(props);
+    }
+    this.refreshIndex();
+    //2. Query for a subset of the entities
+    String inCorrectQuery = "select * where ordinal >= 10 order by ordinal asc";
+    QueryParameters params = new QueryParameters().setQuery(inCorrectQuery).setLimit(numValuesTested / 2);
+    Collection activities = this.app().collection("activities").get(params);
+    //3. Validate that the correct entities are returned
+    assertEquals(numValuesTested / 2, activities.response.getEntityCount());
+
+    List entities = activities.response.getEntities();
+    for (int i = 0; i < numValuesTested / 2; i++) {
+      assertEquals(numValuesTested / 2 + i, Integer.parseInt(((LinkedHashMap<String, Object>) entities.get(i)).get("ordinal").toString()));
+    }
 
-        int totalEntitiesContained = verificationOfQueryResults( collectionName, correctValues, true, inquisitiveQuery );
+  }
 
-        assertEquals( numOfEntities, totalEntitiesContained );
+  /**
+   * Validate sort order with AND/OR query
+   * 1. Insert entities
+   * 2. Use AND/OR query to retrieve entities
+   * 3. Verify the order of results
+   * @throws Exception
+   */
+  @Test
+  public void queryCheckAsc() throws Exception {
+    int numOfEntities = 20;
+    String collectionName = "imagination";
+
+    Entity[] correctValues = new Entity[numOfEntities];
+    Entity props = new Entity();
+    props.put("WhoHelpedYou", "Ruff");
+    //1. Insert entities
+    for (int i = 0; i < numOfEntities; i++) {
+      props.put("ordinal", i);
+      correctValues[i] = this.app().collection(collectionName).post(props);
     }
 
+    this.refreshIndex();
 
-    @Test
-    public void queryReturnCheckWithShortHand() throws Exception {
-      int numOfEntities = 20;
+    //2. Use AND/OR query to retrieve entities
+    String inquisitiveQuery = "select * where Ordinal gte 0 and Ordinal lte 10 "
+        + "or WhoHelpedYou eq 'Ruff' ORDER BY Ordinal asc";
+    QueryParameters params = new QueryParameters().setQuery(inquisitiveQuery).setLimit(numOfEntities / 2);
+    Collection activities = this.app().collection(collectionName).get(params);
 
-      String collectionName = "imagination" + RandomStringUtils.randomAlphabetic( 5 );
+    //3. Verify the order of results
+    assertEquals(numOfEntities / 2, activities.response.getEntityCount());
+    List entities = activities.response.getEntities();
+    for (int i = 0; i < numOfEntities / 2; i++) {
+      assertEquals(i, Integer.parseInt(((LinkedHashMap<String, Object>) entities.get(i)).get("ordinal").toString()));
+    }
+  }
 
-      Entity[] correctValues = new Entity[numOfEntities];
-      Entity props = new Entity();
-      props.put( "WhoHelpedYou", "Ruff" );
-      for(int i=0; i< numOfEntities; i++){
-        props.put("ordinal", i);
-        correctValues[i] = this.app().collection(collectionName).post(props);
-      }
 
-      this.refreshIndex(  );
+  /**
+   * Test a standard query
+   * 1. Insert a number of entities
+   * 2. Issue a query
+   * 3. validate that a full page of (10) entities is returned
+   * @throws Exception
+   */
+  @Test
+  public void queryReturnCheck() throws Exception {
+    int numOfEntities = 20;
+    String collectionName = "imagination";
+
+    Entity[] correctValues = new Entity[numOfEntities];
+    Entity props = new Entity();
+    props.put("WhoHelpedYou", "Ruff");
+    //1. Insert a number of entities
+    for (int i = 0; i < numOfEntities; i++) {
+      props.put("ordinal", i);
+      correctValues[i] = this.app().collection(collectionName).post(props);
+    }
 
-      String inquisitiveQuery = "select * where Ordinal gte 0 and Ordinal lte 2000 or WhoHelpedYou eq 'Ruff'";
+    this.refreshIndex();
 
-      int totalEntitiesContained = verificationOfQueryResults( collectionName, correctValues, true, inquisitiveQuery );
+    //2. Issue a query
+    String inquisitiveQuery = String.format("select * where ordinal >= 0 and ordinal <= %d or WhoHelpedYou = 'Ruff'", numOfEntities);
+    QueryParameters params = new QueryParameters().setQuery(inquisitiveQuery);
+    Collection activities = this.app().collection(collectionName).get(params);
 
-      assertEquals( numOfEntities, totalEntitiesContained );
+    //3. validate that a full page of (10) entities is returned
+    assertEquals(10, activities.response.getEntityCount());
+    List entities = activities.response.getEntities();
+    for (int i = 0; i < 10; i++) {
+      assertEquals(i, Integer.parseInt(((LinkedHashMap<String, Object>) entities.get(i)).get("ordinal").toString()));
+    }
+  }
 
+  /**
+   * Test a standard query using alphanumeric operators
+   * 1. Insert a number of entities
+   * 2. Issue a query using alphanumeric operators
+   * 3. validate that a full page of (10) entities is returned
+   * @throws Exception
+   */
+  @Test
+  public void queryReturnCheckWithShortHand() throws Exception {
+    int numOfEntities = 10;
+    String collectionName = "imagination";
+
+    Entity[] correctValues = new Entity[numOfEntities];
+    Entity props = new Entity();
+    props.put("WhoHelpedYou", "Ruff");
+    //1. Insert a number of entities
+    for (int i = 0; i < numOfEntities; i++) {
+      props.put("ordinal", i);
+      correctValues[i] = this.app().collection(collectionName).post(props);
     }
 
-  public int verificationOfQueryResults( String collectionName, Entity[] correctValues, boolean reverse, String checkedQuery )
-      throws Exception {
-
-    int totalEntitiesContained = 0;
-    QueryParameters params = new QueryParameters();
-    params.setQuery(checkedQuery);
-    Collection checkedNodes = this.app().collection(collectionName).get(params);
-
-    while ( correctValues.length != totalEntitiesContained )//correctNode.get("entities") != null)
-    {
-      totalEntitiesContained += checkedNodes.response.getEntityCount();
-      if ( !reverse ) {
-        for ( int index = 0; index < checkedNodes.response.getEntityCount(); index++ ) {
-          assertEquals( correctValues[index].get("uuid"),
-              ((LinkedHashMap)checkedNodes.response.getEntities().get( index )).get("uuid") );
-        }
-      }
-      else {
-        for ( int index = 0; index < checkedNodes.response.getEntityCount(); index++ ) {
-          assertEquals( correctValues[correctValues.length - 1 - index].get("uuid"),
-              ((LinkedHashMap)checkedNodes.response.getEntities().get( index )).get("uuid") );
-        }
-      }
+    this.refreshIndex();
 
-      if ( checkedNodes.getCursor() != null ) {
-        checkedNodes = this.app().getNextPage(checkedNodes,true);
-      }
+    //2. Issue a query using alphanumeric operators
+    String inquisitiveQuery = "select * where Ordinal gte 0 and Ordinal lte 2000 or WhoHelpedYou eq 'Ruff'";
+    QueryParameters params = new QueryParameters().setQuery(inquisitiveQuery);
+    Collection activities = this.app().collection(collectionName).get(params);
 
-      else {
-        break;
-      }
+    //3. validate that a full page of (10) entities is returned
+    assertEquals(10, activities.response.getEntityCount());
+    List entities = activities.response.getEntities();
+    for (int i = 0; i < 10; i++) {
+      assertEquals(i, Integer.parseInt(((LinkedHashMap<String, Object>) entities.get(i)).get("ordinal").toString()));
     }
-    return totalEntitiesContained;
   }
 
 }


[40/50] [abbrv] incubator-usergrid git commit: Simplified the setup of some of the tests

Posted by gr...@apache.org.
Simplified the setup of some of the 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/5ae01ef8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5ae01ef8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5ae01ef8

Branch: refs/heads/two-dot-o-import
Commit: 5ae01ef80bf187418528ab347158457be626ad65
Parents: 394eda7
Author: grey <gr...@apigee.com>
Authored: Fri Jan 9 08:52:35 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Fri Jan 9 08:52:35 2015 -0800

----------------------------------------------------------------------
 .../rest/management/OrganizationsIT.java        | 137 +++++++++----------
 1 file changed, 67 insertions(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5ae01ef8/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
index 4ec0b57..239fe7d 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
@@ -24,12 +24,9 @@ import java.util.UUID;
 
 import org.junit.Ignore;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import org.apache.usergrid.persistence.index.utils.UUIDUtils;
 import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
-
 import org.apache.usergrid.rest.test.resource2point0.RestClient;
 import org.apache.usergrid.rest.test.resource2point0.model.Entity;
 import org.apache.usergrid.rest.test.resource2point0.model.Organization;
@@ -62,19 +59,12 @@ public class OrganizationsIT extends AbstractRestIT {
     @Test
     public void createOrgAndOwner() throws Exception {
 
-        //Created a uuid username because I am creating a organization
-        String username = "createOrgAndOwner" + UUIDUtils.newTimeUUID();
-        String name = username;
-        String password = "password";
-        String orgName = username;
-        String email = username + "@usergrid.com";
-
         //User property to see if owner properties exist when created.
         Map<String, Object> userProperties = new HashMap<String, Object>();
         userProperties.put( "company", "Apigee" );
 
         //Create organization
-        Organization organization = new Organization( orgName, username, email, name, password, userProperties );
+        Organization organization = createOrgPayload( "createOrgAndOwner", userProperties );
 
         //Get back organization response
         Organization organizationResponse = clientSetup.getRestClient().management().orgs().post( organization );
@@ -83,14 +73,15 @@ public class OrganizationsIT extends AbstractRestIT {
 
         //Creates token
         Token token =
-                clientSetup.getRestClient().management().token().post( new Token( "password", username, password ) );
+                clientSetup.getRestClient().management().token().post( new Token( "password",
+                        organization.getUsername(), organization.getPassword() ) );
 
         assertNotNull( token );
 
         //Assert that the get returns the correct org and owner.
-        Organization returnedOrg = clientSetup.getRestClient().management().orgs().organization( orgName ).get();
+        Organization returnedOrg = clientSetup.getRestClient().management().orgs().organization( organization.getOrganization()).get();
 
-        assertTrue( returnedOrg != null && returnedOrg.getName().equals( orgName ) );
+        assertTrue( returnedOrg != null && returnedOrg.getName().equals( organization.getOrganization() ) );
 
         User returnedUser = returnedOrg.getOwner();
 
@@ -108,29 +99,25 @@ public class OrganizationsIT extends AbstractRestIT {
     @Test
     public void testCreateDuplicateOrgName() throws Exception {
 
-        String username = "testCreateDuplicateOrgName" + UUIDUtils.newTimeUUID();
-        String name = username;
-        String password = "password";
-        String orgName = username;
-        String email = username + "@usergrid.com";
-
         //Create organization
-        Organization orgPayload = new Organization( orgName, username, email, name, password, null );
+        Organization organization = createOrgPayload( "testCreateDuplicateOrgName", null );
 
-        Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post( orgPayload );
+        Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post( organization );
         this.refreshIndex();
 
         assertNotNull( orgCreatedResponse );
 
         //Ensure that the token from the newly created organization works.
-        Token tokenPayload = new Token( "password", username, password );
+        Token tokenPayload = new Token( "password", organization.getUsername(), organization.getPassword() );
         Token tokenReturned = clientSetup.getRestClient().management().token().post( tokenPayload );
 
         assertNotNull( tokenReturned );
 
         //Try to create a organization with the same name as an organization that already exists, ensure that it fails
         Organization orgTestDuplicatePayload =
-                new Organization( orgName, username + "test", email + "test", name + "test", password, null );
+                new Organization( organization.getOrganization(), organization.getUsername() + "test",
+                        organization.getEmail() + "test", organization.getName() + "test",
+                        organization.getPassword(), null );
         try {
             clientSetup.getRestClient().management().orgs().post( orgTestDuplicatePayload );
             fail("Should not have been able to create duplicate organization");
@@ -141,7 +128,7 @@ public class OrganizationsIT extends AbstractRestIT {
 
         // Post to get token of what should be a non existent user due to the failure of creation above
 
-        tokenPayload = new Token( "password", username + "test", password );
+        tokenPayload = new Token( "password", organization.getName() + "test", organization.getPassword() );
         Token tokenError = null;
         try {
             tokenError = clientSetup.getRestClient().management().token().post( tokenPayload );
@@ -165,34 +152,30 @@ public class OrganizationsIT extends AbstractRestIT {
     @Test
     public void testCreateDuplicateOrgEmail() throws Exception {
 
-        //Setup the org/owner combo
-        String username = "testCreateDuplicateOrgEmail" + UUIDUtils.newTimeUUID();
-        String name = username;
-        String password = "password";
-        String orgName = username;
-        String email = username + "@usergrid.com";
-
-        Organization orgPayload = new Organization( orgName, username, email, name, password, null );
+        Organization organization = createOrgPayload( "testCreateDuplicateOrgEmail", null );
 
         //create the org/owner
-        Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post( orgPayload );
+        Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post( organization );
 
         this.refreshIndex();
 
         assertNotNull( orgCreatedResponse );
 
         //get token from organization that was created to verify it exists.
-        Token tokenPayload = new Token( "password", username, password );
+        Token tokenPayload = new Token( "password", organization.getUsername(), organization.getPassword() );
         Token tokenReturned = clientSetup.getRestClient().management().token().post( tokenPayload );
 
         assertNotNull( tokenReturned );
 
         //recreate a new payload using a duplicate email
-        orgPayload = new Organization( orgName+"test", username+"test", email, name+"test", password+"test", null );
+        Organization orgDuplicatePayload = new Organization( organization.getOrganization()+"test",
+                organization.getUsername()+"test", organization.getEmail(),
+                organization.getName()+"test", organization.getPassword()+"test", null );
+
 
         //verify that we cannot create an organization that shares a email with another preexisting organization.
         try {
-            clientSetup.getRestClient().management().orgs().post( orgPayload );
+            clientSetup.getRestClient().management().orgs().post( orgDuplicatePayload );
             fail( "Should not have created organization" );
         }
         catch ( UniformInterfaceException ex ) {
@@ -200,7 +183,7 @@ public class OrganizationsIT extends AbstractRestIT {
         }
 
         //try to get the token from the organization that failed to be created to verify it was not made.
-        tokenPayload = new Token( "password", username + "test", password );
+        tokenPayload = new Token( "password", organization.getUsername()+"test", organization.getPassword()+"test" );
         Token tokenError = null;
         try {
             tokenError = clientSetup.getRestClient().management().token().post( tokenPayload );
@@ -223,40 +206,33 @@ public class OrganizationsIT extends AbstractRestIT {
     public void testOrgPOSTParams() throws IOException {
 
         //Create organization defaults
-        String username = "testCreateDuplicateOrgEmail" + UUIDUtils.newTimeUUID();
-        String name = username;
-        String password = "password";
-        String orgName = username;
-        String email = username + "@usergrid.com";
+        Organization organization =  createOrgPayload( "testOrgPOSTParams",null );
 
         //Append them to the end as query parameters
         QueryParameters queryParameters = new QueryParameters();
-        queryParameters.setKeyValue( "organization",orgName );
-        queryParameters.setKeyValue( "username",username );
-        queryParameters.setKeyValue( "grant_type",password );
-        queryParameters.setKeyValue( "email",email  );
-        queryParameters.setKeyValue( "name",name );
-        queryParameters.setKeyValue( "password",password );
+        queryParameters.setKeyValue( "organization",organization.getOrganization());
+        queryParameters.setKeyValue( "username",organization.getUsername() );
+        queryParameters.setKeyValue( "grant_type","password" );
+        queryParameters.setKeyValue( "email",organization.getEmail() );
+        queryParameters.setKeyValue( "name",organization.getName() );
+        queryParameters.setKeyValue( "password",organization.getPassword() );
 
         //Post the organization and verify it worked
-        Organization organization = clientSetup.getRestClient().management().orgs().post( queryParameters );
+        Organization organizationReturned = clientSetup.getRestClient().management().orgs().post( queryParameters );
 
-        assertNotNull( organization );
-        assertEquals( orgName, organization.getName() );
+        assertNotNull( organizationReturned );
+        assertEquals( organization.getOrganization(), organizationReturned.getName());
 
         //get token from organization that was created to verify it exists. also sets the current context.
-        Token tokenPayload = new Token( "password", username, password );
+        Token tokenPayload = new Token( "password", organization.getName(), organization.getPassword() );
         Token tokenReturned = clientSetup.getRestClient().management().token().post( tokenPayload );
 
         assertNotNull( tokenReturned );
 
         //Assert that the get returns the correct org and owner.
-        Organization returnedOrg = clientSetup.getRestClient().management().orgs().organization( orgName ).get();
+        Organization returnedOrg = clientSetup.getRestClient().management().orgs().organization( organization.getOrganization() ).get();
 
-        assertTrue( returnedOrg != null && returnedOrg.getName().equals( orgName ) );
-        /**
-         * TODO: check all the parameters, make helper methods for duplicate code.
-         */
+        assertTrue( returnedOrg != null && returnedOrg.getName().equals(organization.getOrganization()) );
 
     }
 
@@ -268,23 +244,34 @@ public class OrganizationsIT extends AbstractRestIT {
     @Test
     public void testOrgPOSTForm() throws IOException {
 
+        Organization organization =  createOrgPayload( "testOrgPOSTForm",null );
+
         //create the form to hold the organization
-        UUID timeUuid = UUIDUtils.newTimeUUID();
         Form form = new Form();
-        form.add( "organization", "testOrgPOSTForm" + timeUuid );
-        form.add( "username", "testOrgPOSTForm" + timeUuid );
+        form.add( "organization", organization.getOrganization() );
+        form.add( "username", organization.getUsername() );
         form.add( "grant_type", "password" );
-        form.add( "email", "testOrgPOSTForm" + timeUuid + "@apigee.com" );
-        form.add( "name", "testOrgPOSTForm" );
-        form.add( "password", "password" );
+        form.add( "email", organization.getEmail() );
+        form.add( "name", organization.getName() );
+        form.add( "password", organization.getPassword() );
 
         //Post the organization and verify it worked.
-        Organization organization = clientSetup.getRestClient().management().orgs().post( form );
+        Organization organizationReturned = clientSetup.getRestClient().management().orgs().post( form );
+
+        assertNotNull( organizationReturned );
+        assertEquals( organization.getOrganization(),organizationReturned.getName() );
 
-        assertNotNull( organization );
-        assertEquals( "testOrgPOSTForm" + timeUuid ,organization.getName() );
+        //get token from organization that was created to verify it exists. also sets the current context.
+        Token tokenPayload = new Token( "password", organization.getName(), organization.getPassword() );
+        Token tokenReturned = clientSetup.getRestClient().management().token().post( tokenPayload );
+
+        assertNotNull( tokenReturned );
+
+        //Assert that the get returns the correct org and owner.
+        Organization returnedOrg = clientSetup.getRestClient().management().orgs().organization( organization.getOrganization() ).get();
+
+        assertTrue( returnedOrg != null && returnedOrg.getName().equals(organization.getOrganization()) );
 
-        //TODO: makes changes here as well.
     }
 
 
@@ -323,8 +310,7 @@ public class OrganizationsIT extends AbstractRestIT {
         adminUserPayload.put( "password", username );
 
         //create adminUser
-        Entity adminUserResponse = restClient.management().orgs().organization( clientSetup.getOrganizationName() )
-                                           .users().post( adminUserPayload );
+        Entity adminUserResponse = restClient.management().orgs().organization( clientSetup.getOrganizationName() ).users().post( adminUserPayload );
 
         //verify that the response contains the correct data
         assertNotNull( adminUserResponse );
@@ -382,4 +368,15 @@ public class OrganizationsIT extends AbstractRestIT {
         assertEquals( 6, orgResponse.getProperties().get( "puppies" ));
 
     }
+    
+    /**
+     * Create an organization payload with almost the same value for everyfield.
+     * @param baseName
+     * @param properties
+     * @return
+     */
+    public Organization createOrgPayload(String baseName,Map properties){
+        String orgName = baseName + UUIDUtils.newTimeUUID();
+        return new Organization( orgName+ UUIDUtils.newTimeUUID(),orgName,orgName+"@usergrid",orgName,orgName, properties);
+    }
 }


[50/50] [abbrv] incubator-usergrid git commit: Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o-import

Posted by gr...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o-import

# By Shawn Feldman (194) and others
# Via Todd Nine (47) and others
* 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid: (571 commits)
  added apache header to editor config
  Ignore known failing test
  Added fix for entity class and array list casting.
  Simplified the setup of some of the tests
  Cleanup the imports and add an actual loop in the connection loopback test.
  Added todo for final commit for fix.
  Revert "Made the styles path relative so they will no longer go to the root and get 401 errors."
  Added in a bunch of comments to clarify what was going on in PermissionsResourceIT
  Added missing comment to tests in OwnershipResourceIT Added revamped comments and cleaned the tests in ConnectionResourceTest
  Finished adding comments for OwnershipResourceIT
  Added a comment clearing what the token post method accomplishes. Adding clarifying comments to meVerify, contextualPathOwnership, and contextualConnectionOwnership test.
  Fixes and comments while looking over the tests
  [USERGRID-303]Fixed paging issue in orderByReturnCorrectResults
  [USERGRID-303]fixed tests after framework update
  [USERGRID-303]Code formatting and updates for query tests
  [USERGRID-303]Updated AND/OR query tests to work with new test framework
  [USERGRID-303]Updated 'order by' tests to work with new test framework
  [USERGRID-303]Updates to AndOrQueryTest
  Cleared up and added some comments to the tests in organizationIt Added comment to one of the methods in AbstractRestIt.
  Added comments to configuration options. removed 'root' declaration
  ...

Conflicts:
	portal/config.js
	stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
	stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
	stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
	stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
	stack/services/pom.xml
	stack/services/src/test/java/org/apache/usergrid/management/cassandra/ExportServiceIT.java
	stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java

Fixed some naming errors as well.


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

Branch: refs/heads/two-dot-o-import
Commit: 6deac18951acfffc271d60ccb919db3ffcf38fa0
Parents: 5d6c4ac bcabda2
Author: grey <gr...@apigee.com>
Authored: Tue Jan 13 11:14:26 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Tue Jan 13 11:14:26 2015 -0800

----------------------------------------------------------------------
 portal/Gruntfile.js                             |  194 ++-
 portal/build.sh                                 |    2 -
 portal/config.js                                |   97 +-
 portal/js/push/push-config.html                 |   89 +-
 portal/js/push/push-history.html                |    8 +-
 .../push/push-send-notification-controller.js   |   44 +-
 stack/.editorconfig                             |   42 +
 stack/awscluster/assembly.xml                   |    8 +-
 stack/awscluster/gatling-cluster-cf.json        |  387 +++++
 stack/awscluster/pom.xml                        |  379 +++--
 stack/awscluster/src/main/cql/create_locks.cql  |   44 -
 .../awscluster/src/main/cql/create_usergrid.cql |   96 --
 .../main/cql/create_usergrid_applications.cql   |  408 -----
 stack/awscluster/src/main/cql/update_locks.cql  |   23 +
 .../awscluster/src/main/cql/update_usergrid.cql |   27 +
 .../main/cql/update_usergrid_applications.cql   |   46 +
 .../main/dist/init_instance/create_keyspaces.sh |   39 -
 .../src/main/dist/init_instance/create_raid0.sh |   24 +-
 .../dist/init_instance/create_raid0_2disks.sh   |   54 -
 .../src/main/dist/init_instance/init_cass.sh    |   70 -
 .../main/dist/init_instance/init_db_server.sh   |   24 +-
 .../main/dist/init_instance/init_es_server.sh   |   71 +
 .../dist/init_instance/init_graphite_server.sh  |   13 +-
 .../dist/init_instance/init_opscenter_server.sh |  287 ++++
 .../main/dist/init_instance/init_rest_server.sh |  124 +-
 .../dist/init_instance/install_cassandra.sh     |   28 +-
 .../dist/init_instance/install_elasticsearch.sh |   75 +-
 .../init_instance/install_opscenter_agent.sh    |   13 +-
 .../main/dist/init_instance/install_yourkit.sh  |    6 +-
 .../main/dist/init_instance/update_keyspaces.sh |   66 +
 stack/awscluster/src/main/dist/update.sh        |   16 +-
 .../src/main/groovy/NodeRegistry.groovy         |  189 ++-
 .../src/main/groovy/configure_cassandra.groovy  |   26 +-
 .../main/groovy/configure_elasticsearch.groovy  |   99 +-
 .../groovy/configure_opscenter_agent.groovy     |    4 +-
 .../groovy/configure_opscenter_cassandra.groovy |  120 ++
 .../groovy/configure_opscenter_usergrid.groovy  |   58 +
 .../src/main/groovy/configure_usergrid.groovy   |   43 +-
 .../src/main/groovy/registry_list.groovy        |   36 -
 .../src/main/groovy/tag_instance.groovy         |   10 +-
 stack/awscluster/ugcluster-cf.json              |  837 +++++++++-
 .../main/resources/usergrid-default.properties  |   10 +-
 .../src/test/resources/usergrid-test.properties |   11 +-
 stack/core/.test-tdoe-5thread.log.swp           |  Bin 0 -> 28672 bytes
 stack/core/pom.xml                              |   84 +-
 .../corepersistence/CpEntityDeleteListener.java |   95 --
 .../CpEntityIndexDeleteListener.java            |   98 --
 .../corepersistence/CpEntityManager.java        | 1407 ++++++++---------
 .../corepersistence/CpEntityManagerFactory.java |  210 +--
 .../corepersistence/CpManagerCache.java         |  133 +-
 .../corepersistence/CpRelationManager.java      | 1475 +++++++++---------
 .../usergrid/corepersistence/CpSetup.java       |   37 +-
 .../usergrid/corepersistence/CpVisitor.java     |   11 +-
 .../usergrid/corepersistence/CpWalker.java      |  156 +-
 .../usergrid/corepersistence/GuiceModule.java   |   54 +-
 .../HybridEntityManagerFactory.java             |   49 +-
 .../usergrid/corepersistence/ManagerCache.java  |   69 +
 .../events/EntityDeletedHandler.java            |   68 +
 .../events/EntityVersionCreatedHandler.java     |   69 +
 .../events/EntityVersionDeletedHandler.java     |  102 ++
 .../migration/EntityDataMigration.java          |  147 ++
 .../migration/EntityTypeMappingMigration.java   |   99 ++
 .../migration/GraphShardVersionMigration.java   |  152 ++
 .../corepersistence/migration/Versions.java     |   45 +
 .../results/FilteringLoader.java                |   91 +-
 .../results/ResultsLoaderFactory.java           |   10 +-
 .../results/ResultsLoaderFactoryImpl.java       |   17 +-
 .../results/ResultsVerifier.java                |    6 +-
 .../results/VersionVerifier.java                |    8 +-
 .../rx/AllEntitiesInSystemObservable.java       |  101 ++
 .../rx/ApplicationObservable.java               |  128 ++
 .../rx/EdgesFromSourceObservable.java           |   63 +
 .../rx/EdgesToTargetObservable.java             |   63 +
 .../corepersistence/rx/TargetIdObservable.java  |   66 +
 .../corepersistence/util/CpEntityMapUtils.java  |   83 +-
 .../corepersistence/util/CpNamingUtils.java     |   95 +-
 .../apache/usergrid/metrics/MetricsFactory.java |   21 +-
 .../usergrid/persistence/EntityManager.java     |   13 +-
 .../persistence/EntityManagerFactory.java       |   71 +-
 .../usergrid/persistence/SimpleEntityRef.java   |    6 +
 .../persistence/cassandra/CassandraService.java |    3 +
 .../cassandra/EntityManagerFactoryImpl.java     |   42 +
 .../cassandra/EntityManagerImpl.java            |   94 +-
 .../cassandra/RelationManagerImpl.java          |   18 +-
 .../usergrid/persistence/entities/Notifier.java |    2 -
 .../org/apache/usergrid/AbstractCoreIT.java     |   12 +-
 .../apache/usergrid/ConcurrentCoreITSuite.java  |   51 -
 .../usergrid/ConcurrentCoreIteratorITSuite.java |   82 -
 .../usergrid/ConcurrentCoreTestSuite.java       |   46 -
 .../org/apache/usergrid/CoreApplication.java    |   21 +-
 .../org/apache/usergrid/CoreITSetupImpl.java    |   16 +-
 .../java/org/apache/usergrid/CoreITSuite.java   |   55 -
 .../java/org/apache/usergrid/CoreTestSuite.java |   45 -
 .../apache/usergrid/batch/SchedulerITSuite.java |   50 -
 .../usergrid/batch/SchedulerTestSuite.java      |   34 -
 .../batch/job/AbstractSchedulerRuntimeIT.java   |   28 +-
 .../usergrid/batch/job/SchedulerRuntime1IT.java |    2 +
 .../usergrid/batch/job/SchedulerRuntime2IT.java |    2 +
 .../usergrid/batch/job/SchedulerRuntime3IT.java |    2 +
 .../usergrid/batch/job/SchedulerRuntime4IT.java |    2 +
 .../usergrid/batch/job/SchedulerRuntime5IT.java |    2 +
 .../usergrid/batch/job/SchedulerRuntime6IT.java |    2 +
 .../usergrid/batch/job/SchedulerRuntime7IT.java |    2 +
 .../usergrid/batch/job/SchedulerRuntime8IT.java |    2 +-
 .../batch/job/SchedulerRuntimeIntervalIT.java   |   49 +-
 .../CpEntityDeleteListenerTest.java             |   92 --
 .../CpEntityIndexDeleteListenerTest.java        |  114 --
 .../corepersistence/EntityWriteHelper.java      |   59 +
 .../corepersistence/StaleIndexCleanupTest.java  |  332 +++-
 .../corepersistence/TestGuiceModule.java        |    9 +-
 .../migration/EntityDataMigrationIT.java        |  259 +++
 .../migration/EntityTypeMappingMigrationIT.java |  175 +++
 .../migration/GraphShardVersionMigrationIT.java |  222 +++
 .../migration/MigrationTestRule.java            |  101 ++
 .../migration/TestProgressObserver.java         |   71 +
 .../rx/AllEntitiesInSystemObservableIT.java     |  139 ++
 .../rx/ApplicationObservableTestIT.java         |   82 +
 .../rx/EdgesFromSourceObservableIT.java         |  140 ++
 .../rx/EdgesToTargetObservableIT.java           |  150 ++
 .../rx/TargetIdObservableTestIT.java            |  131 ++
 .../usergrid/persistence/CollectionIT.java      |  206 +--
 .../apache/usergrid/persistence/CounterIT.java  |   93 +-
 .../usergrid/persistence/CountingMutatorIT.java |    4 +-
 .../persistence/EntityConnectionsIT.java        |   43 +-
 .../persistence/EntityDictionaryIT.java         |   11 +-
 .../usergrid/persistence/EntityManagerIT.java   |   47 +-
 .../org/apache/usergrid/persistence/GeoIT.java  |  656 +++++---
 .../persistence/GeoQueryBooleanTest.java        |    7 +-
 .../apache/usergrid/persistence/IndexIT.java    |   35 +-
 .../usergrid/persistence/LargeEntityIT.java     |  112 ++
 .../usergrid/persistence/PathQueryIT.java       |   10 +-
 .../PerformanceEntityRebuildIndexTest.java      |   46 +-
 .../persistence/PerformanceEntityWriteTest.java |    2 +-
 .../usergrid/persistence/PermissionsIT.java     |    5 +-
 .../apache/usergrid/persistence/QueryTest.java  |   15 +
 .../cassandra/EntityManagerFactoryImplIT.java   |   24 +-
 .../SimpleIndexBucketLocatorImplTest.java       |  177 ---
 .../SimpleIndexShardLocatorImplTest.java        |  177 +++
 .../query/AbstractIteratingQueryIT.java         |   36 +-
 .../query/AllInConnectionNoTypeIT.java          |    2 +-
 .../system/UsergridSystemMonitorIT.java         |   14 +-
 stack/core/src/test/resources/largeentity.json  | 1329 ++++++++++++++++
 stack/core/src/test/resources/log4j.properties  |    5 +-
 .../resources/usergrid-custom-test.properties   |    7 +-
 stack/corepersistence/collection/pom.xml        |    7 +-
 .../collection/EntityCollectionManager.java     |   25 +-
 .../collection/EntityDeletedFactory.java        |   34 +
 .../persistence/collection/EntitySet.java       |    4 +-
 .../collection/EntityVersionCleanupFactory.java |   35 +
 .../collection/EntityVersionCreatedFactory.java |   31 +
 .../persistence/collection/VersionSet.java      |   22 +-
 .../collection/event/EntityDeleted.java         |    5 +-
 .../collection/event/EntityVersionCreated.java  |   14 +-
 .../collection/event/EntityVersionDeleted.java  |   11 +-
 .../exception/DataCorruptionException.java      |   32 +
 .../exception/EntityTooLargeException.java      |   67 +
 .../collection/guice/CollectionModule.java      |   24 +-
 .../collection/impl/CollectionScopeImpl.java    |    4 +-
 .../impl/EntityCollectionManagerImpl.java       |  309 ++--
 .../collection/impl/EntityDeletedTask.java      |  148 ++
 .../impl/EntityVersionCleanupTask.java          |  224 +--
 .../impl/EntityVersionCreatedTask.java          |  122 ++
 .../mvcc/MvccEntitySerializationStrategy.java   |   23 +-
 .../mvcc/MvccLogEntrySerializationStrategy.java |    3 +-
 .../mvcc/stage/delete/MarkCommit.java           |  140 +-
 .../mvcc/stage/write/WriteCommit.java           |    3 +-
 .../serialization/SerializationFig.java         |   17 +-
 .../UniqueValueSerializationStrategy.java       |    3 +-
 .../impl/CollectionPrefixedKey.java             |  100 ++
 .../impl/CollectionScopedRowKeySerializer.java  |   25 +-
 .../serialization/impl/EntityRepairImpl.java    |    2 +-
 .../impl/EntityVersionSerializer.java           |    3 -
 .../MvccEntitySerializationStrategyImpl.java    |  400 ++---
 ...vccEntitySerializationStrategyProxyImpl.java |  162 ++
 .../MvccEntitySerializationStrategyV1Impl.java  |  219 +++
 .../MvccEntitySerializationStrategyV2Impl.java  |  238 +++
 .../MvccLogEntrySerializationStrategyImpl.java  |   68 +-
 .../serialization/impl/SerializationModule.java |   27 +-
 .../serialization/impl/SettingsValidation.java  |   58 +
 .../UniqueValueSerializationStrategyImpl.java   |   33 +-
 .../collection/CollectionContextImplTest.java   |    3 -
 .../EntityCollectionManagerFactoryTest.java     |    8 +-
 .../collection/EntityCollectionManagerIT.java   |   73 +-
 .../EntityCollectionManagerStressTest.java      |    8 +-
 .../EntityCollectionManagerSyncIT.java          |    6 +-
 .../collection/guice/MigrationManagerRule.java  |   38 -
 .../collection/guice/TestCollectionModule.java  |   13 +-
 .../collection/guice/TestModule.java            |   48 -
 .../impl/EntityVersionCleanupTaskTest.java      |  450 ++++--
 .../impl/EntityVersionCreatedTaskTest.java      |  244 +++
 ...niqueValueSerializationStrategyImplTest.java |    6 +-
 .../stage/write/WriteOptimisticVerifyTest.java  |    2 +-
 .../mvcc/stage/write/WriteUniqueVerifyIT.java   |    6 +-
 .../mvcc/stage/write/WriteUniqueVerifyTest.java |    6 +-
 .../serialization/EntityRepairImplTest.java     |    2 +-
 ...MvccEntitySerializationStrategyImplTest.java |   95 +-
 ...cEntitySerializationStrategyProxyV1Test.java |   85 +
 ...cEntitySerializationStrategyProxyV2Test.java |   83 +
 ...ccEntitySerializationStrategyV1ImplTest.java |   55 +
 ...ccEntitySerializationStrategyV2ImplTest.java |   55 +
 .../MvccEntitySerializationStrategyV2Test.java  |  229 +++
 .../impl/MvccLESSTransientTest.java             |   39 +-
 ...ccLogEntrySerializationStrategyImplTest.java |    6 +-
 .../impl/ScopedRowKeySerializerTest.java        |   18 +-
 .../impl/SettingsValidationTest.java            |  131 ++
 .../collection/util/EntityHelper.java           |  105 ++
 .../src/test/resources/log4j.properties         |   21 +-
 stack/corepersistence/common/pom.xml            |   28 +-
 .../core/astyanax/BucketScopedRowKey.java       |  115 ++
 .../astyanax/BucketScopedRowKeySerializer.java  |   91 ++
 .../core/astyanax/CassandraConfig.java          |   24 +
 .../core/astyanax/CassandraConfigImpl.java      |   23 +
 .../persistence/core/astyanax/CassandraFig.java |   26 +
 .../core/astyanax/ColumnNameIterator.java       |    1 -
 .../persistence/core/astyanax/ColumnSearch.java |   43 +-
 .../persistence/core/astyanax/ColumnTypes.java  |   19 +-
 .../core/astyanax/CompositeFieldSerializer.java |    1 +
 .../persistence/core/astyanax/FieldBuffer.java  |   70 +
 .../core/astyanax/FieldBufferBuilder.java       |   86 +
 .../core/astyanax/FieldBufferParser.java        |   81 +
 .../core/astyanax/FieldBufferSerializer.java    |  134 ++
 .../core/astyanax/IdRowCompositeSerializer.java |    1 +
 .../astyanax/MultiKeyColumnNameIterator.java    |    2 -
 .../core/astyanax/MultiRowColumnIterator.java   |  234 ++-
 .../core/astyanax/MultiTennantColumnFamily.java |    9 +-
 .../OrganizationScopedRowKeySerializer.java     |   85 -
 .../persistence/core/astyanax/ScopedRowKey.java |   14 +-
 .../core/astyanax/ScopedRowKeySerializer.java   |   83 +
 .../astyanax/StringRowCompositeSerializer.java  |   61 +
 .../persistence/core/guice/CommonModule.java    |   43 +-
 .../persistence/core/guice/CurrentImpl.java     |   42 +
 .../persistence/core/guice/PreviousImpl.java    |   42 +
 .../persistence/core/guice/ProxyImpl.java       |   42 +
 .../core/guicyfig/SetConfigTestBypass.java      |  108 ++
 .../core/hystrix/HystrixCassandra.java          |    3 -
 .../persistence/core/migration/Migration.java   |   36 -
 .../core/migration/MigrationException.java      |   37 -
 .../core/migration/MigrationManager.java        |   34 -
 .../core/migration/MigrationManagerFig.java     |   22 -
 .../core/migration/MigrationManagerImpl.java    |  196 ---
 .../core/migration/data/DataMigration.java      |   81 +
 .../migration/data/DataMigrationException.java  |   37 +
 .../migration/data/DataMigrationManager.java    |   64 +
 .../data/DataMigrationManagerImpl.java          |  282 ++++
 .../data/MigrationInfoSerialization.java        |   63 +
 .../data/MigrationInfoSerializationImpl.java    |  175 +++
 .../core/migration/schema/Migration.java        |   36 +
 .../migration/schema/MigrationException.java    |   37 +
 .../core/migration/schema/MigrationManager.java |   34 +
 .../migration/schema/MigrationManagerFig.java   |   40 +
 .../migration/schema/MigrationManagerImpl.java  |  214 +++
 .../core/shard/ExpandingShardLocator.java       |   76 +
 .../persistence/core/shard/ShardLocator.java    |   77 +
 .../persistence/core/shard/StringHashUtils.java |   34 +
 .../core/task/NamedTaskExecutorImpl.java        |  141 +-
 .../usergrid/persistence/core/task/Task.java    |   19 +-
 .../persistence/core/task/TaskExecutor.java     |   18 +
 .../usergrid/persistence/core/util/Health.java  |   23 +
 .../core/astyanax/ColumnNameIteratorTest.java   |   27 +-
 .../astyanax/FieldBufferSerializerTest.java     |  126 ++
 .../MultiKeyColumnNameIteratorTest.java         |   26 +-
 .../astyanax/MultiRowColumnIteratorTest.java    |   62 +-
 .../core/cassandra/CassandraRule.java           |  114 --
 .../persistence/core/cassandra/ITRunner.java    |   60 -
 .../core/guice/MaxMigrationModule.java          |   39 +
 .../core/guice/MaxMigrationVersion.java         |   40 +
 .../core/guice/MigrationManagerRule.java        |   23 +-
 .../core/guice/TestCommonModule.java            |   34 +
 .../persistence/core/guice/TestModule.java      |   48 +
 .../data/DataMigrationManagerImplTest.java      |  220 +++
 .../data/MigrationInfoSerializationTest.java    |  116 ++
 .../core/shard/ExpandingShardLocatorTest.java   |   65 +
 .../core/shard/ShardLocatorTest.java            |   64 +
 .../core/task/NamedTaskExecutorImplTest.java    |   56 +-
 .../persistence/core/test/ITRunner.java         |  103 ++
 .../persistence/core/test/UseModules.java       |   69 +
 stack/corepersistence/graph/pom.xml             |   15 +-
 .../persistence/graph/guice/GraphModule.java    |   34 +-
 .../graph/impl/GraphManagerImpl.java            |   13 +-
 .../graph/impl/stage/EdgeMetaRepairImpl.java    |    3 +-
 .../impl/stage/NodeDeleteListenerImpl.java      |    3 +-
 .../EdgeMetadataSerialization.java              |    2 +-
 .../graph/serialization/NodeSerialization.java  |    2 +-
 .../impl/EdgeMetadataSerializationImpl.java     |  476 ------
 .../EdgeMetadataSerializationProxyImpl.java     |  276 ++++
 .../impl/EdgeMetadataSerializationV1Impl.java   |  478 ++++++
 .../impl/EdgeMetadataSerializationV2Impl.java   |  627 ++++++++
 .../impl/NodeSerializationImpl.java             |   36 +-
 .../impl/shard/EdgeColumnFamilies.java          |   14 +-
 .../impl/shard/EdgeShardSerialization.java      |    2 +-
 .../count/NodeShardCounterSerialization.java    |    2 +-
 .../NodeShardCounterSerializationImpl.java      |   10 +-
 .../impl/shard/impl/EdgeSearcher.java           |   18 +-
 .../shard/impl/EdgeShardSerializationImpl.java  |   14 +-
 .../impl/ShardedEdgeSerializationImpl.java      |   76 +-
 .../impl/shard/impl/ShardsColumnIterator.java   |   21 +-
 .../shard/impl/SizebasedEdgeColumnFamilies.java |   34 +-
 .../impl/shard/impl/SourceEdgeSearcher.java     |   22 -
 .../serialize/EdgeShardRowKeySerializer.java    |    2 +
 .../shard/impl/serialize/RowSerializer.java     |    2 +-
 .../shard/impl/serialize/RowTypeSerializer.java |    3 +-
 .../graph/CommittedGraphManagerIT.java          |    4 +-
 .../persistence/graph/GraphManagerIT.java       |   11 +-
 .../persistence/graph/GraphManagerLoadTest.java |    6 +-
 .../graph/GraphManagerShardConsistencyIT.java   |   13 +-
 .../graph/GraphManagerShardingIT.java           |    6 +-
 .../graph/GraphManagerStressTest.java           |    6 +-
 .../usergrid/persistence/graph/SimpleTest.java  |    6 +-
 .../graph/StorageGraphManagerIT.java            |    4 +-
 .../graph/guice/TestGraphModule.java            |   13 +-
 .../graph/impl/EdgeDeleteListenerTest.java      |    8 +-
 .../graph/impl/NodeDeleteListenerTest.java      |    8 +-
 .../graph/impl/stage/EdgeDeleteRepairTest.java  |    6 +-
 .../graph/impl/stage/EdgeMetaRepairTest.java    |    8 +-
 .../EdgeMetaDataSerializationProxyV1Test.java   |   85 +
 .../EdgeMetaDataSerializationProxyV2Test.java   |   82 +
 .../EdgeMetaDataSerializationV1Test.java        |   69 +
 .../EdgeMetaDataSerializationV2Test.java        |   52 +
 .../EdgeMetadataSerializationTest.java          |   35 +-
 .../EdgeSerializationChopTest.java              |    6 +-
 .../serialization/EdgeSerializationTest.java    |   59 +-
 .../serialization/NodeSerializationTest.java    |   12 +-
 .../PermanentSerializationTest.java             |    9 +-
 .../graph/serialization/TestCount.java          |   52 +-
 .../impl/shard/EdgeShardSerializationTest.java  |   42 +-
 .../impl/shard/NodeShardAllocationTest.java     |   15 +-
 .../impl/shard/NodeShardCacheTest.java          |  118 +-
 .../impl/shard/ShardEntryGroupTest.java         |   57 +-
 .../impl/shard/ShardGroupCompactionTest.java    |  181 ++-
 .../shard/count/NodeShardApproximationTest.java |   18 +-
 .../NodeShardCounterSerializationTest.java      |   16 +-
 .../shard/impl/ShardEntryGroupIteratorTest.java |    9 +-
 ...rceDirectedEdgeDescendingComparatorTest.java |    4 +-
 .../1.4-UG/_maven.repositories                  |    4 -
 .../1.4-UG/jukito-build-tools-1.4-UG.jar        |  Bin 4603 -> 0 bytes
 .../1.4-UG/jukito-build-tools-1.4-UG.pom        |   13 -
 .../jukito-build-tools/maven-metadata-local.xml |   12 -
 .../jukito-parent/1.4-UG/_maven.repositories    |    3 -
 .../1.4-UG/jukito-parent-1.4-UG.pom             |  313 ----
 .../jukito-parent/maven-metadata-local.xml      |   12 -
 .../jukito-samples/1.4-UG/_maven.repositories   |    4 -
 .../1.4-UG/jukito-samples-1.4-UG.jar            |  Bin 5103 -> 0 bytes
 .../1.4-UG/jukito-samples-1.4-UG.pom            |   33 -
 .../jukito-samples/maven-metadata-local.xml     |   12 -
 .../jukito/jukito/1.4-UG/_maven.repositories    |    5 -
 .../jukito/1.4-UG/jukito-1.4-UG-sources.jar     |  Bin 30660 -> 0 bytes
 .../org/jukito/jukito/1.4-UG/jukito-1.4-UG.jar  |  Bin 42832 -> 0 bytes
 .../org/jukito/jukito/1.4-UG/jukito-1.4-UG.pom  |   93 --
 .../org/jukito/jukito/maven-metadata-local.xml  |   12 -
 stack/corepersistence/map/pom.xml               |    6 -
 .../persistence/map/guice/MapModule.java        |    2 +-
 .../persistence/map/impl/MapSerialization.java  |    2 +-
 .../map/impl/MapSerializationImpl.java          |   97 +-
 .../persistence/map/MapManagerTest.java         |    6 +-
 .../persistence/map/guice/TestMapModule.java    |    2 +-
 .../persistence/model/field/LocationField.java  |    7 +-
 stack/corepersistence/pom.xml                   |    5 +-
 stack/corepersistence/queryindex/pom.xml        |   11 -
 .../persistence/index/AliasedEntityIndex.java   |   48 +
 .../usergrid/persistence/index/EntityIndex.java |   64 +-
 .../persistence/index/EntityIndexBatch.java     |   11 +-
 .../persistence/index/EntityIndexFactory.java   |    2 -
 .../usergrid/persistence/index/IndexFig.java    |   31 +
 .../persistence/index/IndexIdentifier.java      |   92 ++
 .../usergrid/persistence/index/IndexScope.java  |    9 +-
 .../usergrid/persistence/index/SearchTypes.java |  130 ++
 .../persistence/index/guice/IndexModule.java    |    1 -
 .../index/impl/EsEntityIndexBatchImpl.java      |  162 +-
 .../index/impl/EsEntityIndexImpl.java           |  592 +++++--
 .../persistence/index/impl/EsIndexCache.java    |  114 ++
 .../persistence/index/impl/EsProvider.java      |  202 +--
 .../persistence/index/impl/EsQueryVistor.java   |    4 +-
 .../persistence/index/impl/FailureMonitor.java  |   41 +
 .../index/impl/FailureMonitorImpl.java          |  101 ++
 .../persistence/index/impl/IndexScopeImpl.java  |   14 +-
 .../persistence/index/impl/IndexingUtils.java   |  137 +-
 .../index/query/CandidateResults.java           |   10 +-
 .../persistence/index/query/EntityResults.java  |   10 +-
 .../persistence/index/query/Identifier.java     |    6 +-
 .../usergrid/persistence/index/query/Query.java |  111 +-
 .../persistence/index/query/Results.java        |    4 +-
 .../index/guice/TestIndexModule.java            |    2 +-
 .../index/impl/CorePerformanceIT.java           |   42 +-
 .../index/impl/ElasticSearchResource.java       |   82 +
 .../index/impl/ElasticSearchRule.java           |   50 -
 .../impl/EntityConnectionIndexImplTest.java     |  252 ++-
 .../index/impl/EntityIndexMapUtils.java         |    4 +-
 .../persistence/index/impl/EntityIndexTest.java |  262 +++-
 .../persistence/index/impl/EsRunner.java        |   51 +
 .../persistence/index/impl/EsTestUtils.java     |   48 +
 .../persistence/query/tree/GrammarTreeTest.java |    2 +-
 .../src/test/resources/dynamic-test.properties  |    2 +-
 .../src/test/resources/usergrid-UNIT.properties |    8 +-
 stack/corepersistence/queue/pom.xml             |   17 +-
 .../persistence/queue/DefaultQueueManager.java  |   68 +
 .../usergrid/persistence/queue/Queue.java       |    4 +
 .../usergrid/persistence/queue/QueueFig.java    |    5 +-
 .../persistence/queue/QueueScopeFactory.java    |   34 +
 .../persistence/queue/guice/QueueModule.java    |   10 +-
 .../queue/impl/QueueScopeFactoryImpl.java       |   47 +
 .../queue/impl/SQSQueueManagerImpl.java         |  128 +-
 .../persistence/queue/QueueManagerTest.java     |   45 +-
 .../queue/guice/TestQueueModule.java            |    2 +-
 .../usergrid/launcher/EmbeddedServerHelper.java |    4 +-
 stack/loadtests/README.md                       |   47 +
 stack/loadtests/pom.xml                         |  148 ++
 stack/loadtests/runtests.sh                     |  120 ++
 .../datagenerators/EntityDataGenerator.scala    |   83 +
 .../datagenerators/FeederGenerator.scala        |  155 ++
 .../apache/usergrid/helpers/Extractors.scala    |   84 +
 .../org/apache/usergrid/helpers/Setup.scala     |  178 +++
 .../scenarios/ApplicationScenarios.scala        |   52 +
 .../scenarios/ConnectionScenarios.scala         |   65 +
 .../usergrid/scenarios/DeviceScenarios.scala    |   89 ++
 .../usergrid/scenarios/EntityScenarios.scala    |   65 +
 .../usergrid/scenarios/GeoScenarios.scala       |   48 +
 .../scenarios/NotificationScenarios.scala       |   85 +
 .../usergrid/scenarios/NotifierScenarios.scala  |   70 +
 .../scenarios/OrganizationScenarios.scala       |   60 +
 .../usergrid/scenarios/TokenScenarios.scala     |   57 +
 .../usergrid/scenarios/UserScenarios.scala      |  209 +++
 .../org/apache/usergrid/settings/Headers.scala  |   47 +
 .../org/apache/usergrid/settings/Settings.scala |   74 +
 .../org/apache/usergrid/settings/Utils.scala    |   91 ++
 .../usergrid/simulations/AppSimulation.scala    |   44 +
 .../simulations/ConnectionsSimulation.scala     |   53 +
 .../simulations/DeleteUsersSimulation.scala     |   56 +
 .../simulations/GetEntitySimulation.scala       |   44 +
 .../simulations/GetUserPagesSimulation.scala    |   51 +
 .../simulations/GetUsersSimulation.scala        |   51 +
 .../PostCustomEntitySimulation.scala            |   61 +
 .../simulations/PostUsersSimulation.scala       |   51 +
 .../PushNotificationTargetUserSimulation.scala  |   43 +
 .../simulations/PutUsersSimulation.scala        |   56 +
 .../usergrid/simulations/SetupSimulation.scala  |   45 +
 stack/loadtests/src/main/scripts/gatling-mvn.sh |   31 +
 stack/loadtests/src/main/scripts/gatling-ug.sh  |   51 +
 stack/loadtests/src/test/resources/gatling.conf |  154 ++
 .../src/test/resources/logback-test.xml         |   40 +
 stack/loadtests/src/test/resources/logback.xml  |   38 +
 .../loadtests/src/test/resources/recorder.conf  |   37 +
 stack/loadtests/src/test/scala/Engine.scala     |   32 +
 .../src/test/scala/IDEPathHelper.scala          |   37 +
 stack/loadtests/src/test/scala/Recorder.scala   |   28 +
 .../_maven.repositories                         |    8 -
 ...14c97c6e3ef40c88590e1b196d3ec55b-javadoc.jar |  Bin 160201 -> 0 bytes
 ...14c97c6e3ef40c88590e1b196d3ec55b-sources.jar |  Bin 59744 -> 0 bytes
 ...63dec68314c97c6e3ef40c88590e1b196d3ec55b.jar |  Bin 67751 -> 0 bytes
 ...7c6e3ef40c88590e1b196d3ec55b.jar.lastUpdated |   13 -
 ...63dec68314c97c6e3ef40c88590e1b196d3ec55b.pom |  166 --
 ...7c6e3ef40c88590e1b196d3ec55b.pom.lastUpdated |   13 -
 .../pushy-0.4-apigee.pom                        |  166 --
 stack/pom.xml                                   |   69 +-
 .../org/apache/usergrid/rest/IndexResource.java |  227 +++
 .../rest/JacksonCustomMapperProvider.java       |    7 +-
 .../apache/usergrid/rest/MigrateResource.java   |  165 ++
 .../org/apache/usergrid/rest/RootResource.java  |   42 +-
 .../apache/usergrid/rest/SwaggerServlet.java    |    5 +-
 .../apache/usergrid/rest/SystemResource.java    |  166 +-
 .../usergrid/rest/TextToJsonSwapWriter.java     |    8 +-
 .../IllegalArgumentExceptionMapper.java         |    8 +
 .../exceptions/ManagementExceptionMapper.java   |   13 +-
 .../rest/exceptions/ThrowableMapper.java        |   12 +
 .../rest/management/ManagementResource.java     |    2 +
 .../organizations/OrganizationResource.java     |   13 +-
 .../applications/ApplicationResource.java       |  169 +-
 .../rest/management/users/UsersResource.java    |   38 +-
 stack/rest/src/main/webapp/WEB-INF/web.xml      |    2 +-
 .../apache/usergrid/rest/AbstractRestIT.java    |   29 +-
 .../java/org/apache/usergrid/rest/BasicIT.java  |  124 +-
 .../java/org/apache/usergrid/rest/ITSetup.java  |   22 +-
 .../apache/usergrid/rest/IndexResourceIT.java   |   80 +
 .../org/apache/usergrid/rest/RestITSuite.java   |    4 +-
 .../apache/usergrid/rest/TestContextSetup.java  |   14 +-
 .../applications/ApplicationResourceIT.java     |    2 -
 .../applications/assets/AssetResourceIT.java    |   43 +-
 .../collection/BrowserCompatibilityTest.java    |    2 +-
 .../collection/DuplicateNameIT.java             |    4 +-
 .../activities/ActivityResourceIT.java          |  133 +-
 .../collection/activities/PutTest.java          |   33 +-
 .../collection/devices/DevicesResourceIT.java   |   39 +-
 .../collection/groups/GroupResourceIT.java      |  684 +++++---
 .../collection/groups/UpdateGroupIT.java        |  114 --
 .../collection/paging/PagingEntitiesTest.java   |  141 --
 .../collection/paging/PagingResourceIT.java     |  440 +++---
 .../users/ConnectionResourceTest.java           |  282 ++--
 .../collection/users/OwnershipResourceIT.java   |  424 ++---
 .../collection/users/PermissionsResourceIT.java |  723 +++------
 .../collection/users/RetrieveUsersTest.java     |   40 +-
 .../collection/users/UserResourceIT.java        | 1260 ++++++---------
 .../applications/queries/AndOrQueryTest.java    |  389 +++--
 .../queries/BadGrammarQueryTest.java            |   78 +-
 .../applications/queries/BasicGeoTests.java     |  268 ++++
 .../applications/queries/GeoPagingTest.java     |  361 +++--
 .../applications/queries/MatrixQueryTests.java  |  181 +--
 .../rest/applications/queries/OrderByTest.java  |  269 ++--
 .../rest/applications/utils/TestUtils.java      |   19 +
 .../rest/applications/utils/UserRepo.java       |   51 +-
 .../usergrid/rest/management/AccessTokenIT.java |  381 ++---
 .../usergrid/rest/management/AdminUsersIT.java  |    6 -
 .../rest/management/ExportResourceIT.java       |  333 ++--
 .../rest/management/ManagementResourceIT.java   |  143 +-
 .../rest/management/OrganizationsIT.java        |  498 +++---
 .../rest/management/RegistrationIT.java         |   61 +-
 .../usergrid/rest/test/resource/Connection.java |    9 +
 .../rest/test/resource/OrgUserUUIDWrapper.java  |   42 +
 .../rest/test/resource/TestContext.java         |   88 +-
 .../rest/test/resource/TestOrganization.java    |   55 +
 .../rest/test/resource/ValueResource.java       |    2 +
 .../rest/test/resource/app/Application.java     |   16 +-
 .../rest/test/resource/app/Collection.java      |   81 +
 .../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 |   26 +-
 .../resource/mgmt/OrganizationsCollection.java  |   28 +-
 .../test/resource2point0/AbstractRestIT.java    |  159 ++
 .../rest/test/resource2point0/ClientSetup.java  |  113 ++
 .../rest/test/resource2point0/DumbClient.java   |   58 +
 .../rest/test/resource2point0/RestClient.java   |  114 ++
 .../endpoints/ApplicationsResource.java         |   48 +
 .../endpoints/CollectionEndpoint.java           |  221 +++
 .../endpoints/EntityEndpoint.java               |  176 +++
 .../endpoints/NamedResource.java                |  109 ++
 .../endpoints/OrganizationResource.java         |   55 +
 .../resource2point0/endpoints/RootResource.java |   85 +
 .../endpoints/TokenResource.java                |   61 +
 .../resource2point0/endpoints/UrlResource.java  |   44 +
 .../endpoints/mgmt/ApplicationResource.java     |   48 +
 .../endpoints/mgmt/ManagementResource.java      |   44 +
 .../endpoints/mgmt/OrgResource.java             |  114 ++
 .../endpoints/mgmt/OrganizationResource.java    |   83 +
 .../endpoints/mgmt/TokenResource.java           |   54 +
 .../endpoints/mgmt/UsersResource.java           |   61 +
 .../resource2point0/model/ActivityEntity.java   |   49 +
 .../test/resource2point0/model/ApiResponse.java |  219 +++
 .../test/resource2point0/model/Application.java |   39 +
 .../model/ChangePasswordEntity.java             |   33 +
 .../test/resource2point0/model/Collection.java  |   98 ++
 .../rest/test/resource2point0/model/Entity.java |  204 +++
 .../resource2point0/model/Organization.java     |  117 ++
 .../resource2point0/model/QueryParameters.java  |   93 ++
 .../rest/test/resource2point0/model/Token.java  |   72 +
 .../rest/test/resource2point0/model/User.java   |  101 ++
 .../resource2point0/state/ClientContext.java    |   39 +
 .../usergrid/rest/test/security/TestUser.java   |    5 +
 .../resources/usergrid-custom-test.properties   |    6 +-
 stack/services/pom.xml                          |  267 +---
 .../cassandra/ManagementServiceImpl.java        |    2 -
 .../management/importer/FileImportJob.java      |    6 +-
 .../usergrid/management/importer/ImportJob.java |    5 +-
 .../management/importer/ImportServiceImpl.java  |   26 +-
 .../services/devices/DevicesService.java        |   55 +-
 .../notifications/ApplicationQueueManager.java  |  586 +------
 .../notifications/InactiveDeviceManager.java    |   79 +
 .../notifications/NotificationsService.java     |   47 +-
 .../services/notifications/ProviderAdapter.java |   42 +-
 .../notifications/ProviderAdapterFactory.java   |   49 +
 .../services/notifications/QueueListener.java   |   97 +-
 .../services/notifications/TaskManager.java     |   24 +-
 .../services/notifications/TestAdapter.java     |   23 +-
 .../notifications/apns/APNsAdapter.java         |  200 +--
 .../notifications/apns/EntityPushManager.java   |   76 +
 .../apns/ExpiredTokenListener.java              |   52 +
 .../services/notifications/gcm/GCMAdapter.java  |  142 +-
 .../impl/ApplicationQueueManagerImpl.java       |  523 +++++++
 .../services/notifiers/NotifiersService.java    |   30 +-
 .../services/users/devices/DevicesService.java  |   33 +
 .../usergrid/ConcurrentServiceITSuite.java      |   60 -
 .../org/apache/usergrid/NewOrgAppAdminRule.java |  159 ++
 .../org/apache/usergrid/ServiceApplication.java |   18 +-
 .../org/apache/usergrid/ServiceITSetupImpl.java |    1 +
 .../org/apache/usergrid/ServiceITSuite.java     |   63 -
 .../apache/usergrid/management/EmailFlowIT.java |  124 +-
 .../usergrid/management/OrganizationIT.java     |   36 +-
 .../org/apache/usergrid/management/RoleIT.java  |   12 +-
 .../cassandra/ApplicationCreatorIT.java         |   46 +-
 .../management/cassandra/ExportServiceIT.java   |  115 +-
 .../management/cassandra/ImportServiceIT.java   |   23 +-
 .../cassandra/ManagementServiceIT.java          |   93 +-
 .../security/providers/FacebookProviderIT.java  |   21 +-
 .../providers/PingIdentityProviderIT.java       |   12 +-
 .../security/tokens/TokenServiceIT.java         |   55 +-
 .../usergrid/services/AbstractServiceIT.java    |   13 +-
 .../usergrid/services/ConnectionsServiceIT.java |    4 +-
 .../usergrid/services/GroupServiceIT.java       |    4 +-
 .../usergrid/services/RolesServiceIT.java       |    2 +-
 .../usergrid/services/ServiceFactoryIT.java     |    4 +-
 .../usergrid/services/ServiceRequestIT.java     |   14 +-
 .../usergrid/services/TestQueueManager.java     |   65 -
 .../usergrid/services/UsersServiceIT.java       |    2 +-
 .../AbstractServiceNotificationIT.java          |   34 +-
 .../notifications/NotifiersServiceIT.java       |   35 +-
 .../apns/MockSuccessfulProviderAdapter.java     |   38 +-
 .../apns/NotificationsServiceIT.java            |  363 ++---
 .../gcm/MockSuccessfulProviderAdapter.java      |   33 +-
 .../gcm/NotificationsServiceIT.java             |  284 +---
 .../resources/usergrid-custom-test.properties   |    4 +-
 stack/test-utils/pom.xml                        |   12 +-
 .../org/apache/usergrid/ElasticSearchMain.java  |  107 --
 .../apache/usergrid/ElasticSearchResource.java  |  178 ---
 .../java/org/apache/usergrid/TestHelper.java    |   75 +
 .../usergrid/cassandra/CassandraResource.java   |  572 ++-----
 .../cassandra/CassandraResourceTest.java        |    7 +-
 .../resources/usergrid-custom-test.properties   |    2 +-
 606 files changed, 35539 insertions(+), 16075 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6deac189/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index d1a0442,3ab767c..2ef13dc
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@@ -70,24 -55,7 +55,9 @@@ import org.apache.usergrid.persistence.
  import org.apache.usergrid.persistence.RelationManager;
  import org.apache.usergrid.persistence.Results;
  import org.apache.usergrid.persistence.Schema;
- import static org.apache.usergrid.persistence.Schema.COLLECTION_ROLES;
- import static org.apache.usergrid.persistence.Schema.COLLECTION_USERS;
- import static org.apache.usergrid.persistence.Schema.DICTIONARY_PERMISSIONS;
- import static org.apache.usergrid.persistence.Schema.DICTIONARY_ROLENAMES;
- import static org.apache.usergrid.persistence.Schema.DICTIONARY_ROLETIMES;
- import static org.apache.usergrid.persistence.Schema.DICTIONARY_SETS;
- import static org.apache.usergrid.persistence.Schema.PROPERTY_CREATED;
- import static org.apache.usergrid.persistence.Schema.PROPERTY_INACTIVITY;
- import static org.apache.usergrid.persistence.Schema.PROPERTY_MODIFIED;
- import static org.apache.usergrid.persistence.Schema.PROPERTY_NAME;
- import static org.apache.usergrid.persistence.Schema.PROPERTY_TIMESTAMP;
- import static org.apache.usergrid.persistence.Schema.PROPERTY_TYPE;
- import static org.apache.usergrid.persistence.Schema.PROPERTY_UUID;
- import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
- import static org.apache.usergrid.persistence.Schema.TYPE_ENTITY;
- import static org.apache.usergrid.persistence.Schema.getDefaultSchema;
  import org.apache.usergrid.persistence.SimpleEntityRef;
 +import static org.apache.usergrid.persistence.SimpleEntityRef.getUuid;
++
  import org.apache.usergrid.persistence.SimpleRoleRef;
  import org.apache.usergrid.persistence.TypedEntity;
  import org.apache.usergrid.persistence.cassandra.ApplicationCF;
@@@ -277,9 -348,8 +350,8 @@@ public class CpEntityManager implement
       */
      @Metered( group = "core", name = "EntityManager_create" )
      @TraceParticipant
-     public <A extends Entity> A create( 
-         String entityType, Class<A> entityClass, Map<String, Object> properties, UUID importId ) 
-         throws Exception {
 -    public <A extends Entity> A create( String entityType, Class<A> entityClass, 
++    public <A extends Entity> A create( String entityType, Class<A> entityClass,
+             Map<String, Object> properties, UUID importId ) throws Exception {
  
          UUID timestampUuid = importId != null ? importId : UUIDUtils.newTimeUUID();
  
@@@ -467,36 -526,41 +528,41 @@@
          Id entityId = new SimpleId( entity.getUuid(), entity.getType() );
  
          if ( logger.isDebugEnabled() ) {
--            logger.debug( "Updating entity {}:{} from scope\n   app {}\n   owner {}\n   name {}", 
++            logger.debug( "Updating entity {}:{} from scope\n   app {}\n   owner {}\n   name {}",
                  new Object[] {
-                     entityId.getType(), entityId.getUuid(), 
-                     collectionScope.getApplication(), 
 -                    entityId.getType(), 
 -                    entityId.getUuid(), 
++                    entityId.getType(),
++                    entityId.getUuid(),
+                     collectionScope.getApplication(),
 -                    collectionScope.getOwner(), 
 +                    collectionScope.getOwner(),
                      collectionScope.getName()
-             } );
+                 } );
          }
  
- //        if ( !UUIDUtils.isTimeBased( entityId.getUuid() ) ) {
- //            throw new IllegalArgumentException(
- //                "Entity Id " + entityId.getType() + ":"+ entityId.getUuid() +" uuid not time based");
- //        }
+         //        if ( !UUIDUtils.isTimeBased( entityId.getUuid() ) ) {
+         //            throw new IllegalArgumentException(
+         //                "Entity Id " + entityId.getType() + ":"+ entityId.getUuid() +" uuid not time based");
+         //        }
  
- //        org.apache.usergrid.persistence.model.entity.Entity cpEntity =
- //                ecm.load( entityId ).toBlockingObservable().last();
+         //        org.apache.usergrid.persistence.model.entity.Entity cpEntity =
+         //                ecm.load( entityId ).toBlockingObservable().last();
  
  
-         org.apache.usergrid.persistence.model.entity.Entity cpEntity = 
+         org.apache.usergrid.persistence.model.entity.Entity cpEntity =
                  new org.apache.usergrid.persistence.model.entity.Entity( entityId );
  
-         cpEntity = CpEntityMapUtils.fromMap(
-                 cpEntity, entity.getProperties(), entity.getType(), true );
+         cpEntity = CpEntityMapUtils.fromMap( cpEntity, entity.getProperties(), entity.getType(), true );
  
          try {
-             cpEntity = ecm.update( cpEntity ).toBlockingObservable().last();
-             cpEntity = ecm.load( entityId ).toBlockingObservable().last();
+             cpEntity = ecm.write( cpEntity ).toBlocking().last();
+ //            cpEntity = ecm.update( cpEntity ).toBlockingObservable().last();
+ //
+ //
+ //            // need to reload entity so bypass entity cache
+ //            cpEntity = ecm.load( entityId ).toBlockingObservable().last();
  
-             logger.debug("Wrote {}:{} version {}", new Object[] { 
-                 cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion() });
+             logger.debug( "Wrote {}:{} version {}", new Object[] {
+                     cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion()
+             } );
          }
          catch ( WriteUniqueVerifyException wuve ) {
              handleWriteUniqueVerifyException( entity, wuve );
@@@ -820,9 -821,8 +823,8 @@@
      }
  
  
-     private Iterable<EntityRef> getEntityRefsForUniqueProperty( String collName, String propName,
-                                                                 String alias ) throws Exception {
- 
 -    private Iterable<EntityRef> getEntityRefsForUniqueProperty( 
++    private Iterable<EntityRef> getEntityRefsForUniqueProperty(
+             String collName, String propName, String alias ) throws Exception {
  
          final Id id = getIdForUniqueEntityField( collName, propName, alias );
  
@@@ -850,20 -851,20 +853,20 @@@
              UUID entityId = entityRef.getUuid();
              String entityType = entityRef.getType();
              try {
-                 get( entityRef ).getType(); 
+                 get( entityRef ).getType();
              }
              catch ( Exception e ) {
-                 logger.error( "Unable to load entity " 
-                         + entityRef.getType() + ":" + entityRef.getUuid(), e ); 
 -                logger.error( "Unable to load entity " + entityRef.getType() 
++                logger.error( "Unable to load entity " + entityRef.getType()
+                         + ":" + entityRef.getUuid(), e );
              }
              if ( entityRef == null ) {
--                throw new EntityNotFoundException( 
++                throw new EntityNotFoundException(
                          "Entity " + entityId.toString() + " cannot be verified" );
              }
              if ( ( entityType != null ) && !entityType.equalsIgnoreCase( entityRef.getType() ) ) {
-                 throw new UnexpectedEntityTypeException( "Entity " + entityId 
-                     + " is not the expected type, expected " + entityType 
-                     + ", found " + entityRef.getType() );
+                 throw new UnexpectedEntityTypeException(
 -                        "Entity " + entityId + " is not the expected type, expected " 
++                        "Entity " + entityId + " is not the expected type, expected "
+                                 + entityType + ", found " + entityRef.getType() );
              }
          }
          return entityRef;
@@@ -879,7 -880,7 +882,7 @@@
  
  
      @Override
--    public List<Entity> getPartialEntities( 
++    public List<Entity> getPartialEntities(
              Collection<UUID> ids, Collection<String> properties ) throws Exception {
          throw new UnsupportedOperationException( "Not supported yet." );
      }
@@@ -894,7 -895,7 +897,7 @@@
  
  
      @Override
--    public void setProperty( 
++    public void setProperty(
              EntityRef entityRef, String propertyName, Object propertyValue ) throws Exception {
  
          setProperty( entityRef, propertyName, propertyValue, false );
@@@ -902,9 -903,8 +905,8 @@@
  
  
      @Override
-     public void setProperty( 
-             EntityRef entityRef, String propertyName, Object propertyValue, boolean override )
-             throws Exception {
 -    public void setProperty( EntityRef entityRef, String propertyName, Object propertyValue, 
 -            boolean override ) throws Exception { 
++    public void setProperty( EntityRef entityRef, String propertyName, Object propertyValue,
++            boolean override ) throws Exception {
  
          if ( ( propertyValue instanceof String ) && ( ( String ) propertyValue ).equals( "" ) ) {
              propertyValue = null;
@@@ -912,7 -912,7 +914,7 @@@
  
          Entity entity = get( entityRef );
  
--        propertyValue = Schema.getDefaultSchema().validateEntityPropertyValue( 
++        propertyValue = Schema.getDefaultSchema().validateEntityPropertyValue(
                  entity.getType(), propertyName, propertyValue );
  
          entity.setProperty( propertyName, propertyValue );
@@@ -1022,17 -1017,16 +1019,16 @@@
  
  
      @Override
-     public void addToDictionary( EntityRef entityRef, String dictionaryName, Object elementValue ) 
-             throws Exception {
 -    public void addToDictionary( EntityRef entityRef, String dictionaryName, 
++    public void addToDictionary( EntityRef entityRef, String dictionaryName,
+             Object elementValue ) throws Exception {
  
          addToDictionary( entityRef, dictionaryName, elementValue, null );
      }
  
  
      @Override
-     public void addToDictionary( 
-             EntityRef entityRef, String dictionaryName, Object elementName, Object elementValue )
-             throws Exception {
 -    public void addToDictionary( EntityRef entityRef, String dictionaryName, Object elementName, 
++    public void addToDictionary( EntityRef entityRef, String dictionaryName, Object elementName,
+             Object elementValue ) throws Exception {
  
          if ( elementName == null ) {
              return;
@@@ -1369,12 -1344,10 +1346,10 @@@
  
  
      @Override
-     public Entity createItemInCollection( 
-             EntityRef entityRef, String collectionName, String itemType,
-             Map<String, Object> props ) throws Exception {
 -    public Entity createItemInCollection( EntityRef entityRef, String collectionName, 
++    public Entity createItemInCollection( EntityRef entityRef, String collectionName,
+             String itemType, Map<String, Object> props ) throws Exception {
  
-         return getRelationManager( entityRef )
-                 .createItemInCollection( collectionName, itemType, props );
+         return getRelationManager( entityRef ).createItemInCollection( collectionName, itemType, props );
      }
  
  
@@@ -1421,7 -1390,7 +1392,7 @@@
  
  
      @Override
--    public ConnectionRef createConnection( EntityRef connectingEntity, String pairedConnectionType, 
++    public ConnectionRef createConnection( EntityRef connectingEntity, String pairedConnectionType,
              EntityRef pairedEntity, String connectionType, EntityRef connectedEntityRef )
              throws Exception {
  
@@@ -1448,12 -1417,11 +1419,11 @@@
  
  
      @Override
--    public ConnectionRef connectionRef( EntityRef connectingEntity, String pairedConnectionType, 
-             EntityRef pairedEntity, String connectionType, EntityRef connectedEntityRef ) 
-             throws Exception {
++    public ConnectionRef connectionRef( EntityRef connectingEntity, String pairedConnectionType,
+             EntityRef pairedEntity, String connectionType, EntityRef connectedEntityRef ) throws Exception {
  
-         return getRelationManager( connectingEntity ).connectionRef( 
-                 pairedConnectionType, pairedEntity, connectionType, connectedEntityRef );
+         return getRelationManager( connectingEntity )
+                 .connectionRef( pairedConnectionType, pairedEntity, connectionType, connectedEntityRef );
      }
  
  
@@@ -1482,15 -1449,7 +1451,7 @@@
  
  
      @Override
-     public Results getConnectedEntities(UUID uuid, String connectionType, 
-             String connectedEntityType, Level resultsLevel) throws Exception {
- 
-         return getConnectedEntities( get(uuid), connectionType, connectedEntityType, resultsLevel);
-     }
- 
- 
-     @Override
--    public Results getConnectedEntities( EntityRef entityRef, String connectionType, 
++    public Results getConnectedEntities( EntityRef entityRef, String connectionType,
              String connectedEntityType, Level resultsLevel ) throws Exception {
  
          return getRelationManager( entityRef )
@@@ -1499,7 -1458,7 +1460,7 @@@
  
  
      @Override
--    public Results getConnectingEntities( EntityRef entityRef, String connectionType, 
++    public Results getConnectingEntities( EntityRef entityRef, String connectionType,
              String connectedEntityType, Level resultsLevel ) throws Exception {
  
          return getRelationManager( entityRef )
@@@ -1607,12 -1562,11 +1564,11 @@@
      }
  
  
--    private Entity batchCreateRole( String roleName, String roleTitle, long inactivity, 
-             String propertyName, UUID ownerId, Map<String, Object> additionalProperties ) 
-             throws Exception {
++    private Entity batchCreateRole( String roleName, String roleTitle, long inactivity,
+             String propertyName, UUID ownerId, Map<String, Object> additionalProperties ) throws Exception {
  
          UUID timestampUuid = UUIDUtils.newTimeUUID();
-         long timestamp = UUIDUtils.getUUIDLong(timestampUuid);
+         long timestamp = UUIDUtils.getUUIDLong( timestampUuid );
  
          Map<String, Object> properties = new TreeMap<>( CASE_INSENSITIVE_ORDER );
          properties.put( PROPERTY_TYPE, Role.ENTITY_TYPE );
@@@ -1630,15 -1584,16 +1586,16 @@@
          batchCreate( null, Role.ENTITY_TYPE, null, properties, id, timestampUuid );
  
          Mutator<ByteBuffer> batch = createMutator( cass.getApplicationKeyspace( applicationId ), be );
-         CassandraPersistenceUtils.addInsertToMutator( batch, ENTITY_DICTIONARIES, 
-                 CassandraPersistenceUtils.key( ownerId, Schema.DICTIONARY_ROLENAMES ), 
-                 roleName, roleTitle, timestamp );
-         CassandraPersistenceUtils.addInsertToMutator( batch, ENTITY_DICTIONARIES, 
-                 CassandraPersistenceUtils.key( ownerId, Schema.DICTIONARY_ROLETIMES ), 
-                 roleName, inactivity, timestamp );
-         CassandraPersistenceUtils.addInsertToMutator( batch, ENTITY_DICTIONARIES, 
-                 CassandraPersistenceUtils.key( ownerId, DICTIONARY_SETS ), 
-                 Schema.DICTIONARY_ROLENAMES, null, timestamp );
+         CassandraPersistenceUtils.addInsertToMutator( batch, ENTITY_DICTIONARIES,
 -                CassandraPersistenceUtils.key( ownerId, 
++                CassandraPersistenceUtils.key( ownerId,
+                         Schema.DICTIONARY_ROLENAMES ), roleName, roleTitle, timestamp );
+         CassandraPersistenceUtils.addInsertToMutator( batch, ENTITY_DICTIONARIES,
 -                CassandraPersistenceUtils.key( ownerId, 
++                CassandraPersistenceUtils.key( ownerId,
+                         Schema.DICTIONARY_ROLETIMES ), roleName, inactivity,
+                 timestamp );
+         CassandraPersistenceUtils.addInsertToMutator( batch, ENTITY_DICTIONARIES,
+                 CassandraPersistenceUtils.key( ownerId, DICTIONARY_SETS ), Schema.DICTIONARY_ROLENAMES, null,
+                 timestamp );
  
          CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
  
@@@ -1651,9 -1606,8 +1608,8 @@@
          roleName = roleName.toLowerCase();
          permission = permission.toLowerCase();
          long timestamp = cass.createTimestamp();
-         Mutator<ByteBuffer> batch = createMutator( 
-             cass.getApplicationKeyspace( applicationId ), be );
-         CassandraPersistenceUtils.addInsertToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES, 
+         Mutator<ByteBuffer> batch = createMutator( cass.getApplicationKeyspace( applicationId ), be );
 -        CassandraPersistenceUtils.addInsertToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES, 
++        CassandraPersistenceUtils.addInsertToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES,
              getRolePermissionsKey( roleName ), permission, ByteBuffer.allocate( 0 ), timestamp );
          CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
      }
@@@ -1665,21 -1618,19 +1620,19 @@@
  
          roleName = roleName.toLowerCase();
          long timestamp = cass.createTimestamp();
-         Mutator<ByteBuffer> batch = createMutator( 
-                 cass.getApplicationKeyspace( applicationId ), be );
+         Mutator<ByteBuffer> batch = createMutator( cass.getApplicationKeyspace( applicationId ), be );
          for ( String permission : permissions ) {
              permission = permission.toLowerCase();
--            CassandraPersistenceUtils.addInsertToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES, 
-                     getRolePermissionsKey( roleName ), permission,
-                     ByteBuffer.allocate( 0 ), timestamp );
++            CassandraPersistenceUtils.addInsertToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES,
+                 getRolePermissionsKey( roleName ), permission, ByteBuffer.allocate( 0 ), timestamp);
          }
          CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
      }
  
  
      private Object getRolePermissionsKey( String roleName ) {
-         return CassandraPersistenceUtils.key( SimpleRoleRef.getIdForRoleName( roleName ), 
-                 DICTIONARY_PERMISSIONS );
 -        return CassandraPersistenceUtils.key( 
++        return CassandraPersistenceUtils.key(
+                 SimpleRoleRef.getIdForRoleName( roleName ), DICTIONARY_PERMISSIONS );
      }
  
  
@@@ -1699,9 -1651,8 +1653,8 @@@
          roleName = roleName.toLowerCase();
          permission = permission.toLowerCase();
          long timestamp = cass.createTimestamp();
-         Mutator<ByteBuffer> batch = createMutator( cass.getApplicationKeyspace( applicationId ), be );
-         CassandraPersistenceUtils.addDeleteToMutator( 
-                 batch, ApplicationCF.ENTITY_DICTIONARIES, 
+         Mutator<ByteBuffer> batch = createMutator( cass.getApplicationKeyspace( applicationId ), be);
 -        CassandraPersistenceUtils.addDeleteToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES, 
++        CassandraPersistenceUtils.addDeleteToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES,
                  getRolePermissionsKey( roleName ), permission, timestamp );
          CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
      }
@@@ -1710,7 -1661,7 +1663,7 @@@
      @Override
      public Set<String> getRolePermissions( String roleName ) throws Exception {
          roleName = roleName.toLowerCase();
--        return cass.getAllColumnNames( cass.getApplicationKeyspace( applicationId ), 
++        return cass.getAllColumnNames( cass.getApplicationKeyspace( applicationId ),
                  ApplicationCF.ENTITY_DICTIONARIES, getRolePermissionsKey( roleName ) );
      }
  
@@@ -1791,7 -1737,7 +1739,7 @@@
      @Override
      public Set<String> getGroupRolePermissions( UUID groupId, String roleName ) throws Exception {
          roleName = roleName.toLowerCase();
--        return cass.getAllColumnNames( cass.getApplicationKeyspace( applicationId ), 
++        return cass.getAllColumnNames( cass.getApplicationKeyspace( applicationId ),
                  ApplicationCF.ENTITY_DICTIONARIES, getRolePermissionsKey( groupId, roleName ) );
      }
  
@@@ -1836,9 -1780,8 +1782,8 @@@
  
      @Override
      public Set<String> getUserPermissions( UUID userId ) throws Exception {
-         return cast(
-                 getDictionaryAsSet( new SimpleEntityRef( User.ENTITY_TYPE, userId ), 
-                         Schema.DICTIONARY_PERMISSIONS ) );
 -        return cast(getDictionaryAsSet( 
++        return cast(getDictionaryAsSet(
+                 new SimpleEntityRef( User.ENTITY_TYPE, userId ), Schema.DICTIONARY_PERMISSIONS ) );
      }
  
  
@@@ -1923,25 -1861,23 +1863,23 @@@
  
  
      @Override
-     public void incrementAggregateCounters( 
-             UUID userId, UUID groupId, String category, String counterName, long value ) {
 -    public void incrementAggregateCounters( UUID userId, UUID groupId, String category, 
++    public void incrementAggregateCounters( UUID userId, UUID groupId, String category,
+             String counterName, long value ) {
  
          long cassandraTimestamp = cass.createTimestamp();
-         incrementAggregateCounters( 
-                 userId, groupId, category, counterName, value, cassandraTimestamp );
+         incrementAggregateCounters( userId, groupId, category, counterName, value, cassandraTimestamp );
      }
  
  
--    private void incrementAggregateCounters( UUID userId, UUID groupId, String category, 
++    private void incrementAggregateCounters( UUID userId, UUID groupId, String category,
              String counterName, long value, long cassandraTimestamp ) {
+ 
          // TODO short circuit
          if ( !skipAggregateCounters ) {
-             Mutator<ByteBuffer> m = 
-                     createMutator( cass.getApplicationKeyspace( applicationId ), be );
+             Mutator<ByteBuffer> m = createMutator( cass.getApplicationKeyspace( applicationId ), be );
  
-             counterUtils.batchIncrementAggregateCounters( 
-                     m, applicationId, userId, groupId, null, category, counterName,
-                     value, cassandraTimestamp / 1000, cassandraTimestamp );
 -            counterUtils.batchIncrementAggregateCounters( m, applicationId, userId, groupId, null, 
++            counterUtils.batchIncrementAggregateCounters( m, applicationId, userId, groupId, null,
+                     category, counterName, value, cassandraTimestamp / 1000, cassandraTimestamp );
  
              CassandraPersistenceUtils.batchExecute( m, CassandraService.RETRY_COUNT );
          }
@@@ -1949,15 -1885,15 +1887,15 @@@
  
  
      @Override
--    public Results getAggregateCounters( UUID userId, UUID groupId, String category, 
++    public Results getAggregateCounters( UUID userId, UUID groupId, String category,
              String counterName, CounterResolution resolution, long start, long finish, boolean pad ) {
--        return this.getAggregateCounters( 
++        return this.getAggregateCounters(
                  userId, groupId, null, category, counterName, resolution, start, finish, pad );
      }
  
  
      @Override
--    public Results getAggregateCounters( UUID userId, UUID groupId, UUID queueId, String category, 
++    public Results getAggregateCounters( UUID userId, UUID groupId, UUID queueId, String category,
          String counterName, CounterResolution resolution, long start, long finish, boolean pad ) {
  
          start = resolution.round( start );
@@@ -2067,7 -2000,7 +2002,7 @@@
                  }
              }
              CounterUtils.AggregateCounterSelection selection = selections.get( r.getKey() );
--            countSets.add( new AggregateCounterSet( selection.getName(), selection.getUserId(), 
++            countSets.add( new AggregateCounterSet( selection.getName(), selection.getUserId(),
                      selection.getGroupId(), selection.getCategory(), counters ) );
          }
  
@@@ -2096,7 -2029,7 +2031,7 @@@
              return new SimpleEntityRef( "user", identifier.getUUID() );
          }
          if ( identifier.isName() ) {
--            return this.getAlias( new SimpleEntityRef( 
++            return this.getAlias( new SimpleEntityRef(
                      Application.ENTITY_TYPE, applicationId ), "user", identifier.getName() );
          }
          if ( identifier.isEmail() ) {
@@@ -2188,7 -2120,7 +2122,7 @@@
          if ( !skipAggregateCounters ) {
              long timestamp = cass.createTimestamp();
              Mutator<ByteBuffer> m = createMutator( cass.getApplicationKeyspace( applicationId ), be );
--            counterUtils.batchIncrementAggregateCounters( 
++            counterUtils.batchIncrementAggregateCounters(
                      m, applicationId, userId, groupId, null, category, counters, timestamp );
  
              CassandraPersistenceUtils.batchExecute( m, CassandraService.RETRY_COUNT );
@@@ -2222,8 -2149,8 +2151,8 @@@
          final EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
  
          //convert to a string, that's what we store
-         final Id results = ecm.getIdField( 
-             new StringField( propertyName, propertyValue.toString() ) ).toBlocking() .lastOrDefault( null );
 -        final Id results = ecm.getIdField( new StringField( 
++        final Id results = ecm.getIdField( new StringField(
+                 propertyName, propertyValue.toString() ) ).toBlocking() .lastOrDefault( null );
  
          return results;
      }
@@@ -2426,13 -2341,8 +2343,8 @@@
  
  
      @Override
-     public <A extends Entity> A batchCreate( 
-             Mutator<ByteBuffer> ignored, 
-             String entityType, 
-             Class<A> entityClass, 
-             Map<String, Object> properties, 
-             UUID importId, 
-             UUID timestampUuid )
 -    public <A extends Entity> A batchCreate( Mutator<ByteBuffer> ignored, String entityType, 
++    public <A extends Entity> A batchCreate( Mutator<ByteBuffer> ignored, String entityType,
+             Class<A> entityClass, Map<String, Object> properties, UUID importId, UUID timestampUuid )
              throws Exception {
  
          String eType = Schema.normalizeEntityType( entityType );
@@@ -2569,22 -2473,23 +2475,23 @@@
          EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
  
          if ( logger.isDebugEnabled() ) {
--            logger.debug( "Writing entity {}:{} into scope\n   app {}\n   owner {}\n   name {} data {}", 
++            logger.debug( "Writing entity {}:{} into scope\n   app {}\n   owner {}\n   name {} data {}",
                  new Object[] {
-                     entity.getType(), entity.getUuid(), 
-                     collectionScope.getApplication(), 
 -                    entity.getType(), 
 -                    entity.getUuid(), 
++                    entity.getType(),
++                    entity.getUuid(),
+                     collectionScope.getApplication(),
 -                    collectionScope.getOwner(), 
 -                    collectionScope.getName(), 
 +                    collectionScope.getOwner(),
 +                    collectionScope.getName(),
-                     CpEntityMapUtils.toMap(cpEntity)
-             } );
- //
- //            if ( entity.getType().equals("group")) {
- //                logger.debug("Writing Group");
- //                for ( Field field : cpEntity.getFields() ) {
- //                    logger.debug(
- //                        "   Writing Group name={} value={}", field.getName(), field.getValue() );
- //                }
- //            }
+                     CpEntityMapUtils.toMap( cpEntity )
+                 } );
+             //
+             //            if ( entity.getType().equals("group")) {
+             //                logger.debug("Writing Group");
+             //                for ( Field field : cpEntity.getFields() ) {
+             //                    logger.debug(
+             //                        "   Writing Group name={} value={}", field.getName(), field.getValue() );
+             //                }
+             //            }
          }
  
          try {
@@@ -2641,7 -2551,7 +2553,7 @@@
  
      private void incrementEntityCollection( String collection_name, long cassandraTimestamp ) {
          try {
--            incrementAggregateCounters( null, null, null, 
++            incrementAggregateCounters( null, null, null,
                      APPLICATION_COLLECTION + collection_name, ONE_COUNT, cassandraTimestamp );
          }
          catch ( Exception e ) {
@@@ -2649,12 -2559,12 +2561,12 @@@
                      new Object[] { collection_name, e } );
          }
          try {
-             incrementAggregateCounters( null, null, null, APPLICATION_ENTITIES, ONE_COUNT, 
-                     cassandraTimestamp );
 -            incrementAggregateCounters( null, null, null, 
++            incrementAggregateCounters( null, null, null,
+                     APPLICATION_ENTITIES, ONE_COUNT, cassandraTimestamp );
          }
          catch ( Exception e ) {
 -            logger.error( "Unable to increment counter application.entities for collection: " 
 +            logger.error( "Unable to increment counter application.entities for collection: "
-                     + "{} with timestamp: {}", 
+                     + "{} with timestamp: {}",
                      new Object[] { collection_name, cassandraTimestamp, e } );
          }
      }
@@@ -2663,7 -2573,7 +2575,7 @@@
      private void handleWriteUniqueVerifyException( Entity entity, WriteUniqueVerifyException wuve )
              throws DuplicateUniquePropertyExistsException {
  
--        // we may have multiple conflicts, but caller expects only one 
++        // we may have multiple conflicts, but caller expects only one
          Map<String, Field> violiations = wuve.getVioliations();
  
          if ( violiations != null ) {
@@@ -2680,18 -2590,16 +2592,16 @@@
  
  
      @Override
-     public Mutator<ByteBuffer> batchSetProperty( 
-             Mutator<ByteBuffer> batch, EntityRef entity, String propertyName,
-             Object propertyValue, UUID timestampUuid ) throws Exception {
 -    public Mutator<ByteBuffer> batchSetProperty( Mutator<ByteBuffer> batch, EntityRef entity, 
++    public Mutator<ByteBuffer> batchSetProperty( Mutator<ByteBuffer> batch, EntityRef entity,
+             String propertyName, Object propertyValue, UUID timestampUuid ) throws Exception {
  
          throw new UnsupportedOperationException( "Not supported yet." );
      }
  
  
      @Override
-     public Mutator<ByteBuffer> batchSetProperty( 
-             Mutator<ByteBuffer> batch, EntityRef entity, String propertyName,
-             Object propertyValue, boolean force, boolean noRead,
 -    public Mutator<ByteBuffer> batchSetProperty( Mutator<ByteBuffer> batch, EntityRef entity, 
 -            String propertyName, Object propertyValue, boolean force, boolean noRead, 
++    public Mutator<ByteBuffer> batchSetProperty( Mutator<ByteBuffer> batch, EntityRef entity,
++            String propertyName, Object propertyValue, boolean force, boolean noRead,
              UUID timestampUuid ) throws Exception {
  
          throw new UnsupportedOperationException( "Not supported yet." );
@@@ -2720,25 -2628,25 +2630,25 @@@
                      batch, dictionaryName, elementValue, removeFromDictionary, timestampUuid );
          }
  
--        ApplicationCF dictionary_cf = entityHasDictionary 
++        ApplicationCF dictionary_cf = entityHasDictionary
                  ? ENTITY_DICTIONARIES : ENTITY_COMPOSITE_DICTIONARIES;
  
          if ( elementValue != null ) {
              if ( !removeFromDictionary ) {
                  // Set the new value
  
--                elementCoValue = CassandraPersistenceUtils.toStorableBinaryValue( 
++                elementCoValue = CassandraPersistenceUtils.toStorableBinaryValue(
                          elementCoValue, !entityHasDictionary );
  
-                 CassandraPersistenceUtils.addInsertToMutator( batch, dictionary_cf, 
+                 CassandraPersistenceUtils.addInsertToMutator( batch, dictionary_cf,
                          CassandraPersistenceUtils.key( entity.getUuid(), dictionaryName ),
-                     entityHasDictionary 
-                         ? elementValue : asList( elementValue ), elementCoValue, timestamp );
 -                        entityHasDictionary ? elementValue : asList( elementValue ), 
++                        entityHasDictionary ? elementValue : asList( elementValue ),
+                         elementCoValue, timestamp );
  
                  if ( !entityHasDictionary ) {
-                     CassandraPersistenceUtils.addInsertToMutator( batch, ENTITY_DICTIONARIES, 
-                         CassandraPersistenceUtils.key( entity.getUuid(), DICTIONARY_SETS ), 
-                         dictionaryName, null, timestamp );
+                     CassandraPersistenceUtils.addInsertToMutator( batch, ENTITY_DICTIONARIES,
 -                            CassandraPersistenceUtils.key( entity.getUuid(), DICTIONARY_SETS ), 
++                            CassandraPersistenceUtils.key( entity.getUuid(), DICTIONARY_SETS ),
+                             dictionaryName, null, timestamp );
                  }
              }
              else {
@@@ -2753,21 -2661,19 +2663,19 @@@
  
  
      @Override
--    public Mutator<ByteBuffer> batchUpdateDictionary( Mutator<ByteBuffer> batch, EntityRef entity, 
--            String dictionaryName, Object elementValue, boolean removeFromDictionary, 
++    public Mutator<ByteBuffer> batchUpdateDictionary( Mutator<ByteBuffer> batch, EntityRef entity,
++            String dictionaryName, Object elementValue, boolean removeFromDictionary,
              UUID timestampUuid )
              throws Exception {
  
-         return batchUpdateDictionary( 
-                 batch, entity, dictionaryName, elementValue, null, removeFromDictionary,
-                 timestampUuid );
 -        return batchUpdateDictionary( batch, entity, dictionaryName, elementValue, null, 
++        return batchUpdateDictionary( batch, entity, dictionaryName, elementValue, null,
+                 removeFromDictionary, timestampUuid );
      }
  
  
      @Override
--    public Mutator<ByteBuffer> batchUpdateProperties( Mutator<ByteBuffer> batch, EntityRef entity, 
-             Map<String, Object> properties, UUID timestampUuid )
-             throws Exception {
++    public Mutator<ByteBuffer> batchUpdateProperties( Mutator<ByteBuffer> batch, EntityRef entity,
+             Map<String, Object> properties, UUID timestampUuid ) throws Exception {
  
          throw new UnsupportedOperationException( "Not supported yet." );
      }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6deac189/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
index 32c259a,a0c4c5b..24be179
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
@@@ -217,7 -218,7 +218,7 @@@ public class EntityManagerImpl implemen
      }
  
  
--    public EntityManager init( 
++    public EntityManager init(
              EntityManagerFactoryImpl emf, CassandraService cass, CounterUtils counterUtils,
              UUID applicationId, boolean skipAggregateCounters ) {
  
@@@ -522,7 -523,7 +523,7 @@@
           * both entities will be unable to update and must be deleted
           */
  
--        Set<UUID> ownerEntityIds = getUUIDsForUniqueProperty( 
++        Set<UUID> ownerEntityIds = getUUIDsForUniqueProperty(
              new SimpleEntityRef(Application.ENTITY_TYPE, applicationId), entityType, propertyName, propertyValue );
  
          //if there are no entities for this property, we know it's unique.  If there are,
@@@ -540,17 -541,17 +541,17 @@@
       * @param propertyName The name of the unique property
       * @param propertyValue The value of the unique property
       */
--    private Set<UUID> getUUIDsForUniqueProperty( 
++    private Set<UUID> getUUIDsForUniqueProperty(
              EntityRef ownerEntityRef, String collectionName, String propertyName,
              Object propertyValue ) throws Exception {
  
  
          String collectionNameInternal = defaultCollectionName( collectionName );
  
--        Object key = createUniqueIndexKey( 
++        Object key = createUniqueIndexKey(
              ownerEntityRef.getUuid(), collectionNameInternal, propertyName, propertyValue );
  
--        List<HColumn<ByteBuffer, ByteBuffer>> cols = cass.getColumns( 
++        List<HColumn<ByteBuffer, ByteBuffer>> cols = cass.getColumns(
              cass.getApplicationKeyspace( applicationId ), ENTITY_UNIQUE, key, null, null, 2, false );
  
  
@@@ -567,7 -568,7 +568,7 @@@
          }
  
          /**
--         * Doing this in a loop sucks, but we need to account for possibly having more than 
++         * Doing this in a loop sucks, but we need to account for possibly having more than
           * 1 entry in the index due
           * to corruption.  We need to allow them to update, otherwise
           * both entities will be unable to update and must be deleted
@@@ -611,11 -612,11 +612,11 @@@
  
  
      /**
--     * Create a row key for the entity of the given type with the name and value in the property.  
++     * Create a row key for the entity of the given type with the name and value in the property.
       * Used for fast unique
       * index lookups
       */
--    private Object createUniqueIndexKey( 
++    private Object createUniqueIndexKey(
              UUID ownerId, String collectionName, String propertyName, Object value ) {
          return key( ownerId, collectionName, propertyName, value );
      }
@@@ -623,14 -624,14 +624,14 @@@
  
      @Override
      @Metered( group = "core", name = "EntityManager_getAlias_single" )
--    public EntityRef getAlias( EntityRef ownerRef, String collectionType, String aliasValue ) 
++    public EntityRef getAlias( EntityRef ownerRef, String collectionType, String aliasValue )
              throws Exception {
  
          Assert.notNull( ownerRef, "ownerRef is required" );
          Assert.notNull( collectionType, "collectionType is required" );
          Assert.notNull( aliasValue, "aliasValue is required" );
  
--        Map<String, EntityRef> results = getAlias( 
++        Map<String, EntityRef> results = getAlias(
                  ownerRef, collectionType, Collections.singletonList( aliasValue ) );
  
          if ( results == null || results.size() == 0 ) {
@@@ -642,7 -643,7 +643,7 @@@
          if ( results.size() > 1 ) {
              logger.warn(
                  "More than 1 entity with Owner id '{}' of type '{}' and alias '{}' exists.  "
--              + "This is a duplicate alias, and needs audited", 
++              + "This is a duplicate alias, and needs audited",
                      new Object[] { ownerRef, collectionType, aliasValue } );
          }
  
@@@ -658,7 -659,7 +659,7 @@@
  
      @Override
      @Metered( group = "core", name = "EntityManager_getAlias_multi" )
--    public Map<String, EntityRef> getAlias( 
++    public Map<String, EntityRef> getAlias(
              EntityRef ownerRef, String collectionName, List<String> aliases ) throws Exception {
  
          Assert.notNull( ownerRef, "ownerRef is required" );
@@@ -682,8 -683,8 +683,8 @@@
  
      @SuppressWarnings( "unchecked" )
      @Override
--    public <A extends Entity> A create( 
--            String entityType, Class<A> entityClass, Map<String, Object> properties ) 
++    public <A extends Entity> A create(
++            String entityType, Class<A> entityClass, Map<String, Object> properties )
              throws Exception {
  
          if ( ( entityType != null ) && ( entityType.startsWith( TYPE_ENTITY ) || entityType
@@@ -702,7 -703,7 +703,7 @@@
  
  
      @Override
--    public Entity create( UUID importId, String entityType, Map<String, Object> properties ) 
++    public Entity create( UUID importId, String entityType, Map<String, Object> properties )
              throws Exception {
          return create( entityType, null, properties, importId );
      }
@@@ -736,7 -737,7 +737,7 @@@
       */
      @Metered( group = "core", name = "EntityManager_create" )
      @TraceParticipant
--    public <A extends Entity> A create( 
++    public <A extends Entity> A create(
              String entityType, Class<A> entityClass, Map<String, Object> properties,
              UUID importId ) throws Exception {
  
@@@ -754,7 -755,7 +755,7 @@@
  
      @SuppressWarnings( "unchecked" )
      @Metered( group = "core", name = "EntityManager_batchCreate" )
--    public <A extends Entity> A batchCreate( 
++    public <A extends Entity> A batchCreate(
              Mutator<ByteBuffer> m, String entityType, Class<A> entityClass,
              Map<String, Object> properties, UUID importId, UUID timestampUuid )
              throws Exception {
@@@ -1091,7 -1092,7 +1092,7 @@@
          Map<String, Object> results = null;
  
          // if (entityType == null) {
--        results = deserializeEntityProperties( cass.getAllColumns( 
++        results = deserializeEntityProperties( cass.getAllColumns(
                  cass.getApplicationKeyspace( applicationId ), ENTITY_PROPERTIES, entity_key ) );
          // } else {
          // Set<String> columnNames = Schema.getPropertyNames(entityType);
@@@ -1110,7 -1111,7 +1111,7 @@@
  
          if ( !entityId.equals( id ) ) {
  
--            logger.error( "Expected entity id {}, found {}. Returning null entity", 
++            logger.error( "Expected entity id {}, found {}. Returning null entity",
                      new Object[]{entityId, id, new Throwable()} );
              return null;
          }
@@@ -1133,7 -1134,7 +1134,7 @@@
       * @throws Exception the exception
       */
      @Metered( group = "core", name = "EntityManager_getEntities" )
--    public <A extends Entity> List<A> getEntities( 
++    public <A extends Entity> List<A> getEntities(
              Collection<UUID> entityIds, Class<A> entityClass ) throws Exception {
  
          List<A> entities = new ArrayList<A>();
@@@ -1147,7 -1148,7 +1148,7 @@@
          Rows<UUID, String, ByteBuffer> results = null;
  
          // if (entityType == null) {
--        results = cass.getRows( cass.getApplicationKeyspace( applicationId ), 
++        results = cass.getRows( cass.getApplicationKeyspace( applicationId ),
                  ENTITY_PROPERTIES, entityIds, ue, se, be );
          // } else {
          // Set<String> columnNames = Schema.getPropertyNames(entityType);
@@@ -1405,7 -1406,7 +1406,7 @@@
       * @throws Exception the exception
       */
      @Metered( group = "core", name = "EntityManager_updateProperties" )
--    public void updateProperties( 
++    public void updateProperties(
              UUID entityId, String type, Map<String, Object> properties ) throws Exception {
  
          EntityRef entity = new SimpleEntityRef( type, entityId );
@@@ -1552,8 -1553,8 +1553,8 @@@
              return new SimpleEntityRef( "user", identifier.getUUID() );
          }
          if ( identifier.isName() ) {
--            return this.getAlias( 
--                    new SimpleEntityRef(Application.ENTITY_TYPE, applicationId), 
++            return this.getAlias(
++                    new SimpleEntityRef(Application.ENTITY_TYPE, applicationId),
                      "user", identifier.getName() );
          }
          if ( identifier.isEmail() ) {
@@@ -1564,15 -1565,15 +1565,15 @@@
              query.setLimit( 1 );
              query.setResultsLevel( REFS );
  
--            Results r = getRelationManager( 
++            Results r = getRelationManager(
                  ref( Application.ENTITY_TYPE, applicationId ) ).searchCollection( "users", query );
              if ( r != null && r.getRef() != null ) {
                  return r.getRef();
              }
              else {
                  // look-aside as it might be an email in the name field
--                return this.getAlias( 
--                        new SimpleEntityRef(Application.ENTITY_TYPE, applicationId), 
++                return this.getAlias(
++                        new SimpleEntityRef(Application.ENTITY_TYPE, applicationId),
                          "user", identifier.getEmail() );
              }
          }
@@@ -1589,8 -1590,8 +1590,8 @@@
              return new SimpleEntityRef( "group", identifier.getUUID() );
          }
          if ( identifier.isName() ) {
--            return this.getAlias( 
--                    new SimpleEntityRef(Application.ENTITY_TYPE, applicationId), 
++            return this.getAlias(
++                    new SimpleEntityRef(Application.ENTITY_TYPE, applicationId),
                      "group", identifier.getName() );
          }
          return null;
@@@ -1598,17 -1599,17 +1599,17 @@@
  
  
      @Override
--    public Results getAggregateCounters( UUID userId, UUID groupId, String category, 
++    public Results getAggregateCounters( UUID userId, UUID groupId, String category,
          String counterName, CounterResolution resolution, long start, long finish, boolean pad ) {
  
--        return this.getAggregateCounters( 
++        return this.getAggregateCounters(
                  userId, groupId, null, category, counterName, resolution, start, finish, pad );
      }
  
  
      @Override
      @Metered( group = "core", name = "EntityManager_getAggregateCounters" )
--    public Results getAggregateCounters( UUID userId, UUID groupId, UUID queueId, String category, 
++    public Results getAggregateCounters( UUID userId, UUID groupId, UUID queueId, String category,
              String counterName, CounterResolution resolution, long start, long finish, boolean pad ) {
  
          start = resolution.round( start );
@@@ -1620,7 -1621,7 +1621,7 @@@
          q.setRange( start, finish, false, ALL_COUNT );
  
          QueryResult<CounterSlice<Long>> r = q.setKey(
--                counterUtils.getAggregateCounterRow( 
++                counterUtils.getAggregateCounterRow(
                          counterName, userId, groupId, queueId, category, resolution ) ).execute();
  
          List<AggregateCounter> counters = new ArrayList<AggregateCounter>();
@@@ -1794,7 -1795,7 +1795,7 @@@
              UUID entityId = entityRef.getUuid();
              String entityType = entityRef.getType();
              try {
--                get( entityRef ).getType(); 
++                get( entityRef ).getType();
              }
              catch ( Exception e ) {
                  logger.error( "Unable to load entity: {}", new Object[] {entityRef.getUuid(), e} );
@@@ -1852,7 -1853,7 +1853,7 @@@
              e = ( A ) getEntity( entityId, ( Class<Entity> ) entityClass );
          }
          catch ( ClassCastException e1 ) {
--            logger.error( "Unable to get typed entity: {} of class {}", 
++            logger.error( "Unable to get typed entity: {} of class {}",
                      new Object[] {entityId, entityClass.getCanonicalName(), e1} );
          }
          return e;
@@@ -1860,7 -1861,7 +1861,7 @@@
  
  
      @Override
--    public Results get( Collection<UUID> entityIds, Class<? extends Entity> entityClass, 
++    public Results get( Collection<UUID> entityIds, Class<? extends Entity> entityClass,
              Level resultsLevel ) throws Exception {
          return fromEntities( getEntities( entityIds, entityClass ) );
      }
@@@ -1878,7 -1879,7 +1879,7 @@@
      }
  
  
--    public Results loadEntities( Results results, Level resultsLevel, 
++    public Results loadEntities( Results results, Level resultsLevel,
              Map<UUID, UUID> associatedMap, int count ) throws Exception {
  
          results = results.trim( count );
@@@ -1904,7 -1905,7 +1905,7 @@@
                      }
                  }
              }
--            List<DynamicEntity> linked = getEntities( 
++            List<DynamicEntity> linked = getEntities(
                      new ArrayList<UUID>( associatedIds.values() ), (Class)null );
  
              for ( DynamicEntity l : linked ) {
@@@ -2732,7 -2733,7 +2733,7 @@@
  
  
      @Override
--    public Results getConnectedEntities( EntityRef entityRef, String connectionType, 
++    public Results getConnectedEntities( EntityRef entityRef, String connectionType,
              String connectedEntityType, Level resultsLevel ) throws Exception {
  
          return getRelationManager( entityRef )
@@@ -2741,7 -2742,7 +2742,7 @@@
  
  
      @Override
--    public Results getConnectingEntities( EntityRef entityRef, String connectionType, 
++    public Results getConnectingEntities( EntityRef entityRef, String connectionType,
              String connectedEntityType, Level resultsLevel ) throws Exception {
  
          return getConnectingEntities( entityRef, connectionType, connectedEntityType, resultsLevel, 0);
@@@ -2887,7 -2888,7 +2888,7 @@@
  
          for ( UUID uuid : ids ) {
              EntityRef ref = new SimpleEntityRef( type, uuid );
--            Entity entity = null; 
++            Entity entity = null;
              try {
                  entity = get( ref );
              } catch (Exception ex) {
@@@ -2923,17 -2924,15 +2924,14 @@@
      public void flushManagerCaches() {
          // no-op
      }
--    
++
      @Override
      public void reindex(EntityManagerFactory.ProgressObserver po) throws Exception {
--        throw new UnsupportedOperationException("Not supported."); 
++        throw new UnsupportedOperationException("Not supported.");
      }
  
 -
      @Override
-     public Results getConnectedEntities(UUID uuid, String connectionType, 
-             String connectedEntityType, Level resultsLevel) throws Exception {
- 
-         return getConnectedEntities( get(uuid), connectionType, connectedEntityType, resultsLevel);
+     public Health getIndexHealth() {
+         return Health.GREEN; // no good way to assess index status using old-school entity manager
      }
- 
  }


[05/50] [abbrv] incubator-usergrid git commit: fixed app level user token method

Posted by gr...@apache.org.
fixed app level user token method


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

Branch: refs/heads/two-dot-o-import
Commit: ac4e0ae31601096cf4b6ce9e4556d8405a62b83c
Parents: 132b630
Author: Rod Simpson <ro...@apigee.com>
Authored: Mon Jan 5 21:10:03 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Mon Jan 5 21:10:03 2015 -0700

----------------------------------------------------------------------
 .../apache/usergrid/rest/test/resource2point0/AbstractRestIT.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ac4e0ae3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
index 370823d..339bb8b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
@@ -121,7 +121,7 @@ public class AbstractRestIT extends JerseyTest {
 
 
     protected Token getAppUserToken(String username, String password){
-        return this.clientSetup.getRestClient().token().post(new Token(username,password));
+        return this.app().token().post(new Token(username,password));
     }
 
     public void refreshIndex() {


[42/50] [abbrv] incubator-usergrid git commit: Ignore known failing test

Posted by gr...@apache.org.
Ignore known failing test


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

Branch: refs/heads/two-dot-o-import
Commit: a66eeb9f2f42b9d5ddc85670990183e44ad9f01b
Parents: 4a17e5f
Author: grey <gr...@apigee.com>
Authored: Fri Jan 9 10:36:02 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Fri Jan 9 10:36:02 2015 -0800

----------------------------------------------------------------------
 .../rest/applications/collection/groups/GroupResourceIT.java    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a66eeb9f/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 8f3fbcc..c41c494 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
@@ -24,6 +24,8 @@ import com.sun.jersey.api.client.UniformInterfaceException;
 import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource2point0.model.Collection;
 import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+
+import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -101,7 +103,7 @@ public class GroupResourceIT extends AbstractRestIT {
 
         String groupName = "testgroup";
         String groupPath = "testgroup";
-        this.createGroup(groupName, groupPath);
+        this.createGroup( groupName, groupPath );
 
     }
 
@@ -388,6 +390,7 @@ public class GroupResourceIT extends AbstractRestIT {
      * Post a group activity and make sure it can be read back only by group members
      *
      */
+    @Ignore("Fails. See todo in the test itself.")
     @Test
     public void postGroupActivity() throws IOException {
 


[15/50] [abbrv] incubator-usergrid git commit: Removed test duplicated test. Fixed logic issue with helper method.

Posted by gr...@apache.org.
Removed test duplicated test.
Fixed logic issue with helper method.


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

Branch: refs/heads/two-dot-o-import
Commit: f9927a78731c5eb92080b8c6fb8d24f62d4d2173
Parents: 6c01589
Author: grey <gr...@apigee.com>
Authored: Tue Jan 6 17:19:27 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Tue Jan 6 17:19:27 2015 -0800

----------------------------------------------------------------------
 .../collection/paging/PagingResourceIT.java     | 183 ++++++++++---------
 1 file changed, 93 insertions(+), 90 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f9927a78/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/paging/PagingResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/paging/PagingResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/paging/PagingResourceIT.java
index b0c6efe..fb45e6e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/paging/PagingResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/paging/PagingResourceIT.java
@@ -45,50 +45,6 @@ import static org.junit.Assert.assertNull;
 public class PagingResourceIT extends AbstractRestIT {
 
     /**
-     * Creates 40 objects and then retrieves all 40 by paging through sets of 10 with a cursor.
-     * @throws Exception
-     */
-    @Test
-    public void collectionPaging() throws Exception {
-
-        String collectionName = "testCollectionPaging" ;
-
-        int size = 40;
-        int numOfPages = 4;
-
-        //Creates 40 entities by posting entities with names 0 - size in order.
-        createEntities( collectionName, size );
-
-        //Pages through 4 pages of entities and verifies that they have the posted names
-        pageAndVerifyEntities( collectionName, null,numOfPages );
-
-    }
-
-    /**
-     * Creates a number of entities with sequential names going up to the numOfEntities and posts them to the
-     * collection specified with CollectionName.
-     * @param collectionName
-     * @param numOfEntities
-     */
-    public List<Entity> createEntities(String collectionName ,int numOfEntities ){
-        List<Entity> entities = new LinkedList<>(  );
-
-        for ( int i = 0; i < numOfEntities; i++ ) {
-            Map<String, Object> entityPayload = new HashMap<String, Object>();
-            entityPayload.put( "name", String.valueOf( i ) );
-            Entity entity = new Entity( entityPayload );
-
-            entities.add( entity );
-
-            this.app().collection( collectionName ).post( entity );
-        }
-
-        this.refreshIndex();
-
-        return entities;
-    }
-
-    /**
      * Creates 40 objects and then creates a query to delete sets of 10 entities per call. Checks at the end
      * to make sure there are no entities remaining.
      * @throws Exception
@@ -107,8 +63,7 @@ public class PagingResourceIT extends AbstractRestIT {
         //sets the number of entities we want to delete per call.
         int deletePageSize = 10;
         int totalNumOfPages = numOfEntities/deletePageSize;
-        QueryParameters queryParameters = new QueryParameters();
-        queryParameters.setLimit( deletePageSize );
+        QueryParameters queryParameters = new QueryParameters().setLimit( deletePageSize );
 
         //deletes the entities using the above set value. Then verifies that those entities were deleted.
         deleteByPage(deletePageSize,totalNumOfPages,collectionName,queryParameters);
@@ -142,7 +97,7 @@ public class PagingResourceIT extends AbstractRestIT {
 
             this.refreshIndex();
 
-            assertEquals( "Only 10 entities should have been deleted", deletePageSize, response.getEntityCount() );
+            assertEquals( "Entities should have been deleted", deletePageSize, response.getEntityCount() );
         }
     }
 
@@ -155,7 +110,10 @@ public class PagingResourceIT extends AbstractRestIT {
 
         String collectionName = "testEmptyQAndLimitIgnored";
 
-        createEntities( collectionName, 1 );
+        int numOfEntities = 1;
+        int numOfPages = 1;
+
+        createEntities( collectionName, numOfEntities );
 
         //passes in empty parameters
         QueryParameters parameters = new QueryParameters();
@@ -163,14 +121,14 @@ public class PagingResourceIT extends AbstractRestIT {
         parameters.setKeyValue( "limit", "" );
 
         //sends GET call using empty parameters
-        pageAndVerifyEntities( collectionName,parameters, 1 );
+        pageAndVerifyEntities( collectionName,parameters, numOfPages, numOfEntities );
 
     }
 
 
 
     /**
-     * Checks to make sure we get a cursor when we should ( by creating 50 entities ) and then checks to make sure
+     * Checks to make sure we get a cursor when we should ( by creating 11 entities ) and then checks to make sure
      * we do not get a cursor when we create a collection of only 5 entities.
      * @throws Exception
      */
@@ -179,22 +137,24 @@ public class PagingResourceIT extends AbstractRestIT {
 
         // test that we do get cursor when we need one
         // create enough widgets to make sure we need a cursor
-        int widgetsSize = 11;
+        int numOfEntities = 11;
+        int numOfPages = 2;
         Map<String, Object> entityPayload = new HashMap<String, Object>();
         String collectionName = "testCursor" ;
 
-        createEntities( collectionName, widgetsSize );
+        createEntities( collectionName, numOfEntities );
 
         //checks to make sure we have a cursor
-        pageAndVerifyEntities( collectionName,null,2 );
+        pageAndVerifyEntities( collectionName,null,numOfPages, numOfEntities );
 
         //Create new collection of only 5 entities
         String trinketCollectionName = "trinkets" ;
-        int trinketsSize = 5;
-        createEntities( trinketCollectionName,trinketsSize );
+        numOfEntities = 5;
+        numOfPages = 1;
+        createEntities( trinketCollectionName, numOfEntities );
 
         //checks to make sure we don't get a cursor for just 5 entities.
-        pageAndVerifyEntities( trinketCollectionName,null,1 );
+        pageAndVerifyEntities( trinketCollectionName,null,numOfPages, numOfEntities );
 
     }
 
@@ -204,15 +164,16 @@ public class PagingResourceIT extends AbstractRestIT {
      */
     @Test
     public void pagingEntities() throws IOException {
-        int maxSize = 100;
-        int totalPagesExpected = 10;
+
+        int numOfEntities = 100;
+        int numOfPages = 10;
         String collectionName = "testPagingEntities" ;
 
         //creates entities
-        createEntities( collectionName,maxSize );
+        createEntities( collectionName,numOfEntities );
 
         //pages through entities and verifies that they are correct.
-        pageAndVerifyEntities( collectionName,null,totalPagesExpected );
+        pageAndVerifyEntities( collectionName,null,numOfPages,numOfEntities);
     }
 
 
@@ -227,18 +188,19 @@ public class PagingResourceIT extends AbstractRestIT {
 
 
         long created = 0;
-        int maxSize = 100;
-        int totalPagesExpected = 10;
+        int numOfEntities = 100;
+        int numOfPages = 10;
         Entity connectedEntity = null;
         Map<String, Object> entityPayload = new HashMap<String, Object>();
         String collectionName = "pageThroughConnectedEntities" ;
 
-        for ( created = 0; created < maxSize; created++ ) {
+        for ( created = 1; created <= numOfEntities; created++ ) {
 
             entityPayload.put( "name", "value" + created );
             Entity entity = new Entity( entityPayload );
             entity = this.app().collection( collectionName ).post( entity );
-            if(created == 0){
+            refreshIndex();
+            if(created == 1){
                 connectedEntity = entity;
             }
             else if (created > 0){
@@ -246,15 +208,12 @@ public class PagingResourceIT extends AbstractRestIT {
             }
         }
 
+        refreshIndex();
+
         Collection colConnection =  this.app().collection( collectionName ).entity( connectedEntity ).connection( "likes" ).get();
         assertNotNull( colConnection );
         assertNotNull( colConnection.getCursor() );
-        pageAndVerifyEntities( collectionName,null,totalPagesExpected );
-
-        /**
-         * the below checks to make sure we get a cursor back and go through each one to page the entities.
-         */
-
+        pageAndVerifyEntities( collectionName,null,numOfPages,numOfEntities );
 
     }
 
@@ -270,17 +229,17 @@ public class PagingResourceIT extends AbstractRestIT {
 
         long created = 0;
         int indexForChangedEntities = 15;
-        int maxSize = 20;
-        int numOfChangedEntities = maxSize - indexForChangedEntities;
+        int numOfEntities = 20;
+        int numOfChangedEntities = numOfEntities - indexForChangedEntities;
         Map<String, Object> entityPayload = new HashMap<String, Object>();
 
         String collectionName = "merp";
 
         //Creates Entities
-        for ( created = 0; created < maxSize; created++ ) {
+        for ( created = 0; created < numOfEntities; created++ ) {
 
             //Creates all entities between 15 and 20 with the verb stop
-            if ( created >= indexForChangedEntities && created < maxSize ) {
+            if ( created >= indexForChangedEntities && created < numOfEntities ) {
 
                 entityPayload.put( "verb", "stop" );
             }
@@ -295,7 +254,7 @@ public class PagingResourceIT extends AbstractRestIT {
             this.app().collection( collectionName ).post( entity );
         }
 
-        this.refreshIndex();
+        refreshIndex();
 
         //Creates query looking for entities with the very stop.
         String query = "select * where verb = 'stop'";
@@ -305,6 +264,7 @@ public class PagingResourceIT extends AbstractRestIT {
         //Get the collection with the query applied to it
         Collection queryCollection = this.app().collection( collectionName ).get( queryParameters );
         assertNotNull( queryCollection );
+        //assert that there is no cursor because there is <10 entities.
         assertNull( queryCollection.getCursor() );
         assertEquals( numOfChangedEntities, queryCollection.getNumOfEntities() );
 
@@ -318,39 +278,82 @@ public class PagingResourceIT extends AbstractRestIT {
 
     /**
      * Not a test
-     * Helper method that takes in the <collectionName> collection applies the queryParameters and pages through
-     * results for the given number of pages.
+     * A method that calls the cursor a numOfPages number of times and verifies that entities are stored in order of
+     * creation from the createEntities method.
      * @param collectionName
      * @param numOfPages
      * @return
      */
-    //TODO: add in a +1 to numOfPAges so that if we want to loop through a collection with no pages we would put in 0 instead of 1 page.
-    public Collection pageAndVerifyEntities(String collectionName,QueryParameters queryParameters, int numOfPages ){
+    public Collection pageAndVerifyEntities(String collectionName,QueryParameters queryParameters, int numOfPages, int numOfEntities ){
         //Get the entities that exist in the collection
         Collection testCollections = this.app().collection( collectionName ).get(queryParameters);
 
         //checks to make sure we can page through all entities in order.
 
-        //Used as an index to see what value we're on.
-        int index = 0;
+        //Used as an index to see what value we're on and also used to keep track of the current index of the entity.
+        int entityIndex = 1;
+        int pageIndex = 0;
+
 
-        //Tells us how many pages we want to sort through
-        for ( int i = 0; i < numOfPages; i++ ) {
+        //Counts all the entities in pages with cursors
+        while(testCollections.getCursor()!=null){
             //page through returned entities.
             while ( testCollections.hasNext() ) {
                 Entity returnedEntity = testCollections.next();
-                //verifies that the names are in order
-                assertEquals( String.valueOf( index++ ), returnedEntity.get( "name" ) );
+                //verifies that the names are in order, named string values will always +1 of the current index
+                assertEquals( String.valueOf( entityIndex ), returnedEntity.get( "name" ) );
+                entityIndex++;
             }
-            if(testCollections.getCursor()!=null) {
-                testCollections =
+            testCollections =
                         this.app().collection( collectionName ).getNextPage( testCollections, queryParameters, true );
-            }
+            //increment the page count because we have just loops through a page of entities
+            pageIndex++;
+
         }
 
-        //make sure the cursor is null after we have no more entities to page through.
-        assertNull( testCollections.getCursor() );
+        //if the testCollection does have entities then increment the page
+        if(testCollections.hasNext()) {
+         pageIndex++;
+        }
+
+        //handles left over entities at the end of the page when the cursor is null.
+        while ( testCollections.hasNext() ) {
+            //increment the page count because having entities ( while no cursor ) counts as having a page.
+            Entity returnedEntity = testCollections.next();
+            //verifies that the names are in order, named string values will always +1 of the current index
+            assertEquals( String.valueOf( entityIndex ), returnedEntity.get( "name" ) );
+            entityIndex++;
+        }
+
+
+        //added in a minus one to account for the adding the additional 1 above.
+        assertEquals( numOfEntities, entityIndex-1 );
+        assertEquals( numOfPages, pageIndex );
         return testCollections;
     }
 
+    /**
+     * Creates a number of entities with sequential names going up to the numOfEntities and posts them to the
+     * collection specified with CollectionName.
+     * @param collectionName
+     * @param numOfEntities
+     */
+    public List<Entity> createEntities(String collectionName ,int numOfEntities ){
+        List<Entity> entities = new LinkedList<>(  );
+
+        for ( int i = 1; i <= numOfEntities; i++ ) {
+            Map<String, Object> entityPayload = new HashMap<String, Object>();
+            entityPayload.put( "name", String.valueOf( i ) );
+            Entity entity = new Entity( entityPayload );
+
+            entities.add( entity );
+
+            this.app().collection( collectionName ).post( entity );
+        }
+
+        this.refreshIndex();
+
+        return entities;
+    }
+
 }


[20/50] [abbrv] incubator-usergrid git commit: Merge remote-tracking branch 'r3b/USERGRID-288b' into apache_usergrid/two-dot-o

Posted by gr...@apache.org.
Merge remote-tracking branch 'r3b/USERGRID-288b' into apache_usergrid/two-dot-o


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

Branch: refs/heads/two-dot-o-import
Commit: adff75fba7ac35b2925440878b75a78367a5671f
Parents: 28d19f2 3f1f5ac
Author: Rod Simpson <ro...@apigee.com>
Authored: Wed Jan 7 11:24:58 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Wed Jan 7 11:24:58 2015 -0700

----------------------------------------------------------------------
 .../applications/queries/GeoPagingTest.java     | 563 +++++++++----------
 1 file changed, 262 insertions(+), 301 deletions(-)
----------------------------------------------------------------------



[39/50] [abbrv] incubator-usergrid git commit: Cleanup the imports and add an actual loop in the connection loopback test.

Posted by gr...@apache.org.
Cleanup the imports and add an actual loop in the connection loopback test.


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

Branch: refs/heads/two-dot-o-import
Commit: 9fcb1502f661a96881e3572319d3c68607cb40c3
Parents: d567dd1
Author: grey <gr...@apigee.com>
Authored: Thu Jan 8 16:42:15 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Thu Jan 8 16:42:15 2015 -0800

----------------------------------------------------------------------
 .../users/ConnectionResourceTest.java           | 30 +++++++++++---------
 1 file changed, 16 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9fcb1502/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
index 8ab63f7..716b15f 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
@@ -17,30 +17,25 @@
 package org.apache.usergrid.rest.applications.collection.users;
 
 
-import java.util.LinkedHashMap;
+import java.io.IOException;
 import java.util.Map;
 import java.util.UUID;
 
-import javax.ws.rs.core.MediaType;
+import org.junit.Before;
+import org.junit.Test;
 
-import com.fasterxml.jackson.databind.JsonNode;
 import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.CollectionEndpoint;
-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.User;
 
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import com.sun.jersey.api.client.ClientResponse;
 import com.sun.jersey.api.client.UniformInterfaceException;
-import java.io.IOException;
 
-import static org.apache.usergrid.utils.MapUtils.hashMap;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 
 /**
@@ -103,8 +98,7 @@ public class ConnectionResourceTest extends AbstractRestIT {
         //Set user Scott to get back a nonexistant connection.
         try {
             this.app().collection("users").entity("scott").connection("likes").entity(uuid).get();
-
-            assert ( false );
+            fail("We shouldn't be able to see user1 connection through user2");
         }
         catch ( UniformInterfaceException uie ) {
             assertEquals( 404, uie.getResponse().getStatus() );
@@ -142,6 +136,14 @@ public class ConnectionResourceTest extends AbstractRestIT {
         UUID returned = collection.next().getUuid();
 
         assertEquals( "Should point to thing1 as an incoming entity connection", thing1Id, returned );
+
+        //Follow the connection through the loop to make sure it works. 
+        Entity thing1Return = this.app().collection("things").entity(thing1Id).connection( "likes" )
+            .collection( "things" ).entity( thing2Id ).connection( "likes" )
+            .collection( "things" ).entity( thing1Id ).get();
+
+        assertEquals(thing1Id,thing1Return.getUuid());
+
     }
 
 


[18/50] [abbrv] incubator-usergrid git commit: Merge remote-tracking branch 'r3b/editorconfig' into apache_usergrid/two-dot-o

Posted by gr...@apache.org.
Merge remote-tracking branch 'r3b/editorconfig' into apache_usergrid/two-dot-o


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

Branch: refs/heads/two-dot-o-import
Commit: 1e3a16e938472002b4ff297214be9ad8925d6677
Parents: fe7719a ad3ac16
Author: Rod Simpson <ro...@apigee.com>
Authored: Wed Jan 7 11:19:39 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Wed Jan 7 11:19:39 2015 -0700

----------------------------------------------------------------------
 stack/.editorconfig | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
----------------------------------------------------------------------



[38/50] [abbrv] incubator-usergrid git commit: Added todo for final commit for fix.

Posted by gr...@apache.org.
Added todo for final commit for fix.


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

Branch: refs/heads/two-dot-o-import
Commit: 394eda7426c5610ba6797a1c5956256cfbbf52bd
Parents: c8a05a1
Author: grey <gr...@apigee.com>
Authored: Thu Jan 8 16:28:42 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Thu Jan 8 16:28:42 2015 -0800

----------------------------------------------------------------------
 .../rest/management/OrganizationsIT.java        | 29 ++++++++++++++++----
 .../rest/test/resource2point0/ClientSetup.java  |  1 +
 2 files changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/394eda74/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
index 2c2ad52..4ec0b57 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
@@ -22,6 +22,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
+import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -36,6 +37,7 @@ import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
 import org.apache.usergrid.rest.test.resource2point0.model.Token;
 import org.apache.usergrid.rest.test.resource2point0.model.User;
 
+import com.sun.jersey.api.client.ClientResponse;
 import com.sun.jersey.api.client.UniformInterfaceException;
 import com.sun.jersey.api.representation.Form;
 
@@ -50,9 +52,7 @@ import static org.junit.Assert.fail;
  * Handles all management organization endpoint tests. Any tests that work with organizations specifically can be found here
  */
 public class OrganizationsIT extends AbstractRestIT {
-    private static final Logger LOG = LoggerFactory.getLogger( OrganizationsIT.class );
 
-    //TODO: make enum?
     String duplicateUniquePropertyExistsErrorMessage = "duplicate_unique_property_exists";
     String invalidGrantErrorMessage = "invalid_grant";
 
@@ -69,6 +69,7 @@ public class OrganizationsIT extends AbstractRestIT {
         String orgName = username;
         String email = username + "@usergrid.com";
 
+        //User property to see if owner properties exist when created.
         Map<String, Object> userProperties = new HashMap<String, Object>();
         userProperties.put( "company", "Apigee" );
 
@@ -241,7 +242,22 @@ public class OrganizationsIT extends AbstractRestIT {
         Organization organization = clientSetup.getRestClient().management().orgs().post( queryParameters );
 
         assertNotNull( organization );
-        assertEquals( orgName,organization.getName() );
+        assertEquals( orgName, organization.getName() );
+
+        //get token from organization that was created to verify it exists. also sets the current context.
+        Token tokenPayload = new Token( "password", username, password );
+        Token tokenReturned = clientSetup.getRestClient().management().token().post( tokenPayload );
+
+        assertNotNull( tokenReturned );
+
+        //Assert that the get returns the correct org and owner.
+        Organization returnedOrg = clientSetup.getRestClient().management().orgs().organization( orgName ).get();
+
+        assertTrue( returnedOrg != null && returnedOrg.getName().equals( orgName ) );
+        /**
+         * TODO: check all the parameters, make helper methods for duplicate code.
+         */
+
     }
 
 
@@ -267,6 +283,8 @@ public class OrganizationsIT extends AbstractRestIT {
 
         assertNotNull( organization );
         assertEquals( "testOrgPOSTForm" + timeUuid ,organization.getName() );
+
+        //TODO: makes changes here as well.
     }
 
 
@@ -274,6 +292,7 @@ public class OrganizationsIT extends AbstractRestIT {
      * Returns error from unimplemented delete method by trying to call the delete organization endpoint
      * @throws IOException
      */
+    @Ignore("It should return a 501, so when this is fixed the test can be run")
     @Test
     public void noOrgDelete() throws IOException {
 
@@ -282,9 +301,7 @@ public class OrganizationsIT extends AbstractRestIT {
             clientSetup.getRestClient().management().orgs().organization( clientSetup.getOrganizationName() ).delete();
             fail( "Delete is not implemented yet" );
         }catch(UniformInterfaceException uie){
-            assertEquals(500,uie.getResponse().getStatus());
-            //TODO: I think the below is what it should return (501 not implemented ) ,but instead it expects the above
-           // assertEquals( ClientResponse.Status.NOT_IMPLEMENTED ,uie.getResponse().getStatus());
+            assertEquals( ClientResponse.Status.NOT_IMPLEMENTED ,uie.getResponse().getStatus());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/394eda74/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
index b644030..f564eab 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
@@ -41,6 +41,7 @@ import javax.ws.rs.core.MediaType;
 public class ClientSetup implements TestRule {
 
     RestClient restClient;
+    //TODO: store the password as a string here as well
     protected String username, orgName, appName;
     protected Organization organization;
     protected Application application;


[10/50] [abbrv] incubator-usergrid git commit: fix resourse test

Posted by gr...@apache.org.
fix resourse test


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

Branch: refs/heads/two-dot-o-import
Commit: e964551e7f735c0b1c64122b80d33ccf36cd4568
Parents: 389fb9d
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Jan 6 09:08:46 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Jan 6 09:08:46 2015 -0700

----------------------------------------------------------------------
 .../users/ConnectionResourceTest.java           | 86 +++++++-------------
 1 file changed, 31 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e964551e/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
index 0e18b13..2949b85 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
@@ -29,6 +29,7 @@ import org.apache.usergrid.rest.test.resource2point0.endpoints.CollectionEndpoin
 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.User;
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -36,10 +37,8 @@ import com.sun.jersey.api.client.ClientResponse;
 import com.sun.jersey.api.client.UniformInterfaceException;
 import java.io.IOException;
 
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 import static org.apache.usergrid.utils.MapUtils.hashMap;
+import static org.junit.Assert.*;
 
 
 /**
@@ -49,7 +48,7 @@ import static org.apache.usergrid.utils.MapUtils.hashMap;
  * @since 4.0
  */
 public class ConnectionResourceTest extends AbstractRestIT {
-   
+
 
 
     @Test
@@ -58,31 +57,22 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
         CollectionEndpoint activities = this.app().collection("peeps");
 
-        Entity stuff = new Entity().chainPut("type", "chicken");
+        Entity stuff = new Entity().chainPut("name", "chicken").chainPut("type","chicken");
 
         activities.post(stuff);
 
 
-        Entity payload = new Entity();
-        payload.put( "username", "todd" );
-
-        Entity objectOfDesire = new Entity();
-        objectOfDesire.put( "codingmunchies", "doritoes" );
-
-        Entity entity = this.app().collection("users").post(payload);
-
-
-        payload.put( "username", "scott" );
+        User payload = new User("todd", "todd", "todd@apigee.com", "password");
+        payload.put("username", "todd");
+        this.app().collection("users").post(payload);
+        payload = new User("scott", "scott", "scott@apigee.com", "password");
+        this.app().collection("users").post(payload);
 
-         entity = this.app().collection("users").post(payload);
         refreshIndex();
 
+        /*finish setting up the two users */
 
-    /*finish setting up the two users */
-
-
-
-        entity = this.app().collection("users").entity("todd").connection("likes").entity("peeps").post();
+        Entity entity = this.app().collection("users").entity("todd").connection("likes").collection("peeps").entity("chicken").post();
 
         assertNotNull(entity);
 
@@ -113,50 +103,27 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
         UUID thing2Id = things.post( new Entity().chainPut("name", "thing2") ).getUuid();
 
-
         refreshIndex();
 
         //create the connection
         things.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
-
+        things.entity( thing2Id ).connection( "likes" ).entity( thing1Id ).post();
 
         refreshIndex();
 
         //test we have the "likes" in our connection meta data response
 
-        Entity response = things.entity( "thing1" ).get();
+        Collection collection =this.app().collection("things").entity(thing1Id).connection( "likes" ).get();
 
-        String url =((Map) ((Map)response.get( "metadata" )).get( "connections" )).get( "likes" ).toString();
+        assertTrue("Connection url returned in entity", collection.hasNext());
 
-
-        assertNotNull( "Connection url returned in entity", url );
-
-        //trim off the start /
-        url = url.substring( 1 );
-
-
-        //now that we know the URl is correct, follow it
-
-        Collection collection = this.app().collection(url).get();
-
-        Entity entity  =collection.next();
-        UUID returnedUUID = entity.getUuid();
+        UUID returnedUUID  = collection.next().getUuid();
 
         assertEquals( thing2Id, returnedUUID );
 
-
         //now follow the loopback, which should be pointers to the other entity
 
-        url = ((Map) ((Map)entity.get( "metadata" )).get( "connections" )).get("likes").toString();
-
-        assertNotNull( "Incoming edge URL provited", url );
-
-        //trim off the start /
-        url = url.substring( 1 );
-
-        //now we should get thing1 from the loopback url
-
-        collection = this.app().collection(url).get();
+        collection  = this.app().collection("things").entity(thing2Id).connection("likes").get();
 
         UUID returned = collection.next().getUuid();
 
@@ -186,7 +153,7 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
         Entity response = things.entity( "thing1" ).get();
 
-        String url =((Map) ((Map)response.get( "metadata" )).get( "connections" )).get( "likes" ).toString();
+        String url =((Map) ((Map)response.get( "metadata" )).get( "connections" )).get("likes").toString();
 
 
         assertNotNull( "Connection url returned in entity", url );
@@ -232,9 +199,14 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
         refreshIndex();
 
-        Entity node = things.entity ( "thing2" ).get();
+        int status = 0;
+        try {
+            Entity node = things.entity("thing2").get();
+        }catch (UniformInterfaceException e){
+            status = e.getResponse().getStatus();
+        }
+        assertEquals(404,status);
 
-        assertNull(node);
 
     }
 
@@ -256,9 +228,13 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
         refreshIndex();
 
-        Entity node = things.entity ( "thing1" ).get();
-
-        assertNull(node);
+        int status = 0;
+        try {
+            Entity node = things.entity("thing1").get();
+        }catch (UniformInterfaceException e){
+            status = e.getResponse().getStatus();
+        }
+        assertEquals(404,status);
 
     }
 


[16/50] [abbrv] incubator-usergrid git commit: Added comments to configuration options. removed 'root' declaration

Posted by gr...@apache.org.
Added comments to configuration options. removed 'root' declaration


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

Branch: refs/heads/two-dot-o-import
Commit: f153cda7cd820dcc57127d8a65f53389bb5dfde0
Parents: 8dc4405
Author: ryan bridges <rb...@apigee.com>
Authored: Fri Dec 5 10:08:26 2014 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Wed Jan 7 13:14:26 2015 -0500

----------------------------------------------------------------------
 stack/.editorconfig | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f153cda7/stack/.editorconfig
----------------------------------------------------------------------
diff --git a/stack/.editorconfig b/stack/.editorconfig
index 21ba8b8..cc4e3a0 100644
--- a/stack/.editorconfig
+++ b/stack/.editorconfig
@@ -1,19 +1,26 @@
-# top-most EditorConfig file
-root = true
-
-# Unix-style newlines with a newline ending every file
 [*]
+# Unix-style newlines with a newline ending every file
 end_of_line = lf
+# New line at the end of every file
 insert_final_newline = true
+# set default character set to utf-8
 charset = utf-8
+# Trim trailing whitespace from the end of lines
 trim_trailing_whitespace = true
+# Use spaces instead of tabs
 indent_style = space
+# Indent new lines with 4 spaces
 indent_size = 4
+# Lines that are a continuation of the previous line get an extra 4 spaces
 continuation_indent_size = 4
-max_line_length = 80
+# Set the maximum line length to 120
+max_line_length = 120
 
 # java
 [*.java]
+# Do not move curly braces to the next line
 curly_bracket_next_line = false
+# Add a space before and after brackets "[],{},()"
 spaces_around_brackets = both
+# Add a space on either side of an operator
 spaces_around_operators = true


[35/50] [abbrv] incubator-usergrid git commit: Added missing comment to tests in OwnershipResourceIT Added revamped comments and cleaned the tests in ConnectionResourceTest

Posted by gr...@apache.org.
Added missing comment to tests in OwnershipResourceIT
Added revamped comments and cleaned the tests in ConnectionResourceTest


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

Branch: refs/heads/two-dot-o-import
Commit: 944bcf9b1a480699a8343190a4820161b9f5ee3e
Parents: 0b89441
Author: grey <gr...@apigee.com>
Authored: Thu Jan 8 11:45:16 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Thu Jan 8 11:45:16 2015 -0800

----------------------------------------------------------------------
 .../users/ConnectionResourceTest.java           | 151 ++++++++++---------
 .../collection/users/OwnershipResourceIT.java   |   6 +-
 2 files changed, 84 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/944bcf9b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
index 2949b85..8ab63f7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
@@ -30,6 +30,8 @@ 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.User;
+
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -42,86 +44,98 @@ import static org.junit.Assert.*;
 
 
 /**
- * // TODO: Document this
- *
- * @author ApigeeCorporation
- * @since 4.0
+ * Contains tests that center around using connections with entities and users.
  */
 public class ConnectionResourceTest extends AbstractRestIT {
 
+    private CollectionEndpoint thingsResource;
+    private UUID thing1Id;
+    private UUID thing2Id;
 
 
-    @Test
-    public void connectionsQueryTest() throws IOException {
+    /**
+     * Setup two thing objects for use in the following tests
+     */
+    @Before
+    public void setup(){
+        this.thingsResource =  this.app().collection("things");
+
+        thing1Id =  thingsResource.post( new Entity().chainPut("name", "thing1") ).getUuid();
+
+        thing2Id = thingsResource.post( new Entity().chainPut("name", "thing2") ).getUuid();
 
+        refreshIndex();
+    }
+    /**
+     * Checks to see that a connection associated with one user cannot be retrieved by a different user.
+     * @throws IOException
+     */
+    @Test
+    public void connectionMisMatchTest() throws IOException {
 
+        //Creates collection and posts a chicken entity to it.
         CollectionEndpoint activities = this.app().collection("peeps");
 
         Entity stuff = new Entity().chainPut("name", "chicken").chainPut("type","chicken");
 
         activities.post(stuff);
 
-
+        //Create two users
         User payload = new User("todd", "todd", "todd@apigee.com", "password");
-        payload.put("username", "todd");
         this.app().collection("users").post(payload);
         payload = new User("scott", "scott", "scott@apigee.com", "password");
         this.app().collection("users").post(payload);
 
         refreshIndex();
 
-        /*finish setting up the two users */
-
+        //Set user Todd  to connect to the chicken entity.
         Entity entity = this.app().collection("users").entity("todd").connection("likes").collection("peeps").entity("chicken").post();
 
         assertNotNull(entity);
 
         refreshIndex();
 
+        //Get the collection and get the chicken entity.
         Collection collection = this.app().collection("peeps").get();
 
         String uuid = collection.next().get("uuid").toString();
 
-
+        //Set user Scott to get back a nonexistant connection.
         try {
-            entity = this.app().collection("users").entity("scott").connection("likes").entity(uuid).get();
+            this.app().collection("users").entity("scott").connection("likes").entity(uuid).get();
 
             assert ( false );
         }
         catch ( UniformInterfaceException uie ) {
-            assertEquals( 404, uie.getResponse().getClientResponseStatus().getStatusCode() );
+            assertEquals( 404, uie.getResponse().getStatus() );
         }
     }
 
 
+    /**
+     * Checks that we can setup a connection loop and that we can retrieve both entities from the loop.
+     * @throws IOException
+     */
     @Test
     public void connectionsLoopbackTest() throws IOException {
 
-        CollectionEndpoint things = this.app().collection("things");
-
-        UUID thing1Id =  things.post( new Entity().chainPut("name", "thing1") ).getUuid();
-
-        UUID thing2Id = things.post( new Entity().chainPut("name", "thing2") ).getUuid();
-
-        refreshIndex();
-
-        //create the connection
-        things.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
-        things.entity( thing2Id ).connection( "likes" ).entity( thing1Id ).post();
+        //create a connection loop by having thing1 connect to thing2 and vise versa.
+        thingsResource.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
+        thingsResource.entity( thing2Id ).connection( "likes" ).entity( thing1Id ).post();
 
         refreshIndex();
 
-        //test we have the "likes" in our connection meta data response
-
+        //Do a get on thing1 to make sure we have the connection present
         Collection collection =this.app().collection("things").entity(thing1Id).connection( "likes" ).get();
 
         assertTrue("Connection url returned in entity", collection.hasNext());
 
+        //Verify that thing1 is connected to thing2
         UUID returnedUUID  = collection.next().getUuid();
 
         assertEquals( thing2Id, returnedUUID );
 
-        //now follow the loopback, which should be pointers to the other entity
+        //now follow the loopback from thing2, which should be pointers to thing1
 
         collection  = this.app().collection("things").entity(thing2Id).connection("likes").get();
 
@@ -131,38 +145,32 @@ public class ConnectionResourceTest extends AbstractRestIT {
     }
 
 
+    /**
+     * Checks that we can get a valid uuid from a connection url and follow it to the correct entity.
+     * @throws IOException
+     */
     @Test
-    public void connectionsUUIDTest() throws IOException {
-
-        CollectionEndpoint things = this.app().collection("things");
-
-        UUID thing1Id =   things.post( new Entity().chainPut("name", "thing1") ).getUuid();
+    public void connectionsUrlTest() throws IOException {
 
-        UUID thing2Id =  things.post( new Entity().chainPut("name", "thing2") ).getUuid();
+        //Create a connection between thing1 and thing2
+        thingsResource.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
 
 
         refreshIndex();
 
-        //create the connection
-        things.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
-
-
-        refreshIndex();
-
-        //test we have the "likes" in our connection meta data response
-
-        Entity response = things.entity( "thing1" ).get();
+        //Do a get on thing1 to make sure we have the connection present
+        Entity response = thingsResource.entity( "thing1" ).get();
 
         String url =((Map) ((Map)response.get( "metadata" )).get( "connections" )).get("likes").toString();
 
 
         assertNotNull( "Connection url returned in entity", url );
 
-        //trim off the start /
+        //trim off the starting / from the url.
         url = url.substring( 1 );
 
 
-        //now that we know the URl is correct, follow it
+        //now that we know the URl is correct, follow it to get the entity in the connection
 
         Collection collection = this.app().collection(url).get();
 
@@ -170,38 +178,37 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
         assertEquals( thing2Id, returnedUUID );
 
-        //get on the collection works, now get it directly by uuid
-
-        //now we should get thing1 from the loopback url
-
-        response = things.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).get();
+        //get on the collection works, now get it directly by uuid. We should also get thing1 from the loopback url.
+        response = thingsResource.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).get();
 
         UUID returned = response.getUuid();
 
         assertEquals( "Should point to thing2 as an entity connection", thing2Id, returned );
     }
 
-    @Test //USERGRID-3011
-    public void connectionsDeleteSecondEntityInConnectionTest() throws IOException {
-
-        CollectionEndpoint things = this.app().collection("things");
 
-        UUID thing1Id =  things.post( new Entity().chainPut("name", "thing1") ).getUuid();
+    /**
+     * Deletes the connected to entity and make sure the delete persists.
+     * @throws IOException
+     */
+    @Test //USERGRID-3011
+    public void deleteConnectedEntity() throws IOException {
 
-        UUID thing2Id = things.post( new Entity().chainPut("name", "thing2") ).getUuid();
+        //create the connection
+        thingsResource.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
 
         refreshIndex();
 
-        //create the connection
-        things.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
-
-        ApiResponse response = things.entity( "thing2" ).delete();
+        //Delete the connected entity.
+        thingsResource.entity( "thing2" ).delete();
 
         refreshIndex();
 
+        //Make sure that we can no longer retrieve the entity.
         int status = 0;
         try {
-            Entity node = things.entity("thing2").get();
+            thingsResource.entity("thing2").get();
+            fail( "Entity should have been deleted." );
         }catch (UniformInterfaceException e){
             status = e.getResponse().getStatus();
         }
@@ -210,27 +217,29 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
     }
 
-    @Test //USERGRID-3011
-    public void connectionsDeleteFirstEntityInConnectionTest() throws IOException {
-
-        CollectionEndpoint things = this.app().collection("things");
 
-        UUID thing1Id =   things.post( new Entity().chainPut("name", "thing1") ).getUuid();
+    /**
+     * Delete the connecting entity and make sure the delete persists.
+     * @throws IOException
+     */
+    @Test //USERGRID-3011
+    public void deleteConnectingEntity() throws IOException {
 
-        UUID thing2Id =   things.post( new Entity().chainPut("name", "thing2") ).getUuid();
+        //create the connection
+        thingsResource.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
 
         refreshIndex();
 
-        //create the connection
-        things.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
-
-        ApiResponse response = things.entity( "thing1" ).delete();
+        //Delete the connecting entity
+        thingsResource.entity( "thing1" ).delete();
 
         refreshIndex();
 
+        //Make sure that we can no longer retrieve the entity.
         int status = 0;
         try {
-            Entity node = things.entity("thing1").get();
+            thingsResource.entity("thing1").get();
+            fail( "Entity should have been deleted." );
         }catch (UniformInterfaceException e){
             status = e.getResponse().getStatus();
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/944bcf9b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
index 30b12f1..52e27c7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
@@ -218,7 +218,8 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
 
     /**
-     *
+     * Tests that we can have our own personal connections without being seen by other users, but are still visible
+     * from a root context. 
      * @throws IOException
      */
     @Test
@@ -373,7 +374,8 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
 
     /**
-     *
+     * Checks that a once guests permissions are opened up that a user can view the connections/entities
+     * and get/post/delete things on that connection.
      * @throws IOException
      */
     @Test


[12/50] [abbrv] incubator-usergrid git commit: Added a helper method to collections. Changed the test to use this new helper method.

Posted by gr...@apache.org.
Added a helper method to collections.
Changed the test to use this new helper method.


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

Branch: refs/heads/two-dot-o-import
Commit: 6c0158992ee28817f903a32f18c9af5745cadda8
Parents: 1e4d934
Author: grey <gr...@apigee.com>
Authored: Tue Jan 6 11:48:36 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Tue Jan 6 11:48:36 2015 -0800

----------------------------------------------------------------------
 .../rest/applications/collection/paging/PagingResourceIT.java    | 4 ++--
 .../usergrid/rest/test/resource2point0/model/Collection.java     | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6c015899/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/paging/PagingResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/paging/PagingResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/paging/PagingResourceIT.java
index 2d3c609..b0c6efe 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/paging/PagingResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/paging/PagingResourceIT.java
@@ -117,7 +117,7 @@ public class PagingResourceIT extends AbstractRestIT {
         //verifies that we can't get anymore entities from the collection
         Collection getCollection = this.app().collection( collectionName ).get();
 
-        assertEquals( "All entities should have been removed", 0, getCollection.getResponse().getEntityCount() );
+        assertFalse( "All entities should have been removed", getCollection.hasNext());
 
         //now do 1 more delete, we shouldn't get any results
         ApiResponse response = this.app().collection( collectionName ).delete( queryParameters );
@@ -306,7 +306,7 @@ public class PagingResourceIT extends AbstractRestIT {
         Collection queryCollection = this.app().collection( collectionName ).get( queryParameters );
         assertNotNull( queryCollection );
         assertNull( queryCollection.getCursor() );
-        assertEquals( numOfChangedEntities, queryCollection.getResponse().getEntities().size() );
+        assertEquals( numOfChangedEntities, queryCollection.getNumOfEntities() );
 
         //Gets the supposed number of changed entities and checks they have the correct verb.
         for(int i = 0; i<numOfChangedEntities; i++){

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6c015899/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Collection.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Collection.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Collection.java
index 54d691d..2168e64 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Collection.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Collection.java
@@ -88,6 +88,9 @@ public class Collection implements Iterable<Entity>, Iterator<Entity> {
         throw new UnsupportedOperationException( "Remove is unsupported" );
     }
 
+    public int getNumOfEntities(){
+        return response.getEntityCount();
+    }
 
     public ApiResponse getResponse(){return response;}
 


[33/50] [abbrv] incubator-usergrid git commit: Added a comment clearing what the token post method accomplishes. Adding clarifying comments to meVerify, contextualPathOwnership, and contextualConnectionOwnership test.

Posted by gr...@apache.org.
Added a comment clearing what the token post method accomplishes.
Adding clarifying comments to meVerify, contextualPathOwnership, and contextualConnectionOwnership test.


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

Branch: refs/heads/two-dot-o-import
Commit: fac2e053bd71a16fb9b4c550aa14b66d774bb880
Parents: f789821
Author: grey <gr...@apigee.com>
Authored: Wed Jan 7 16:33:14 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Wed Jan 7 16:33:14 2015 -0800

----------------------------------------------------------------------
 .../collection/users/OwnershipResourceIT.java   | 85 +++++++++++++-------
 .../endpoints/TokenResource.java                |  2 +-
 2 files changed, 56 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fac2e053/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
index fc85ca0..f562ccd 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
@@ -39,7 +39,7 @@ import static org.junit.Assert.fail;
 
 
 /**
- *
+ * Take in tests that handle owner permissions relating to a specific user.
  */
 @Concurrent()
 public class OwnershipResourceIT extends AbstractRestIT {
@@ -48,43 +48,58 @@ public class OwnershipResourceIT extends AbstractRestIT {
     private User user1;
     private User user2;
 
+
+    /**
+     * Setup two user objects for use in the following tests.
+     */
     @Before
     public void setup(){
         this.usersResource =  this.app().collection("users");
         String email = "testuser1@usergrid.org";
         String email2 = "testuser2@usergrid.org";
 
+        user1 = new User("testuser1","testuser1", email, "password" );
         user2 = new User("testuser2","testuser2", email2, "password" );
 
-        user1 = new User("testuser1","testuser1", email, "password" );
         user1 = new User(this.usersResource.post(user1));
         user2 = new User(this.usersResource.post(user2));
 
         refreshIndex();
     }
 
+
+    /**
+     * Verifies that me and user1 are the same and that we can revoke the token from user1 and have the me call fail.
+     * @throws Exception
+     */
     @Test
     public void meVerify() throws Exception {
 
+        //Clear the applications previous token and start anonymous
         this.app().token().clearToken();
 
+        //Set the token for getting the me entity.
         Token token = this.app().token().post(new Token(user1.getUsername(),"password"));
 
+        //Get the entity known as "me" out of the users collection and asserts it isn't null and is equal to user1.
         Entity userNode = usersResource.entity("me").get();
 
         assertNotNull( userNode );
+        assertEquals( user1.getName(), userNode.get( "username" ) );
 
+        //Gets the uuid of the me entity.
         String uuid = userNode.getUuid().toString();
         assertNotNull( uuid );
 
+        //Revoke the user1 token
         usersResource.entity(user1).connection("revoketokens").post(new Entity().chainPut("token", token.getAccessToken()));
 
         refreshIndex();
 
+        //See if we can still access the me entity after revoking its token
         try {
-             userNode = usersResource.entity("me").get();
-
-            fail();
+             usersResource.entity("me").get();
+             fail("This should not work after we've revoked the usertoken");
         }
         catch ( Exception ex ) {
             ex.printStackTrace();
@@ -93,14 +108,19 @@ public class OwnershipResourceIT extends AbstractRestIT {
     }
 
 
+    /**
+     * Checks that that can only see our own devices when looking at our own path. Then checks that we can see
+     * both devices from a root path.
+     * @throws IOException
+     */
     @Test
     public void contextualPathOwnership() throws IOException {
 
-        // anonymous user
+        //Clear the applications previous token and start anonymous
         this.app().token().clearToken();
 
-
-        Token token = this.app().token().post(new Token(user1.getUsername(),"password"));
+        //Setting the token to be in a user1 context.
+        this.app().token().post(new Token(user1.getUsername(),"password"));
 
 
         // create device 1 on user1 devices
@@ -108,17 +128,17 @@ public class OwnershipResourceIT extends AbstractRestIT {
                .post(new Entity( ).chainPut("name", "device1").chainPut("number", "5551112222"));
         refreshIndex();
 
-        // anonymous user
+        //Clear the current user token
         this.app().token().clearToken();
 
-        // create device 2 on user 2
-         token = this.app().token().post(new Token(user2.getUsername(),"password"));
+        // create device 2 on user 2 and switch the context to use user2
+        Token token = this.app().token().post(new Token(user2.getUsername(),"password"));
         usersResource.entity("me").collection("devices")
                 .post(new Entity( ).chainPut("name", "device2").chainPut("number", "5552223333"));
 
         refreshIndex();
 
-        // now query on user 1.
+        //Check that we can get back device1 on user1
         token = this.app().token().post(new Token(user1.getUsername(),"password"));
 
         CollectionEndpoint devices = usersResource.entity( user1 ).collection("devices");
@@ -127,7 +147,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertNotNull( data );
         assertEquals("device1", data.get("name").toString());
 
-        // check we can't see device2
+        // check we can't see device2 on user1
         int status = 0;
         try {
             data = devices.entity("device2").get();
@@ -142,7 +162,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertEquals("device1", devicesData.next().get("name").toString());
         assertTrue(!devicesData.hasNext());
 
-        // log in as user 2 and check it
+        // log in as user 2 and check that we can see device 2
         token = this.app().token().post(new Token(user2.getUsername(),"password"));
 
         devices =  usersResource.entity("me").collection("devices");
@@ -151,7 +171,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertNotNull( data );
         assertEquals( "device2", data.get("name").toString() );
 
-        // check we can't see device1
+        // check we can't see device1 on user2
         status = 0;
         try{
         data = devices.entity("device1").get();
@@ -169,7 +189,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         // we should see both devices when loaded from the root application
 
         devices  = this.app().collection("devices");
-        // test for user 1
+        // test we can see both devices for user 1 under root application
         token = this.app().token().post(new Token(user1.getUsername(),"password"));
 
         data = devices.entity("device1").get();
@@ -181,7 +201,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertNotNull( data );
         assertEquals( "device2", data.get("name").toString() );
 
-        // test for user 2
+        // test we can see both devices for user 2 under root application
         token = this.app().token().post(new Token(user2.getUsername(),"password"));
 
 
@@ -197,13 +217,18 @@ public class OwnershipResourceIT extends AbstractRestIT {
     }
 
 
+    /**
+     * 
+     * @throws IOException
+     */
     @Test
     public void contextualConnectionOwnership() throws IOException {
 
         // anonymous user
         this.app().token().clearToken();
 
-         this.app().token().post(new Token(user1.getUsername(),"password"));
+        //Setting the token to be in a user1 context.
+        this.app().token().post(new Token(user1.getUsername(),"password"));
 
 
         // create a 4peaks restaurant
@@ -211,14 +236,12 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
         refreshIndex();
 
-        // create our connection
+        //Create a restaurant and link it to user1/me
         data = usersResource.entity("me")
                 .connection("likes").collection( "restaurants" ).entity( "4peaks" ).post();
 
         refreshIndex();
 
-       String peaksId = data.getUuid().toString();
-
         // anonymous user
         this.app().token().clearToken();
 
@@ -235,24 +258,26 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
         String arrogantButcherId = data.getUuid().toString();
 
-        // now query on user 1.
+        //Setting the token to be in a user1 context.
         this.app().token().post(new Token(user1.getUsername(),"password"));
 
+        //Setup the connection between user1 and the restaurant collection.
         CollectionEndpoint likeRestaurants =
                 usersResource.entity( "me" ).connection( "likes" )
                        .collection( "restaurants" );
 
-        // check we can get it via id
+        //Check that we can get the restaurant by using its uuid
+        String peaksId = data.getUuid().toString();
         data = likeRestaurants.entity(peaksId).get();
         assertNotNull( data );
         assertEquals("4peaks", data.get("name").toString());
 
-        // check we can get it by name
+        //Check that we can get the restaurant by name
         data = likeRestaurants.entity( "4peaks" ).get();
         assertNotNull( data );
         assertEquals( "4peaks", data.get("name").toString() );
 
-        // check we can't see arrogantbutcher by name or id
+        // check we can't see arrogantbutcher by name or id from user1
         int status = 200;
         try {
             data = likeRestaurants.entity("arrogantbutcher").get();
@@ -269,13 +294,13 @@ public class OwnershipResourceIT extends AbstractRestIT {
         }
         assertEquals(status, 404);
 
-        // do a collection load, make sure we're not entities we shouldn't see
+        // do a collection load, make sure we're not getting entities we shouldn't see
         Collection collectionData = likeRestaurants.get();
 
         assertEquals("4peaks", collectionData.next().get("name").toString());
         assertTrue( !collectionData.hasNext() );
 
-        // log in as user 2 and check it
+        // log in as user 2 and check that we can see the arrogantbutcher
         this.app().token().post(new Token(user2.getUsername(),"password"));
 
         likeRestaurants = usersResource.entity("me").connection( "likes" )
@@ -289,7 +314,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertNotNull( data );
         assertEquals( "arrogantbutcher", data.get("name").toString() );
 
-        // check we can't see 4peaks
+        // check we can't see 4peaks as user2
          status = 200;
         try {
             data = likeRestaurants.entity( "4peaks" ).get();
@@ -316,7 +341,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
         // we should see both devices when loaded from the root application
 
-        // test for user 1
+        //Check we can see both restaurants as user1 from the root application
         this.app().token().post(new Token(user1.getUsername(),"password"));
 
         CollectionEndpoint restaurants = this.app().collection( "restaurants" );
@@ -330,7 +355,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertNotNull( data );
         assertEquals( "arrogantbutcher", data.get("name").toString() );
 
-        // test for user 2
+        //Check we can see both restaurants as user2 from the root application
         this.app().token().post(new Token(user2.getUsername(),"password"));
         restaurants = this.app().collection("restaurants");
         data = restaurants.entity( "4peaks" ).get();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fac2e053/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
index c7c5367..d28bde2 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
@@ -37,7 +37,7 @@ public class TokenResource extends NamedResource {
 
 
     /**
-     * Obtains an access token
+     * Obtains an access token and sets the token for the context to use in later calls
      *
      * @param token
      * @return


[48/50] [abbrv] incubator-usergrid git commit: Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o-import

Posted by gr...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6deac189/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ImportServiceIT.java
----------------------------------------------------------------------
diff --cc stack/services/src/test/java/org/apache/usergrid/management/cassandra/ImportServiceIT.java
index 5453324,0000000..439a63e
mode 100644,000000..100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ImportServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ImportServiceIT.java
@@@ -1,713 -1,0 +1,714 @@@
 +/*
 + * 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.management.cassandra;
 +
 +import com.google.common.collect.BiMap;
 +import com.google.common.collect.ImmutableSet;
 +import com.google.inject.Module;
 +import org.apache.usergrid.ServiceITSetup;
 +import org.apache.usergrid.ServiceITSetupImpl;
- import org.apache.usergrid.ServiceITSuite;
 +import org.apache.usergrid.batch.JobExecution;
 +import org.apache.usergrid.cassandra.CassandraResource;
 +import org.apache.usergrid.cassandra.ClearShiroSubject;
 +import org.apache.usergrid.cassandra.Concurrent;
 +import org.apache.usergrid.management.OrganizationInfo;
 +import org.apache.usergrid.management.UserInfo;
 +import org.apache.usergrid.management.export.ExportService;
 +import org.apache.usergrid.management.export.S3Export;
 +import org.apache.usergrid.management.export.S3ExportImpl;
 +import org.apache.usergrid.management.importer.ImportService;
 +import org.apache.usergrid.management.importer.S3Import;
 +import org.apache.usergrid.management.importer.S3ImportImpl;
 +import org.apache.usergrid.persistence.*;
 +import org.apache.usergrid.persistence.entities.JobData;
 +import org.jclouds.ContextBuilder;
 +import org.jclouds.blobstore.BlobStore;
 +import org.jclouds.blobstore.BlobStoreContext;
 +import org.jclouds.blobstore.domain.Blob;
 +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
 +import org.jclouds.logging.log4j.config.Log4JLoggingModule;
 +import org.jclouds.netty.config.NettyPayloadModule;
 +import org.junit.*;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +import java.util.*;
++
++import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
 +import org.apache.usergrid.persistence.index.query.Query.Level;
 +import static org.hamcrest.core.Is.is;
 +import static org.hamcrest.core.IsNot.not;
 +import static org.junit.Assert.*;
 +import static org.mockito.Mockito.mock;
 +import static org.mockito.Mockito.when;
 +
 +
 +@Concurrent
 +public class ImportServiceIT {
 +
 +    private static final Logger LOG = LoggerFactory.getLogger(ImportServiceIT.class);
 +
-     private static CassandraResource cassandraResource = ServiceITSuite.cassandraResource;
++    private static CassandraResource cassandraResource = CassandraResource.newWithAvailablePorts();
 +
 +    // app-level data generated only once
 +    private static UserInfo adminUser;
 +    private static OrganizationInfo organization;
 +    private static UUID applicationId;
 +
 +    @Rule
 +    public ClearShiroSubject clearShiroSubject = new ClearShiroSubject();
 +
 +    @ClassRule
-     public static final ServiceITSetup setup = new ServiceITSetupImpl( cassandraResource, ServiceITSuite.elasticSearchResource );
++    public static final ServiceITSetup setup = new ServiceITSetupImpl( cassandraResource, new ElasticSearchResource() );
 +
 +
 +    @BeforeClass
 +    public static void setup() throws Exception {
 +        //creates sample test application
 +        LOG.info( "in setup" );
 +        adminUser = setup.getMgmtSvc().createAdminUser( "test", "test user", "test@test.com", "test", false, false );
 +        organization = setup.getMgmtSvc().createOrganization( "test-organization", adminUser, true );
 +        applicationId = setup.getMgmtSvc().createApplication( organization.getUuid(), "intern-app" ).getId();
 +    }
 +
 +    //creates 2nd application for testing import from an organization having multiple applications
 +    void createAndSetup2ndApplication() throws Exception {
 +
 +        UUID appId = setup.getMgmtSvc().createApplication( organization.getUuid(), "test-app-2" ).getId();
 +        EntityManager emTest = setup.getEmf().getEntityManager(appId);
 +
 +        Map<String, Object> userProperties = null;
 +
 +        Entity entityTest[] = new Entity[5];
 +        //creates entities and set permissions
 +        for ( int i = 0; i < 5; i++ ) {
 +            userProperties = new LinkedHashMap<String, Object>();
 +            userProperties.put( "name", "user" + i );
 +            userProperties.put( "email", "user" + i + "@test.com" );
 +            entityTest[i] = emTest.create( "testobject", userProperties );
 +        }
 +
 +        //create connection
-         emTest.createConnection( new SimpleEntityRef( "testobject",  entityTest[0].getUuid()), 
-                                  "related", 
++        emTest.createConnection( new SimpleEntityRef( "testobject",  entityTest[0].getUuid()),
++                                 "related",
 +                                 new SimpleEntityRef( "testobject",  entityTest[1].getUuid()));
 +
-         emTest.createConnection( new SimpleEntityRef( "testobject",  entityTest[1].getUuid()), 
-                                  "related", 
++        emTest.createConnection( new SimpleEntityRef( "testobject",  entityTest[1].getUuid()),
++                                 "related",
 +                                 new SimpleEntityRef( "testobject",  entityTest[0].getUuid()));
 +    }
 +
 +    @Ignore //For this test please input your s3 credentials into settings.xml or Attach a -D with relevant fields.
 +    // test case to check if a collection file is imported correctly
 +    //@Test
 +    public void testIntegrationImportCollection() throws Exception {
 +
 +        // creates 5 entities in user collection
 +        EntityManager em = setup.getEmf().getEntityManager( applicationId );
 +
 +        //intialize user object to be posted
 +        Map<String, Object> userProperties = null;
 +
 +        Entity entity[] = new Entity[10];
 +        //creates entities
 +        for ( int i = 0; i < 10; i++ ) {
 +            userProperties = new LinkedHashMap<String, Object>();
 +            userProperties.put( "username", "user" + i );
 +            userProperties.put( "email", "user" + i + "@test.com" );
 +            entity[i] = em.create( "user", userProperties );
 +        }
 +
 +        //creates test connections between first 2 users
-         em.createConnection( new SimpleEntityRef( "user",  entity[0].getUuid()), 
++        em.createConnection( new SimpleEntityRef( "user",  entity[0].getUuid()),
 +                "related", new SimpleEntityRef( "user",  entity[1].getUuid()));
-         em.createConnection( new SimpleEntityRef( "user",  entity[1].getUuid()), 
++        em.createConnection( new SimpleEntityRef( "user",  entity[1].getUuid()),
 +                "related", new SimpleEntityRef( "user",  entity[0].getUuid()));
 +
 +        //Export the collection which needs to be tested for import
 +        ExportService exportService = setup.getExportService();
 +        S3Export s3Export = new S3ExportImpl();
 +        HashMap<String, Object> payload = payloadBuilder();
 +
 +        payload.put( "organizationId",  organization.getUuid());
 +        payload.put( "applicationId", applicationId );
 +        payload.put("collectionName", "users");
 +
 +        // schdeule the export job
 +        UUID exportUUID = exportService.schedule( payload );
 +
 +        //create and initialize jobData returned in JobExecution.
 +        JobData jobData = jobExportDataCreator(payload, exportUUID, s3Export);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        //export the collection and wait till export finishes
 +        exportService.doExport( jobExecution );
 +        while ( !exportService.getState( exportUUID ).equals( "FINISHED" ) ) {
 +            ;
 +        }
 +        //TODO: can check if temp file got created
 +
 +        // import
 +        S3Import s3Import = new S3ImportImpl();
 +        ImportService importService = setup.getImportService();
 +
 +        //schedule the import job
 +        UUID importUUID = importService.schedule( payload );
 +
 +        //create and initialize jobData returned in JobExecution.
 +        jobData = jobImportDataCreator( payload,importUUID, s3Import );
 +
 +        jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        //import the collection and wait till import job finishes
 +        importService.doImport(jobExecution);
 +        while ( !importService.getState( importUUID ).equals( "FINISHED" ) ) {
 +            ;
 +        }
 +        try {
 +
 +            //checks if temp import files are created i.e. downloaded from S3
 +            assertThat(importService.getEphemeralFile().size(), is(not(0)));
 +
 +            //check if entities are actually updated i.e. created and modified should be different
 +            Results collections = em.getCollection(applicationId, "users", null, Level.ALL_PROPERTIES);
 +            List<Entity> entities = collections.getEntities();
 +
 +            // check if connections are created for only the 1st 2 entities in user collection
 +            Results r;
 +            List<ConnectionRef> connections;
 +            for (int i = 0; i < 2; i++) {
 +                r = em.getConnectedEntities(entities.get(i), "related", null, Level.IDS);
 +                connections = r.getConnections();
 +                assertNotNull(connections);
 +            }
 +
 +            //check if dictionary is created
 +            EntityRef er;
 +            Map<Object, Object> dictionaries1, dictionaries2;
 +
 +            for (int i = 0; i < 3; i++) {
 +
 +                er = entities.get(i);
 +                dictionaries1 = em.getDictionaryAsMap(er, "connected_types");
 +                dictionaries2 = em.getDictionaryAsMap(er, "connecting_types");
 +
 +                if (i == 2) {
 +                    //for entity 2, these should be empty
 +                    assertThat(dictionaries1.size(), is(0));
 +                    assertThat(dictionaries2.size(), is(0));
 +                } else {
 +                    assertThat(dictionaries1.size(), is(not(0)));
 +                    assertThat(dictionaries2.size(), is(not(0)));
 +                }
 +            }
 +        }
 +        finally {
 +            //delete bucket
 +            deleteBucket();
 +        }
 +    }
 +
 +    @Ignore //For this test please input your s3 credentials into settings.xml or Attach a -D with relevant fields.
 +    // test case to check if application is imported correctly
 +    //@Test
 +    public void testIntegrationImportApplication() throws Exception {
 +
 +        EntityManager em = setup.getEmf().getEntityManager( applicationId );
 +
 +        //intialize user object to be posted
 +        Map<String, Object> userProperties = null;
 +
 +        Entity entity[] = new Entity[5];
 +        //creates entities for a custom collection "custom" entities
 +        for ( int i = 0; i < 5; i++ ) {
 +            userProperties = new LinkedHashMap<String, Object>();
 +            userProperties.put( "parameter1", "user" + i );
 +            userProperties.put( "parameter2", "user" + i + "@test.com" );
 +            entity[i] = em.create( "custom", userProperties );
 +        }
 +        //creates connections
-         em.createConnection( new SimpleEntityRef( "custom",  entity[0].getUuid() ), 
++        em.createConnection( new SimpleEntityRef( "custom",  entity[0].getUuid() ),
 +                "related", new SimpleEntityRef( "custom",  entity[1].getUuid() ) );
-         em.createConnection( new SimpleEntityRef( "custom",  entity[1].getUuid() ), 
++        em.createConnection( new SimpleEntityRef( "custom",  entity[1].getUuid() ),
 +                "related", new SimpleEntityRef( "custom",  entity[0].getUuid() ) );
 +
 +
 +        //Export the application which needs to be tested for import
 +        ExportService exportService = setup.getExportService();
 +        S3Export s3Export = new S3ExportImpl();
 +        HashMap<String, Object> payload = payloadBuilder();
 +
 +        payload.put( "organizationId",  organization.getUuid());
 +        payload.put( "applicationId", applicationId );
 +
 +        // schedule the export job
 +        UUID exportUUID = exportService.schedule( payload );
 +
 +        //create and initialize jobData returned in JobExecution.
 +        JobData jobData = jobExportDataCreator(payload, exportUUID, s3Export);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        //export the application and wait for the export job to finish
 +        exportService.doExport( jobExecution );
 +        while ( !exportService.getState( exportUUID ).equals( "FINISHED" ) ) {
 +            ;
 +        }
 +
 +        // import
 +        S3Import s3Import = new S3ImportImpl();
 +        ImportService importService = setup.getImportService();
 +
 +        // scheduele the import job
 +        UUID importUUID = importService.schedule( payload );
 +
 +        //create and initialize jobData returned in JobExecution.
 +        jobData = jobImportDataCreator( payload,importUUID, s3Import );
 +
 +        jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        // import the application file and wait for it to finish
 +        importService.doImport(jobExecution);
 +        while ( !importService.getState( importUUID ).equals( "FINISHED" ) ) {
 +            ;
 +        }
 +
 +        try {
 +            //checks if temp import files are created i.e. downloaded from S3
 +            assertThat(importService.getEphemeralFile().size(), is(not(0)));
 +
 +            Set<String> collections = em.getApplicationCollections();
 +            Iterator<String> collectionsItr = collections.iterator();
 +            // check if all collections in the application are updated
 +            while (collectionsItr.hasNext()) {
 +                String collectionName = collectionsItr.next();
 +                Results collection = em.getCollection(applicationId, collectionName, null, Level.ALL_PROPERTIES);
 +                List<Entity> entities = collection.getEntities();
 +                for (Entity eachEntity : entities) {
 +                    //check for dictionaries --> checking permissions in the dictionaries
 +                    EntityRef er;
 +                    Map<Object, Object> dictionaries;
 +
 +                    //checking for permissions for the roles collection
 +                    if (collectionName.equals("roles")) {
 +                        if (eachEntity.getName().equalsIgnoreCase("admin")) {
 +                            er = eachEntity;
 +                            dictionaries = em.getDictionaryAsMap(er, "permissions");
 +                            assertThat(dictionaries.size(), is(0));
 +                        } else {
 +                            er = eachEntity;
 +                            dictionaries = em.getDictionaryAsMap(er, "permissions");
 +                            assertThat(dictionaries.size(), is(not(0)));
 +                        }
 +                    }
 +                }
 +                if (collectionName.equals("customs")) {
 +                    // check if connections are created for only the 1st 2 entities in the custom collection
 +                    Results r;
 +                    List<ConnectionRef> connections;
 +                    for (int i = 0; i < 2; i++) {
 +                        r = em.getConnectedEntities(entities.get(i), "related", null,Level.IDS);
 +                        connections = r.getConnections();
 +                        assertNotNull(connections);
 +                    }
 +                }
 +            }
 +        }
 +        finally {
 +            //delete bucket
 +            deleteBucket();
 +        }
 +    }
 +
 +    @Ignore //For this test please input your s3 credentials into settings.xml or Attach a -D with relevant fields.
 +    // test case to check if all applications file for an organization are imported correctly
 +    //@Test
 +    public void testIntegrationImportOrganization() throws Exception {
 +
 +        // //creates 5 entities in usertests collection
 +        EntityManager em = setup.getEmf().getEntityManager( applicationId );
 +
 +        //intialize user object to be posted
 +        Map<String, Object> userProperties = null;
 +
 +        Entity entity[] = new Entity[5];
 +        //creates entities
 +        for ( int i = 0; i < 5; i++ ) {
 +            userProperties = new LinkedHashMap<String, Object>();
 +            userProperties.put( "name", "user" + i );
 +            userProperties.put( "email", "user" + i + "@test.com" );
 +            entity[i] = em.create( "usertests", userProperties );
 +            em.getCollections(entity[i]).contains("usertests");
 +        }
 +
 +        //creates test connections between first 2 entities in usertests collection
 +        ConnectedEntityRef ref = em.createConnection( entity[0], "related", entity[1]);
 +
 +        em.createConnection( entity[1], "related", entity[0]);
 +
 +        //create 2nd test application, add entities to it, create connections and set permissions
 +        createAndSetup2ndApplication();
 +
 +        //export all applications in an organization
 +        ExportService exportService = setup.getExportService();
 +        S3Export s3Export = new S3ExportImpl();
 +        HashMap<String, Object> payload = payloadBuilder();
 +
 +        payload.put( "organizationId",  organization.getUuid());
 +
 +        //schdeule the export job
 +        UUID exportUUID = exportService.schedule( payload );
 +
 +        //create and initialize jobData returned in JobExecution.
 +        JobData jobData = jobExportDataCreator(payload, exportUUID, s3Export);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        //export organization data and wait for the export job to finish
 +        exportService.doExport( jobExecution );
 +        while ( !exportService.getState( exportUUID ).equals( "FINISHED" ) ) {
 +            ;
 +        }
 +        //TODo: can check if the temp files got created
 +
 +        // import
 +        S3Import s3Import = new S3ImportImpl();
 +        ImportService importService = setup.getImportService();
 +
 +        //schedule the import job
 +        UUID importUUID = importService.schedule( payload );
 +
 +        //create and initialize jobData returned in JobExecution.
 +        jobData = jobImportDataCreator( payload,importUUID, s3Import );
 +
 +        jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        //import the all application files for the organization and wait for the import to finish
 +        importService.doImport(jobExecution);
 +        while ( !importService.getState( importUUID ).equals( "FINISHED" ) ) {
 +            ;
 +        }
 +
 +        try {
 +            //checks if temp import files are created i.e. downloaded from S3
 +            assertThat(importService.getEphemeralFile().size(), is(not(0)));
 +
 +            //get all applications for an organization
 +            BiMap<UUID, String> applications = setup.getMgmtSvc().getApplicationsForOrganization(organization.getUuid());
 +            for (BiMap.Entry<UUID, String> app : applications.entrySet()) {
 +                //check if all collections-entities are updated - created and modified should be different
 +                UUID appID = app.getKey();
 +                em = setup.getEmf().getEntityManager(appID);
 +                Set<String> collections = em.getApplicationCollections();
 +                Iterator<String> itr = collections.iterator();
 +                while (itr.hasNext()) {
 +                    String collectionName = itr.next();
 +                    Results collection = em.getCollection(appID, collectionName, null, Level.ALL_PROPERTIES);
 +                    List<Entity> entities = collection.getEntities();
 +
 +                    if (collectionName.equals("usertests")) {
 +
 +                        // check if connections are created for only the 1st 2 entities in user collection
 +                        Results r;
 +                        List<ConnectionRef> connections;
 +                        for (int i = 0; i < 2; i++) {
 +                            r = em.getConnectedEntities(entities.get(i), "related", null, Level.IDS);
 +                            connections = r.getConnections();
 +                            assertNotNull(connections);
 +                        }
 +
 +                        //check if dictionary is created
 +                        EntityRef er;
 +                        Map<Object, Object> dictionaries1, dictionaries2;
 +                        for (int i = 0; i < 3; i++) {
 +                            er = entities.get(i);
 +                            dictionaries1 = em.getDictionaryAsMap(er, "connected_types");
 +                            dictionaries2 = em.getDictionaryAsMap(er, "connecting_types");
 +
 +                            if (i == 2) {
 +                                //for entity 2, these should be empty
 +                                assertThat(dictionaries1.size(), is(0));
 +                                assertThat(dictionaries2.size(), is(0));
 +                            } else {
 +                                assertThat(dictionaries1.size(), is(not(0)));
 +                                assertThat(dictionaries2.size(), is(not(0)));
 +                            }
 +                        }
 +                    }
 +                }
 +            }
 +        }
 +        finally {
 +            //delete bucket
 +            deleteBucket();
 +        }
 +    }
 +
 +    /**
 +     * Test to schedule a job with null config
 +     */
 +    @Test
 +    public void testScheduleJobWithNullConfig() throws Exception {
 +        HashMap<String, Object> payload = null;
 +
 +        ImportService importService = setup.getImportService();
 +        UUID importUUID = importService.schedule(payload);
 +
 +        assertNull(importUUID);
 +    }
 +
 +    /**
 +     * Test to get state of a job with null UUID
 +     */
 +    @Test
 +    public void testGetStateWithNullUUID() throws Exception {
 +        UUID uuid= null;
 +
 +        ImportService importService = setup.getImportService();
 +        String state = importService.getState(uuid);
 +
 +        assertEquals(state,"UUID passed in cannot be null");
 +    }
 +
 +    /**
 +     * Test to get state of a job with fake UUID
 +     */
 +    @Test
 +    public void testGetStateWithFakeUUID() throws Exception {
 +        UUID fake = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
 +
 +        ImportService importService = setup.getImportService();
 +        String state = importService.getState(fake);
 +
 +        assertEquals(state,"No Such Element found");
 +    }
 +
 +
 +    /**
 +     * Test to get error message of a job with null state
 +     */
 +    @Test
 +    public void testErrorMessageWithNullState() throws Exception {
 +        UUID state = null;
 +        ImportService importService = setup.getImportService();
 +        String error = importService.getErrorMessage(state);
 +
 +        assertEquals(error,"UUID passed in cannot be null");
 +    }
 +
 +    /**
 +     * Test to get error message of a job with fake UUID
 +     */
 +    @Test
 +    public void testErrorMessageWithFakeUUID() throws Exception {
 +        UUID state = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
 +        ImportService importService = setup.getImportService();
 +        String error = importService.getErrorMessage(state);
 +
 +        assertEquals(error,"No Such Element found");
 +    }
 +
 +    /**
 +     * Test to the doImport method with null organziation ID
 +     */
 +    @Ignore
 +    //@Test
 +    public void testDoImportWithNullOrganizationID() throws Exception {
 +        // import
 +        S3Import s3Import = new S3ImportImpl();
 +        ImportService importService = setup.getImportService();
 +
 +        HashMap<String, Object> payload = payloadBuilder();
 +
 +        //schedule the import job
 +        UUID importUUID = importService.schedule( payload );
 +
 +        //create and initialize jobData returned in JobExecution.
 +        JobData jobData = jobImportDataCreator(payload, importUUID, s3Import);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        importService.doImport(jobExecution);
 +        assertEquals(importService.getState(importUUID),"FAILED");
 +    }
 +
 +    @Ignore
 +    /**
 +     * Test to the doImport method with fake organization ID
 +     */
 +    //@Test
 +    public void testDoImportWithFakeOrganizationID() throws Exception {
 +
 +        UUID fakeOrgId = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
 +        // import
 +        S3Import s3Import = new S3ImportImpl();
 +        ImportService importService = setup.getImportService();
 +
 +        HashMap<String, Object> payload = payloadBuilder();
 +
 +        payload.put("organizationId",fakeOrgId);
 +        //schedule the import job
 +        UUID importUUID = importService.schedule( payload );
 +
 +        //create and initialize jobData returned in JobExecution.
 +        JobData jobData = jobImportDataCreator(payload, importUUID, s3Import);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        //import the all application files for the organization and wait for the import to finish
 +        importService.doImport(jobExecution);
 +        assertEquals(importService.getState(importUUID),"FAILED");
 +    }
 +
 +    /**
 +     * Test to the doImport method with fake application ID
 +     */
 +    @Ignore
 +    //@Test
 +    public void testDoImportWithFakeApplicationID() throws Exception {
 +
 +        UUID fakeappId = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
 +        // import
 +        S3Import s3Import = new S3ImportImpl();
 +        ImportService importService = setup.getImportService();
 +
 +        HashMap<String, Object> payload = payloadBuilder();
 +
 +        payload.put("organizationId",organization.getUuid());
 +        payload.put("applicationId",fakeappId);
 +
 +        //schedule the import job
 +        UUID importUUID = importService.schedule( payload );
 +
 +        //create and initialize jobData returned in JobExecution.
 +        JobData jobData = jobImportDataCreator(payload, importUUID, s3Import);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        //import the application files for the organization and wait for the import to finish
 +        importService.doImport(jobExecution);
 +        assertEquals(importService.getState(importUUID),"FAILED");
 +    }
 +
 +    /**
 +     * Test to the doImport Collection method with fake application ID
 +     */
 +    //@Test
 +    @Ignore
 +    public void testDoImportCollectionWithFakeApplicationID() throws Exception {
 +
 +        UUID fakeappId = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
 +        // import
 +        S3Import s3Import = new S3ImportImpl();
 +        ImportService importService = setup.getImportService();
 +
 +        HashMap<String, Object> payload = payloadBuilder();
 +
 +        payload.put("organizationId",organization.getUuid());
 +        payload.put("applicationId",fakeappId);
 +        payload.put("collectionName","custom-test");
 +
 +        //schedule the import job
 +        UUID importUUID = importService.schedule( payload );
 +
 +        //create and initialize jobData returned in JobExecution.
 +        JobData jobData = jobImportDataCreator(payload, importUUID, s3Import);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        //import the all collection files for the organization-application and wait for the import to finish
 +        importService.doImport(jobExecution);
 +        assertEquals(importService.getState(importUUID),"FAILED");
 +    }
 +
 +    /*Creates fake payload for testing purposes.*/
 +    public HashMap<String, Object> payloadBuilder() {
 +        HashMap<String, Object> payload = new HashMap<String, Object>();
 +        Map<String, Object> properties = new HashMap<String, Object>();
 +        Map<String, Object> storage_info = new HashMap<String, Object>();
 +        storage_info.put( "s3_key", System.getProperty( "secretKey" ) );
 +        storage_info.put( "s3_access_id", System.getProperty( "accessKey" ) );
 +        storage_info.put( "bucket_location", System.getProperty( "bucketName" ) );
 +
 +        properties.put( "storage_provider", "s3" );
 +        properties.put( "storage_info", storage_info );
 +
 +        payload.put( "path","test-organization/test-app" );
 +        payload.put( "properties", properties );
 +        return payload;
 +    }
 +
 +    //creates fake import job
 +    public JobData jobImportDataCreator(HashMap<String, Object> payload,UUID importUUID,S3Import s3Import) {
 +        JobData jobData = new JobData();
 +
 +        jobData.setProperty( "jobName", "importJob" );
 +        jobData.setProperty( "importInfo", payload );
 +        jobData.setProperty( "importId", importUUID );
 +        jobData.setProperty( "s3Import", s3Import );
 +
 +        return jobData;
 +    }
 +
 +    //creates fake export job
 +    public JobData jobExportDataCreator(HashMap<String, Object> payload,UUID exportUUID,S3Export s3Export) {
 +        JobData jobData = new JobData();
 +
 +        jobData.setProperty( "jobName", "exportJob" );
 +        jobData.setProperty( "exportInfo", payload );
 +        jobData.setProperty( "exportId", exportUUID );
 +        jobData.setProperty( "s3Export", s3Export);
 +
 +        return jobData;
 +    }
 +
 +    // delete the s3 bucket which was created for testing
 +    public void deleteBucket() {
 +
 +        String bucketName = System.getProperty( "bucketName" );
 +        String accessId = System.getProperty( "accessKey" );
 +        String secretKey = System.getProperty( "secretKey" );
 +
 +        Properties overrides = new Properties();
 +        overrides.setProperty( "s3" + ".identity", accessId );
 +        overrides.setProperty( "s3" + ".credential", secretKey );
 +
 +        Blob bo = null;
 +        BlobStore blobStore = null;
 +        final Iterable<? extends Module> MODULES = ImmutableSet
 +                .of(new JavaUrlHttpCommandExecutorServiceModule(), new Log4JLoggingModule(),
 +                        new NettyPayloadModule());
 +
 +        BlobStoreContext context =
 +                ContextBuilder.newBuilder("s3").credentials( accessId, secretKey ).modules( MODULES )
 +                        .overrides( overrides ).buildView( BlobStoreContext.class );
 +
 +        blobStore = context.getBlobStore();
 +        blobStore.deleteContainer( bucketName );
 +    }
 +}


[24/50] [abbrv] incubator-usergrid git commit: [USERGRID-303]Updated 'order by' tests to work with new test framework

Posted by gr...@apache.org.
[USERGRID-303]Updated 'order by' tests to work with new test framework


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

Branch: refs/heads/two-dot-o-import
Commit: 281172822bc3053220e2b38d1af4b61dfa217ffb
Parents: dc625ac
Author: ryan bridges <rb...@apigee.com>
Authored: Wed Jan 7 09:14:14 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Wed Jan 7 14:44:29 2015 -0500

----------------------------------------------------------------------
 .../rest/applications/queries/OrderByTest.java  | 270 ++++++++++---------
 1 file changed, 140 insertions(+), 130 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/28117282/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
index f00912c..3ba5787 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
@@ -17,21 +17,19 @@
 package org.apache.usergrid.rest.applications.queries;
 
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+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.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import com.fasterxml.jackson.databind.JsonNode;
 import java.io.IOException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.rest.TestContextSetup;
-import org.apache.usergrid.rest.test.resource.CustomCollection;
+import java.util.LinkedHashMap;
 
 import static org.junit.Assert.assertEquals;
-import static org.apache.usergrid.utils.MapUtils.hashMap;
 
 
 /**
@@ -41,132 +39,144 @@ import static org.apache.usergrid.utils.MapUtils.hashMap;
  * @since 4.0
  */
 public class OrderByTest extends AbstractRestIT {
-
-    @Rule
-    public TestContextSetup context = new TestContextSetup( this );
-
-
-    @Test
-    // USERGRID-1400
-    public void orderByShouldNotAffectResults() throws IOException {
-
-        CustomCollection activities = context.customCollection( "activities" );
-
-        long created = 0;
-        Map actor = hashMap( "displayName", "Erin" );
-        Map props = new HashMap();
-        props.put( "actor", actor );
-        props.put( "verb", "go" );
-        props.put( "content", "bragh" );
-        for ( int i = 0; i < 20; i++ ) {
-            props.put( "ordinal", i );
-            JsonNode activity = activities.create( props );
-            if ( i == 5 ) {
-                created = activity.findValue( "created" ).longValue();
-            }
-        }
-
-        refreshIndex(context.getOrgName(), context.getAppName());
-
-        String query = "select * where created > " + created;
-        JsonNode node = activities.withQuery( query ).get();
-        assertEquals( 10, node.get( "entities" ).size() );
-
-        query = query + " order by created desc";
-        node = activities.withQuery( query ).get();
-        assertEquals( 10, node.get( "entities" ).size() );
+  private static Logger log = LoggerFactory.getLogger(OrderByTest.class);
+
+  /**
+   * Inserts a number of entities. Query a subset of entities
+   * with unspecified 'order by' and then ordered by 'created'
+   * to ensure the result is unchanged.
+   * 1. Insert entities
+   * 2. Query without 'order by'
+   * 3. Query with 'order by'
+   * 4. Ensure the same entities are returned
+   * @throws IOException
+   */
+  @Test
+  // USERGRID-1400
+  public void orderByShouldNotAffectResults() throws IOException {
+
+    long created = 0;
+    Entity actor = new Entity();
+    actor.put("displayName", "Erin");
+    Entity props = new Entity();
+    props.put("actor", actor);
+    props.put("verb", "go");
+    props.put("content", "bragh");
+    //1. Insert entities
+    for (int i = 0; i < 20; i++) {
+      props.put("ordinal", i);
+      Entity activity = this.app().collection("activity").post(props);
+      log.info("Created", activity.get("created").toString());
+      if (i == 5) {
+        created = Long.parseLong(activity.get("created").toString());
+      }
     }
 
+    refreshIndex();
+    //2. Query without 'order by'
+    String query = "select * where created > " + created;
+    QueryParameters params = new QueryParameters().setQuery(query);
+    Collection activitiesWithoutOrderBy = this.app().collection("activities").get(params);
+    assertEquals(10, activitiesWithoutOrderBy.response.getEntityCount());
+    //3. Query with 'order by'
+    query = query + " order by created desc";
+    params.setQuery(query);
+    Collection activitiesWithOrderBy = this.app().collection("activities").get(params);
+    assertEquals(10, activitiesWithOrderBy.response.getEntityCount());
+    //4. Ensure the same entities are returned
+    while(activitiesWithoutOrderBy.hasNext() && activitiesWithOrderBy.hasNext()) {
+      Entity activityWithoutOrderBy = activitiesWithoutOrderBy.next();
+      Entity activityWithOrderBy = activitiesWithOrderBy.next();
+      assertEquals(activityWithoutOrderBy.get("uuid").toString(), activityWithOrderBy.get("uuid").toString());
+    }
+  }
 
-    @Test
-    // USERGRID-1520
-    public void orderByComesBeforeLimitResult() throws IOException {
-
-        CustomCollection activities = context.customCollection( "activities" );
-
-        Map actor = hashMap( "displayName", "Erin" );
-        Map props = new HashMap();
-        int checkResultsNum = 0;
-
-        props.put( "actor", actor );
-        props.put( "verb", "go" );
-        props.put( "content", "bragh" );
-
-        for ( int i = 0; i < 20; i++ ) {
-            props.put( "ordinal", i );
-            JsonNode activity = activities.create( props );
-        }
-
-        refreshIndex(context.getOrgName(), context.getAppName());
-
-        String query = "select * where created > " + 1 + " order by created desc";
-
-        JsonNode incorrectNode = activities.withQuery( query ).withLimit( 5 ).get();
-
-        assertEquals( 5, incorrectNode.get( "entities" ).size() );
 
-        while ( checkResultsNum < 5 ) {
-            assertEquals( activities.entityIndex( query, checkResultsNum ),
-                    activities.entityIndexLimit( query, 5, checkResultsNum ) );
-            checkResultsNum++;
-        }
+  /**
+   * Ensure successful query when 'limit' and 'order by' are specified
+   * 1. Insert entities
+   * 2. Query a subset of the entities, specifying order and limit
+   * 3. Ensure the correct number of results are returned
+   * @throws IOException
+   */
+  @Test
+  // USERGRID-1520
+  public void orderByComesBeforeLimitResult() throws IOException {
+
+    Entity actor = new Entity();
+    actor.put("displayName", "Erin");
+    Entity props = new Entity();
+    props.put("actor", actor);
+    props.put("verb", "go");
+    props.put("content", "bragh");
+    //1. Insert entities
+    for (int i = 0; i < 20; i++) {
+      props.put("ordinal", i);
+      this.app().collection("activity").post(props);
     }
 
-  /*
-   * public JsonNode entityIndex(JsonNode container, int index) { return
-   * container.get("entities").get(index); }
+    refreshIndex();
+    //2. Query a subset of the entities, specifying order and limit
+    String query = "select * where created > " + 1 + " order by created desc";
+    QueryParameters params = new QueryParameters().setQuery(query).setLimit(5);
+    Collection activities = this.app().collection("activities").get(params);
+    //3. Ensure the correct number of results are returned
+    assertEquals(5, activities.response.getEntityCount());
+
+  }
+
+  /**
+   * Ensure that results are returned in the correct descending order, when specified
+   * 1. Insert a number of entities and add them to an array
+   * 2. Query for the entities in descending order
+   * 3. Validate that the order is correct
+   * @throws IOException
    */
+  @Test
+  // USERGRID-1521
+  public void orderByReturnCorrectResults() throws IOException {
+
+    int size = 20;
+    Entity[] activities = new Entity[size];
+
+    Entity actor = new Entity();
+    actor.put("displayName", "Erin");
+    Entity props = new Entity();
+    props.put("actor", actor);
+    props.put("verb", "go");
+    props.put("content", "bragh");
+    //1. Insert a number of entities and add them to an array
+    for (int i = 0; i < size; i++) {
+      props.put("ordinal", i);
+      Entity e = this.app().collection("activity").post(props);
+      activities[i] = e;
+      log.info(String.valueOf(e.get("uuid").toString()));
+      log.info(String.valueOf(Long.parseLong(activities[0].get("created").toString())));
+    }
 
-
-    @Test
-    // USERGRID-1521
-    public void orderByReturnCorrectResults() throws IOException {
-
-        CustomCollection activities = context.customCollection( "activities" );
-
-        int size = 200;
-
-        Map<String, String> actor = hashMap( "displayName", "Erin" );
-        Map<String, Object> props = new HashMap<String, Object>();
-
-        props.put( "actor", actor );
-        props.put( "verb", "go" );
-        props.put( "content", "bragh" );
-
-        List<JsonNode> activites = new ArrayList<JsonNode>( size );
-
-        for ( int i = 0; i < size; i++ ) {
-            props.put( "ordinal", i );
-            JsonNode activity = activities.create( props ).get( "entities" ).get( 0 );
-            activites.add( activity );
-        }
-
-        refreshIndex(context.getOrgName(), context.getAppName());
-
-        long lastCreated = activites.get( activites.size() - 1 ).get( "created" ).asLong();
-
-        String errorQuery = String.format( "select * where created <= %d order by created desc", lastCreated );
-        String cursor = null;
-        int index = size - 1;
-
-        do {
-            JsonNode response = activities.withQuery( errorQuery ).get();
-            JsonNode cursorNode = response.get( "cursor" );
-
-            cursor = cursorNode != null ? cursorNode.asText() : null;
-
-            JsonNode entities = response.get( "entities" );
-
-            int returnSize = entities.size();
-
-            for ( int i = 0; i < returnSize; i++, index-- ) {
-                assertEquals( activites.get( index ), entities.get( i ) );
-            }
-
-            activities = activities.withCursor( cursor );
-        }
-        while ( cursor != null && cursor.length() > 0 );
-
-        assertEquals( "Paged to last result", -1, index );
+    refreshIndex();
+
+
+     ArrayUtils.reverse(activities);
+    long lastCreated = Long.parseLong(activities[0].get("created").toString());
+    //2. Query for the entities in descending order
+    String errorQuery = String.format("select * where created <= %d order by created desc", lastCreated);
+    String cursor = null;
+    int index = size - 1;
+
+    QueryParameters params = new QueryParameters().setQuery(errorQuery);
+    Collection activitiesResponse = this.app().collection("activities").get(params);
+    //3. Validate that the order is correct
+    do {
+      int returnSize = activitiesResponse.response.getEntityCount();
+      //loop through the current page of results
+      for (int i = 0; i < returnSize; i++, index--) {
+        assertEquals(((LinkedHashMap<String, Object>) activitiesResponse.response.getEntities().get(i)).get("uuid").toString(),
+            ((Entity) activities[index]).get("uuid").toString());
+      }
+      //grab the next page of results
+      activitiesResponse = this.app().getNextPage(activitiesResponse, true);
     }
+    while (activitiesResponse.getCursor() != null);
+  }
 }