You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2015/03/19 00:56:09 UTC
incubator-usergrid git commit: Got generics working,
but before is still broken. Starting refactor of rest test framework.
Repository: incubator-usergrid
Updated Branches:
refs/heads/USERGRID-493 [created] ee2160657
Got generics working, but before is still broken. Starting refactor of 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/ee216065
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/ee216065
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/ee216065
Branch: refs/heads/USERGRID-493
Commit: ee2160657510012d3c31cfa794f70747d4023808
Parents: eb0c689
Author: GERey <gr...@apigee.com>
Authored: Wed Mar 18 16:56:07 2015 -0700
Committer: GERey <gr...@apigee.com>
Committed: Wed Mar 18 16:56:07 2015 -0700
----------------------------------------------------------------------
.../applications/ApplicationResourceIT.java | 2 +-
.../collection/users/UserResourceIT.java | 4 +-
.../usergrid/rest/management/AdminUsersIT.java | 40 ++++++------
.../rest/management/ImportResourceIT.java | 20 +++---
.../rest/management/OrganizationsIT.java | 16 ++---
.../organizations/AdminEmailEncodingIT.java | 3 +-
.../test/resource2point0/AbstractRestIT.java | 4 +-
.../rest/test/resource2point0/ClientSetup.java | 8 ++-
.../endpoints/NamedResource.java | 68 ++++++++++++++++++++
.../endpoints/mgmt/ApplicationResource.java | 10 +--
.../endpoints/mgmt/PasswordResource.java | 16 -----
.../endpoints/mgmt/TokenResource.java | 27 --------
.../endpoints/mgmt/UsersResource.java | 15 -----
13 files changed, 125 insertions(+), 108 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ee216065/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 3b4a0b6..5e40037 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
@@ -584,7 +584,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
String clientId = orgCredentials.getClientId();
String clientSecret = orgCredentials.getClientSecret();
- Token token = clientSetup.getRestClient().management().token().post(new Token("client_credentials", clientId, clientSecret));
+ Token token = clientSetup.getRestClient().management().token().post(Token.class,new Token("client_credentials", clientId, clientSecret));
//GET the token endpoint, adding authorization header
Token apiResponse = this.app().token().getResource(false)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ee216065/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
index 8761dd3..1901c39 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
@@ -881,7 +881,7 @@ public class UserResourceIT extends AbstractRestIT {
assertNotNull(entity1);
assertNotNull(entity2);
- Token adminToken = this.clientSetup.getRestClient().management().token().post(new Token(clientSetup.getUsername(), clientSetup.getUsername()));
+ Token adminToken = this.clientSetup.getRestClient().management().token().post(Token.class,new Token(clientSetup.getUsername(), clientSetup.getUsername()));
// now revoke the tokens
this.app().token().setToken(adminToken);
@@ -929,7 +929,7 @@ public class UserResourceIT extends AbstractRestIT {
assertNotNull(entity2);
// now revoke the token3
- adminToken = this.clientSetup.getRestClient().management().token().post(new Token(clientSetup.getUsername(), clientSetup.getUsername()));
+ adminToken = this.clientSetup.getRestClient().management().token().post(Token.class,new Token(clientSetup.getUsername(), clientSetup.getUsername()));
// now revoke the tokens
this.app().token().setToken(adminToken);
usersResource.entity("edanuff").connection("revoketokens").post();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ee216065/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 fffb28a..973ed7d 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
@@ -93,16 +93,16 @@ public class AdminUsersIT extends AbstractRestIT {
passwordPayload.put( "oldpassword", password );
// change the password as admin. The old password isn't required
- management.users().user( username ).password().post(passwordPayload);
+ management.users().user( username ).password().post(Entity.class,passwordPayload);
this.refreshIndex();
//Get the token using the new password
- management.token().post( new Token( username, "testPassword" ) );
+ management.token().post( Token.class, new Token( username, "testPassword" ) );
//Check that we cannot get the token using the old password
try {
- management.token().post( new Token( username, password ) );
+ management.token().post( Token.class, new Token( username, password ));
fail( "We shouldn't be able to get a token using the old password" );
}catch(UniformInterfaceException uie) {
errorParse( 400,"invalid_grant",uie );
@@ -125,18 +125,19 @@ public class AdminUsersIT extends AbstractRestIT {
passwordPayload.put( "oldpassword", password );
// change the password as admin. The old password isn't required
- management.users().user( username ).password().post( passwordPayload );
+ management.users().user( username ).password().post(Entity.class, passwordPayload );
this.refreshIndex();
//Get the token using the new password
- management.token().post( new Token( username, "testPassword" ) );
+ management.token().post( Token.class, new Token( username, "testPassword" ) );
+
// Check that we can't change the password using the old password.
try {
- management.users().user( username ).password().post( passwordPayload );
+ management.users().user( username ).password().post( Entity.class ,passwordPayload );
fail("We shouldn't be able to change the password with the same payload");
}
catch ( UniformInterfaceException uie ) {
@@ -164,11 +165,12 @@ public class AdminUsersIT extends AbstractRestIT {
this.refreshIndex();
- assertNotNull( management.token().post( new Token( username, "testPassword" ) ) );
+ assertNotNull(management.token().post( Token.class, new Token( username, "testPassword" ) ));
+
//Check that we cannot get the token using the old password
try {
- management.token().post( new Token( username, password ) );
+ management.token().post( Token.class, new Token( username, password) );
fail( "We shouldn't be able to get a token using the old password" );
}catch(UniformInterfaceException uie) {
errorParse( 400,"invalid_grant",uie );
@@ -306,8 +308,9 @@ public class AdminUsersIT extends AbstractRestIT {
clientSetup.getRestClient().testPropertiesResource().post( testPropertiesPayload );
refreshIndex();
- Token superuserToken = management().token().post(
- new Token( clientSetup.getSuperuserName(), clientSetup.getSuperuserPassword() ) );
+ Token superuserToken = management.token().post( Token.class,
+ new Token( clientSetup.getSuperuserName(), clientSetup.getSuperuserPassword() ) );
+
@@ -343,7 +346,7 @@ public class AdminUsersIT extends AbstractRestIT {
clientSetup.getRestClient().testPropertiesResource().post( testPropertiesPayload );
refreshIndex();
- Token testToken = management().token().post(
+ Token testToken = management().token().post(Token.class,
new Token( originalTestProperties.getAsString( PROPERTIES_TEST_ACCOUNT_ADMIN_USER_EMAIL ),
originalTestProperties.getAsString( PROPERTIES_TEST_ACCOUNT_ADMIN_USER_PASSWORD ) ));
@@ -414,7 +417,7 @@ public class AdminUsersIT extends AbstractRestIT {
public void checkFormPasswordReset() throws Exception {
- management().users().user( clientSetup.getUsername() ).resetpw().post(null);
+ management().users().user( clientSetup.getUsername() ).resetpw().post(new Form());
//Create mocked inbox
List<Message> inbox = Mailbox.get( clientSetup.getEmail() );
@@ -501,7 +504,7 @@ public class AdminUsersIT extends AbstractRestIT {
//Makes sure we can't replace a password with itself ( as it is the only one in the history )
try {
- management().users().user( clientSetup.getUsername() ).password().post( payload );
+ management().users().user( clientSetup.getUsername() ).password().post(Entity.class ,payload );
fail( "should fail with conflict" );
}
@@ -511,7 +514,7 @@ public class AdminUsersIT extends AbstractRestIT {
//Change the password
payload.put( "newpassword", passwords[1] );
- management().users().user( clientSetup.getUsername() ).password().post( payload );
+ management().users().user( clientSetup.getUsername() ).password().post( Entity.class,payload );
refreshIndex();
@@ -520,7 +523,7 @@ public class AdminUsersIT extends AbstractRestIT {
//Make sure that we can't change the password with itself using a different entry in the history.
try {
- management().users().user( clientSetup.getUsername() ).password().post( payload );
+ management().users().user( clientSetup.getUsername() ).password().post( Entity.class,payload );
fail( "should fail with conflict" );
}
@@ -603,12 +606,12 @@ public class AdminUsersIT extends AbstractRestIT {
adminUserPayload.put( "password", username );
//post new admin user besides the default
- management().orgs().organization( clientSetup.getOrganizationName() ).users().post( adminUserPayload );
+ management().orgs().organization( clientSetup.getOrganizationName() ).users().post(ApiResponse.class ,adminUserPayload );
refreshIndex();
//Retrieves the admin users
- Entity adminUsers = management().orgs().organization( clientSetup.getOrganizationName() ).users().get();
+ Entity adminUsers = management().orgs().organization( clientSetup.getOrganizationName() ).users().get(Entity.class);
assertEquals("There need to be 2 admin users",2,( ( ArrayList ) adminUsers.getResponse().getData() ).size());
@@ -623,7 +626,8 @@ public class AdminUsersIT extends AbstractRestIT {
@Test
public void createOrgFromUserConnectionFail() throws Exception {
- Token token = management().token().post( new Token( clientSetup.getUsername(),clientSetup.getPassword() ) );
+ Token token = management().token().post(Token.class ,new Token( clientSetup.getUsername(),clientSetup.getPassword() ) );
+
// try to create the same org again off the connection
try {
management().users().user( clientSetup.getUsername() ).organizations().post( clientSetup.getOrganization(),token );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ee216065/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
index 52a095a..355c57a 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
@@ -139,7 +139,7 @@ public class ImportResourceIT extends AbstractRestIT {
.app()
.addToPath(app)
.addToPath("imports")
- .post(payload);
+ .post(Entity.class,payload);
assertNotNull(entity);
@@ -177,7 +177,7 @@ public class ImportResourceIT extends AbstractRestIT {
.app()
.addToPath(app)
.addToPath("imports")
- .post(payload);
+ .post(Entity.class,payload);
assertNotNull(entity);
@@ -200,7 +200,7 @@ public class ImportResourceIT extends AbstractRestIT {
//log into the new org/app and get a token
Token tokenPayload = new Token("password", newOrgUsername, newOrgPassword);
- Token newOrgToken = clientSetup.getRestClient().management().token().post(tokenPayload);
+ Token newOrgToken = clientSetup.getRestClient().management().token().post(Token.class,tokenPayload);
//save the old token and set the newly issued token as current
context().setToken(newOrgToken);
@@ -227,7 +227,7 @@ public class ImportResourceIT extends AbstractRestIT {
Entity payload = new Entity();
try {
- this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
+ this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
} catch (UniformInterfaceException uie) {
responseStatus = uie.getResponse().getClientResponseStatus();
}
@@ -246,7 +246,7 @@ public class ImportResourceIT extends AbstractRestIT {
properties.remove("storage_info");
try {
- this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
+ this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
} catch (UniformInterfaceException uie) {
responseStatus = uie.getResponse().getClientResponseStatus();
}
@@ -267,7 +267,7 @@ public class ImportResourceIT extends AbstractRestIT {
try {
- this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
+ this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
} catch (UniformInterfaceException uie) {
responseStatus = uie.getResponse().getClientResponseStatus();
}
@@ -289,7 +289,7 @@ public class ImportResourceIT extends AbstractRestIT {
storage_info.remove("s3_key");
try {
- this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
+ this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
} catch (UniformInterfaceException uie) {
responseStatus = uie.getResponse().getClientResponseStatus();
}
@@ -302,7 +302,7 @@ public class ImportResourceIT extends AbstractRestIT {
storage_info.remove("s3_access_id");
try {
- this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
+ this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
} catch (UniformInterfaceException uie) {
responseStatus = uie.getResponse().getClientResponseStatus();
}
@@ -315,7 +315,7 @@ public class ImportResourceIT extends AbstractRestIT {
storage_info.remove("bucket_location");
try {
- this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
+ this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
} catch (UniformInterfaceException uie) {
responseStatus = uie.getResponse().getClientResponseStatus();
}
@@ -626,7 +626,7 @@ public class ImportResourceIT extends AbstractRestIT {
}});
Entity importEntity = this.management().orgs().organization(org).app().addToPath(app).addToPath("imports")
- .post(importPayload);
+ .post(Entity.class,importPayload);
int maxRetries = 120;
int retries = 0;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ee216065/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 8cb079e..19a1b2e 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
@@ -73,7 +73,7 @@ public class OrganizationsIT extends AbstractRestIT {
//Creates token
Token token =
- clientSetup.getRestClient().management().token().post( new Token( "password",
+ clientSetup.getRestClient().management().token().post(Token.class, new Token( "password",
organization.getUsername(), organization.getPassword() ) );
assertNotNull( token );
@@ -109,7 +109,7 @@ 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( tokenPayload );
+ Token tokenReturned = clientSetup.getRestClient().management().token().post(Token.class, tokenPayload );
assertNotNull( tokenReturned );
@@ -131,7 +131,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( tokenPayload );
+ tokenError = clientSetup.getRestClient().management().token().post(Token.class, tokenPayload );
fail( "Should not have created user" );
}
catch ( UniformInterfaceException ex ) {
@@ -163,7 +163,7 @@ public class OrganizationsIT extends AbstractRestIT {
//get token from organization that was created to verify it exists.
Token tokenPayload = new Token( "password", organization.getUsername(), organization.getPassword() );
- Token tokenReturned = clientSetup.getRestClient().management().token().post( tokenPayload );
+ Token tokenReturned = clientSetup.getRestClient().management().token().post(Token.class, tokenPayload );
assertNotNull( tokenReturned );
@@ -186,7 +186,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( tokenPayload );
+ tokenError = clientSetup.getRestClient().management().token().post(Token.class, tokenPayload );
fail( "Should not have created organization" );
}
catch ( UniformInterfaceException ex ) {
@@ -225,7 +225,7 @@ 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( tokenPayload );
+ Token tokenReturned = clientSetup.getRestClient().management().token().post(Token.class, tokenPayload );
assertNotNull( tokenReturned );
@@ -263,7 +263,7 @@ 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( tokenPayload );
+ Token tokenReturned = clientSetup.getRestClient().management().token().post(Token.class, tokenPayload );
assertNotNull( tokenReturned );
@@ -310,7 +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(Entity.class, adminUserPayload );
//verify that the response contains the correct data
assertNotNull( adminUserResponse );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ee216065/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
index 379a359..d54d3b2 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
@@ -116,7 +116,8 @@ public class AdminEmailEncodingIT extends AbstractRestIT {
assertNotNull(organization);
//Retrieve an authorization token using the credentials created above
- Token tokenReturned = clientSetup.getRestClient().management().token().post(new Token("password", username, password));
+ Token tokenReturned = clientSetup.getRestClient().management().token()
+ .post(Token.class,new Token("password", username, password));
assertNotNull(tokenReturned);
//Instruct the test framework to use the new token
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ee216065/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 4e3b480..b1b8078 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
@@ -166,13 +166,13 @@ public class AbstractRestIT extends JerseyTest {
protected Token getAdminToken(String username, String password){
- return this.clientSetup.getRestClient().management().token().post(
+ return this.clientSetup.getRestClient().management().token().post(Token.class,
new Token(username, password)
);
}
protected Token getAdminToken(){
- return this.clientSetup.getRestClient().management().token().post(
+ return this.clientSetup.getRestClient().management().token().post(Token.class,
new Token(this.clientSetup.getUsername(),this.clientSetup.getUsername())
);
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ee216065/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 3455744..e68cee5 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
@@ -91,16 +91,18 @@ public class ClientSetup implements TestRule {
String name = testClass + "." + methodName;
restClient.superuserSetup();
- superuserToken = restClient.management().token().post( new Token( superuserName, superuserPassword ) );
+ superuserToken = restClient.management().token().post(Token.class, new Token( superuserName, superuserPassword ) );
username = "user_"+name + UUIDUtils.newTimeUUID();
password = username;
orgName = "org_"+name+UUIDUtils.newTimeUUID();
appName = "app_"+name+UUIDUtils.newTimeUUID();
- organization = restClient.management().orgs().post(new Organization( orgName,username,username+"@usergrid.com",username,username, null ));
+ organization = restClient.management().orgs()
+ .post(new Organization(
+ orgName,username,username+"@usergrid.com",username,username, null ));
- restClient.management().token().post(new Token(username,username));
+ Token token = restClient.management().token().post(Token.class,new Token(username,username));
restClient.management().orgs().organization(organization.getName()).app().post(new Application(appName));
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ee216065/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 bf5dbf0..c2d0cf3 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
@@ -17,10 +17,13 @@
package org.apache.usergrid.rest.test.resource2point0.endpoints;
+import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
import org.apache.usergrid.rest.test.resource2point0.model.Token;
import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
+import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.client.WebResource;
import java.util.HashMap;
@@ -29,6 +32,8 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import javax.ws.rs.core.MediaType;
+
/**
* Base class that is extended by named endpoints.
@@ -105,5 +110,68 @@ public abstract class NamedResource implements UrlResource {
return resource;
}
+ //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;
+
+ if(token != null) {
+ resource = getResource( true, token );
+ }
+ else
+ resource = getResource( true );
+
+ 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 requestEntity
+ * @param <T>
+ * @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);
+
+ }
+
+ //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());
+
+ }
+
+ //Get Resources
+// public Entity get() {
+// WebResource resource = getResource(true);
+//
+// ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE )
+// .accept( MediaType.APPLICATION_JSON ).get( ApiResponse.class);
+// return new Entity(response);
+// }
+
+ //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() );
+
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ee216065/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
index 6b7742f..be480f8 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
@@ -51,11 +51,11 @@ public class ApplicationResource extends NamedResource {
.accept(MediaType.APPLICATION_JSON).post(application);
}
- public Entity post(Entity payload){
- ApiResponse response = getResource(true).type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
- .post(ApiResponse.class, payload);
- return new Entity(response);
- }
+// public Entity post(Entity payload){
+// ApiResponse response = getResource(true).type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
+// .post(ApiResponse.class, payload);
+// return new Entity(response);
+// }
public Entity get() {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ee216065/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/PasswordResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/PasswordResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/PasswordResource.java
index c901022..c9e17ee 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/PasswordResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/PasswordResource.java
@@ -42,20 +42,4 @@ public class PasswordResource extends NamedResource {
super( "password", context, parent );
}
- public Entity post(Token token, Map<String,Object> payload){
- WebResource resource;
-
- if(token != null) {
- resource = getResource( true, token );
- }
- else
- resource = getResource( true );
-
- return resource.type( MediaType.APPLICATION_JSON_TYPE )
- .accept( MediaType.APPLICATION_JSON ).post( Entity.class, payload );
- }
-
- public Entity post(Map<String, Object> payload){
- return post( null, payload );
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ee216065/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/TokenResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/TokenResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/TokenResource.java
index cb4d286..cdd6663 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/TokenResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/TokenResource.java
@@ -35,19 +35,6 @@ public class TokenResource extends NamedResource {
super("token", context, parent);
}
-
- /**
- * Obtains an access token and sets the token for the context to use in later calls
- *
- * @return
- */
- public Token post() {
- Token token = getResource().type(MediaType.APPLICATION_JSON_TYPE)
- .accept(MediaType.APPLICATION_JSON).post(Token.class);
- this.context.setToken(token);
- return token;
- }
-
/**
* Obtains an access token and sets the token for the context to use in later calls
*
@@ -63,20 +50,6 @@ public class TokenResource extends NamedResource {
return token;
}
- /**
- * Obtains an access token and sets the token for the context to use in later calls
- *
- * @param token
- * @return
- */
- public Token post(Token token) {
- token = getResource().type(MediaType.APPLICATION_JSON_TYPE)
- .accept(MediaType.APPLICATION_JSON).post(Token.class, token);
- this.context.setToken(token);
- return token;
- }
-
-
public TokenResource setToken(Token token) {
this.context.setToken(token);
return this;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ee216065/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/UsersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/UsersResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/UsersResource.java
index e62d5aa..18ba7d5 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/UsersResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/UsersResource.java
@@ -54,19 +54,4 @@ public class UsersResource extends NamedResource {
return new UserResource( identifier, context, this );
}
- public Entity post(Entity userPayload){
- WebResource resource = getResource(true);
-
- ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE )
- .accept( MediaType.APPLICATION_JSON ).post( ApiResponse.class, userPayload);
- return new Entity(response);
- }
-
- public Entity get() {
- WebResource resource = getResource(true);
-
- ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE )
- .accept( MediaType.APPLICATION_JSON ).get( ApiResponse.class);
- return new Entity(response);
- }
}