usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject incubator-usergrid git commit: Cleaning up rest test framework to allow better refactors in the future.
Date Wed, 03 Jun 2015 17:59:24 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o-dev 0cd12bfee -> aec9884d4


Cleaning up rest test framework to allow better refactors in the future.


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

Branch: refs/heads/two-dot-o-dev
Commit: aec9884d46940cf7199f0139437d5ff4f62a800d
Parents: 0cd12bf
Author: GERey <greyes@apigee.com>
Authored: Wed Jun 3 10:59:22 2015 -0700
Committer: GERey <greyes@apigee.com>
Committed: Wed Jun 3 10:59:22 2015 -0700

----------------------------------------------------------------------
 .../usergrid/rest/management/AccessTokenIT.java |  4 +--
 .../rest/management/ManagementResourceIT.java   |  8 ++---
 .../endpoints/NamedResource.java                | 38 +++++++++-----------
 3 files changed, 22 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/aec9884d/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
index a5adc0e..3ead63f 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
@@ -235,7 +235,7 @@ public class AccessTokenIT extends AbstractRestIT {
 
         // using a superuser token, revoke all tokens associated with the admin user
         management().token().setToken( clientSetup.getSuperuserToken() );
-        management().users().user( clientSetup.getUsername() ).revokeTokens().post( ApiResponse.class
);
+        management().users().user( clientSetup.getUsername() ).revokeTokens().post(true ,
ApiResponse.class, null);
 
         refreshIndex();
 
@@ -276,7 +276,7 @@ public class AccessTokenIT extends AbstractRestIT {
         queryParameters.addParam( "token", token1.getAccessToken() );
 
         management().token().setToken( clientSetup.getSuperuserToken() );
-        management().users().user( clientSetup.getUsername() ).revokeToken().post( ApiResponse.class,queryParameters
);
+        management().users().user( clientSetup.getUsername() ).revokeToken().post( false,
ApiResponse.class,queryParameters );
 
         refreshIndex();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/aec9884d/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
index f278189..cefb339 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
@@ -22,7 +22,7 @@ import com.sun.jersey.api.client.ClientResponse.Status;
 import com.sun.jersey.api.client.UniformInterfaceException;
 import com.sun.jersey.api.representation.Form;
 import org.apache.commons.lang.RandomStringUtils;
-import org.apache.usergrid.management.OrganizationOwnerInfo;
+
 import org.apache.usergrid.persistence.index.utils.UUIDUtils;
 import org.apache.usergrid.rest.management.organizations.OrganizationsResource;
 import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
@@ -457,7 +457,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertNotNull(response.get("email").toString());
 
         // now revoke the tokens
-        response = management.users().user(clientSetup.getUsername()).revokeTokens().post(true,Entity.class);
+        response = management.users().user(clientSetup.getUsername()).revokeTokens().post(true,Entity.class,
null);
 
         // the tokens shouldn't work
 
@@ -480,13 +480,13 @@ public class ManagementResourceIT extends AbstractRestIT {
         // now revoke the token3
         QueryParameters queryParameters = new QueryParameters();
         queryParameters.addParam( "token", token3.getAccessToken() );
-        response = management.users().user(clientSetup.getUsername()).revokeToken().post(
Entity.class,queryParameters );;
+        management.users().user(clientSetup.getUsername()).revokeToken().post( false, Entity.class,queryParameters
);
 
         // the token3 shouldn't work
         status = null;
 
         try {
-            response = management.users().user(clientSetup.getUsername()).get();
+            management.users().user(clientSetup.getUsername()).get();
         }
         catch ( UniformInterfaceException uie ) {
             status = uie.getResponse().getClientResponseStatus();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/aec9884d/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
index 41dcc18..ced20bb 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
@@ -172,7 +172,7 @@ public class NamedResource implements UrlResource {
         else
             resource = getResource( true );
 
-        return postResource(resource,payload);
+        return postResource( resource, payload );
     }
 
 
@@ -196,26 +196,18 @@ public class NamedResource implements UrlResource {
     public ApiResponse postEntity(Entity requestEntity, boolean useToken) {
         return getResource(useToken).type(MediaType.APPLICATION_JSON_TYPE)
             .accept( MediaType.APPLICATION_JSON )
-            .post(ApiResponse.class, requestEntity);
+            .post( ApiResponse.class, requestEntity );
 
     }
     //For edge cases like Organizations and Tokens
     public ApiResponse postEntity(Entity requestEntity) {
         return getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
             .accept( MediaType.APPLICATION_JSON )
-            .post(ApiResponse.class, requestEntity);
+            .post( ApiResponse.class, requestEntity );
 
     }
 
-    public <T> T post(Class<T> type, QueryParameters queryParameters) {
-        WebResource resource = getResource();
-        resource = addParametersToResource(resource, queryParameters);
-        GenericType<T> gt = new GenericType<>((Class) type);
-        return resource.type(MediaType.APPLICATION_JSON_TYPE)
-                            .accept( MediaType.APPLICATION_JSON )
-                            .post(gt.getRawClass());
 
-    }
 
     public <T> T postWithToken(Class<T> type, Object requestEntity) {
         GenericType<T> gt = new GenericType<>((Class) type);
@@ -225,24 +217,26 @@ public class NamedResource implements UrlResource {
 
     }
 
-    //For edge cases like Organizations and Tokens without any payload
-    public <T> T post(Class<T> type) {
-        GenericType<T> gt = new GenericType<>((Class) type);
-        return getResource().type(MediaType.APPLICATION_JSON_TYPE)
-                            .accept( MediaType.APPLICATION_JSON )
-                            .post(gt.getRawClass());
-
-    }
+    //Used for empty posts
+    public <T> T post( boolean userToken, Class<T> type, final QueryParameters
queryParameters ) {
+        WebResource resource = getResource(userToken);
+        resource = addParametersToResource(resource, queryParameters);
 
-    //For edge cases like Organizations and Tokens without any payload
-    public <T> T post(boolean useToken , Class<T> type) {
         GenericType<T> gt = new GenericType<>((Class) type);
-        return getResource(useToken).type(MediaType.APPLICATION_JSON_TYPE)
+        return resource.type( MediaType.APPLICATION_JSON_TYPE )
             .accept( MediaType.APPLICATION_JSON )
             .post(gt.getRawClass());
 
     }
 
+
+    /**
+     * Used to test POST using form payloads.
+     * @param type
+     * @param requestEntity
+     * @param <T>
+     * @return
+     */
     public <T> T post(Class<T> type, Form requestEntity) {
         GenericType<T> gt = new GenericType<>((Class) type);
         return getResource()


Mime
View raw message