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 2014/12/17 01:17:27 UTC

incubator-usergrid git commit: Deleted RestResource as now it is obsolete due to generics. Fixed some test errors in organization and added way to add query params along with form calls. Added method called errorParse that checks the error message for th

Repository: incubator-usergrid
Updated Branches:
  refs/heads/UG-rest-test-framework-overhaul 9084e3653 -> 0305a6160


Deleted RestResource as now it is obsolete due to generics.
Fixed some test errors in organization and added way to add query params along with form calls.
Added method called errorParse that checks the error message for the value, should be made general so that different error codes can be returned.
Fixed addParametersToResource due to the fact that java is pass by value.
Added way to add form data to the QueryParameters


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

Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 0305a6160506428b416291f49172e14af37adb29
Parents: 9084e36
Author: grey <gr...@apigee.com>
Authored: Tue Dec 16 16:17:16 2014 -0800
Committer: grey <gr...@apigee.com>
Committed: Tue Dec 16 16:17:16 2014 -0800

----------------------------------------------------------------------
 .../rest/management/OrganizationsIT.java        | 263 +++++++++----------
 .../test/resource2point0/AbstractRestIT.java    |  12 +
 .../endpoints/NamedResource.java                |  28 +-
 .../resource2point0/endpoints/RestResource.java |  59 -----
 .../endpoints/mgmt/OrgResource.java             |  44 +++-
 .../endpoints/mgmt/OrganizationResource.java    |  12 +
 .../resource2point0/model/QueryParameters.java  |  16 ++
 7 files changed, 236 insertions(+), 198 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0305a616/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 7d576a9..cf94c04 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
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-//jnote to self, remaining test failures are due to duplicate org names in the cassandra external. Easily fixed.
 package org.apache.usergrid.rest.management;
 
 
@@ -40,6 +39,12 @@ import org.apache.usergrid.rest.TestContextSetup;
 import org.apache.usergrid.rest.management.organizations.OrganizationsResource;
 import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
 
+import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
+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.fasterxml.jackson.databind.JsonNode;
 import com.sun.jersey.api.client.ClientResponse;
 import com.sun.jersey.api.client.UniformInterfaceException;
@@ -47,25 +52,26 @@ import com.sun.jersey.api.representation.Form;
 
 import junit.framework.Assert;
 
-import static junit.framework.Assert.fail;
 import static org.apache.usergrid.utils.MapUtils.hashMap;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 
 /**
- * Created by ApigeeCorporation on 9/17/14.
+ * Handles all management organization endpoint tests. Any tests that work with organizations specifically can be found here
  */
 public class OrganizationsIT extends AbstractRestIT {
     private static final Logger LOG = LoggerFactory.getLogger( OrganizationsIT.class );
 
+    String duplicateUniquePropertyExistsErrorMessage = "duplicate_unique_property_exists";
+    String invalidGrantErrorMessage = "invalid_grant";
 
     /**
      * Tests that a Organization and Owner can be created and that they persist properties and default permissions.
      */
-
     @Test
     public void createOrgAndOwner() throws Exception {
 
@@ -114,14 +120,12 @@ public class OrganizationsIT extends AbstractRestIT {
     @Test
     public void testCreateDuplicateOrgName() throws Exception {
 
-        // create organization with name
         String username = "testCreateDuplicateOrgName" + UUIDUtils.newTimeUUID();
         String name = username;
         String password = "password";
         String orgName = username;
         String email = username + "@usergrid.com";
 
-
         //Create organization
         Organization orgPayload = new Organization( orgName, username, email, name, password, null );
 
@@ -137,14 +141,15 @@ public class OrganizationsIT extends AbstractRestIT {
         Organization orgTestDuplicateResponse = null;
         try {
             orgTestDuplicateResponse = clientSetup.getRestClient().management().orgs().post( orgTestDuplicatePayload );
+            fail("Should not have been able to create duplicate organization");
         }
-        catch ( Exception ex ) {
-            //TODO: add a check here to make sure proper error message was returned
+        catch ( UniformInterfaceException ex ) {
+            errorParse( 400,duplicateUniquePropertyExistsErrorMessage, ex );
         }
 
         //refreshIndex( "create-duplicate-orgname-org" + timeuuid, "dummy" );
 
-        // now attempt to login as the user for the second organization
+        // Post to get token of what should be a non existent user.
 
         Token tokenPayload = new Token( "password", username + "test", password );
         Token tokenError = null;
@@ -153,8 +158,61 @@ public class OrganizationsIT extends AbstractRestIT {
             fail( "Should not have created user" );
         }
         catch ( UniformInterfaceException ex ) {
+            errorParse( 400,invalidGrantErrorMessage, ex );
+
+        }
+
+        assertNull( tokenError );
+
+        tokenPayload = new Token( "password", username, password );
+        Token tokenReturned = clientSetup.getRestClient().management().token().post( tokenPayload );
+
+        assertNotNull( tokenReturned );
+    }
+
+
+    /**
+     * Tests creation of an organization with a duplicate email. Then checks to make sure correct
+     * error message is thrown. Also makes sure that the owner of the duplicate org isn't created
+     * while the original is still intact.
+     * @throws Exception
+     */
+    @Test
+    public void testCreateDuplicateOrgEmail() throws Exception {
+
+        String username = "testCreateDuplicateOrgEmail" + UUIDUtils.newTimeUUID();
+        String name = username;
+        String password = "password";
+        String orgName = username;
+        String email = username + "@usergrid.com";
+
+        Organization orgPayload = new Organization( orgName, username, email, name, password, null );
+
+        Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post( orgPayload );
+
+        assertNotNull( orgCreatedResponse );
+
+        orgPayload = new Organization( orgName+"test", username+"test", email, name+"test", password+"test", null );
+
+        try {
+            clientSetup.getRestClient().management().orgs().post( orgPayload );
+            fail( "Should not have created organization" );
+        }
+        catch ( UniformInterfaceException ex ) {
+            errorParse( 400,duplicateUniquePropertyExistsErrorMessage,ex);
+        }
+
+        //refreshIndex( "test-organization", "test-app" );
+
+        Token tokenPayload = new Token( "password", username + "test", password );
+        Token tokenError = null;
+        try {
+            tokenError = clientSetup.getRestClient().management().token().post( tokenPayload );
+            fail( "Should not have created organization" );
+        }
+        catch ( UniformInterfaceException ex ) {
             //TODO: Should throw a 404 not a 400.
-            System.out.println();
+            errorParse( 400,invalidGrantErrorMessage,ex );
         }
 
         assertNull( tokenError );
@@ -164,128 +222,69 @@ public class OrganizationsIT extends AbstractRestIT {
 
         assertNotNull( tokenReturned );
     }
-//
-//
-//    @Test
-//    public void testCreateDuplicateOrgEmail() throws Exception {
-//
-//        String timeUuid = UUIDUtils.newTimeUUID().toString();
-//        Map<String, String> payload =
-//                hashMap( "email", "duplicate-email" + timeUuid + "@mockserver.com" ).map( "password", "password" )
-//                                                                                    .map( "organization",
-//                                                                                            "very-nice-org"
-//                                                                                                    + timeUuid );
-//
-//        JsonNode node = mapper.readTree(
-//                resource().path( "/management/organizations" ).accept( MediaType.APPLICATION_JSON )
-//                          .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ) );
-//
-//        logNode( node );
-//        assertNotNull( node );
-//
-//        payload = hashMap( "email", "duplicate-email" + timeUuid + "@mockserver.com" ).map( "username", "anotheruser" )
-//                                                                                      .map( "password", "password" )
-//                                                                                      .map( "organization",
-//                                                                                              "not-so-nice-org"
-//                                                                                                      + timeUuid );
-//
-//        boolean failed = false;
-//        try {
-//            node = mapper.readTree( resource().path( "/management/organizations" ).accept( MediaType.APPLICATION_JSON )
-//                                              .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ) );
-//        }
-//        catch ( UniformInterfaceException ex ) {
-//            Assert.assertEquals( 400, ex.getResponse().getStatus() );
-//            JsonNode errorJson = ex.getResponse().getEntity( JsonNode.class );
-//            Assert.assertEquals( "duplicate_unique_property_exists", errorJson.get( "error" ).asText() );
-//            failed = true;
-//        }
-//        Assert.assertTrue( failed );
-//
-//        refreshIndex( "test-organization", "test-app" );
-//
-//        payload = hashMap( "grant_type", "password" ).map( "username", "create-dupe-orgname2" )
-//                                                     .map( "password", "password" );
-//        try {
-//            node = mapper.readTree( resource().path( "/management/token" ).accept( MediaType.APPLICATION_JSON )
-//                                              .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ) );
-//            fail( "Should not have created user" );
-//        }
-//        catch ( Exception ex ) {
-//        }
-//
-//        logNode( node );
-//
-//        refreshIndex( "test-organization", "test-app" );
-//
-//        payload =
-//                hashMap( "username", "duplicate-email" + timeUuid + "@mockserver.com" ).map( "grant_type", "password" )
-//                                                                                       .map( "password", "password" );
-//        node = mapper.readTree( resource().path( "/management/token" ).accept( MediaType.APPLICATION_JSON )
-//                                          .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ) );
-//        logNode( node );
-//    }
-//
-//
-//    @Test
-//    public void testOrgPOSTParams() throws IOException {
-//        UUID timeUuid = UUIDUtils.newTimeUUID();
-//        JsonNode node = mapper.readTree( resource().path( "/management/organizations" )
-//                                                   .queryParam( "organization", "testOrgPOSTParams" + timeUuid )
-//                                                   .queryParam( "username", "testOrgPOSTParams" + timeUuid )
-//                                                   .queryParam( "grant_type", "password" ).queryParam( "email",
-//                        "testOrgPOSTParams" + timeUuid + "@apigee.com" + timeUuid )
-//                                                   .queryParam( "name", "testOrgPOSTParams" )
-//                                                   .queryParam( "password", "password" )
-//
-//                                                   .accept( MediaType.APPLICATION_JSON )
-//                                                   .type( MediaType.APPLICATION_FORM_URLENCODED )
-//                                                   .post( String.class ) );
-//
-//        assertEquals( "ok", node.get( "status" ).asText() );
-//    }
-//
-//
-//    @Test
-//    public void testOrgPOSTForm() throws IOException {
-//
-//        UUID timeUuid = UUIDUtils.newTimeUUID();
-//        Form form = new Form();
-//        form.add( "organization", "testOrgPOSTForm" + timeUuid );
-//        form.add( "username", "testOrgPOSTForm" + timeUuid );
-//        form.add( "grant_type", "password" );
-//        form.add( "email", "testOrgPOSTForm" + timeUuid + "@apigee.com" );
-//        form.add( "name", "testOrgPOSTForm" );
-//        form.add( "password", "password" );
-//
-//        JsonNode node = mapper.readTree(
-//                resource().path( "/management/organizations" ).accept( MediaType.APPLICATION_JSON )
-//                          .type( MediaType.APPLICATION_FORM_URLENCODED ).post( String.class, form ) );
-//
-//        assertEquals( "ok", node.get( "status" ).asText() );
-//    }
-//
-//
-//    @Test
-//    public void noOrgDelete() throws IOException {
-//
-//
-//        String mgmtToken = context.getActiveUser().getToken();
-//
-//        ClientResponse.Status status = null;
-//        JsonNode node = null;
-//
-//        try {
-//            node = mapper.readTree( resource().path( context.getOrgName() ).queryParam( "access_token", mgmtToken )
-//                                              .accept( MediaType.APPLICATION_JSON )
-//                                              .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class ) );
-//        }
-//        catch ( UniformInterfaceException uie ) {
-//            status = uie.getResponse().getClientResponseStatus();
-//        }
-//
-//        assertEquals( ClientResponse.Status.NOT_IMPLEMENTED, status );
-//    }
+
+
+    //TODO:
+    @Test
+    public void testOrgPOSTParams() throws IOException {
+
+        String username = "testCreateDuplicateOrgEmail" + UUIDUtils.newTimeUUID();
+        String name = username;
+        String password = "password";
+        String orgName = username;
+        String email = username + "@usergrid.com";
+
+        UUID timeUuid = UUIDUtils.newTimeUUID();
+
+        QueryParameters queryParameters = new QueryParameters();
+        queryParameters.setKeyValue( "organization",orgName );
+        queryParameters.setKeyValue( "username",username );
+        queryParameters.setKeyValue( "grant_type",password );
+        queryParameters.setKeyValue( "email",email  );
+        queryParameters.setKeyValue( "name",name );
+        queryParameters.setKeyValue( "password",password );
+
+        Organization organization = clientSetup.getRestClient().management().orgs().post( queryParameters );
+
+        assertNotNull( organization );
+        assertEquals( orgName,organization.getName() );
+    }
+
+    @Test
+    public void testOrgPOSTForm() throws IOException {
+
+        UUID timeUuid = UUIDUtils.newTimeUUID();
+        Form form = new Form();
+        form.add( "organization", "testOrgPOSTForm" + timeUuid );
+        form.add( "username", "testOrgPOSTForm" + timeUuid );
+        form.add( "grant_type", "password" );
+        form.add( "email", "testOrgPOSTForm" + timeUuid + "@apigee.com" );
+        form.add( "name", "testOrgPOSTForm" );
+        form.add( "password", "password" );
+
+        Organization organization = clientSetup.getRestClient().management().orgs().post( form );
+
+        assertNotNull( organization );
+        assertEquals( "testOrgPOSTForm" + timeUuid ,organization.getName() );
+    }
+
+
+    /**
+     * Returns error from unimplemented delete method
+     * @throws IOException
+     */
+    @Test
+    public void noOrgDelete() throws IOException {
+
+        try {
+            clientSetup.getRestClient().management().orgs().organization( clientSetup.getOrganizationName() ).delete();
+            fail( "Delete is not implemented yet" );
+        }catch(UniformInterfaceException uie){
+            assertEquals(500,uie.getResponse().getStatus());
+           // assertEquals( ClientResponse.Status.NOT_IMPLEMENTED ,uie.getResponse().getStatus());
+        }
+
+    }
 //
 //
 //    @Test

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0305a616/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 be99a13..4bc35d7 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
@@ -31,6 +31,8 @@ import org.apache.usergrid.java.client.Client;
 import org.apache.usergrid.rest.ITSetup;
 import org.apache.usergrid.rest.RestITSuite;
 
+import com.fasterxml.jackson.databind.JsonNode;
+import com.sun.jersey.api.client.UniformInterfaceException;
 import com.sun.jersey.api.client.config.ClientConfig;
 import com.sun.jersey.api.client.config.DefaultClientConfig;
 import com.sun.jersey.api.json.JSONConfiguration;
@@ -39,6 +41,9 @@ import com.sun.jersey.test.framework.JerseyTest;
 import com.sun.jersey.test.framework.WebAppDescriptor;
 import com.sun.jersey.test.framework.spi.container.TestContainerFactory;
 
+import static org.junit.Assert.assertEquals;
+
+
 
 /**
  * How would we get the client from here
@@ -110,4 +115,11 @@ public class AbstractRestIT extends JerseyTest {
         return getApplicationResource();
     }
 
+
+    public void errorParse(Integer expectedStatus, String expectedErrorMessage, UniformInterfaceException uie){
+        assertEquals((Integer)400,expectedStatus);
+        JsonNode errorJson = uie.getResponse().getEntity( JsonNode.class );
+        assertEquals( expectedErrorMessage, errorJson.get( "error" ).asText() );
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0305a616/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 641aec9..d0dd079 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
@@ -22,6 +22,10 @@ import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
 
 import com.sun.jersey.api.client.WebResource;
 
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
 import java.util.UUID;
 
 
@@ -61,24 +65,38 @@ public class NamedResource implements UrlResource {
         return useToken ? resource.queryParam("access_token",this.context.getToken().getAccessToken()) :  parent.getResource().path( getPath() );
     }
 
-    protected WebResource addParametersToResource(final WebResource resource, final QueryParameters parameters){
+    protected WebResource addParametersToResource(WebResource resource, final QueryParameters parameters){
+
         if(parameters == null){
             return resource;
         }
         if ( parameters.getQuery() != null ) {
-            resource.queryParam( "ql", parameters.getQuery() );
+            resource = resource.queryParam( "ql", parameters.getQuery() );
         }
 
         if ( parameters.getCursor() != null ) {
-           resource.queryParam( "cursor", parameters.getCursor() );
+           resource = resource.queryParam( "cursor", parameters.getCursor() );
         }
 
         if ( parameters.getStart() != null ) {
-            resource.queryParam("start", parameters.getStart().toString());
+            resource = resource.queryParam("start", parameters.getStart().toString());
         }
 
         if ( parameters.getLimit() != null ) {
-             resource.queryParam("limit", parameters.getLimit().toString());
+             resource = resource.queryParam("limit", parameters.getLimit().toString());
+        }
+        //We can also post the params as queries
+        if ( parameters.getFormPostData().size() > 0){
+            Map<String,String> formData = parameters.getFormPostData();
+            Set<String> keySet = formData.keySet();
+            Iterator<String> keyIterator = keySet.iterator();
+
+
+            while(keyIterator.hasNext()){
+                String key = keyIterator.next();
+                String value = formData.get( key );
+                resource = resource.queryParam( key, value );
+            }
         }
         return resource;
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0305a616/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/RestResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/RestResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/RestResource.java
deleted file mode 100644
index f20868c..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/RestResource.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.usergrid.rest.test.resource2point0.endpoints;
-
-
-import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
-import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
-
-import com.sun.jersey.api.client.WebResource;
-
-
-/**
- * Class that would hold all the rest calls that are duplicated ( such as posts, or puts where all we have to do
- * is send a map through jersey.
- */
-public class RestResource extends NamedResource {
-
-    //TODO: wouldn't need a name, so maybe it isn't a NamedResource but just a URL Resource.
-    public RestResource( final ClientContext context, final UrlResource parent ) {
-        super("name",context, parent );
-    }
-
-    public ApiResponse post(){
-        return null;
-    }
-
-    public ApiResponse put(){
-        return null;
-
-    }
-
-    public ApiResponse get(){
-        return null;
-
-    }
-
-    public ApiResponse delete(){
-        return null;
-
-    }
-
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0305a616/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrgResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrgResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrgResource.java
index 4c7dc46..5c39005 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrgResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrgResource.java
@@ -23,17 +23,23 @@ import org.apache.usergrid.rest.test.resource2point0.endpoints.NamedResource;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.UrlResource;
 import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
 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.User;
 import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
 
+import com.fasterxml.jackson.databind.JsonNode;
+import com.sun.jersey.api.client.UniformInterfaceException;
+import com.sun.jersey.api.client.WebResource;
 
+import com.sun.jersey.api.representation.Form;
+
+
+//TODO: add error checking to each of the rest calls.
 /**
  * Manages the Management/ORG endpoint.
  */
 public class OrgResource  extends NamedResource {
 
-    //TODO: need to find a way to integrate having the orgs/<org_name> into the same endpoint.
-    //maybe I could append the orgs to the end of the parent
     public OrgResource( final ClientContext context, final UrlResource parent ) {
         super( "orgs", context, parent );
     }
@@ -43,6 +49,39 @@ public class OrgResource  extends NamedResource {
         return new OrganizationResource( orgname,context,this );
     }
 
+    /**
+     * This post is for the POST params case, where the entire call is made using queryParameters
+     * @return
+     */
+    public Organization post(Form form){
+        //Seems like an apiresponse can't handle what gets returned from the from urlended media type
+
+        ApiResponse response = getResource().type( MediaType.APPLICATION_FORM_URLENCODED )
+                                       .accept( MediaType.APPLICATION_JSON ).post( ApiResponse.class, form );
+
+
+        Organization organization = new Organization(response);
+        organization.setOwner(new User( response ));
+        return organization;
+    }
+
+    /**
+     * This post is for the POST params case, where the entire call is made using queryParameters
+     * @return
+     */
+    public Organization post(QueryParameters parameters){
+        //Seems like an apiresponse can't handle what gets returned from the from urlended media type
+        WebResource resource = addParametersToResource( getResource(), parameters);
+
+            ApiResponse response = resource.type( MediaType.APPLICATION_FORM_URLENCODED )
+                                        .accept( MediaType.APPLICATION_JSON ).post( ApiResponse.class );
+
+
+        Organization organization = new Organization(response);
+        organization.setOwner(new User( response ));
+        return organization;
+    }
+
     public Organization post(Organization organization){
         ApiResponse response = getResource().type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
                      .post( ApiResponse.class,organization );
@@ -69,4 +108,5 @@ public class OrgResource  extends NamedResource {
                 .delete(ApiResponse.class);
 
     }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0305a616/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
index 96ec55c..ac74142 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
@@ -47,6 +47,18 @@ public class OrganizationResource extends NamedResource {
         return org;
     }
 
+
+    /**
+     * This has not been implemented and will return an error.
+     * @return
+     */
+    public Organization delete(){
+        Map<String,Object> response = getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
+                                                       .accept(MediaType.APPLICATION_JSON).delete(Organization.class);
+        Organization org =  new Organization().mapOrgResponse(response);
+        return org;
+    }
+
     public ApplicationResource app(){
         return new ApplicationResource(  context ,this );
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0305a616/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/QueryParameters.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/QueryParameters.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/QueryParameters.java
index f2a8e12..0c11fdd 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/QueryParameters.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/QueryParameters.java
@@ -20,8 +20,13 @@
 
 package org.apache.usergrid.rest.test.resource2point0.model;
 
+import java.util.HashMap;
+import java.util.Map;
 import java.util.UUID;
 
+import org.apache.usergrid.services.ServiceParameter;
+
+
 /**
  * Classy class class.
  */
@@ -30,6 +35,7 @@ public class QueryParameters {
     private String cursor;
     private UUID start;
     private Integer limit;
+    private Map<String,String> formPostData = new HashMap<String,String>(  );
 
     public QueryParameters() {
     }
@@ -70,4 +76,14 @@ public class QueryParameters {
         return this;
     }
 
+    public Map<String,String> getFormPostData(){
+        return formPostData;
+    }
+
+    public QueryParameters setKeyValue(String key, String value){
+        this.formPostData.put(key,value);
+        return this;
+    }
+
+
 }