From ee2160657510012d3c31cfa794f70747d4023808 Mon Sep 17 00:00:00 2001 From: GERey Date: Wed, 18 Mar 2015 16:56:07 -0700 Subject: [PATCH] Got generics working, but before is still broken. Starting refactor of rest test framework. --- .../applications/ApplicationResourceIT.java | 2 +- .../collection/users/UserResourceIT.java | 4 +- .../rest/management/AdminUsersIT.java | 40 ++++++----- .../rest/management/ImportResourceIT.java | 20 +++--- .../rest/management/OrganizationsIT.java | 16 ++--- .../organizations/AdminEmailEncodingIT.java | 3 +- .../test/resource2point0/AbstractRestIT.java | 4 +- .../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(-) 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 3b4a0b66a5..5e40037d12 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 void clientCredentialsFlowWithHeaderAuthorization() throws Exception { 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) 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 8761dd3c0e..1901c398af 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 void revokeToken() throws Exception { 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 void revokeToken() throws Exception { 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(); 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 fffb28ad86..973ed7d8a9 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 void setSelfAdminPasswordAsAdmin() throws IOException { 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 void passwordMismatchErrorAdmin() { 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 void setAdminPasswordAsSysAdmin() throws IOException { 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 void testSystemAdminNeedsNoConfirmation() throws Exception{ 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 void testTestUserNeedsNoConfirmation() throws Exception{ 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 void reactivateTest() throws Exception { 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 inbox = Mailbox.get( clientSetup.getEmail() ); @@ -501,7 +504,7 @@ public void checkPasswordHistoryConflict() throws Exception { //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 void checkPasswordHistoryConflict() throws Exception { //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 void checkPasswordHistoryConflict() throws Exception { //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 void listOrgUsersByName() { 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 void listOrgUsersByName() { @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 ); 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 52a095aaf2..355c57ae90 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 void importGetCollectionJobStatTest() throws Exception { .app() .addToPath(app) .addToPath("imports") - .post(payload); + .post(Entity.class,payload); assertNotNull(entity); @@ -177,7 +177,7 @@ public void importTokenAuthorizationTest() throws Exception { .app() .addToPath(app) .addToPath("imports") - .post(payload); + .post(Entity.class,payload); assertNotNull(entity); @@ -200,7 +200,7 @@ public void importTokenAuthorizationTest() throws Exception { //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 void importPostApplicationNullPointerProperties() throws Exception { 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 void importPostApplicationNullPointerStorageInfo() throws Exception { 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 void importPostApplicationNullPointerStorageProvider() throws Exception { 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 void importPostApplicationNullPointerStorageVerification() throws Excepti 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 void importPostApplicationNullPointerStorageVerification() throws Excepti 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 void importPostApplicationNullPointerStorageVerification() throws Excepti 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 @@ private Entity importCollection() throws Exception { }}); Entity importEntity = this.management().orgs().organization(org).app().addToPath(app).addToPath("imports") - .post(importPayload); + .post(Entity.class,importPayload); int maxRetries = 120; int retries = 0; 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 8cb079ed60..19a1b2e915 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 void createOrgAndOwner() throws Exception { //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 void testCreateDuplicateOrgName() throws Exception { //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 void testCreateDuplicateOrgName() throws Exception { 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 void testCreateDuplicateOrgEmail() throws Exception { //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 void testCreateDuplicateOrgEmail() throws Exception { 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 void testOrgPOSTParams() throws IOException { //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 void testOrgPOSTForm() throws IOException { //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 void testCreateOrgUserAndReturnCorrectUsername() throws Exception { 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 ); 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 379a359567..d54d3b28d1 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 @@ private void doTest(String symbol) throws UniformInterfaceException { 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 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 4e3b480e56..b1b80781d2 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 void errorParse(int expectedStatus, String expectedErrorMessage, UniformI 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()) ); } 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 3455744ae3..e68cee56bd 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 @@ protected void before( Description description ) throws IOException { 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)); 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 bf5dbf0a42..c2d0cf36bc 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.Set; import java.util.UUID; +import javax.ws.rs.core.MediaType; + /** * Base class that is extended by named endpoints. @@ -105,5 +110,68 @@ protected WebResource addParametersToResource(WebResource resource, final QueryP return resource; } + //Post Resources + public Entity postResource(WebResource resource, Map 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 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 + * @return + */ + //For edge cases like Organizations and Tokens + public T post(Class type, Object requestEntity) { + GenericType 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 post(Class type) { + GenericType 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 get(Class type) { + GenericType gt = new GenericType<>((Class) type); + return getResource( true ).type(MediaType.APPLICATION_JSON_TYPE) + .accept( MediaType.APPLICATION_JSON ) + .get( gt.getRawClass() ); + + } } 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 6b7742f955..be480f81dd 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 void post(Application application) { .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() { 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 c9010226bf..c9e17ee168 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 PasswordResource( final ClientContext context, final UrlResource parent ) super( "password", context, parent ); } - public Entity post(Token token, Map 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 payload){ - return post( null, payload ); - } } 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 cb4d286858..cdd6663769 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 TokenResource(final ClientContext context, final UrlResource parent) { 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 Token get(QueryParameters params) { 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; 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 e62d5aa3bb..18ba7d5e3f 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 UserResource user(String identifier) { 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); - } }