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

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

Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-273 d35cba68b -> e80df0d5a


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/USERGRID-273
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
 


[27/50] 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 to...@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/USERGRID-273
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>
 


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

Posted by to...@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/USERGRID-273
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


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

Posted by to...@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/USERGRID-273
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);
+  }
 }


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

Posted by to...@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/USERGRID-273
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());
+
     }
 
 


[33/50] 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 to...@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/USERGRID-273
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 () {


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

Posted by to...@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/USERGRID-273
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


[36/50] incubator-usergrid git commit: [USERGRID-320] Added base class for common methods for query tests

Posted by to...@apache.org.
[USERGRID-320] Added base class for common methods 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/b07d52df
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/b07d52df
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/b07d52df

Branch: refs/heads/USERGRID-273
Commit: b07d52df290ddfae093f30a962b72fa814851f94
Parents: 5c23a7f
Author: ryan bridges <rb...@apigee.com>
Authored: Mon Jan 12 10:54:41 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Mon Jan 12 10:54:41 2015 -0500

----------------------------------------------------------------------
 .../applications/queries/QueryTestBase.java     | 56 ++++++++++++++++++++
 1 file changed, 56 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b07d52df/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java
new file mode 100644
index 0000000..b9287da
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java
@@ -0,0 +1,56 @@
+package org.apache.usergrid.rest.applications.queries;
+
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A base class containing common methods used by query tests
+ */
+public class QueryTestBase  extends AbstractRestIT {
+    private static Logger log = LoggerFactory.getLogger(QueryTestBase.class);
+    /**
+     * Create a number of entities in the specified collection
+     * with properties to make them independently searchable
+     *
+     * @param numberOfEntities
+     * @param collectionName
+     * @return an array of the Entity objects created
+     */
+    protected Entity[] generateTestEntities(int numberOfEntities, String collectionName) {
+        Entity[] entities = new Entity[numberOfEntities];
+        Entity props = new Entity();
+        //Insert the desired number of entities
+        for (int i = 0; i < numberOfEntities; i++) {
+            Entity actor = new Entity();
+            actor.put("displayName", String.format("Test User %d", i));
+            actor.put("username", String.format("user%d", i));
+            props.put("actor", actor);
+            //give each entity a unique, numeric ordinal value
+            props.put("ordinal", i);
+            //Set half the entities to have a 'madeup' property of 'true'
+            // and set the other half to 'false'
+            if (i < numberOfEntities / 2) {
+                props.put("madeup", false);
+            } else {
+                props.put("madeup", true);
+            }
+            //Set even-numbered users to have a verb of 'go' and the rest to 'stop'
+            if (i % 2 == 0) {
+                props.put("verb", "go");
+            } else {
+                props.put("verb", "stop");
+            }
+            //create the entity in the desired collection and add it to the return array
+            entities[i] = this.app().collection(collectionName).post(props);
+            log.info(entities[i].entrySet().toString());
+        }
+        //refresh the index so that they are immediately searchable
+        this.refreshIndex();
+
+        return entities;
+    }
+
+
+}


[45/50] incubator-usergrid git commit: [USERGRID-320] Added/Updated comments

Posted by to...@apache.org.
[USERGRID-320] Added/Updated comments


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

Branch: refs/heads/USERGRID-273
Commit: 3ad331b6e84173173911dbe1fe8241398889049b
Parents: 8fb45d1
Author: ryan bridges <rb...@apigee.com>
Authored: Wed Jan 14 18:23:49 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Wed Jan 14 18:23:49 2015 -0500

----------------------------------------------------------------------
 .../applications/queries/AndOrQueryTest.java    | 38 +++++++++++++-------
 .../queries/BadGrammarQueryTest.java            |  6 ++--
 .../rest/applications/queries/OrderByTest.java  | 16 ++++++---
 3 files changed, 41 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3ad331b6/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 d5956b5..fbd067e 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
@@ -33,7 +33,6 @@ import static org.junit.Assert.*;
 /**
  * // TODO: Document this
  *
- * @author ApigeeCorporation
  * @since 4.0
  */
 public class AndOrQueryTest extends QueryTestBase {
@@ -49,20 +48,22 @@ public class AndOrQueryTest extends QueryTestBase {
     public void queryAndInclusive() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
-        //create our test entities
+        // create our test entities
         generateTestEntities(numOfEntities, collectionName);
-        //Query where madeup = true (the last half) and the last quarter of entries
+        // Query where madeup = true (the last half) and the last quarter of entries
         QueryParameters params = new QueryParameters()
             .setQuery("select * where madeup = true AND ordinal >= " + (numOfEntities - numOfEntities / 4));
         Collection activities = this.app().collection("activities").get(params);
-        //results should have madeup = true and ordinal 15-19
+        // results should have madeup = true and ordinal 15-19
         assertEquals(numOfEntities / 4, activities.getResponse().getEntityCount());
+        // loop though entities that were returned, and test against the ordinals and values we are
+        // expecting, starting with the last entity and decrementing
         int index = 19;
         while (activities.hasNext()) {
             Entity activity = activities.next();
-            //ensure the 'madeup' property is set to true
+            // ensure the 'madeup' property is set to true
             assertTrue(Boolean.parseBoolean(activity.get("madeup").toString()));
-            //make sure the correct ordinal properties are returned
+            // make sure the correct ordinal properties are returned
             assertEquals(index--, Long.parseLong(activity.get("ordinal").toString()));
         }
 
@@ -86,6 +87,8 @@ public class AndOrQueryTest extends QueryTestBase {
         Collection activities = this.app().collection("activities").get(params);
         //results should have madeup = true and ordinal 10-14
         assertEquals(numOfEntities / 4, activities.getResponse().getEntityCount());
+        // loop though entities that were returned, and test against the ordinals and values we are
+        // expecting, starting with the last expected entity and decrementing
         int index = 14;
         while (activities.hasNext()) {
             Entity activity = activities.next();
@@ -116,19 +119,26 @@ public class AndOrQueryTest extends QueryTestBase {
         int index = numOfEntities - 1;
         int count = 0;
         int returnSize = activities.getResponse().getEntityCount();
+        //loop through the returned results
         for (int i = 0; i < returnSize; i++, index--) {
             count++;
             Entity activity = activities.getResponse().getEntities().get(i);
             log.info(String.valueOf(activity.get("ordinal")) + " " + String.valueOf(activity.get("madeup")));
+            //if the entity is in the first half, the property "madeup" should be false
             if (index < numOfEntities / 2) {
                 assertFalse(Boolean.parseBoolean(String.valueOf(activity.get("madeup"))));
-            } else if (index >= (numOfEntities - numOfEntities / 4)) {
+            }
+            //else if the entity is in the second half, the property "madeup" should be true
+            else if (index >= (numOfEntities - numOfEntities / 4)) {
                 assertTrue(Boolean.parseBoolean(String.valueOf(activity.get("madeup"))));
             }
+            //test to ensure that the ordinal is in the first half (where "madeup = false")
+            //OR that the ordinal is in the last quarter of the entity list (where "ordinal >=  (numOfEntities - numOfEntities / 4))")
             long ordinal = Long.parseLong(String.valueOf(activity.get("ordinal")));
             assertTrue(ordinal < (numOfEntities / 2) || ordinal >= (numOfEntities - numOfEntities / 4));
         }
-        //results should have madeup = false or ordinal 15-19
+        //results should have madeup = false or ordinal 0-9,15-19
+        //A total of 15 entities should be returned
         assertEquals(3 * numOfEntities / 4, count);
     }
 
@@ -158,13 +168,17 @@ public class AndOrQueryTest extends QueryTestBase {
             Entity activity = activities.getResponse().getEntities().get(i);
             long ordinal = Long.parseLong(String.valueOf(activity.get("ordinal")));
             log.info(ordinal + " " + String.valueOf(activity.get("verb")));
+            //if the entity is in the first three quarters, the property "verb" should be "go"
             if (ordinal < (numOfEntities - numOfEntities / 4)) {
                 assertEquals("go", String.valueOf(activity.get("verb")));
-            } else if (ordinal >= (numOfEntities - numOfEntities / 4)) {
+            }
+            //if the entity is in the last quarter, the property "verb" should be "stop"
+            else if (ordinal >= (numOfEntities - numOfEntities / 4)) {
                 assertEquals("stop", String.valueOf(activity.get("verb")));
             }
         }
         //results should be even ordinals in the first 3 quarters and odd ordinals from the last quarter
+        //Should return 1 more than half the number of entities
         assertEquals(1 + numOfEntities / 2, count);
     }
 
@@ -176,7 +190,7 @@ public class AndOrQueryTest extends QueryTestBase {
      *
      * @throws IOException
      */
-    @Test //USERGRID-900
+    @Test
     public void queryWithAndPastLimit() throws IOException {
         int numValuesTested = 40;
 
@@ -203,7 +217,7 @@ public class AndOrQueryTest extends QueryTestBase {
      *
      * @throws IOException
      */
-    @Test //USERGRID-1475
+    @Test
     public void queryNegated() throws IOException {
         int numValuesTested = 20;
 
@@ -229,7 +243,7 @@ public class AndOrQueryTest extends QueryTestBase {
      *
      * @throws Exception
      */
-    @Test //USERGRID-1615
+    @Test
     public void queryReturnCount() throws Exception {
         int numValuesTested = 20;
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3ad331b6/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 49120ab..fbc88c7 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
@@ -75,7 +75,7 @@ public class BadGrammarQueryTest extends QueryTestBase {
         generateTestEntities(numOfEntities, collectionName);
 
         //Issue an invalid query
-        String query = "select * where name != \"go\"";
+        String query = "select * where NOT name = \"go\"";
         try {
 
             QueryParameters params = new QueryParameters().setQuery(query);
@@ -112,12 +112,12 @@ public class BadGrammarQueryTest extends QueryTestBase {
             assertEquals(400, uie.getResponse().getStatus());
         }
     }
+
     /**
      * We should get an exception if the property name
      * is missing from the clause
      * @throws IOException
      */
-
     @Test
     public void exceptionOnMissingProperty() throws IOException {
 
@@ -138,12 +138,12 @@ public class BadGrammarQueryTest extends QueryTestBase {
             assertEquals(400, uie.getResponse().getStatus());
         }
     }
+
     /**
      * We should get an exception if the property value
      * is missing from the clause
      * @throws IOException
      */
-
     @Test
     public void exceptionOnMissingPropertyValue() throws IOException {
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3ad331b6/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 1e3b1b7..75f4a3f 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
@@ -82,11 +82,13 @@ public class OrderByTest extends QueryTestBase {
             .setLimit(numOfEntities);
         Collection activities = this.app().collection("activities").get(params);
         assertEquals(numOfEntities, activities.getResponse().getEntityCount());
+        //Since the sort order is descending, start at the last entity we created
         int index = numOfEntities - 1;
         //results should be sorted by ordinal
         while (activities.hasNext()) {
             Entity activity = activities.next();
             //make sure the correct ordinal properties are returned
+            //decrement the index to get the next entity in reverse order
             assertEquals(index--, Long.parseLong(activity.get("ordinal").toString()));
         }
     }
@@ -110,6 +112,8 @@ public class OrderByTest extends QueryTestBase {
         assertEquals(numOfEntities, activities.getResponse().getEntityCount());
         int index = 0;
         //results should be sorted false, then true
+        //The first half of entities returned should have "madeup = false"
+        //The second half of entities returned should have "madeup = true"
         while (activities.hasNext()) {
             Entity activity = activities.next();
             if (index++ < numOfEntities / 2) {
@@ -142,6 +146,8 @@ public class OrderByTest extends QueryTestBase {
         while (activities.hasNext()) {
             Entity activity = activities.next();
             //make sure the booleans are ordered correctly
+            //The first half of entities returned should have "madeup = true"
+            //The second half of entities returned should have "madeup = false"
             if (index++ < numOfEntities / 2) {
                 assertEquals("true", activity.get("madeup").toString());
             } else {
@@ -161,7 +167,7 @@ public class OrderByTest extends QueryTestBase {
         String collectionName = "activities";
         //create our test entities
         generateTestEntities(numOfEntities, collectionName);
-
+        //Sort by the "verb" property to test alphabetical sorting of string properties
         QueryParameters params = new QueryParameters()
             .setQuery("select * order by verb asc")
             .setLimit(numOfEntities);
@@ -171,6 +177,8 @@ public class OrderByTest extends QueryTestBase {
         //results should be sorted "go", then "stop"
         while (activities.hasNext()) {
             Entity activity = activities.next();
+            //The first half of entities returned should have "verb = 'go'"
+            //The second half of entities returned should have "verb = 'stop'"
             if (index++ < numOfEntities / 2) {
                 assertEquals("go", activity.get("verb").toString());
             } else {
@@ -191,6 +199,7 @@ public class OrderByTest extends QueryTestBase {
         //create our test entities
         generateTestEntities(numOfEntities, collectionName);
 
+        //Sort by the "verb" property, DESC to test reverse alphabetical sorting of string properties
         QueryParameters params = new QueryParameters()
             .setQuery("select * order by verb desc")
             .setLimit(numOfEntities);
@@ -200,6 +209,8 @@ public class OrderByTest extends QueryTestBase {
         //results should be sorted "stop", then "go"
         while (activities.hasNext()) {
             Entity activity = activities.next();
+            //The first half of entities returned should have "verb = 'stop'"
+            //The second half of entities returned should have "verb = 'go'"
             if (index++ < numOfEntities / 2) {
                 assertEquals("stop", activity.get("verb").toString());
             } else {
@@ -221,7 +232,6 @@ public class OrderByTest extends QueryTestBase {
      * @throws IOException
      */
     @Test
-    // USERGRID-1400
     public void orderByShouldNotAffectResults() throws IOException {
 
         long created = 0;
@@ -270,7 +280,6 @@ public class OrderByTest extends QueryTestBase {
      * @throws IOException
      */
     @Test
-    // USERGRID-1520
     public void orderByComesBeforeLimitResult() throws IOException {
 
         Entity actor = new Entity();
@@ -304,7 +313,6 @@ public class OrderByTest extends QueryTestBase {
      * @throws IOException
      */
     @Test
-    // USERGRID-1521
     public void orderByReturnCorrectResults() throws IOException {
 
         int size = 20;


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

Posted by to...@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/USERGRID-273
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;}
 


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

Posted by to...@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/USERGRID-273
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;
   }
 
 }


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

Posted by to...@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/USERGRID-273
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

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

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



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

Posted by to...@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/USERGRID-273
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);
   }


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

Posted by to...@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/USERGRID-273
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(-)
----------------------------------------------------------------------



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

Posted by to...@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/USERGRID-273
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(+)
----------------------------------------------------------------------



[20/50] 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 to...@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/USERGRID-273
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(-)
----------------------------------------------------------------------



[46/50] incubator-usergrid git commit: [USERGRID-326] Additional corrections and comments

Posted by to...@apache.org.
[USERGRID-326] Additional corrections and comments


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

Branch: refs/heads/USERGRID-273
Commit: 2b7d2318c6699838b980e1627e374958172ef862
Parents: 8daa6e5
Author: ryan bridges <rb...@apigee.com>
Authored: Wed Jan 14 18:45:52 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Wed Jan 14 18:45:52 2015 -0500

----------------------------------------------------------------------
 .../apache/usergrid/rest/PartialUpdateTest.java | 27 ++++++++++----------
 .../endpoints/CollectionEndpoint.java           |  2 +-
 2 files changed, 14 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2b7d2318/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
index bdc4e66..e6ada31 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
@@ -77,8 +77,6 @@ public class PartialUpdateTest extends AbstractRestIT {
             try {
                 // PUT the updates to the user and ensure they were saved
                 userNode = this.app().collection("users").entity(userNode).put(updateProps);
-                assertNotNull(userNode);
-
             } catch (UniformInterfaceException uie) {
                 fail("Update failed due to: " + uie.getResponse().getEntity(String.class));
             }
@@ -112,23 +110,24 @@ public class PartialUpdateTest extends AbstractRestIT {
                 Double.parseDouble(((Map<String, Object>) userNode.get("location")).get("longitude").toString()), 0);
         }
 
-        // Update bart's employer without specifying any required fields
+        // Update bart's employer without specifying the full entity
         // (this time with username specified in URL)
         Entity updateProps = new Entity();
         updateProps.put("employer", "ACME Corporation");
 
-        for (int i = 1; i < 10; i++) {
-            try {
-                userNode = this.app().collection("users").entity((String) props.get("username")).put(updateProps);
+        try { //  PUT /users/fred   put /users/uuid
+            userNode = this.app().collection("users").entity(props.getString("username")).put(updateProps);
 
-            } catch (UniformInterfaceException uie) {
-                fail("Update failed due to: " + uie.getResponse().getEntity(String.class));
-            }
-            refreshIndex();
-
-            userNode = this.app().collection("users").entity(userNode).get();
-            assertNotNull(userNode);
-            assertEquals("ACME Corporation", userNode.get("employer").toString());
+        } catch (UniformInterfaceException uie) {
+            fail("Update failed due to: " + uie.getResponse().getEntity(String.class));
         }
+        refreshIndex();
+
+        userNode = this.app().collection("users").entity(userNode).get();
+        assertNotNull(userNode);
+        //Test that the updated property is returned
+        assertEquals(updateProps.get("employer"), userNode.get("employer").toString());
+        //Test that the original properties are still there
+        assertEquals(props.get("username").toString(), userNode.get("username").toString());
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2b7d2318/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionEndpoint.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionEndpoint.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionEndpoint.java
index 325a5fa..3cb7a32 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionEndpoint.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionEndpoint.java
@@ -49,7 +49,7 @@ public class CollectionEndpoint extends NamedResource {
 
 
     public EntityEndpoint entity(final String identifier ){
-        return new EntityEndpoint(identifier, context, this);
+        return uniqueID(identifier);
     }
 
 


[35/50] incubator-usergrid git commit: [USERGRID-320] Fixed casting error in GeoPagingTest due to framework change

Posted by to...@apache.org.
[USERGRID-320] Fixed casting error in GeoPagingTest due to framework change


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

Branch: refs/heads/USERGRID-273
Commit: 5c23a7fcded09a0c35e8aaf31b6bbce556d19a2e
Parents: cbe8468
Author: ryan bridges <rb...@apigee.com>
Authored: Mon Jan 12 10:53:42 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Mon Jan 12 10:53:42 2015 -0500

----------------------------------------------------------------------
 .../apache/usergrid/rest/applications/queries/GeoPagingTest.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5c23a7fc/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 044a249..6c48af2 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
@@ -198,7 +198,7 @@ public class GeoPagingTest extends AbstractRestIT {
       // 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
-        LinkedHashMap<String, Object> entity = (LinkedHashMap<String, Object>) entities.get(i);
+        Entity entity = (Entity)entities.get(i);
         Entity savedEntity = saved[7 + i];
         assertEquals(savedEntity.get("uuid"), entity.get("uuid"));
       }


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

Posted by to...@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/USERGRID-273
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


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

Posted by to...@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/USERGRID-273
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


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

Posted by to...@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/USERGRID-273
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){


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

Posted by to...@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/USERGRID-273
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


[42/50] 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 to...@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/USERGRID-273
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(-)
----------------------------------------------------------------------



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

Posted by to...@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/USERGRID-273
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


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

Posted by to...@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/USERGRID-273
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" ));
 
     }
 }


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

Posted by to...@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/USERGRID-273
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);


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

Posted by to...@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/USERGRID-273
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
----------------------------------------------------------------------


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

Posted by to...@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/USERGRID-273
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


[40/50] 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 to...@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/USERGRID-273
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
----------------------------------------------------------------------


[47/50] incubator-usergrid git commit: Merge remote-tracking branch 'r3b/USERGRID-320' into apache_usergrid/two-dot-o

Posted by to...@apache.org.
Merge remote-tracking branch 'r3b/USERGRID-320' 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/e6561c77
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e6561c77
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e6561c77

Branch: refs/heads/USERGRID-273
Commit: e6561c77864aad2ca016d524e837c346f7bbd3b0
Parents: bcabda2 3ad331b
Author: Rod Simpson <ro...@apigee.com>
Authored: Tue Jan 20 10:58:54 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Tue Jan 20 10:58:54 2015 -0700

----------------------------------------------------------------------
 .../applications/queries/AndOrQueryTest.java    | 528 ++++++++++---------
 .../queries/BadGrammarQueryTest.java            | 213 ++++++--
 .../applications/queries/GeoPagingTest.java     |   2 +-
 .../rest/applications/queries/OrderByTest.java  | 447 +++++++++++-----
 .../applications/queries/QueryTestBase.java     |  56 ++
 5 files changed, 843 insertions(+), 403 deletions(-)
----------------------------------------------------------------------



[48/50] incubator-usergrid git commit: Merge remote-tracking branch 'r3b/USERGRID-326' into apache_usergrid/two-dot-o

Posted by to...@apache.org.
Merge remote-tracking branch 'r3b/USERGRID-326' 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/561815ae
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/561815ae
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/561815ae

Branch: refs/heads/USERGRID-273
Commit: 561815ae8762ef10a284fcbd739fffd240c61174
Parents: e6561c7 2b7d231
Author: Rod Simpson <ro...@apigee.com>
Authored: Tue Jan 20 10:59:43 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Tue Jan 20 10:59:43 2015 -0700

----------------------------------------------------------------------
 .../apache/usergrid/rest/PartialUpdateTest.java | 170 ++++++++-----------
 .../endpoints/CollectionEndpoint.java           |   2 +-
 2 files changed, 76 insertions(+), 96 deletions(-)
----------------------------------------------------------------------



[37/50] incubator-usergrid git commit: [USERGRID-320] Additional tests and comments

Posted by to...@apache.org.
[USERGRID-320] Additional tests and comments


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

Branch: refs/heads/USERGRID-273
Commit: 4efd58bd7bb2df8fcaed3d3c4891fc3230b5a111
Parents: b07d52d
Author: ryan bridges <rb...@apigee.com>
Authored: Mon Jan 12 11:31:16 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Mon Jan 12 11:31:16 2015 -0500

----------------------------------------------------------------------
 .../applications/queries/AndOrQueryTest.java    |  65 +---
 .../queries/BadGrammarQueryTest.java            | 213 +++++++++--
 .../rest/applications/queries/OrderByTest.java  | 367 +++++++++----------
 3 files changed, 361 insertions(+), 284 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4efd58bd/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 d67e62a..6cd21da 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,7 +17,6 @@
 package org.apache.usergrid.rest.applications.queries;
 
 
-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;
@@ -37,50 +36,9 @@ import static org.junit.Assert.*;
  * @author ApigeeCorporation
  * @since 4.0
  */
-public class AndOrQueryTest extends AbstractRestIT {
+public class AndOrQueryTest extends QueryTestBase {
     private static Logger log = LoggerFactory.getLogger(AndOrQueryTest.class);
 
-    /**
-     * Create a number of entities in the specified collection
-     * with properties to make them independently searchable
-     *
-     * @param numberOfEntities
-     * @param collectionName
-     * @return an array of the Entity objects created
-     */
-    private Entity[] generateTestEntities(int numberOfEntities, String collectionName) {
-        Entity[] entities = new Entity[numberOfEntities];
-        Entity props = new Entity();
-        //Insert the desired number of entities
-        for (int i = 0; i < numberOfEntities; i++) {
-            Entity actor = new Entity();
-            actor.put("displayName", String.format("Test User %d", i));
-            actor.put("username", String.format("user%d", i));
-            props.put("actor", actor);
-            //give each entity a unique, numeric ordinal value
-            props.put("ordinal", i);
-            //Set half the entities to have a 'madeup' property of 'true'
-            // and set the other half to 'false'
-            if (i < numberOfEntities / 2) {
-                props.put("madeup", false);
-            } else {
-                props.put("madeup", true);
-            }
-            //Set even-numbered users to have a verb of 'go' and the rest to 'stop'
-            if (i % 2 == 0) {
-                props.put("verb", "go");
-            } else {
-                props.put("verb", "stop");
-            }
-            //create the entity in the desired collection and add it to the return array
-            entities[i] = this.app().collection(collectionName).post(props);
-            log.info(entities[i].entrySet().toString());
-        }
-        //refresh the index so that they are immediately searchable
-        this.refreshIndex();
-
-        return entities;
-    }
 
     /**
      * Test an inclusive AND query to ensure the correct results are returned
@@ -92,7 +50,7 @@ public class AndOrQueryTest extends AbstractRestIT {
         int numOfEntities = 20;
         String collectionName = "activities";
         //create our test entities
-        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+        generateTestEntities(numOfEntities, collectionName);
         //Query where madeup = true (the last half) and the last quarter of entries
         QueryParameters params = new QueryParameters()
             .setQuery("select * where madeup = true AND ordinal >= " + (numOfEntities - numOfEntities / 4));
@@ -120,7 +78,7 @@ public class AndOrQueryTest extends AbstractRestIT {
         int numOfEntities = 20;
         String collectionName = "activities";
 
-        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+        generateTestEntities(numOfEntities, collectionName);
 
         //Query where madeup = true (the last half) and NOT the last quarter of entries
         QueryParameters params = new QueryParameters()
@@ -148,7 +106,7 @@ public class AndOrQueryTest extends AbstractRestIT {
         int numOfEntities = 20;
         String collectionName = "activities";
 
-        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+        generateTestEntities(numOfEntities, collectionName);
 
         //Query where madeup = false (the first half) or the last quarter of entries
         QueryParameters params = new QueryParameters()
@@ -184,7 +142,7 @@ public class AndOrQueryTest extends AbstractRestIT {
         int numOfEntities = 30;
         String collectionName = "activities";
 
-        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+        generateTestEntities(numOfEntities, collectionName);
 
         //Query where the verb = 'go' (half) OR the last quarter by ordinal, but NOT where verb = 'go' AND the ordinal is in the last quarter
         QueryParameters params = new QueryParameters()
@@ -221,9 +179,8 @@ public class AndOrQueryTest extends AbstractRestIT {
     @Test //USERGRID-900
     public void queriesWithAndPastLimit() throws IOException {
         int numValuesTested = 40;
-        long created = 0;
 
-        Entity[] entities = generateTestEntities(numValuesTested, "activities");
+        generateTestEntities(numValuesTested, "activities");
         //3. Query all entities where "madeup = true"
         String errorQuery = "select * where madeup = true";
         QueryParameters params = new QueryParameters()
@@ -250,7 +207,7 @@ public class AndOrQueryTest extends AbstractRestIT {
     public void negatedQuery() throws IOException {
         int numValuesTested = 20;
 
-        Entity[] entities = generateTestEntities(numValuesTested, "activities");
+        generateTestEntities(numValuesTested, "activities");
         //1. Query all entities where "NOT verb = 'go'"
         String query = "select * where not verb = 'go'";
         //2. Limit the query to half of the number of entities
@@ -276,7 +233,7 @@ public class AndOrQueryTest extends AbstractRestIT {
     public void queryReturnCount() throws Exception {
         int numValuesTested = 20;
 
-        Entity[] entities = generateTestEntities(numValuesTested, "activities");
+        generateTestEntities(numValuesTested, "activities");
         //1. Query for a subset of the entities
         String inCorrectQuery = "select * where ordinal >= " + (numValuesTested / 2) + " order by ordinal asc";
         QueryParameters params = new QueryParameters().setQuery(inCorrectQuery).setLimit(numValuesTested / 2);
@@ -303,7 +260,7 @@ public class AndOrQueryTest extends AbstractRestIT {
         int numOfEntities = 20;
         String collectionName = "imagination";
 
-        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+        generateTestEntities(numOfEntities, collectionName);
 
         //2. Use AND/OR query to retrieve entities
         String inquisitiveQuery = "select * where Ordinal gte 0 and Ordinal lte  " + (numOfEntities / 2)
@@ -332,7 +289,7 @@ public class AndOrQueryTest extends AbstractRestIT {
         int numOfEntities = 20;
         String collectionName = "imagination";
 
-        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+        generateTestEntities(numOfEntities, collectionName);
 
         //2. Issue a query
         String inquisitiveQuery = String.format("select * where ordinal >= 0 and ordinal <= %d or WhoHelpedYou = 'Ruff'", numOfEntities);
@@ -359,7 +316,7 @@ public class AndOrQueryTest extends AbstractRestIT {
         int numOfEntities = 10;
         String collectionName = "imagination";
 
-        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+        generateTestEntities(numOfEntities, collectionName);
 
         //2. Issue a query using alphanumeric operators
         String inquisitiveQuery = "select * where Ordinal gte 0 and Ordinal lte 2000 or WhoHelpedYou eq 'Ruff'";

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4efd58bd/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 00b90dc..12da417 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
@@ -18,7 +18,7 @@ package org.apache.usergrid.rest.applications.queries;
 
 
 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.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
 import org.junit.Test;
@@ -30,36 +30,187 @@ import static org.junit.Assert.fail;
 
 
 /**
- * Test for an exception with incorrect query grammar
- * 1. Insert an entity
- * 2. Issue an invalid query
- * 3. Check for an exception
+ * Test for exceptions resulting from invalid query syntax
  */
-public class BadGrammarQueryTest extends AbstractRestIT {
-
-  @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());
+public class BadGrammarQueryTest extends QueryTestBase {
+
+    /**
+     * We should get an exception if the clause contains
+     * an invalid operator.
+     * (eg. "name != 'go'" instead of "NOT name = 'go'")
+     * @throws IOException
+     */
+    @Test
+    public void catchBadQueryGrammar() throws IOException {
+
+        int numOfEntities = 1;
+        String collectionName = "things";
+        //create our test entities
+        generateTestEntities(numOfEntities, collectionName);
+
+        //Issue an invalid query
+        String query = "select * where name != 'go'";
+        try {
+
+            QueryParameters params = new QueryParameters().setQuery(query);
+            this.app().collection(collectionName).get(params);
+            fail("This should throw an exception");
+        } catch (UniformInterfaceException uie) {
+            //Check for an exception
+            assertEquals(400, uie.getResponse().getStatus());
+        }
+    }
+
+    /**
+     * We should get an exception if the clause contains
+     * a string that is surrounded by double-quotes
+     * @throws IOException
+     */
+    @Test
+    public void exceptionOnDoubleQuotes() throws IOException {
+
+        int numOfEntities = 1;
+        String collectionName = "things";
+        //create our test entities
+        generateTestEntities(numOfEntities, collectionName);
+
+        //Issue an invalid query
+        String query = "select * where name != \"go\"";
+        try {
+
+            QueryParameters params = new QueryParameters().setQuery(query);
+            this.app().collection(collectionName).get(params);
+            fail("This should throw an exception");
+        } catch (UniformInterfaceException uie) {
+            //Check for an exception
+            assertEquals(400, uie.getResponse().getStatus());
+        }
     }
-  }
+
+    /**
+     * We should get an exception if the clause contains
+     * a string that is not properly quoted
+     * @throws IOException
+     */
+    @Test
+    public void exceptionOnMissingQuotes() throws IOException {
+
+        int numOfEntities = 1;
+        String collectionName = "things";
+        //create our test entities
+        generateTestEntities(numOfEntities, collectionName);
+
+        //Issue an invalid query
+        String query = "select * where name != go";
+        try {
+
+            QueryParameters params = new QueryParameters().setQuery(query);
+            this.app().collection(collectionName).get(params);
+            fail("This should throw an exception");
+        } catch (UniformInterfaceException uie) {
+            //Check for an exception
+            assertEquals(400, uie.getResponse().getStatus());
+        }
+    }
+    /**
+     * We should get an exception if the property name
+     * is missing from the clause
+     * @throws IOException
+     */
+
+    @Test
+    public void exceptionOnMissingProperty() throws IOException {
+
+        int numOfEntities = 1;
+        String collectionName = "things";
+        //create our test entities
+        generateTestEntities(numOfEntities, collectionName);
+
+        //Issue an invalid query
+        String query = "select * where != 'go'";
+        try {
+
+            QueryParameters params = new QueryParameters().setQuery(query);
+            this.app().collection(collectionName).get(params);
+            fail("This should throw an exception");
+        } catch (UniformInterfaceException uie) {
+            //Check for an exception
+            assertEquals(400, uie.getResponse().getStatus());
+        }
+    }
+    /**
+     * We should get an exception if the property value
+     * is missing from the clause
+     * @throws IOException
+     */
+
+    @Test
+    public void exceptionOnMissingPropertyValue() throws IOException {
+
+        int numOfEntities = 1;
+        String collectionName = "things";
+        //create our test entities
+        generateTestEntities(numOfEntities, collectionName);
+
+        //Issue an invalid query
+        String query = "select * where name != ";
+        try {
+
+            QueryParameters params = new QueryParameters().setQuery(query);
+            this.app().collection(collectionName).get(params);
+            fail("This should throw an exception");
+        } catch (UniformInterfaceException uie) {
+            //Check for an exception
+            assertEquals(400, uie.getResponse().getStatus());
+        }
+    }
+
+    /**
+     * We should get an exception if the operator is missing
+     * from the clause
+     * @throws IOException
+     */
+    @Test
+    public void exceptionOnMissingOperator() throws IOException {
+
+        int numOfEntities = 1;
+        String collectionName = "things";
+        //create our test entities
+        generateTestEntities(numOfEntities, collectionName);
+
+        //Issue an invalid query
+        String query = "select * where name 'go' ";
+        try {
+
+            QueryParameters params = new QueryParameters().setQuery(query);
+            this.app().collection(collectionName).get(params);
+            fail("This should throw an exception");
+        } catch (UniformInterfaceException uie) {
+            //Check for an exception
+            assertEquals(400, uie.getResponse().getStatus());
+        }
+    }
+
+    /**
+     * Limit should be sent separately from the query,
+     * else the query will return only entities with
+     * a property named 'limit'
+     * @throws IOException
+     */
+    @Test
+    public void limitInQuery() throws IOException {
+
+        int numOfEntities =1;
+        String collectionName = "things";
+        //create our test entities
+        generateTestEntities(numOfEntities, collectionName);
+
+
+        //Issue an invalid query
+        String query = "select * where limit = 5";
+        QueryParameters params = new QueryParameters().setQuery(query);
+        Collection collection = this.app().collection(collectionName).get(params);
+        assertEquals(0, collection.getNumOfEntities());
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4efd58bd/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 9acee8d..a30168a 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
@@ -18,7 +18,6 @@ package org.apache.usergrid.rest.applications.queries;
 
 
 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;
@@ -27,11 +26,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
-import java.util.LinkedHashMap;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
 
 
 /**
@@ -40,60 +36,20 @@ import static org.junit.Assert.assertTrue;
  * @author ApigeeCorporation
  * @since 4.0
  */
-public class OrderByTest extends AbstractRestIT {
-  private static Logger log = LoggerFactory.getLogger(OrderByTest.class);
-    /**
-     * Create a number of entities in the specified collection
-     * with properties to make them independently searchable
-     *
-     * @param numberOfEntities
-     * @param collectionName
-     * @return an array of the Entity objects created
-     */
-    private Entity[] generateTestEntities(int numberOfEntities, String collectionName) {
-        Entity[] entities = new Entity[numberOfEntities];
-        Entity props = new Entity();
-        //Insert the desired number of entities
-        for (int i = 0; i < numberOfEntities; i++) {
-            Entity actor = new Entity();
-            actor.put("displayName", String.format("Test User %d", i));
-            actor.put("username", String.format("user%d", i));
-            props.put("actor", actor);
-            //give each entity a unique, numeric ordinal value
-            props.put("ordinal", i);
-            //Set half the entities to have a 'madeup' property of 'true'
-            // and set the other half to 'false'
-            if (i < numberOfEntities / 2) {
-                props.put("madeup", false);
-            } else {
-                props.put("madeup", true);
-            }
-            //Set even-numbered users to have a verb of 'go' and the rest to 'stop'
-            if (i % 2 == 0) {
-                props.put("verb", "go");
-            } else {
-                props.put("verb", "stop");
-            }
-            //create the entity in the desired collection and add it to the return array
-            entities[i] = this.app().collection(collectionName).post(props);
-            log.info(entities[i].entrySet().toString());
-        }
-        //refresh the index so that they are immediately searchable
-        this.refreshIndex();
-
-        return entities;
-    }
+public class OrderByTest extends QueryTestBase {
+    private static Logger log = LoggerFactory.getLogger(OrderByTest.class);
 
     /**
      * Test correct sort order for Long properties
+     *
      * @throws IOException
      */
     @Test
-    public void testSortLongAsc() throws IOException{
+    public void testSortLongAsc() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
         //create our test entities
-        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+        generateTestEntities(numOfEntities, collectionName);
 
         QueryParameters params = new QueryParameters()
             .setQuery("select * order by ordinal asc")
@@ -108,23 +64,25 @@ public class OrderByTest extends AbstractRestIT {
             assertEquals(index++, Long.parseLong(activity.get("ordinal").toString()));
         }
     }
+
     /**
      * Test correct sort order for Long properties
+     *
      * @throws IOException
      */
     @Test
-    public void testSortLongDesc() throws IOException{
+    public void testSortLongDesc() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
         //create our test entities
-        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+        generateTestEntities(numOfEntities, collectionName);
 
         QueryParameters params = new QueryParameters()
             .setQuery("select * order by ordinal desc")
             .setLimit(numOfEntities);
         Collection activities = this.app().collection("activities").get(params);
         assertEquals(numOfEntities, activities.getResponse().getEntityCount());
-        int index = numOfEntities-1;
+        int index = numOfEntities - 1;
         //results should be sorted by ordinal
         while (activities.hasNext()) {
             Entity activity = activities.next();
@@ -132,16 +90,18 @@ public class OrderByTest extends AbstractRestIT {
             assertEquals(index--, Long.parseLong(activity.get("ordinal").toString()));
         }
     }
+
     /**
      * Test correct sort order for Boolean properties
+     *
      * @throws IOException
      */
     @Test
-    public void testSortBooleanAsc() throws IOException{
+    public void testSortBooleanAsc() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
         //create our test entities
-        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+        generateTestEntities(numOfEntities, collectionName);
 
         QueryParameters params = new QueryParameters()
             .setQuery("select * order by madeup asc")
@@ -152,23 +112,25 @@ public class OrderByTest extends AbstractRestIT {
         //results should be sorted false, then true
         while (activities.hasNext()) {
             Entity activity = activities.next();
-            if(index++ < numOfEntities/2){
+            if (index++ < numOfEntities / 2) {
                 assertEquals("false", activity.get("madeup").toString());
-            }else{
+            } else {
                 assertEquals("true", activity.get("madeup").toString());
             }
         }
     }
+
     /**
      * Test correct sort order for Boolean properties
+     *
      * @throws IOException
      */
     @Test
-    public void testSortBooleanDesc() throws IOException{
+    public void testSortBooleanDesc() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
         //create our test entities
-        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+        generateTestEntities(numOfEntities, collectionName);
 
         QueryParameters params = new QueryParameters()
             .setQuery("select * order by madeup desc")
@@ -180,9 +142,9 @@ public class OrderByTest extends AbstractRestIT {
         while (activities.hasNext()) {
             Entity activity = activities.next();
             //make sure the booleans are ordered correctly
-            if(index++ < numOfEntities/2){
+            if (index++ < numOfEntities / 2) {
                 assertEquals("true", activity.get("madeup").toString());
-            }else{
+            } else {
                 assertEquals("false", activity.get("madeup").toString());
             }
         }
@@ -190,14 +152,15 @@ public class OrderByTest extends AbstractRestIT {
 
     /**
      * Test correct sort order for String properties
+     *
      * @throws IOException
      */
     @Test
-    public void testSortStringAsc() throws IOException{
+    public void testSortStringAsc() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
         //create our test entities
-        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+        generateTestEntities(numOfEntities, collectionName);
 
         QueryParameters params = new QueryParameters()
             .setQuery("select * order by verb asc")
@@ -208,23 +171,25 @@ public class OrderByTest extends AbstractRestIT {
         //results should be sorted "go", then "stop"
         while (activities.hasNext()) {
             Entity activity = activities.next();
-            if(index++ < numOfEntities/2){
+            if (index++ < numOfEntities / 2) {
                 assertEquals("go", activity.get("verb").toString());
-            }else{
+            } else {
                 assertEquals("stop", activity.get("verb").toString());
             }
         }
     }
+
     /**
      * Test correct sort order for String properties
+     *
      * @throws IOException
      */
     @Test
-    public void testSortStringDesc() throws IOException{
+    public void testSortStringDesc() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
         //create our test entities
-        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+        generateTestEntities(numOfEntities, collectionName);
 
         QueryParameters params = new QueryParameters()
             .setQuery("select * order by verb desc")
@@ -235,149 +200,153 @@ public class OrderByTest extends AbstractRestIT {
         //results should be sorted "stop", then "go"
         while (activities.hasNext()) {
             Entity activity = activities.next();
-            if(index++ < numOfEntities/2){
+            if (index++ < numOfEntities / 2) {
                 assertEquals("stop", activity.get("verb").toString());
-            }else{
+            } else {
                 assertEquals("go", activity.get("verb").toString());
             }
         }
 
     }
-  /**
-   * 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.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.getResponse().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());
-    }
-  }
-
-
-  /**
-   * 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);
+    /**
+     * 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.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.getResponse().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());
+        }
     }
 
-    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.getResponse().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())));
+
+    /**
+     * 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);
+        }
+
+        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.getResponse().getEntityCount());
+
     }
 
-    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);
-    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.getResponse().getEntityCount();
-      //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[i]).get("uuid").toString());
-      }
-      //grab the next page of results
-      activitiesResponse = this.app().getNextPage(activitiesResponse, params, true);
+    /**
+     * 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())));
+        }
+
+        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);
+        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.getResponse().getEntityCount();
+            //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[i]).get("uuid").toString());
+            }
+            //grab the next page of results
+            activitiesResponse = this.app().getNextPage(activitiesResponse, params, true);
+        }
+        while (activitiesResponse.getCursor() != null);
     }
-    while (activitiesResponse.getCursor() != null);
-  }
 }


[04/50] 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 organizations. Add

Posted by to...@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/USERGRID-273
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;
-//    }
 }


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

Posted by to...@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/USERGRID-273
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);
+    }
 }


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

Posted by to...@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/USERGRID-273
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;


[12/50] 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 to...@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/USERGRID-273
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 );
     }


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

Posted by to...@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/USERGRID-273
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(-)
----------------------------------------------------------------------



[38/50] incubator-usergrid git commit: [USERGRID-320] Additional tests and comments

Posted by to...@apache.org.
[USERGRID-320] Additional tests and comments


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

Branch: refs/heads/USERGRID-273
Commit: c078ae142bda99c5f5f2b19df7235f8e6e3521f6
Parents: 4efd58b
Author: ryan bridges <rb...@apigee.com>
Authored: Mon Jan 12 11:33:00 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Mon Jan 12 11:33:00 2015 -0500

----------------------------------------------------------------------
 .../usergrid/rest/applications/queries/BadGrammarQueryTest.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c078ae14/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 12da417..4dd7548 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
@@ -206,7 +206,7 @@ public class BadGrammarQueryTest extends QueryTestBase {
         generateTestEntities(numOfEntities, collectionName);
 
 
-        //Issue an invalid query
+        //Issue a query with the limit appended
         String query = "select * where limit = 5";
         QueryParameters params = new QueryParameters().setQuery(query);
         Collection collection = this.app().collection(collectionName).get(params);


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

Posted by to...@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/USERGRID-273
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 );


[49/50] incubator-usergrid git commit: added apache lic header

Posted by to...@apache.org.
added apache lic header


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

Branch: refs/heads/USERGRID-273
Commit: 6ebbe50937a53c94e3555e95a964d52c0976388a
Parents: 561815a
Author: Rod Simpson <ro...@apigee.com>
Authored: Tue Jan 20 14:36:47 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Tue Jan 20 14:36:47 2015 -0700

----------------------------------------------------------------------
 .../rest/applications/queries/QueryTestBase.java    | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6ebbe509/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java
index b9287da..5871c84 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java
@@ -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.
+ */
 package org.apache.usergrid.rest.applications.queries;
 
 import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;


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

Posted by to...@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/USERGRID-273
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();


[44/50] incubator-usergrid git commit: [USERGRID-326] Updating PartialUpdateTest to work with the new REST test framework

Posted by to...@apache.org.
[USERGRID-326] Updating PartialUpdateTest to work with the new REST 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/8daa6e5b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/8daa6e5b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/8daa6e5b

Branch: refs/heads/USERGRID-273
Commit: 8daa6e5b8619387b627044225c7befbe00b307ab
Parents: 231a449
Author: ryan bridges <rb...@apigee.com>
Authored: Mon Jan 12 14:23:35 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Mon Jan 12 14:23:35 2015 -0500

----------------------------------------------------------------------
 .../apache/usergrid/rest/PartialUpdateTest.java | 157 ++++++++-----------
 1 file changed, 69 insertions(+), 88 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8daa6e5b/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
index a9e1548..bdc4e66 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
@@ -17,137 +17,118 @@
 package org.apache.usergrid.rest;
 
 
-import com.fasterxml.jackson.databind.JsonNode;
 import com.sun.jersey.api.client.UniformInterfaceException;
-import java.io.IOException;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import javax.ws.rs.core.MediaType;
-
-import org.junit.Rule;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+import org.apache.usergrid.utils.MapUtils;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.fail;
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import static org.junit.Assert.*;
 
 
 /**
- * Partial update test. 
+ * Partial update test.
  */
 public class PartialUpdateTest extends AbstractRestIT {
-    private static final Logger log= LoggerFactory.getLogger(PartialUpdateTest.class );
-    
-    @Rule
-    public TestContextSetup context = new TestContextSetup( this );
+    private static final Logger log = LoggerFactory.getLogger(PartialUpdateTest.class);
 
-    double latitude=37.772837;
-    double longitude=-122.409895;
+    double latitude = 37.772837;
+    double longitude = -122.409895;
 
-    Map<String, Object> geolocation = new LinkedHashMap<String, Object>() {{
-        put("latitude", latitude);
-        put("longitude", longitude);
-    }};
+    Map<String, Double> geolocation = new MapUtils.HashMapBuilder<String, Double>()
+        .map("latitude", latitude)
+        .map("longitude", longitude);
 
-    @Test 
+    @Test
     public void testPartialUpdate() throws IOException {
 
         // create user bart
-        Map<String, Object> userProperties = new LinkedHashMap<String, Object>() {{
-            put( "username", "bart" );
-            put( "employer", "Brawndo" );
-            put( "email", "bart@personal-email.example.com" );
-            put( "location", geolocation);
-        }};
-
-        JsonNode userNode = mapper.readTree( 
-            resource().path( "/test-organization/test-app/users" )
-                .queryParam( "access_token", adminAccessToken )
-                .accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON )
-                .post( String.class, userProperties ));
-
-        assertNotNull( userNode );
-        String uuid = userNode.withArray("entities").get(0).get("uuid").asText();
-        assertNotNull( uuid );
-        refreshIndex( "test-organization", "test-app" );
+        Entity props = new Entity();
+        props.put("username", "bart");
+        props.put("employer", "Brawndo");
+        props.put("email", "bart@personal-email.example.com");
+        props.put("location", geolocation);
+        // POST the entity
+        Entity userNode = this.app().collection("users").post(props);
+        // make sure it was saved properly
+        assertNotNull(userNode);
+        String uuid = userNode.get("uuid").toString();
+        assertNotNull(uuid);
+
+        refreshIndex();
 
         Map<String, Object> updateProperties = new LinkedHashMap<String, Object>();
         // update user bart passing only an update to a property
-        for(int i=1; i<10; i++) {
+        for (int i = 1; i < 10; i++) {
+            // "Move" the user by incrementing their location
+            Entity updateProps = new Entity();
             geolocation.put("latitude", latitude += 0.00001);
             geolocation.put("longitude", longitude += 0.00001);
-            updateProperties.put("employer", "Initech");
-            updateProperties.put("location", geolocation);
+            //update the User's employer property
+            updateProps.put("employer", "Initech");
+            updateProps.put("location", geolocation);
 
             try {
-                JsonNode updatedNode = mapper.readTree(
-                        resource().path("/test-organization/test-app/user/" + uuid)
-                                .queryParam("access_token", adminAccessToken)
-                                .accept(MediaType.APPLICATION_JSON)
-                                .type(MediaType.APPLICATION_JSON)
-                                .put(String.class, updateProperties));
-                assertNotNull(updatedNode);
+                // PUT the updates to the user and ensure they were saved
+                userNode = this.app().collection("users").entity(userNode).put(updateProps);
+                assertNotNull(userNode);
 
             } catch (UniformInterfaceException uie) {
                 fail("Update failed due to: " + uie.getResponse().getEntity(String.class));
             }
 
-            refreshIndex("test-organization", "test-app");
-
-            userNode = mapper.readTree(
-                    resource().path("/test-organization/test-app/users/" + uuid)
-                            .queryParam("access_token", adminAccessToken)
-                            .accept(MediaType.APPLICATION_JSON)
-                            .get(String.class));
+            refreshIndex();
+            // retrieve the user from the backend
+            userNode = this.app().collection("users").entity(userNode).get();
 
             log.info(userNode.toString());
 
+            // verify that the user was returned
             assertNotNull(userNode);
-
-            assertEquals("Initech", userNode.withArray("entities").get(0).get("employer").asText());
-
-            assertNotNull(userNode.withArray("entities").get(0).get("location"));
-            assertNotNull(userNode.withArray("entities").get(0).get("location").get("latitude"));
-            assertNotNull(userNode.withArray("entities").get(0).get("location").get("longitude"));
-
-            assertNotSame( latitude, 
-                userNode.withArray("entities").get(0).get("location").get("latitude").asDouble());
-            assertNotSame( longitude, 
-                userNode.withArray("entities").get(0).get("location").get("longitude").asDouble());
+            // Verify that the user's employer was updated
+            assertEquals("Initech", userNode.get("employer").toString());
+            // verify that the geo data is present
+            assertNotNull(userNode.get("location"));
+            assertNotNull(((Map<String, Object>) userNode.get("location")).get("latitude"));
+            assertNotNull(((Map<String, Object>) userNode.get("location")).get("longitude"));
+
+            // Verify that the location was updated correctly AND that
+            // it is not the same object reference from the original POST
+            log.info(geolocation.get("latitude") + " != " + Double.parseDouble(((Map<String, Object>) userNode.get("location")).get("latitude").toString()));
+            log.info(geolocation.get("longitude") + " != " + Double.parseDouble(((Map<String, Object>) userNode.get("location")).get("longitude").toString()));
+            assertNotSame(geolocation.get("latitude"),
+                Double.parseDouble(((Map<String, Object>) userNode.get("location")).get("latitude").toString()));
+            assertEquals(geolocation.get("latitude").doubleValue(),
+                Double.parseDouble(((Map<String, Object>) userNode.get("location")).get("latitude").toString()), 0);
+            assertNotSame(geolocation.get("longitude"),
+                Double.parseDouble(((Map<String, Object>) userNode.get("location")).get("longitude").toString()));
+            assertEquals(geolocation.get("longitude").doubleValue(),
+                Double.parseDouble(((Map<String, Object>) userNode.get("location")).get("longitude").toString()), 0);
         }
 
-        // Update bart's employer without specifying any required fields 
+        // Update bart's employer without specifying any required fields
         // (this time with username specified in URL)
+        Entity updateProps = new Entity();
+        updateProps.put("employer", "ACME Corporation");
 
-        updateProperties = new LinkedHashMap<String, Object>() {{
-            put( "employer", "ACME Corporation" );
-        }};
-
-        for(int i=1; i<10; i++) {
+        for (int i = 1; i < 10; i++) {
             try {
-                mapper.readTree(
-                        resource().path("/test-organization/test-app/users/bart")
-                                .queryParam("access_token", adminAccessToken)
-                                .accept(MediaType.APPLICATION_JSON)
-                                .type(MediaType.APPLICATION_JSON)
-                                .put(String.class, updateProperties));
+                userNode = this.app().collection("users").entity((String) props.get("username")).put(updateProps);
 
             } catch (UniformInterfaceException uie) {
                 fail("Update failed due to: " + uie.getResponse().getEntity(String.class));
             }
-            refreshIndex("test-organization", "test-app");
+            refreshIndex();
 
-            userNode = mapper.readTree(
-                    resource().path("/test-organization/test-app/users/bart")
-                            .queryParam("access_token", adminAccessToken)
-                            .accept(MediaType.APPLICATION_JSON)
-                            .get(String.class));
+            userNode = this.app().collection("users").entity(userNode).get();
             assertNotNull(userNode);
-            assertEquals("ACME Corporation", userNode.withArray("entities").get(0).get("employer").asText());
+            assertEquals("ACME Corporation", userNode.get("employer").toString());
         }
     }
 }


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

Posted by to...@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/USERGRID-273
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;
+    }
+
 }


[39/50] incubator-usergrid git commit: [USERGRID-320] Consistent method naming

Posted by to...@apache.org.
[USERGRID-320] Consistent method naming


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

Branch: refs/heads/USERGRID-273
Commit: 8fb45d15f3f266a2ba36236efe281363ef3ab21e
Parents: c078ae1
Author: ryan bridges <rb...@apigee.com>
Authored: Mon Jan 12 11:37:21 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Mon Jan 12 11:37:21 2015 -0500

----------------------------------------------------------------------
 .../rest/applications/queries/AndOrQueryTest.java       | 12 ++++++------
 .../rest/applications/queries/BadGrammarQueryTest.java  |  2 +-
 .../usergrid/rest/applications/queries/OrderByTest.java | 12 ++++++------
 3 files changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8fb45d15/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 6cd21da..d5956b5 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
@@ -46,7 +46,7 @@ public class AndOrQueryTest extends QueryTestBase {
      * @throws IOException
      */
     @Test
-    public void andQueryInclusive() throws IOException {
+    public void queryAndInclusive() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
         //create our test entities
@@ -74,7 +74,7 @@ public class AndOrQueryTest extends QueryTestBase {
      * @throws IOException
      */
     @Test
-    public void andQueryExclusive() throws IOException {
+    public void queryAndExclusive() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
 
@@ -102,7 +102,7 @@ public class AndOrQueryTest extends QueryTestBase {
      * @throws IOException
      */
     @Test
-    public void orQueryInclusive() throws IOException {
+    public void queryOrInclusive() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
 
@@ -138,7 +138,7 @@ public class AndOrQueryTest extends QueryTestBase {
      * @throws IOException
      */
     @Test
-    public void orQueryExclusive() throws IOException {
+    public void queryOrExclusive() throws IOException {
         int numOfEntities = 30;
         String collectionName = "activities";
 
@@ -177,7 +177,7 @@ public class AndOrQueryTest extends QueryTestBase {
      * @throws IOException
      */
     @Test //USERGRID-900
-    public void queriesWithAndPastLimit() throws IOException {
+    public void queryWithAndPastLimit() throws IOException {
         int numValuesTested = 40;
 
         generateTestEntities(numValuesTested, "activities");
@@ -204,7 +204,7 @@ public class AndOrQueryTest extends QueryTestBase {
      * @throws IOException
      */
     @Test //USERGRID-1475
-    public void negatedQuery() throws IOException {
+    public void queryNegated() throws IOException {
         int numValuesTested = 20;
 
         generateTestEntities(numValuesTested, "activities");

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8fb45d15/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 4dd7548..49120ab 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
@@ -41,7 +41,7 @@ public class BadGrammarQueryTest extends QueryTestBase {
      * @throws IOException
      */
     @Test
-    public void catchBadQueryGrammar() throws IOException {
+    public void exceptionOnInvalidOperator() throws IOException {
 
         int numOfEntities = 1;
         String collectionName = "things";

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8fb45d15/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 a30168a..1e3b1b7 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
@@ -45,7 +45,7 @@ public class OrderByTest extends QueryTestBase {
      * @throws IOException
      */
     @Test
-    public void testSortLongAsc() throws IOException {
+    public void orderByLongAsc() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
         //create our test entities
@@ -71,7 +71,7 @@ public class OrderByTest extends QueryTestBase {
      * @throws IOException
      */
     @Test
-    public void testSortLongDesc() throws IOException {
+    public void orderByLongDesc() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
         //create our test entities
@@ -97,7 +97,7 @@ public class OrderByTest extends QueryTestBase {
      * @throws IOException
      */
     @Test
-    public void testSortBooleanAsc() throws IOException {
+    public void orderByBooleanAsc() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
         //create our test entities
@@ -126,7 +126,7 @@ public class OrderByTest extends QueryTestBase {
      * @throws IOException
      */
     @Test
-    public void testSortBooleanDesc() throws IOException {
+    public void orderByBooleanDesc() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
         //create our test entities
@@ -156,7 +156,7 @@ public class OrderByTest extends QueryTestBase {
      * @throws IOException
      */
     @Test
-    public void testSortStringAsc() throws IOException {
+    public void orderByStringAsc() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
         //create our test entities
@@ -185,7 +185,7 @@ public class OrderByTest extends QueryTestBase {
      * @throws IOException
      */
     @Test
-    public void testSortStringDesc() throws IOException {
+    public void orderByStringDesc() throws IOException {
         int numOfEntities = 20;
         String collectionName = "activities";
         //create our test entities


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

Posted by to...@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/USERGRID-273
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(-)
----------------------------------------------------------------------



[34/50] incubator-usergrid git commit: [USERGRID-320]Adding additional Query logic and result ordering tests

Posted by to...@apache.org.
[USERGRID-320]Adding additional Query logic and result ordering 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/cbe84689
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/cbe84689
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/cbe84689

Branch: refs/heads/USERGRID-273
Commit: cbe846896509f651f14d1b5422467fc1d31c0a7a
Parents: 231a449
Author: ryan bridges <rb...@apigee.com>
Authored: Fri Jan 9 17:51:14 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Fri Jan 9 17:51:14 2015 -0500

----------------------------------------------------------------------
 .../applications/queries/AndOrQueryTest.java    | 549 +++++++++++--------
 .../rest/applications/queries/OrderByTest.java  | 202 +++++++
 2 files changed, 518 insertions(+), 233 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cbe84689/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 59329bc..d67e62a 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
@@ -22,13 +22,13 @@ 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;
 import java.util.List;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 
 /**
@@ -38,257 +38,340 @@ import static org.junit.Assert.assertTrue;
  * @since 4.0
  */
 public class AndOrQueryTest extends AbstractRestIT {
-  /**
-   * 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);
-      }
-
-      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.getResponse().getEntityCount());
-    while (activities.hasNext()) {
-      assertTrue(Boolean.parseBoolean(activities.next().get("madeup").toString()));
-    }
-  }
-
-
-  /**
-   * 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");
-      }
-
-      props.put("ordinal", i);
-      this.app().collection("activities").post(props);
+    private static Logger log = LoggerFactory.getLogger(AndOrQueryTest.class);
+
+    /**
+     * Create a number of entities in the specified collection
+     * with properties to make them independently searchable
+     *
+     * @param numberOfEntities
+     * @param collectionName
+     * @return an array of the Entity objects created
+     */
+    private Entity[] generateTestEntities(int numberOfEntities, String collectionName) {
+        Entity[] entities = new Entity[numberOfEntities];
+        Entity props = new Entity();
+        //Insert the desired number of entities
+        for (int i = 0; i < numberOfEntities; i++) {
+            Entity actor = new Entity();
+            actor.put("displayName", String.format("Test User %d", i));
+            actor.put("username", String.format("user%d", i));
+            props.put("actor", actor);
+            //give each entity a unique, numeric ordinal value
+            props.put("ordinal", i);
+            //Set half the entities to have a 'madeup' property of 'true'
+            // and set the other half to 'false'
+            if (i < numberOfEntities / 2) {
+                props.put("madeup", false);
+            } else {
+                props.put("madeup", true);
+            }
+            //Set even-numbered users to have a verb of 'go' and the rest to 'stop'
+            if (i % 2 == 0) {
+                props.put("verb", "go");
+            } else {
+                props.put("verb", "stop");
+            }
+            //create the entity in the desired collection and add it to the return array
+            entities[i] = this.app().collection(collectionName).post(props);
+            log.info(entities[i].entrySet().toString());
+        }
+        //refresh the index so that they are immediately searchable
+        this.refreshIndex();
+
+        return entities;
     }
 
+    /**
+     * Test an inclusive AND query to ensure the correct results are returned
+     *
+     * @throws IOException
+     */
+    @Test
+    public void andQueryInclusive() throws IOException {
+        int numOfEntities = 20;
+        String collectionName = "activities";
+        //create our test entities
+        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+        //Query where madeup = true (the last half) and the last quarter of entries
+        QueryParameters params = new QueryParameters()
+            .setQuery("select * where madeup = true AND ordinal >= " + (numOfEntities - numOfEntities / 4));
+        Collection activities = this.app().collection("activities").get(params);
+        //results should have madeup = true and ordinal 15-19
+        assertEquals(numOfEntities / 4, activities.getResponse().getEntityCount());
+        int index = 19;
+        while (activities.hasNext()) {
+            Entity activity = activities.next();
+            //ensure the 'madeup' property is set to true
+            assertTrue(Boolean.parseBoolean(activity.get("madeup").toString()));
+            //make sure the correct ordinal properties are returned
+            assertEquals(index--, Long.parseLong(activity.get("ordinal").toString()));
+        }
 
-    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.getResponse().getEntityCount());
-    while (activities.hasNext()) {
-      assertEquals("stop", activities.next().get("verb").toString());
     }
 
+    /**
+     * Test an exclusive AND query to ensure the correct results are returned
+     *
+     * @throws IOException
+     */
+    @Test
+    public void andQueryExclusive() throws IOException {
+        int numOfEntities = 20;
+        String collectionName = "activities";
+
+        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+
+        //Query where madeup = true (the last half) and NOT the last quarter of entries
+        QueryParameters params = new QueryParameters()
+            .setQuery("select * where madeup = true AND NOT ordinal >= " + (numOfEntities - numOfEntities / 4));
+        Collection activities = this.app().collection("activities").get(params);
+        //results should have madeup = true and ordinal 10-14
+        assertEquals(numOfEntities / 4, activities.getResponse().getEntityCount());
+        int index = 14;
+        while (activities.hasNext()) {
+            Entity activity = activities.next();
+            //ensure the 'madeup' property is set to true
+            assertTrue(Boolean.parseBoolean(activity.get("madeup").toString()));
+            //make sure the correct ordinal properties are returned
+            assertEquals(index--, Long.parseLong(activity.get("ordinal").toString()));
+        }
+    }
 
-  }
-
-  /**
-   * 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");
-    //1. Insert a number of entities
-    for (int i = 0; i < numValuesTested; i++) {
-      props.put("ordinal", i);
-      this.app().collection("activities").post(props);
+    /**
+     * Test an inclusive OR query to ensure the correct results are returned
+     *
+     * @throws IOException
+     */
+    @Test
+    public void orQueryInclusive() throws IOException {
+        int numOfEntities = 20;
+        String collectionName = "activities";
+
+        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+
+        //Query where madeup = false (the first half) or the last quarter of entries
+        QueryParameters params = new QueryParameters()
+            .setQuery("select * where madeup = false OR ordinal >= " + (numOfEntities - numOfEntities / 4))
+            .setLimit((numOfEntities));
+        Collection activities = this.app().collection("activities").get(params);
+        int index = numOfEntities - 1;
+        int count = 0;
+        int returnSize = activities.getResponse().getEntityCount();
+        for (int i = 0; i < returnSize; i++, index--) {
+            count++;
+            Entity activity = activities.getResponse().getEntities().get(i);
+            log.info(String.valueOf(activity.get("ordinal")) + " " + String.valueOf(activity.get("madeup")));
+            if (index < numOfEntities / 2) {
+                assertFalse(Boolean.parseBoolean(String.valueOf(activity.get("madeup"))));
+            } else if (index >= (numOfEntities - numOfEntities / 4)) {
+                assertTrue(Boolean.parseBoolean(String.valueOf(activity.get("madeup"))));
+            }
+            long ordinal = Long.parseLong(String.valueOf(activity.get("ordinal")));
+            assertTrue(ordinal < (numOfEntities / 2) || ordinal >= (numOfEntities - numOfEntities / 4));
+        }
+        //results should have madeup = false or ordinal 15-19
+        assertEquals(3 * numOfEntities / 4, count);
     }
-    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.getResponse().getEntityCount());
-
-    List<Entity> entities = activities.getResponse().getEntities();
-    for (int i = 0; i < numValuesTested / 2; i++) {
-      assertEquals(numValuesTested / 2 + i, Integer.parseInt(entities.get(i).get("ordinal").toString()));
+
+    /**
+     * Test an exclusive OR query to ensure the correct results are returned
+     *
+     * @throws IOException
+     */
+    @Test
+    public void orQueryExclusive() throws IOException {
+        int numOfEntities = 30;
+        String collectionName = "activities";
+
+        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+
+        //Query where the verb = 'go' (half) OR the last quarter by ordinal, but NOT where verb = 'go' AND the ordinal is in the last quarter
+        QueryParameters params = new QueryParameters()
+            .setQuery("select * where (verb = 'go' OR ordinal >= " + (numOfEntities - numOfEntities / 4) + ") AND NOT (verb = 'go' AND ordinal >= " + (numOfEntities - numOfEntities / 4) + ")")
+            .setLimit((numOfEntities));
+        Collection activities = this.app().collection("activities").get(params);
+
+        int index = numOfEntities - 1;
+        int count = 0;
+        int returnSize = activities.getResponse().getEntityCount();
+        for (int i = 0; i < returnSize; i++, index--) {
+            count++;
+            Entity activity = activities.getResponse().getEntities().get(i);
+            long ordinal = Long.parseLong(String.valueOf(activity.get("ordinal")));
+            log.info(ordinal + " " + String.valueOf(activity.get("verb")));
+            if (ordinal < (numOfEntities - numOfEntities / 4)) {
+                assertEquals("go", String.valueOf(activity.get("verb")));
+            } else if (ordinal >= (numOfEntities - numOfEntities / 4)) {
+                assertEquals("stop", String.valueOf(activity.get("verb")));
+            }
+        }
+        //results should be even ordinals in the first 3 quarters and odd ordinals from the last quarter
+        assertEquals(1 + numOfEntities / 2, count);
     }
 
-  }
-
-  /**
-   * 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 props = new Entity();
-    props.put("WhoHelpedYou", "Ruff");
-    //1. Insert entities
-    for (int i = 0; i < numOfEntities; i++) {
-      props.put("ordinal", i);
-      this.app().collection(collectionName).post(props);
+    /**
+     * Ensure limit is respected in queries
+     * 1. Query all entities where "madeup = true"
+     * 2. Limit the query to half of the number of entities
+     * 3. Ensure the correct entities are returned
+     *
+     * @throws IOException
+     */
+    @Test //USERGRID-900
+    public void queriesWithAndPastLimit() throws IOException {
+        int numValuesTested = 40;
+        long created = 0;
+
+        Entity[] entities = generateTestEntities(numValuesTested, "activities");
+        //3. Query all entities where "madeup = true"
+        String errorQuery = "select * where 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.getResponse().getEntityCount());
+        while (activities.hasNext()) {
+            assertTrue(Boolean.parseBoolean(activities.next().get("madeup").toString()));
+        }
     }
 
-    this.refreshIndex();
 
-    //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);
+    /**
+     * Test negated query
+     * 1. Query all entities where "NOT verb = 'go'"
+     * 2. Limit the query to half of the number of entities
+     * 3. Ensure the returned entities have "verb = 'stop'"
+     *
+     * @throws IOException
+     */
+    @Test //USERGRID-1475
+    public void negatedQuery() throws IOException {
+        int numValuesTested = 20;
+
+        Entity[] entities = generateTestEntities(numValuesTested, "activities");
+        //1. Query all entities where "NOT verb = 'go'"
+        String query = "select * where not verb = 'go'";
+        //2. 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);
+        //3. Ensure the returned entities have "verb = 'stop'"
+        assertEquals(numValuesTested / 2, activities.getResponse().getEntityCount());
+        while (activities.hasNext()) {
+            assertEquals("stop", activities.next().get("verb").toString());
+        }
 
-    //3. Verify the order of results
-    assertEquals(numOfEntities / 2, activities.getResponse().getEntityCount());
-    List<Entity> entities = activities.getResponse().getEntities();
-    for (int i = 0; i < numOfEntities / 2; i++) {
-      assertEquals(i, Integer.parseInt(entities.get(i).get("ordinal").toString()));
-    }
-  }
-
-
-  /**
-   * 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 props = new Entity();
-    props.put("WhoHelpedYou", "Ruff");
-    //1. Insert a number of entities
-    for (int i = 0; i < numOfEntities; i++) {
-      props.put("ordinal", i);
-      this.app().collection(collectionName).post(props);
-    }
 
-    this.refreshIndex();
+    }
 
-    //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);
+    /**
+     * Ensure queries return a subset of entities in the correct order
+     * 1. Query for a subset of the entities
+     * 2. Validate that the correct entities are returned
+     *
+     * @throws Exception
+     */
+    @Test //USERGRID-1615
+    public void queryReturnCount() throws Exception {
+        int numValuesTested = 20;
+
+        Entity[] entities = generateTestEntities(numValuesTested, "activities");
+        //1. Query for a subset of the entities
+        String inCorrectQuery = "select * where ordinal >= " + (numValuesTested / 2) + " order by ordinal asc";
+        QueryParameters params = new QueryParameters().setQuery(inCorrectQuery).setLimit(numValuesTested / 2);
+        Collection activities = this.app().collection("activities").get(params);
+        //2. Validate that the correct entities are returned
+        assertEquals(numValuesTested / 2, activities.getResponse().getEntityCount());
+
+        List<Entity> entitiesReturned = activities.getResponse().getEntities();
+        for (int i = 0; i < numValuesTested / 2; i++) {
+            assertEquals(numValuesTested / 2 + i, Integer.parseInt(entitiesReturned.get(i).get("ordinal").toString()));
+        }
 
-    //3. validate that a full page of (10) entities is returned
-    assertEquals(10, activities.getResponse().getEntityCount());
-    List<Entity> entities = activities.getResponse().getEntities();
-    for (int i = 0; i < 10; i++) {
-      assertEquals(i, Integer.parseInt(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 props = new Entity();
-    props.put("WhoHelpedYou", "Ruff");
-    //1. Insert a number of entities
-    for (int i = 0; i < numOfEntities; i++) {
-      props.put("ordinal", i);
-      this.app().collection(collectionName).post(props);
+
+    /**
+     * Validate sort order with AND/OR query
+     * 1. Use AND/OR query to retrieve entities
+     * 2. Verify the order of results
+     *
+     * @throws Exception
+     */
+    @Test
+    public void queryCheckAsc() throws Exception {
+        int numOfEntities = 20;
+        String collectionName = "imagination";
+
+        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+
+        //2. Use AND/OR query to retrieve entities
+        String inquisitiveQuery = "select * where Ordinal gte 0 and Ordinal lte  " + (numOfEntities / 2)
+            + " 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);
+
+        //3. Verify the order of results
+        assertEquals(numOfEntities / 2, activities.getResponse().getEntityCount());
+        List<Entity> entitiesReturned = activities.getResponse().getEntities();
+        for (int i = 0; i < numOfEntities / 2; i++) {
+            assertEquals(i, Integer.parseInt(entitiesReturned.get(i).get("ordinal").toString()));
+        }
     }
 
-    this.refreshIndex();
 
-    //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);
+    /**
+     * Test a standard query
+     * 1. Issue a query
+     * 2. 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[] entities = generateTestEntities(numOfEntities, collectionName);
+
+        //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);
+
+        //3. validate that a full page of (10) entities is returned
+        assertEquals(10, activities.getResponse().getEntityCount());
+        List<Entity> entitiesReturned = activities.getResponse().getEntities();
+        for (int i = 0; i < 10; i++) {
+            assertEquals(i, Integer.parseInt(entitiesReturned.get(i).get("ordinal").toString()));
+        }
+    }
 
-    //3. validate that a full page of (10) entities is returned
-    assertEquals(10, activities.getResponse().getEntityCount());
-    List<Entity> entities = activities.getResponse().getEntities();
-    for (int i = 0; i < 10; i++) {
-      assertEquals(i, Integer.parseInt(entities.get(i).get("ordinal").toString()));
+    /**
+     * Test a standard query using alphanumeric operators
+     * 1. Issue a query using alphanumeric operators
+     * 2. 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[] entities = generateTestEntities(numOfEntities, collectionName);
+
+        //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);
+
+        //3. validate that a full page of (10) entities is returned
+        assertEquals(10, activities.getResponse().getEntityCount());
+        List<Entity> entitiesReturned = activities.getResponse().getEntities();
+        for (int i = 0; i < 10; i++) {
+            assertEquals(i, Integer.parseInt(entitiesReturned.get(i).get("ordinal").toString()));
+        }
     }
-  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cbe84689/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 6d5f39b..9acee8d 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
@@ -30,6 +30,8 @@ import java.io.IOException;
 import java.util.LinkedHashMap;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 
 /**
@@ -40,7 +42,207 @@ import static org.junit.Assert.assertEquals;
  */
 public class OrderByTest extends AbstractRestIT {
   private static Logger log = LoggerFactory.getLogger(OrderByTest.class);
+    /**
+     * Create a number of entities in the specified collection
+     * with properties to make them independently searchable
+     *
+     * @param numberOfEntities
+     * @param collectionName
+     * @return an array of the Entity objects created
+     */
+    private Entity[] generateTestEntities(int numberOfEntities, String collectionName) {
+        Entity[] entities = new Entity[numberOfEntities];
+        Entity props = new Entity();
+        //Insert the desired number of entities
+        for (int i = 0; i < numberOfEntities; i++) {
+            Entity actor = new Entity();
+            actor.put("displayName", String.format("Test User %d", i));
+            actor.put("username", String.format("user%d", i));
+            props.put("actor", actor);
+            //give each entity a unique, numeric ordinal value
+            props.put("ordinal", i);
+            //Set half the entities to have a 'madeup' property of 'true'
+            // and set the other half to 'false'
+            if (i < numberOfEntities / 2) {
+                props.put("madeup", false);
+            } else {
+                props.put("madeup", true);
+            }
+            //Set even-numbered users to have a verb of 'go' and the rest to 'stop'
+            if (i % 2 == 0) {
+                props.put("verb", "go");
+            } else {
+                props.put("verb", "stop");
+            }
+            //create the entity in the desired collection and add it to the return array
+            entities[i] = this.app().collection(collectionName).post(props);
+            log.info(entities[i].entrySet().toString());
+        }
+        //refresh the index so that they are immediately searchable
+        this.refreshIndex();
 
+        return entities;
+    }
+
+    /**
+     * Test correct sort order for Long properties
+     * @throws IOException
+     */
+    @Test
+    public void testSortLongAsc() throws IOException{
+        int numOfEntities = 20;
+        String collectionName = "activities";
+        //create our test entities
+        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+
+        QueryParameters params = new QueryParameters()
+            .setQuery("select * order by ordinal asc")
+            .setLimit(numOfEntities);
+        Collection activities = this.app().collection("activities").get(params);
+        assertEquals(numOfEntities, activities.getResponse().getEntityCount());
+        //results should be ordered by ordinal
+        int index = 0;
+        while (activities.hasNext()) {
+            Entity activity = activities.next();
+            //make sure the correct ordinal properties are returned
+            assertEquals(index++, Long.parseLong(activity.get("ordinal").toString()));
+        }
+    }
+    /**
+     * Test correct sort order for Long properties
+     * @throws IOException
+     */
+    @Test
+    public void testSortLongDesc() throws IOException{
+        int numOfEntities = 20;
+        String collectionName = "activities";
+        //create our test entities
+        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+
+        QueryParameters params = new QueryParameters()
+            .setQuery("select * order by ordinal desc")
+            .setLimit(numOfEntities);
+        Collection activities = this.app().collection("activities").get(params);
+        assertEquals(numOfEntities, activities.getResponse().getEntityCount());
+        int index = numOfEntities-1;
+        //results should be sorted by ordinal
+        while (activities.hasNext()) {
+            Entity activity = activities.next();
+            //make sure the correct ordinal properties are returned
+            assertEquals(index--, Long.parseLong(activity.get("ordinal").toString()));
+        }
+    }
+    /**
+     * Test correct sort order for Boolean properties
+     * @throws IOException
+     */
+    @Test
+    public void testSortBooleanAsc() throws IOException{
+        int numOfEntities = 20;
+        String collectionName = "activities";
+        //create our test entities
+        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+
+        QueryParameters params = new QueryParameters()
+            .setQuery("select * order by madeup asc")
+            .setLimit(numOfEntities);
+        Collection activities = this.app().collection("activities").get(params);
+        assertEquals(numOfEntities, activities.getResponse().getEntityCount());
+        int index = 0;
+        //results should be sorted false, then true
+        while (activities.hasNext()) {
+            Entity activity = activities.next();
+            if(index++ < numOfEntities/2){
+                assertEquals("false", activity.get("madeup").toString());
+            }else{
+                assertEquals("true", activity.get("madeup").toString());
+            }
+        }
+    }
+    /**
+     * Test correct sort order for Boolean properties
+     * @throws IOException
+     */
+    @Test
+    public void testSortBooleanDesc() throws IOException{
+        int numOfEntities = 20;
+        String collectionName = "activities";
+        //create our test entities
+        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+
+        QueryParameters params = new QueryParameters()
+            .setQuery("select * order by madeup desc")
+            .setLimit(numOfEntities);
+        Collection activities = this.app().collection("activities").get(params);
+        assertEquals(numOfEntities, activities.getResponse().getEntityCount());
+        int index = 0;
+        //results should be sorted true, then false
+        while (activities.hasNext()) {
+            Entity activity = activities.next();
+            //make sure the booleans are ordered correctly
+            if(index++ < numOfEntities/2){
+                assertEquals("true", activity.get("madeup").toString());
+            }else{
+                assertEquals("false", activity.get("madeup").toString());
+            }
+        }
+    }
+
+    /**
+     * Test correct sort order for String properties
+     * @throws IOException
+     */
+    @Test
+    public void testSortStringAsc() throws IOException{
+        int numOfEntities = 20;
+        String collectionName = "activities";
+        //create our test entities
+        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+
+        QueryParameters params = new QueryParameters()
+            .setQuery("select * order by verb asc")
+            .setLimit(numOfEntities);
+        Collection activities = this.app().collection("activities").get(params);
+        assertEquals(numOfEntities, activities.getResponse().getEntityCount());
+        int index = 0;
+        //results should be sorted "go", then "stop"
+        while (activities.hasNext()) {
+            Entity activity = activities.next();
+            if(index++ < numOfEntities/2){
+                assertEquals("go", activity.get("verb").toString());
+            }else{
+                assertEquals("stop", activity.get("verb").toString());
+            }
+        }
+    }
+    /**
+     * Test correct sort order for String properties
+     * @throws IOException
+     */
+    @Test
+    public void testSortStringDesc() throws IOException{
+        int numOfEntities = 20;
+        String collectionName = "activities";
+        //create our test entities
+        Entity[] entities = generateTestEntities(numOfEntities, collectionName);
+
+        QueryParameters params = new QueryParameters()
+            .setQuery("select * order by verb desc")
+            .setLimit(numOfEntities);
+        Collection activities = this.app().collection("activities").get(params);
+        assertEquals(numOfEntities, activities.getResponse().getEntityCount());
+        int index = 0;
+        //results should be sorted "stop", then "go"
+        while (activities.hasNext()) {
+            Entity activity = activities.next();
+            if(index++ < numOfEntities/2){
+                assertEquals("stop", activity.get("verb").toString());
+            }else{
+                assertEquals("go", activity.get("verb").toString());
+            }
+        }
+
+    }
   /**
    * Inserts a number of entities. Query a subset of entities
    * with unspecified 'order by' and then ordered by 'created'


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

Posted by to...@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/USERGRID-273
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 {
 


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

Posted by to...@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/USERGRID-273
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(-)
----------------------------------------------------------------------



[23/50] 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 to...@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/USERGRID-273
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


[50/50] incubator-usergrid git commit: Refactored Guice Injector to be a spring bean

Posted by to...@apache.org.
Refactored Guice Injector to be a spring bean

Modified setup lifecycle to seperate system configuration from column family initialization

Added index delete to post test invocation


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

Branch: refs/heads/USERGRID-273
Commit: e80df0d5a50a92fabe8898173d8c9db1559bc5af
Parents: d35cba6 6ebbe50
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Jan 21 15:58:12 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Jan 21 15:58:12 2015 -0700

----------------------------------------------------------------------
 portal/Gruntfile.js                             |    1 -
 stack/.editorconfig                             |   42 +
 .../corepersistence/CpEntityDeleteListener.java |  101 --
 .../CpEntityIndexDeleteListener.java            |   98 --
 .../corepersistence/CpEntityManager.java        |  124 +-
 .../corepersistence/CpRelationManager.java      |   35 +-
 .../usergrid/corepersistence/CpSetup.java       |   16 +-
 .../usergrid/corepersistence/GuiceFactory.java  |    4 +
 .../usergrid/corepersistence/GuiceModule.java   |   41 +-
 .../HybridEntityManagerFactory.java             |  209 ---
 .../usergrid/corepersistence/HybridSetup.java   |   72 -
 .../events/EntityDeletedHandler.java            |   68 +
 .../events/EntityVersionCreatedHandler.java     |   69 +
 .../events/EntityVersionDeletedHandler.java     |  102 ++
 .../results/FilteringLoader.java                |    7 +-
 .../CpEntityDeleteListenerTest.java             |   91 --
 .../CpEntityIndexDeleteListenerTest.java        |  111 --
 .../corepersistence/StaleIndexCleanupTest.java  |  219 ++-
 .../corepersistence/TestGuiceModule.java        |   30 -
 .../migration/GraphShardVersionMigrationIT.java |    5 +-
 .../usergrid/persistence/CollectionIT.java      |   15 +-
 .../query/AbstractIteratingQueryIT.java         |    2 +-
 .../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 -
 .../collection/guice/TestCollectionModule.java  |    4 -
 .../impl/EntityVersionCleanupTaskTest.java      |  450 ++++---
 .../impl/EntityVersionCreatedTaskTest.java      |  244 ++++
 .../core/task/NamedTaskExecutorImpl.java        |  141 +-
 .../core/task/NamedTaskExecutorImplTest.java    |   56 +-
 .../usergrid/persistence/index/EntityIndex.java |   20 +-
 .../persistence/index/EntityIndexBatch.java     |    7 +-
 .../index/impl/EsEntityIndexBatchImpl.java      |    9 +-
 .../index/impl/EsEntityIndexImpl.java           |  142 +-
 .../persistence/index/impl/IndexingUtils.java   |  105 +-
 stack/pom.xml                                   |    2 +
 .../rest/management/ManagementResource.java     |    2 +
 .../apache/usergrid/rest/PartialUpdateTest.java |  170 ++-
 .../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    |  418 ++++--
 .../queries/BadGrammarQueryTest.java            |  197 ++-
 .../applications/queries/GeoPagingTest.java     |  562 ++++----
 .../applications/queries/MatrixQueryTests.java  |  181 ++-
 .../rest/applications/queries/OrderByTest.java  |  394 ++++--
 .../applications/queries/QueryTestBase.java     |   72 +
 .../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 +
 .../notifications/apns/APNsAdapter.java         |    4 +-
 .../notifications/apns/EntityPushManager.java   |    3 +-
 110 files changed, 8319 insertions(+), 4777 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e80df0d5/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e80df0d5/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
index 0000000,0000000..89f89a3
new file mode 100644
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
@@@ -1,0 -1,0 +1,4 @@@
++package org.apache.usergrid.corepersistence;
++
++
++public class GuiceFactory {}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e80df0d5/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
index e00769a,ed6cba2..bbf776f
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
@@@ -37,7 -42,17 +42,18 @@@ import org.slf4j.LoggerFactory
  /**
   * Guice Module that encapsulates Core Persistence.
   */
 -public class GuiceModule extends AbstractModule {
 +public class GuiceModule  extends AbstractModule {
++    private static final Logger log = LoggerFactory.getLogger( GuiceModule.class );
+ 
+     private static final Logger logger = LoggerFactory.getLogger(GuiceModule.class);
+ 
+     private EntityManagerFactory emf;
+ 
+     public static final String EVENTS_DISABLED = "corepersistence.events.disabled";
+ 
+     GuiceModule( EntityManagerFactory emf ) {
+         this.emf = emf;
+     }
  
      @Override
      protected void configure() {
@@@ -49,15 -68,26 +69,26 @@@
          install(new MapModule());
          install(new QueueModule());
  
-         bind(CpEntityDeleteListener.class).asEagerSingleton();
-         bind(CpEntityIndexDeleteListener.class).asEagerSingleton();
          bind(ManagerCache.class).to( CpManagerCache.class );
  
-         Multibinder<DataMigration> dataMigrationMultibinder = Multibinder.newSetBinder( binder(), DataMigration.class );
 -        Multibinder<DataMigration> dataMigrationMultibinder = 
++        Multibinder<DataMigration> dataMigrationMultibinder =
+                 Multibinder.newSetBinder( binder(), DataMigration.class );
          dataMigrationMultibinder.addBinding().to( EntityTypeMappingMigration.class );
          dataMigrationMultibinder.addBinding().to( GraphShardVersionMigration.class );
          dataMigrationMultibinder.addBinding().to( EntityDataMigration.class );
  
 -        Multibinder<EntityDeleted> entityBinder = 
++        Multibinder<EntityDeleted> entityBinder =
+             Multibinder.newSetBinder(binder(), EntityDeleted.class);
+         entityBinder.addBinding().to(EntityDeletedHandler.class);
+ 
 -        Multibinder<EntityVersionDeleted> versionBinder = 
++        Multibinder<EntityVersionDeleted> versionBinder =
+             Multibinder.newSetBinder(binder(), EntityVersionDeleted.class);
+         versionBinder.addBinding().to(EntityVersionDeletedHandler.class);
+ 
+         Multibinder<EntityVersionCreated> versionCreatedMultibinder =
+             Multibinder.newSetBinder( binder(), EntityVersionCreated.class );
+         versionCreatedMultibinder.addBinding().to(EntityVersionCreatedHandler.class);
+ 
  
      }
  

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e80df0d5/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
index 42dc805,af4acdb..0000000
deleted file mode 100644,100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
+++ /dev/null
@@@ -1,209 -1,213 +1,0 @@@
--/*
-- * Copyright 2014 The Apache Software Foundation.
-- *
-- * Licensed 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.corepersistence;
--
--import java.util.Map;
--import java.util.UUID;
--import org.apache.usergrid.persistence.EntityManager;
--import org.apache.usergrid.persistence.EntityManagerFactory;
--import org.apache.usergrid.persistence.cassandra.CassandraService;
--import org.apache.usergrid.persistence.cassandra.CounterUtils;
--import org.apache.usergrid.persistence.cassandra.EntityManagerFactoryImpl;
--import org.apache.usergrid.persistence.core.util.Health;
--import org.slf4j.Logger;
--import org.slf4j.LoggerFactory;
--import org.springframework.beans.BeansException;
--import org.springframework.context.ApplicationContext;
--import org.springframework.context.ApplicationContextAware;
--
--
--/**
-- * Can read from either old EntityManagerImpl or new CpEntityManager, can write to either or both.
-- */
--public class HybridEntityManagerFactory implements EntityManagerFactory, ApplicationContextAware {
--    private static final Logger logger = LoggerFactory.getLogger( CpEntityManagerFactory.class );
--    private final EntityManagerFactory factory;
--
--
--    public HybridEntityManagerFactory( 
--            CassandraService cass, CounterUtils counterUtils, boolean skipAggCounters ) {
--
--        boolean useCP = cass.getPropertiesMap().get("usergrid.persistence").equals("CP");
--        if ( useCP ) {
--            logger.info("HybridEntityManagerFactory: configured for New Core Persistence engine");
--            factory = new CpEntityManagerFactory(cass, counterUtils );
--        } else {
--            logger.info("HybridEntityManagerFactory: configured for Classic Usergrid persistence");
--            factory = new EntityManagerFactoryImpl( cass, counterUtils, skipAggCounters );
--        }
 -    }
 -
 -    public EntityManagerFactory getImplementation() {
 -        return factory; 
--    }
--
--    @Override
--    public String getImpementationDescription() throws Exception {
--        return factory.getImpementationDescription();
--    }
--
--    @Override
--    public EntityManager getEntityManager(UUID applicationId) {
--        return factory.getEntityManager(applicationId);
--    }
--
--    @Override
--    public UUID createApplication(String organizationName, String name) throws Exception {
--        return factory.createApplication(organizationName, name);
--    }
--
--    @Override
--    public UUID createApplication(String organizationName, String name, 
--            Map<String, Object> properties) throws Exception {
--        return factory.createApplication(organizationName, name, properties);
--    }
--
--    @Override
--    public UUID importApplication(String organization, UUID applicationId, String name, 
--            Map<String, Object> properties) throws Exception {
--        return factory.importApplication(organization, applicationId, name, properties);
--    }
--
--    @Override
--    public UUID lookupApplication(String name) throws Exception {
--        return factory.lookupApplication(name);
--    }
--
--    @Override
--    public Map<String, UUID> getApplications() throws Exception {
--        return factory.getApplications();
--    }
--
--    @Override
--    public void setup() throws Exception {
--        factory.setup();
--    }
--
--    @Override
--    public Map<String, String> getServiceProperties() {
--        return factory.getServiceProperties();
--    }
--
--    @Override
--    public boolean updateServiceProperties(Map<String, String> properties) {
--        return factory.updateServiceProperties(properties);
--    }
--
--    @Override
--    public boolean setServiceProperty(String name, String value) {
--        return factory.setServiceProperty(name, value);
--    }
--
--    @Override
--    public boolean deleteServiceProperty(String name) {
--        return factory.deleteServiceProperty(name);
--    }
--
--    @Override
--    public UUID initializeApplication(String orgName, UUID appId, String appName, 
--            Map<String, Object> props) throws Exception {
--        return factory.initializeApplication(orgName, appId, appName, props);
--    }
--
--    @Override
--    public UUID getManagementAppId() {
--        return factory.getManagementAppId();
--    }
--
--    @Override
--    public UUID getDefaultAppId() {
--        return factory.getDefaultAppId();
--    }
--
--    @Override
--    public void refreshIndex() {
--        factory.refreshIndex();
--    }
--
--    @Override
--    public void setApplicationContext(ApplicationContext ac) throws BeansException {
--        factory.setApplicationContext(ac);
--    }
--
--
--    @Override
--    public long performEntityCount() {
--        return factory.performEntityCount();
--    }
--
--
--    @Override
--    public void flushEntityManagerCaches() {
--        factory.flushEntityManagerCaches();
--    }
--
--    @Override
--    public void rebuildInternalIndexes(ProgressObserver po) throws Exception {
--        factory.rebuildInternalIndexes(po);
--    }
--
--    @Override
--    public void rebuildAllIndexes(ProgressObserver po) throws Exception {
--        factory.rebuildAllIndexes(po);
--    }
--
--    @Override
--    public void rebuildApplicationIndexes(UUID appId, ProgressObserver po) throws Exception {
--        factory.rebuildApplicationIndexes(appId, po);
--    }
--
--
--    @Override
--    public void migrateData() throws Exception {
--        factory.migrateData();
--    }
--
--
--    @Override
--    public String getMigrateDataStatus() {
--        return factory.getMigrateDataStatus();
--    }
--
--
--    @Override
--    public int getMigrateDataVersion() {
--        return factory.getMigrateDataVersion();
--    }
--
--
--    @Override
--    public void setMigrationVersion( final int version ) {
--        factory.setMigrationVersion( version );
--    }
--
--
--    @Override
--    public void rebuildCollectionIndex(UUID appId, String collection, ProgressObserver po) {
--        factory.rebuildCollectionIndex(appId, collection, po);
--    }
--
--    @Override
--    public void addIndex(UUID appId, String suffix,final int shards,final int replicas) {
--        factory.addIndex(appId,suffix,shards,replicas);
--    }
--
--    @Override
--    public Health getEntityStoreHealth() {
--        return factory.getEntityStoreHealth();
--    }
--}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e80df0d5/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridSetup.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridSetup.java
index 963f8db,963f8db..0000000
deleted file mode 100644,100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridSetup.java
+++ /dev/null
@@@ -1,72 -1,72 +1,0 @@@
--/*
-- * Copyright 2014 The Apache Software Foundation.
-- *
-- * Licensed 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.corepersistence;
--
--import java.util.Properties;
--import java.util.UUID;
--import org.apache.usergrid.persistence.EntityManagerFactory;
--import org.apache.usergrid.persistence.cassandra.CassandraService;
--import org.apache.usergrid.persistence.cassandra.Setup;
--import org.apache.usergrid.persistence.cassandra.SetupImpl;
--
--
--public class HybridSetup implements Setup {
--
--    private final Setup setup;
--
--    public HybridSetup(Properties props, EntityManagerFactory emf, CassandraService cass ) {
--        
--        boolean useCP = cass.getPropertiesMap().get("usergrid.persistence").equals("CP");
--        if ( useCP ) {
--            setup = new CpSetup( emf, cass);
--        } else {
--            setup = new SetupImpl( emf, cass );
--        }
--
--    }
--
--    @Override
--    public void init() throws Exception {
--        setup.init();
--    }
--
--    @Override
--    public void setupSystemKeyspace() throws Exception {
--        setup.setupSystemKeyspace();
--    }
--
--    @Override
--    public void setupStaticKeyspace() throws Exception {
--        setup.setupStaticKeyspace();
--    }
--
--    @Override
--    public boolean keyspacesExist() {
--        return setup.keyspacesExist();
--    }
--
--    @Override
--    public void createDefaultApplications() throws Exception {
--        setup.createDefaultApplications();
--    }
--
--    @Override
--    public void setupApplicationKeyspace(UUID applicationId, String appName) throws Exception {
--        setup.setupApplicationKeyspace(applicationId, appName);
--    }
--    
--}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e80df0d5/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestGuiceModule.java
----------------------------------------------------------------------
diff --cc stack/core/src/test/java/org/apache/usergrid/corepersistence/TestGuiceModule.java
index 6fce1dd,9a0b195..0000000
deleted file mode 100644,100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestGuiceModule.java
+++ /dev/null
@@@ -1,30 -1,37 +1,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.corepersistence;
--
--import com.google.inject.AbstractModule;
 -import org.apache.usergrid.persistence.EntityManagerFactory;
--
--
--public class TestGuiceModule extends AbstractModule {
 -
 -    private static EntityManagerFactory emf;
 -
 -    public TestGuiceModule( EntityManagerFactory emf ) {
 -        this.emf = emf;
 -    }
--
--    @Override
--    protected void configure() {
-         install( new GuiceModule() );
 -        install( new GuiceModule( emf ) );
--    }
--}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e80df0d5/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
----------------------------------------------------------------------
diff --cc stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
index 3083536,f287047..fdde80b
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
@@@ -54,9 -49,9 +51,10 @@@ import rx.functions.Action1
  import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.assertFalse;
  import static org.junit.Assert.assertTrue;
+ import org.junit.Ignore;
  
  
 +@NotThreadSafe
  public class GraphShardVersionMigrationIT extends AbstractCoreIT {
  
      private Injector injector;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e80df0d5/stack/core/src/test/java/org/apache/usergrid/persistence/query/AbstractIteratingQueryIT.java
----------------------------------------------------------------------

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