usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject incubator-usergrid git commit: change framework to remove excess calls
Date Wed, 03 Jun 2015 20:11:56 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o-dev aec9884d4 -> 67354d04b


change framework to remove excess calls


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

Branch: refs/heads/two-dot-o-dev
Commit: 67354d04bf16ed6243a6fb54e1becdfd7314a6ff
Parents: aec9884
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Wed Jun 3 14:11:40 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Wed Jun 3 14:11:40 2015 -0600

----------------------------------------------------------------------
 .../apache/usergrid/rest/NotificationsIT.java   |   2 +-
 .../rest/applications/ApplicationCreateIT.java  |   4 +-
 .../applications/ApplicationResourceIT.java     |   8 +-
 .../usergrid/rest/management/AccessTokenIT.java |   4 +-
 .../usergrid/rest/management/AdminUsersIT.java  |  13 +-
 .../rest/management/ExportResourceIT.java       |  50 +++----
 .../rest/management/ManagementResourceIT.java   |   6 +-
 .../rest/management/OrganizationsIT.java        |  32 ++---
 .../rest/management/RegistrationIT.java         |   8 +-
 .../test/resource2point0/AbstractRestIT.java    |   8 +-
 .../rest/test/resource2point0/ClientSetup.java  |   4 +-
 .../endpoints/CollectionEndpoint.java           |   2 +-
 .../endpoints/NamedResource.java                | 144 ++++++++++---------
 .../endpoints/OrganizationResource.java         |   6 -
 .../endpoints/mgmt/CredentialsResource.java     |   4 +-
 15 files changed, 145 insertions(+), 150 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/67354d04/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
index fb1d2ad..d5fb2db 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
@@ -79,7 +79,7 @@ public class NotificationsIT extends org.apache.usergrid.rest.test.resource2poin
         // create notifier
         Entity notifier = new Entity().chainPut("name", "mynotifier").chainPut("provider", "noop");
 
-        ApiResponse notifierNode = this.pathResource(getOrgAppPath("notifier")).postEntity(notifier);
+        ApiResponse notifierNode = this.pathResource(getOrgAppPath("notifier")).post(ApiResponse.class,notifier);
 
         //logger.debug("Notifier is: " + notifierNode.toString());
         assertEquals("noop", notifierNode.getEntities().get(0).get("provider").toString());

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/67354d04/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationCreateIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationCreateIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationCreateIT.java
index dbf3e82..921027f 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationCreateIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationCreateIT.java
@@ -55,8 +55,8 @@ public class ApplicationCreateIT extends AbstractRestIT {
         Map applicationMap = new HashMap<String, Object>(  );
         applicationMap.put( "name", appName );
 
-        this.management().orgs().organization( orgName ).apps().post(
-            orgAdminToken,applicationMap );
+        this.management().token().setToken(orgAdminToken);
+        this.management().orgs().organization( orgName ).apps().post(applicationMap );
 
         Entity response = this.management().orgs().organization( orgName ).addToPath( "apps" ).addToPath( appName ).get();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/67354d04/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
index ab208c0..4ce3396 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
@@ -133,7 +133,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
             .management().orgs().organization(clientSetup.getOrganizationName());
 
         //retrieve the credentials
-        Credentials orgCredentials = orgResource.credentials().get();
+        Credentials orgCredentials = new Credentials( orgResource.credentials().get(ApiResponse.class));
         String clientId = orgCredentials.getClientId();
         String clientSecret = orgCredentials.getClientSecret();
 
@@ -442,7 +442,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
         assertNotNull(entity);
         refreshIndex();
         //Retrieve an authentication token for the user
-        Token tokenResponse = resource().path(String.format("/%s/%s/token", orgName, appName))
+        Token tokenResponse = this.app().getResource(false).path(String.format("/%s/%s/token", orgName, appName))
             .queryParam("grant_type", "password")
             .queryParam("username", username)
             .queryParam("password", "password")
@@ -747,7 +747,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
      * @return Credentials
      */
     public Credentials getAppCredentials() throws IOException {
-        return this.app().credentials().get();
+        return new Credentials (this.app().credentials().get(ApiResponse.class,null,true));
     }
 
     /**
@@ -756,7 +756,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
      */
     public Credentials getOrgCredentials() throws IOException {
         String orgName = clientSetup.getOrganizationName().toLowerCase();
-        return clientSetup.getRestClient().management().orgs().organization(orgName).credentials().get();
+        return new Credentials( clientSetup.getRestClient().management().orgs().organization(orgName).credentials().get(ApiResponse.class,null,true) );
 
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/67354d04/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 3ead63f..09b744c 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(true , ApiResponse.class, null);
+        management().users().user( clientSetup.getUsername() ).revokeTokens().post(true , ApiResponse.class, null,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( false, ApiResponse.class,queryParameters );
+        management().users().user( clientSetup.getUsername() ).revokeToken().post( false, ApiResponse.class,null,queryParameters );
 
         refreshIndex();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/67354d04/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
index 99c8ae8..9306f2b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
@@ -91,12 +91,12 @@ public class AdminUsersIT extends AbstractRestIT {
         this.refreshIndex();
 
         //Get the token using the new password
-        Token adminToken = management.token().post( Token.class, new Token( username, "testPassword" )  );
+        Token adminToken = management.token().post( false, Token.class, new Token( username, "testPassword" ) ,null );
         management.token().setToken( adminToken );
 
         //Check that we cannot get the token using the old password
         try {
-            management.token().post( Token.class, new Token( username, password ));
+            management.token().post(false, Token.class, new Token( username, password ),null);
             fail( "We shouldn't be able to get a token using the old password" );
         }catch(UniformInterfaceException uie) {
             errorParse( 400,"invalid_grant",uie );
@@ -156,16 +156,17 @@ public class AdminUsersIT extends AbstractRestIT {
         Map<String, Object> passwordPayload = new HashMap<String, Object>();
         passwordPayload.put( "newpassword", "testPassword" );
 
-        management.users().user( username ).password().post( clientSetup.getSuperuserToken(), passwordPayload );
+        management.token().setToken( clientSetup.getSuperuserToken());
+        management.users().user( username ).password().post( passwordPayload );
 
         this.refreshIndex();
 
-        assertNotNull(management.token().post( Token.class, new Token( username, "testPassword" )  ));
+        assertNotNull(management.token().post( false,Token.class, new Token( username, "testPassword" ) ,null ));
 
 
         //Check that we cannot get the token using the old password
         try {
-            management.token().post( Token.class, new Token( username, password) );
+            management.token().post( false,Token.class, new Token( username, password) ,null);
             fail( "We shouldn't be able to get a token using the old password" );
         }catch(UniformInterfaceException uie) {
             errorParse( 400,"invalid_grant",uie );
@@ -614,7 +615,7 @@ public class AdminUsersIT extends AbstractRestIT {
 //        management().token().setToken( organizationToken );
 
         //Create admin user
-        management().orgs().organization( clientSetup.getOrganizationName() ).users().postWithToken(ApiResponse.class ,adminUserPayload );
+        management().orgs().organization( clientSetup.getOrganizationName() ).users().post(ApiResponse.class ,adminUserPayload );
 
         refreshIndex();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/67354d04/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
index 4a1f12f..8ed6777 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
@@ -74,7 +74,7 @@ public class ExportResourceIT extends AbstractRestIT {
 
             exportEntity = management().orgs().organization( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid()).addToPath( "collection" )
-                        .addToPath( "users" ).addToPath( "export" ).postWithToken(ApiResponse.class,payloadBuilder() );
+                        .addToPath( "users" ).addToPath( "export" ).post(ApiResponse.class,payloadBuilder() );
         }
         catch ( UniformInterfaceException uie ) {
             fail( "We got back "+uie.getResponse().getClientResponseStatus()+" instead of having a successful call" );
@@ -98,7 +98,7 @@ public class ExportResourceIT extends AbstractRestIT {
 
         try {
             exportEntity = management().orgs().organization( clientSetup.getOrganizationName() )
-                                       .addToPath( "export" ).postWithToken( ApiResponse.class, payloadBuilder() );
+                                       .addToPath( "export" ).post( ApiResponse.class, payloadBuilder() );
         }
         catch ( UniformInterfaceException uie ) {
             fail( "We got back "+uie.getResponse().getClientResponseStatus()+" instead of having a successful call" );
@@ -141,7 +141,7 @@ public class ExportResourceIT extends AbstractRestIT {
         try {
             exportEntity = management().orgs().organization( clientSetup.getOrganizationName() )
                                        .app().addToPath( clientSetup.getAppUuid() )
-                                       .addToPath( "export" ).postWithToken( ApiResponse.class, payloadBuilder() );
+                                       .addToPath( "export" ).post( ApiResponse.class, payloadBuilder() );
         }
         catch ( UniformInterfaceException uie ) {
             fail( "We got back "+uie.getResponse().getClientResponseStatus()+" instead of having a successful call" );
@@ -177,7 +177,7 @@ public class ExportResourceIT extends AbstractRestIT {
         exportEntity = management().orgs().organization( clientSetup.getOrganizationName() )
                                    .app().addToPath( clientSetup.getAppUuid()).addToPath( "collection" )
                                    .addToPath( "users" ).addToPath( "export" )
-                                   .postWithToken( ApiResponse.class, payloadBuilder() );
+                                   .post( ApiResponse.class, payloadBuilder() );
 
         assertNotNull( exportEntity );
         String uuid = ( String ) exportEntity.getProperties().get( "Export Entity" );
@@ -223,7 +223,7 @@ public class ExportResourceIT extends AbstractRestIT {
         try {
             management().orgs().organization( clientSetup.getOrganizationName() )
                                        .app().addToPath( clientSetup.getAppUuid() )
-                                       .addToPath( "export" ).postWithToken( ApiResponse.class,
+                                       .addToPath( "export" ).post( ApiResponse.class,
                 new HashMap<String, Object>() );
             fail( "Should not have passed, The payload is empty." );
         }
@@ -238,7 +238,7 @@ public class ExportResourceIT extends AbstractRestIT {
     public void exportPostOrganizationNullPointerProperties() throws Exception {
         try {
             management().orgs().organization( clientSetup.getOrganizationName() )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class, new HashMap<String, Object>()  );
+                        .addToPath( "export" ).post( ApiResponse.class, new HashMap<String, Object>()  );
             fail( "Should not have passed, The payload is empty." );
         }
         catch ( UniformInterfaceException uie ) {
@@ -254,7 +254,7 @@ public class ExportResourceIT extends AbstractRestIT {
             management().orgs().organization( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid() )
                         .addToPath( "collection" ).addToPath( "users" )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class, new HashMap<String, Object>()  );
+                        .addToPath( "export" ).post( ApiResponse.class, new HashMap<String, Object>()  );
 
             fail( "Should not have passed, The payload is empty." );
         }
@@ -272,7 +272,7 @@ public class ExportResourceIT extends AbstractRestIT {
             management().orgs().organization( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid() )
                         .addToPath( "collection" ).addToPath( "users" )
-                        .addToPath( "export" ).addToPath( fake.toString() ).getWithoutToken( ApiResponse.class );
+                        .addToPath( "export" ).addToPath( fake.toString() ).get(ApiResponse.class ,false);
             fail( "Should not have passed as we didn't have an access token." );
         }
         catch ( UniformInterfaceException uie ) {
@@ -288,7 +288,7 @@ public class ExportResourceIT extends AbstractRestIT {
         try {
             management().orgs().organization( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid() )
-                        .addToPath( "export" ).addToPath( fake.toString() ).getWithoutToken( ApiResponse.class );
+                        .addToPath( "export" ).addToPath( fake.toString() ).get(ApiResponse.class ,false);
             fail( "Should not have passed as we didn't have an access token." );
         }
         catch ( UniformInterfaceException uie ) {
@@ -303,7 +303,7 @@ public class ExportResourceIT extends AbstractRestIT {
 
         try {
             management().orgs().organization( clientSetup.getOrganizationName() )
-                        .addToPath( "export" ).addToPath( fake.toString() ).getWithoutToken( ApiResponse.class );
+                        .addToPath( "export" ).addToPath( fake.toString() ).get(ApiResponse.class ,false);
             fail( "Should not have passed as we didn't have an access token." );
         }
         catch ( UniformInterfaceException uie ) {
@@ -321,7 +321,7 @@ public class ExportResourceIT extends AbstractRestIT {
 
         try {
             management().orgs().organization( clientSetup.getOrganizationName() )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class, payload );
+                        .addToPath( "export" ).post( ApiResponse.class, payload );
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
@@ -342,7 +342,7 @@ public class ExportResourceIT extends AbstractRestIT {
         try {
             management().orgs().organization( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid() )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class,
+                        .addToPath( "export" ).post( ApiResponse.class,
                 payload );
             fail( "Should not have passed as we were missing an important part of the payload" );
 
@@ -364,7 +364,7 @@ public class ExportResourceIT extends AbstractRestIT {
             management().orgs().organization( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid() )
                         .addToPath( "collection" ).addToPath( "users" )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class,
+                        .addToPath( "export" ).post( ApiResponse.class,
                 payload );
             fail( "Should not have passed as we were missing an important part of the payload" );
 
@@ -384,7 +384,7 @@ public class ExportResourceIT extends AbstractRestIT {
 
         try {
             management().orgs().organization( clientSetup.getOrganizationName() )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class, payload );
+                        .addToPath( "export" ).post( ApiResponse.class, payload );
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
@@ -405,7 +405,7 @@ public class ExportResourceIT extends AbstractRestIT {
         try {
             management().orgs().organization( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid() )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class,
+                        .addToPath( "export" ).post( ApiResponse.class,
                 payload );
             fail( "Should not have passed as we were missing an important part of the payload" );
 
@@ -427,7 +427,7 @@ public class ExportResourceIT extends AbstractRestIT {
             management().orgs().organization( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid() )
                         .addToPath( "collection" ).addToPath( "users" )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class,
+                        .addToPath( "export" ).post( ApiResponse.class,
                 payload );
             fail( "Should not have passed as we were missing an important part of the payload" );
 
@@ -449,7 +449,7 @@ public class ExportResourceIT extends AbstractRestIT {
 
         try {
             management().orgs().organization( clientSetup.getOrganizationName() )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class, payload );
+                        .addToPath( "export" ).post( ApiResponse.class, payload );
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
@@ -465,7 +465,7 @@ public class ExportResourceIT extends AbstractRestIT {
 
         try {
             management().orgs().organization( clientSetup.getOrganizationName() )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class, payload );
+                        .addToPath( "export" ).post( ApiResponse.class, payload );
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
@@ -481,7 +481,7 @@ public class ExportResourceIT extends AbstractRestIT {
 
         try {
             management().orgs().organization( clientSetup.getOrganizationName() )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class, payload );
+                        .addToPath( "export" ).post( ApiResponse.class, payload );
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
@@ -502,7 +502,7 @@ public class ExportResourceIT extends AbstractRestIT {
         try {
             management().orgs().organization( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid() )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class, payload );
+                        .addToPath( "export" ).post( ApiResponse.class, payload );
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
@@ -519,7 +519,7 @@ public class ExportResourceIT extends AbstractRestIT {
         try {
             management().orgs().organization( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid() )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class, payload );
+                        .addToPath( "export" ).post( ApiResponse.class, payload );
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
@@ -536,7 +536,7 @@ public class ExportResourceIT extends AbstractRestIT {
         try {
             management().orgs().organization( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid() )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class, payload );
+                        .addToPath( "export" ).post( ApiResponse.class, payload );
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
@@ -558,7 +558,7 @@ public class ExportResourceIT extends AbstractRestIT {
             management().orgs().organization( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid() )
                         .addToPath( "collection" ).addToPath( "users" )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class, payload );
+                        .addToPath( "export" ).post( ApiResponse.class, payload );
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
@@ -576,7 +576,7 @@ public class ExportResourceIT extends AbstractRestIT {
             management().orgs().organization( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid() )
                         .addToPath( "collection" ).addToPath( "users" )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class, payload );
+                        .addToPath( "export" ).post( ApiResponse.class, payload );
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
@@ -594,7 +594,7 @@ public class ExportResourceIT extends AbstractRestIT {
             management().orgs().organization( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid() )
                         .addToPath( "collection" ).addToPath( "users" )
-                        .addToPath( "export" ).postWithToken( ApiResponse.class, payload );
+                        .addToPath( "export" ).post( ApiResponse.class, payload );
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/67354d04/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 cefb339..f361e8b 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
@@ -70,7 +70,7 @@ public class ManagementResourceIT extends AbstractRestIT {
     public void setSelfAdminPasswordAsAdwmin() {
         UUID uuid =  UUIDUtils.newTimeUUID();
         management.token().setToken(clientSetup.getSuperuserToken());
-        management.orgs().organization(clientSetup.getOrganizationName()).users().postWithToken(User.class, new User("test" + uuid, "test" + uuid, "test" + uuid + "@email.com", "test"));
+        management.orgs().organization(clientSetup.getOrganizationName()).users().post(ApiResponse.class, new User("test" + uuid, "test" + uuid, "test" + uuid + "@email.com", "test"));
         Map<String, Object> data = new HashMap<>();
         data.put( "newpassword", "foo" );
         data.put( "oldpassword", "test" );
@@ -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, null);
+        response = management.users().user(clientSetup.getUsername()).revokeTokens().post(true,Entity.class,null, null);
 
         // the tokens shouldn't work
 
@@ -480,7 +480,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         // now revoke the token3
         QueryParameters queryParameters = new QueryParameters();
         queryParameters.addParam( "token", token3.getAccessToken() );
-        management.users().user(clientSetup.getUsername()).revokeToken().post( false, Entity.class,queryParameters );
+        management.users().user(clientSetup.getUsername()).revokeToken().post( false, Entity.class,null,queryParameters );
 
         // the token3 shouldn't work
         status = null;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/67354d04/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 f9f8d39..4385a4c 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
@@ -23,17 +23,13 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.UUID;
 
+import org.apache.usergrid.rest.test.resource2point0.model.*;
 import org.junit.Ignore;
 import org.junit.Test;
 
 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;
-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;
@@ -60,8 +56,6 @@ public class OrganizationsIT extends AbstractRestIT {
     @Test
     public void createOrgAndOwner() throws Exception {
 
-        management().token().setToken(clientSetup.getSuperuserToken());
-
         //User property to see if owner properties exist when created.
         Map<String, Object> userProperties = new HashMap<String, Object>();
         userProperties.put( "company", "Apigee" );
@@ -79,8 +73,9 @@ public class OrganizationsIT extends AbstractRestIT {
 
         //Creates token
         Token token =
-                clientSetup.getRestClient().management().token().post(Token.class, new Token( "password",
-                        organization.getUsername(), organization.getPassword() ) );
+                clientSetup.getRestClient().management().token().post(false,Token.class, new Token( "password",
+                        organization.getUsername(), organization.getPassword() ) ,null);
+        this.management().token().setToken(token);
 
         assertNotNull( token );
 
@@ -117,8 +112,8 @@ public class OrganizationsIT extends AbstractRestIT {
 
         //Ensure that the token from the newly created organization works.
         Token tokenPayload = new Token( "password", organization.getUsername(), organization.getPassword() );
-        Token tokenReturned = clientSetup.getRestClient().management().token().post(Token.class, tokenPayload );
-
+        Token tokenReturned = clientSetup.getRestClient().management().token().post(false,Token.class, tokenPayload,null );
+        this.management().token().setToken(tokenReturned);
         assertNotNull( tokenReturned );
 
         //Try to create a organization with the same name as an organization that already exists, ensure that it fails
@@ -139,7 +134,7 @@ public class OrganizationsIT extends AbstractRestIT {
         tokenPayload = new Token( "password", organization.getName() + "test", organization.getPassword() );
         Token tokenError = null;
         try {
-            tokenError = clientSetup.getRestClient().management().token().post(Token.class, tokenPayload );
+            tokenError = clientSetup.getRestClient().management().token().post(false,Token.class, tokenPayload,null );
             fail( "Should not have created user" );
         }
         catch ( UniformInterfaceException ex ) {
@@ -194,7 +189,7 @@ public class OrganizationsIT extends AbstractRestIT {
         tokenPayload = new Token( "password", organization.getUsername()+"test", organization.getPassword()+"test" );
         Token tokenError = null;
         try {
-            tokenError = clientSetup.getRestClient().management().token().post(Token.class, tokenPayload );
+            tokenError = clientSetup.getRestClient().management().token().post(false,Token.class, tokenPayload,null );
             fail( "Should not have created organization" );
         }
         catch ( UniformInterfaceException ex ) {
@@ -276,10 +271,11 @@ public class OrganizationsIT extends AbstractRestIT {
 
         //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(Token.class, tokenPayload);
+        Token tokenReturned = clientSetup.getRestClient().management().token().post(false,Token.class, tokenPayload,null);
 
         assertNotNull( tokenReturned );
-        management().token().setToken(clientSetup.getSuperuserToken());
+
+        this.management().token().setToken(tokenReturned);
 
         //Assert that the get returns the correct org and owner.
         Organization returnedOrg = clientSetup.getRestClient().management().orgs().organization( organization.getOrganization() ).get();
@@ -324,12 +320,12 @@ public class OrganizationsIT extends AbstractRestIT {
         adminUserPayload.put("password", username);
 
         //create adminUser
-        Entity adminUserResponse = management().orgs().organization( clientSetup.getOrganizationName() ).users().postWithToken(Entity.class, adminUserPayload );
+        ApiResponse adminUserEntityResponse = management().orgs().organization( clientSetup.getOrganizationName() ).users().post(ApiResponse.class, adminUserPayload);
 
-        LinkedHashMap user = ((LinkedHashMap)((LinkedHashMap)adminUserResponse.get("data")).get("user"));
+        Entity adminUserResponse = new Entity(adminUserEntityResponse);
         //verify that the response contains the correct data
         assertNotNull( adminUserResponse );
-        assertEquals(username, user.get("username"));
+        assertEquals(username, adminUserResponse.get("username"));
 
         //fetch the stored response
         adminUserResponse = management().users().entity( username ).get(this.getAdminToken(username,username));

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/67354d04/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
index c41e1f6..2972126 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
@@ -81,15 +81,17 @@ public class RegistrationIT extends AbstractRestIT {
 
     public Entity postAddAdminToOrg(String organizationName, String email, String password) throws IOException {
 
-        Entity user = this
+        this.management().token().setToken(this.getAdminToken());
+
+        ApiResponse user = this
             .management()
             .orgs()
             .organization(organizationName)
             .users()
-            .post(this.getAdminToken(), new User().chainPut("email", email).chainPut("password", password)  );
+            .post(new User().chainPut("email", email).chainPut("password", password));
 
         assertNotNull(user);
-        return user;
+        return new Entity(user);
     }
 
     private Message[] getMessages(String host, String user, String password) throws MessagingException, IOException {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/67354d04/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 37e4f99..29b6414 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
@@ -171,14 +171,14 @@ public class AbstractRestIT extends JerseyTest {
 
 
     protected Token getAdminToken(String username, String password){
-        return this.clientSetup.getRestClient().management().token().post(Token.class,
-                new Token(username, password)
+        return this.clientSetup.getRestClient().management().token().post(false,Token.class,
+                new Token(username, password),null
         );
     }
 
     protected Token getAdminToken(){
-        return this.clientSetup.getRestClient().management().token().post(Token.class,
-                new Token(this.clientSetup.getUsername(),this.clientSetup.getUsername())
+        return this.clientSetup.getRestClient().management().token().post(false,Token.class,
+                new Token(this.clientSetup.getUsername(),this.clientSetup.getUsername()),null
         );
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/67354d04/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 51bf09e..6a0a781 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
@@ -101,7 +101,7 @@ public class ClientSetup implements TestRule {
 
         try {
             restClient.superuserSetup();
-            superuserToken = restClient.management().token().get( superuserName, superuserPassword  );
+            superuserToken = restClient.management().token().get(superuserName, superuserPassword);
         } catch ( Exception e ) {
             if ( logger.isDebugEnabled() ) {
                 logger.debug( "Error creating superuser, may already exist", e );
@@ -122,7 +122,7 @@ public class ClientSetup implements TestRule {
         restClient.management().token().get(username,password);
 
         // refreshIndex();
-        clientCredentials = restClient.management().orgs().organization( orgName ).credentials().get(null,true);
+        clientCredentials = restClient.management().orgs().organization( orgName ).credentials().get(Credentials.class);
         //refreshIndex();
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/67354d04/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 0192502..d104e29 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
@@ -109,7 +109,7 @@ public class CollectionEndpoint extends NamedResource {
      * <pre>
      */
     public Collection get(){
-        return get(null, true);
+        return new Collection( get(ApiResponse.class,null,true));
     }
 
     public Collection get( final QueryParameters parameters ){

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/67354d04/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 ced20bb..f5083ba 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
@@ -34,7 +34,7 @@ import java.util.UUID;
 
 import javax.ws.rs.core.MediaType;
 import com.sun.jersey.api.representation.Form;
-
+import org.jclouds.openstack.v2_0.domain.Extension;
 
 
 /**
@@ -156,25 +156,34 @@ public class NamedResource implements UrlResource {
         return sb.toString();
     }
 
-    //Post Resources
-    public Entity postResource(WebResource resource, Map<String,Object> payload){
-        ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
-                                                .post(ApiResponse.class, payload);
-        return new Entity(response);
-    }
-
-    public Entity post(Token token, Map<String,Object> payload){
-        WebResource resource;
+    /**
+     * Need to refactor all instances of tokens to either be passed in or manually set during the test.
+     * There isn't any reason we would want a rest forwarding framework to set something on behave of the user.
+     * @param map
+     * @return
+     */
+    //For edge cases like Organizations and Tokens
+    public ApiResponse  post(Map map) {
+        return post(true,ApiResponse.class,map,null);
 
-        if(token != null) {
-            resource = getResource( true, token );
-        }
-        else
-            resource = getResource( true );
+    }
+    //For edge cases like Organizations and Tokens
+    public ApiResponse  post(boolean useToken, Map map, QueryParameters queryParameters) {
+        return post(true,ApiResponse.class,map,queryParameters);
 
-        return postResource( resource, payload );
     }
+    /**
+     * Need to refactor all instances of tokens to either be passed in or manually set during the test.
+     * There isn't any reason we would want a rest forwarding framework to set something on behave of the user.
+     * @param type
+     * @param <T>
+     * @return
+     */
+    //For edge cases like Organizations and Tokens
+    public <T> T post(Class<T> type) {
+        return post(true,type,null,null);
 
+    }
 
     /**
      * Need to refactor all instances of tokens to either be passed in or manually set during the test.
@@ -185,92 +194,87 @@ public class NamedResource implements UrlResource {
      * @return
      */
     //For edge cases like Organizations and Tokens
-    public <T> T post(Class<T> type, Object requestEntity) {
-        GenericType<T> gt = new GenericType<>((Class) type);
-        return getResource().type(MediaType.APPLICATION_JSON_TYPE)
-                            .accept( MediaType.APPLICATION_JSON )
-                            .post(gt.getRawClass(), requestEntity);
+    public <T> T post(Class<T> type, Entity requestEntity) {
+        return post(true,type,requestEntity,null);
 
     }
-    //For edge cases like Organizations and Tokens
-    public ApiResponse postEntity(Entity requestEntity, boolean useToken) {
-        return getResource(useToken).type(MediaType.APPLICATION_JSON_TYPE)
-            .accept( MediaType.APPLICATION_JSON )
-            .post( ApiResponse.class, requestEntity );
 
-    }
+    /**
+     * Need to refactor all instances of tokens to either be passed in or manually set during the test.
+     * There isn't any reason we would want a rest forwarding framework to set something on behave of the user.
+     * @param type
+     * @param requestEntity
+     * @param <T>
+     * @return
+     */
     //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 );
+    public <T> T post(Class<T> type, Map requestEntity) {
+        return post(true,type,requestEntity,null);
 
     }
 
-
-
-    public <T> T postWithToken(Class<T> type, Object requestEntity) {
+    /**
+     * 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(true).type(MediaType.APPLICATION_JSON_TYPE)
-                            .accept( MediaType.APPLICATION_JSON )
-                            .post(gt.getRawClass(), requestEntity);
+        return getResource()
+            .accept(MediaType.APPLICATION_JSON)
+            .type(MediaType.APPLICATION_FORM_URLENCODED_TYPE)
+            .entity(requestEntity, MediaType.APPLICATION_FORM_URLENCODED_TYPE)
+            .post(gt.getRawClass());
 
     }
 
+
     //Used for empty posts
-    public <T> T post( boolean userToken, Class<T> type, final QueryParameters queryParameters ) {
-        WebResource resource = getResource(userToken);
+    public <T> T post( boolean useToken, Class<T> type, Map entity, final QueryParameters queryParameters ) {
+        WebResource resource = getResource(useToken);
         resource = addParametersToResource(resource, queryParameters);
+        WebResource.Builder builder = resource
+            .type(MediaType.APPLICATION_JSON_TYPE)
+            .accept( MediaType.APPLICATION_JSON );
 
+        if(entity!=null){
+            builder.entity(entity);
+        }
         GenericType<T> gt = new GenericType<>((Class) type);
-        return resource.type( MediaType.APPLICATION_JSON_TYPE )
-            .accept( MediaType.APPLICATION_JSON )
+        return builder
             .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()
-        .accept(MediaType.APPLICATION_JSON)
-        .type(MediaType.APPLICATION_FORM_URLENCODED_TYPE)
-        .entity(requestEntity, MediaType.APPLICATION_FORM_URLENCODED_TYPE)
-        .post(gt.getRawClass());
+    //For edge cases like Organizations and Tokens without any payload
+    public <T> T get(Class<T> type) {
+        return get(type,null,true);
 
     }
 
     //For edge cases like Organizations and Tokens without any payload
-    public <T> T get(Class<T> type) {
-        GenericType<T> gt = new GenericType<>((Class) type);
-        return getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
-                                  .accept(MediaType.APPLICATION_JSON)
-                                  .get(gt.getRawClass());
+    public <T> T get(Class<T> type, boolean useToken) {
+        return get(type,null,useToken);
 
     }
 
-    public <T> T getWithoutToken(Class<T> type) {
-        GenericType<T> gt = new GenericType<>((Class) type);
-        return getResource().type(MediaType.APPLICATION_JSON_TYPE)
-                                  .accept( MediaType.APPLICATION_JSON )
-                                  .get( gt.getRawClass() );
 
+    public <T> T get(Class<T> type,QueryParameters queryParameters) {
+        return get(type,queryParameters,true);
     }
 
-    public <T> T get(Class<T> type,QueryParameters queryParameters) {
-        WebResource resource = getResource();
-        resource = addParametersToResource(resource, queryParameters);
+    public <T> T get(Class<T> type,QueryParameters queryParameters, boolean useToken) {
+        WebResource resource = getResource(useToken);
+        if(queryParameters!=null) {
+            resource = addParametersToResource(resource, queryParameters);
+        }
         GenericType<T> gt = new GenericType<>((Class) type);
         return resource.type(MediaType.APPLICATION_JSON_TYPE)
-                                  .accept( MediaType.APPLICATION_JSON )
-                                  .get( gt.getRawClass() );
+            .accept( MediaType.APPLICATION_JSON )
+            .get( gt.getRawClass() );
 
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/67354d04/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
index cf774d0..c1032b6 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
@@ -43,12 +43,6 @@ public class OrganizationResource extends NamedResource {
         return new ApplicationsResource( name, context ,this );
     }
 
-    public void post(Map<String,String> organization) {
-
-        getResource().type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
-                     .post( ApiResponse.class, organization );
-    }
-
     public Organization get(){
         throw new UnsupportedOperationException("service doesn't exist");
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/67354d04/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/CredentialsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/CredentialsResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/CredentialsResource.java
index 8e5a334..ee83b2e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/CredentialsResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/CredentialsResource.java
@@ -49,7 +49,5 @@ public class CredentialsResource extends NamedResource {
         return get(parameters, true);
     }
 
-    public Credentials get() {
-        return get(null, true);
-    }
+
 }


Mime
View raw message