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/13 01:18:18 UTC

incubator-usergrid git commit: Commented almost all of OrganizationIT to start trying to address one test at a time. Added field for properties in our Organization model but currently not differentiated from regular properties and organization properties

Repository: incubator-usergrid
Updated Branches:
  refs/heads/UG-rest-test-framework-overhaul 64d9b8159 -> 4efb625f4


Commented almost all of OrganizationIT to start trying to address one test at a time.
Added field for properties in our Organization model but currently not differentiated from regular properties and organization properties.
Removed some of the cruft from the dumbClientTest class.
Had the organization that gets sent in via post, create another organization object and a user object.
Created User object that is based off of the Entity class so that we can query User specific things that get returned from the ApiResponse.


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

Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 4efb625f4f7a832bd6b6f478c7523f34df2919a7
Parents: 64d9b81
Author: grey <gr...@apigee.com>
Authored: Fri Dec 12 16:18:15 2014 -0800
Committer: grey <gr...@apigee.com>
Committed: Fri Dec 12 16:18:15 2014 -0800

----------------------------------------------------------------------
 .../rest/management/OrganizationsIT.java        | 600 ++++++++++---------
 .../rest/test/resource2point0/ClientSetup.java  |   2 +-
 .../rest/test/resource2point0/DumbClient.java   |  13 +-
 .../endpoints/mgmt/OrgResource.java             |  22 +-
 .../rest/test/resource2point0/model/Entity.java |   6 +-
 .../resource2point0/model/Organization.java     |  26 +-
 .../rest/test/resource2point0/model/User.java   |  89 ++-
 7 files changed, 374 insertions(+), 384 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4efb625f/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 e3bcd2d..4cfebd9 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
@@ -35,9 +35,10 @@ import org.slf4j.LoggerFactory;
 import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.entities.User;
 import org.apache.usergrid.persistence.index.utils.UUIDUtils;
-import org.apache.usergrid.rest.AbstractRestIT;
 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.Organization;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import com.sun.jersey.api.client.ClientResponse;
@@ -66,7 +67,7 @@ public class OrganizationsIT extends AbstractRestIT {
     @Test
     public void createOrgAndOwner() throws Exception {
 
-        context.management().tokenGet( context.getActiveUser().getUser(), context.getActiveUser().getPassword() );
+//        context.management().tokenGet( context.getActiveUser().getUser(), context.getActiveUser().getPassword() );
         String username = "createOrgAndOwner" + UUIDUtils.newTimeUUID();
         String name = username;
         String password = "password";
@@ -75,301 +76,306 @@ public class OrganizationsIT extends AbstractRestIT {
 
         Map<String, Object> organizationProperties = new HashMap<String, Object>();
         organizationProperties.put( "securityLevel", 5 );
-
-        Map payload =
-                hashMap( "email", email ).map( "username", username ).map( "name", name ).map( "password", password )
-                                         .map( "organization", orgName ).map( "company", "Apigee" );
-
-        Map payload2 = hashMap( "grant_type", "password" ).map( "username", username ).map( "password", password );
-        payload.put( OrganizationsResource.ORGANIZATION_PROPERTIES, organizationProperties );
-
-        JsonNode node = mapper.readTree(
-                resource().path( "/management/organizations" ).accept( MediaType.APPLICATION_JSON )
-                          .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ) );
-
-        UUID userUuid = UUID.fromString( node.get( "data" ).get( "owner" ).get( "uuid" ).asText() );
-
-        node = mapper.readTree( resource().path( "/management/token" ).accept( MediaType.APPLICATION_JSON )
-                                          .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload2 ) );
-
-        //assertNotNull( node );
-
-        node = mapper.readTree( resource().path( "/management/organizations/" + orgName + "/apps/sandbox" )
-                                          .queryParam( "access_token", node.get( "access_token" ).textValue() )
-                                          .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                                          .get( String.class ) );
-
-        assertNotNull( node );
-
-        Set<String> rolePerms = setup.getEmf().getEntityManager(
-                UUID.fromString( node.get( "entities" ).get( 0 ).get( "uuid" ).asText() ) )
-                                     .getRolePermissions( "guest" );
-        assertNotNull( rolePerms );
-        assertTrue( rolePerms.contains( "get,post,put,delete:/**" ) );
-        logNode( node );
-
-        EntityManager em = setup.getEmf().getEntityManager( setup.getEmf().getManagementAppId() );
-        User user = em.get( userUuid, User.class );
-        assertEquals( name, user.getName() );
-        assertEquals( "Apigee", user.getProperty( "company" ) );
-    }
-
-
-    @Test
-    public void testCreateDuplicateOrgName() throws Exception {
-
-        // create organization with name
-        String timeuuid = UUIDUtils.newTimeUUID().toString();
-        Map<String, String> payload =
-                hashMap( "email", "create-duplicate-org" + timeuuid + "@mockserver.com" ).map( "password", "password" )
-                                                                                         .map( "organization",
-                                                                                                 "create-duplicate-orgname-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 );
-
-        refreshIndex( "create-duplicate-orgname-org" + timeuuid, "dummy" );
-
-        // create another org with that same name, but a different user
-        payload = hashMap( "email", "create-duplicate-org2@mockserver.com" ).map( "username", "create-dupe-orgname2" )
-                                                                            .map( "password", "password" )
-                                                                            .map( "organization",
-                                                                                    "create-duplicate-orgname-org"
-                                                                                            + timeuuid );
-        try {
-            node = mapper.readTree( resource().path( "/management/organizations" ).accept( MediaType.APPLICATION_JSON )
-                                              .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ) );
-        }
-        catch ( Exception ex ) {
-        }
-
-        refreshIndex( "create-duplicate-orgname-org" + timeuuid, "dummy" );
-
-        // now attempt to login as the user for the second organization
-        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( "create-duplicate-orgname-org" + timeuuid, "dummy" );
-
-        payload = hashMap( "username", "create-duplicate-org@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 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() );
+        organizationProperties.put( "company", "Apigee" );
+
+
+        Organization organization = new Organization(orgName,username,email,name,password,organizationProperties);
+        //TODO:seperate entity properties from organization properties.
+        //organization.addProperty( "" ).addProperty(  )
+
+        organization = clientSetup.getRestClient().management().orgs().post( organization );
+
+
+//        Map payload =
+//                hashMap( "email", email ).map( "username", username ).map( "name", name ).map( "password", password )
+//                                         .map( "organization", orgName ).map( "company", "Apigee" );
+
+//        Map payload2 = hashMap( "grant_type", "password" ).map( "username", username ).map( "password", password );
+//
+//        //TODO: make it easier to distinguish between owner/entity/response uuid.
+//        UUID userUuid = UUID.fromString( node.get( "data" ).get( "owner" ).get( "uuid" ).asText() );
+//
+//        node = mapper.readTree( resource().path( "/management/token" ).accept( MediaType.APPLICATION_JSON )
+//                                          .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload2 ) );
+//
+//        //assertNotNull( node );
+//
+//        node = mapper.readTree( resource().path( "/management/organizations/" + orgName + "/apps/sandbox" )
+//                                          .queryParam( "access_token", node.get( "access_token" ).textValue() )
+//                                          .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+//                                          .get( String.class ) );
+//
+//        assertNotNull( node );
+//
+//        Set<String> rolePerms = setup.getEmf().getEntityManager(
+//                UUID.fromString( node.get( "entities" ).get( 0 ).get( "uuid" ).asText() ) )
+//                                     .getRolePermissions( "guest" );
+//        assertNotNull( rolePerms );
+//        assertTrue( rolePerms.contains( "get,post,put,delete:/**" ) );
+//        logNode( node );
+//
+//        EntityManager em = setup.getEmf().getEntityManager( setup.getEmf().getManagementAppId() );
+//        User user = em.get( userUuid, User.class );
+//        assertEquals( name, user.getName() );
+//        assertEquals( "Apigee", user.getProperty( "company" ) );
     }
 
-
-    @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 );
-    }
-
-
-    @Test
-    public void testCreateOrgUserAndReturnCorrectUsername() throws Exception {
-
-
-        String mgmtToken = context.getActiveUser().getToken();
-
-        Map<String, String> payload = hashMap( "username", "test-user-2" ).map( "name", "Test User 2" )
-                                                                          .map( "email", "test-user-2@mockserver.com" )
-                                                                          .map( "password", "password" );
-
-        JsonNode node = mapper.readTree(
-                resource().path( "/management/organizations/" + context.getOrgName() + "/users" )
-                          .queryParam( "access_token", mgmtToken ).accept( MediaType.APPLICATION_JSON )
-                          .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ) );
-
-        logNode( node );
-        assertNotNull( node );
-
-        String username = node.get( "data" ).get( "user" ).get( "username" ).asText();
-        String name = node.get( "data" ).get( "user" ).get( "name" ).asText();
-        String email = node.get( "data" ).get( "user" ).get( "email" ).asText();
-
-        assertNotNull( username );
-        assertNotNull( name );
-        assertNotNull( email );
-
-        assertEquals( "test-user-2", username );
-        assertEquals( "Test User 2", name );
-        assertEquals( "test-user-2@mockserver.com", email );
-    }
-
-
-    @Test
-    public void testOrganizationUpdate() throws Exception {
-        String accessToken = context.getActiveUser().getToken();
-        Map<String, Object> properties = new HashMap<String, Object>();
-        properties.put( "securityLevel", 5 );
-        Map payload = new HashMap();
-        payload.put( OrganizationsResource.ORGANIZATION_PROPERTIES, properties );
-
-
-        //update the organizations
-        mapper.readTree( resource().path( "/management/organizations/" + context.getOrgName() )
-                                   .queryParam( "access_token", accessToken ).accept( MediaType.APPLICATION_JSON )
-                                   .type( MediaType.APPLICATION_JSON_TYPE ).put( String.class, payload ) );
-
-
-        refreshIndex( context.getOrgName(), context.getAppName() );
-
-        //get the organization
-        JsonNode node = mapper.readTree( resource().path( "/management/organizations/" + context.getOrgName() )
-                                                   .queryParam( "access_token", accessToken )
-                                                   .accept( MediaType.APPLICATION_JSON )
-                                                   .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ) );
-
-        assertEquals( 5L, node.get( "organization" ).get( "properties" ).get( "securityLevel" )
-                              .asLong() );//orgInfo.getProperties().get( "securityLevel" ) );
-
-        payload = new HashMap();
-        properties.put( "securityLevel", 6 );
-        payload.put( OrganizationsResource.ORGANIZATION_PROPERTIES, properties );
-
-        node = mapper.readTree( resource().path( "/management/organizations/" + context.getOrgName() )
-                                          .queryParam( "access_token", accessToken )
-                                          .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                                          .put( String.class, payload ) );
-        logNode( node );
-
-        refreshIndex( context.getOrgName(), context.getAppName() );
-
-        node = mapper.readTree( resource().path( "/management/organizations/" + context.getOrgName() )
-                                          .queryParam( "access_token", accessToken )
-                                          .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                                          .get( String.class ) );
-        logNode( node );
-        Assert.assertEquals( 6,
-                node.get( "organization" ).get( OrganizationsResource.ORGANIZATION_PROPERTIES ).get( "securityLevel" )
-                    .asInt() );
-    }
+//
+//    @Test
+//    public void testCreateDuplicateOrgName() throws Exception {
+//
+//        // create organization with name
+//        String timeuuid = UUIDUtils.newTimeUUID().toString();
+//        Map<String, String> payload =
+//                hashMap( "email", "create-duplicate-org" + timeuuid + "@mockserver.com" ).map( "password", "password" )
+//                                                                                         .map( "organization",
+//                                                                                                 "create-duplicate-orgname-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 );
+//
+//        refreshIndex( "create-duplicate-orgname-org" + timeuuid, "dummy" );
+//
+//        // create another org with that same name, but a different user
+//        payload = hashMap( "email", "create-duplicate-org2@mockserver.com" ).map( "username", "create-dupe-orgname2" )
+//                                                                            .map( "password", "password" )
+//                                                                            .map( "organization",
+//                                                                                    "create-duplicate-orgname-org"
+//                                                                                            + timeuuid );
+//        try {
+//            node = mapper.readTree( resource().path( "/management/organizations" ).accept( MediaType.APPLICATION_JSON )
+//                                              .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ) );
+//        }
+//        catch ( Exception ex ) {
+//        }
+//
+//        refreshIndex( "create-duplicate-orgname-org" + timeuuid, "dummy" );
+//
+//        // now attempt to login as the user for the second organization
+//        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( "create-duplicate-orgname-org" + timeuuid, "dummy" );
+//
+//        payload = hashMap( "username", "create-duplicate-org@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 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 );
+//    }
+//
+//
+//    @Test
+//    public void testCreateOrgUserAndReturnCorrectUsername() throws Exception {
+//
+//
+//        String mgmtToken = context.getActiveUser().getToken();
+//
+//        Map<String, String> payload = hashMap( "username", "test-user-2" ).map( "name", "Test User 2" )
+//                                                                          .map( "email", "test-user-2@mockserver.com" )
+//                                                                          .map( "password", "password" );
+//
+//        JsonNode node = mapper.readTree(
+//                resource().path( "/management/organizations/" + context.getOrgName() + "/users" )
+//                          .queryParam( "access_token", mgmtToken ).accept( MediaType.APPLICATION_JSON )
+//                          .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ) );
+//
+//        logNode( node );
+//        assertNotNull( node );
+//
+//        String username = node.get( "data" ).get( "user" ).get( "username" ).asText();
+//        String name = node.get( "data" ).get( "user" ).get( "name" ).asText();
+//        String email = node.get( "data" ).get( "user" ).get( "email" ).asText();
+//
+//        assertNotNull( username );
+//        assertNotNull( name );
+//        assertNotNull( email );
+//
+//        assertEquals( "test-user-2", username );
+//        assertEquals( "Test User 2", name );
+//        assertEquals( "test-user-2@mockserver.com", email );
+//    }
+//
+//
+//    @Test
+//    public void testOrganizationUpdate() throws Exception {
+//        String accessToken = context.getActiveUser().getToken();
+//        Map<String, Object> properties = new HashMap<String, Object>();
+//        properties.put( "securityLevel", 5 );
+//        Map payload = new HashMap();
+//        payload.put( OrganizationsResource.ORGANIZATION_PROPERTIES, properties );
+//
+//
+//        //update the organizations
+//        mapper.readTree( resource().path( "/management/organizations/" + context.getOrgName() )
+//                                   .queryParam( "access_token", accessToken ).accept( MediaType.APPLICATION_JSON )
+//                                   .type( MediaType.APPLICATION_JSON_TYPE ).put( String.class, payload ) );
+//
+//
+//        refreshIndex( context.getOrgName(), context.getAppName() );
+//
+//        //get the organization
+//        JsonNode node = mapper.readTree( resource().path( "/management/organizations/" + context.getOrgName() )
+//                                                   .queryParam( "access_token", accessToken )
+//                                                   .accept( MediaType.APPLICATION_JSON )
+//                                                   .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ) );
+//
+//        assertEquals( 5L, node.get( "organization" ).get( "properties" ).get( "securityLevel" )
+//                              .asLong() );//orgInfo.getProperties().get( "securityLevel" ) );
+//
+//        payload = new HashMap();
+//        properties.put( "securityLevel", 6 );
+//        payload.put( OrganizationsResource.ORGANIZATION_PROPERTIES, properties );
+//
+//        node = mapper.readTree( resource().path( "/management/organizations/" + context.getOrgName() )
+//                                          .queryParam( "access_token", accessToken )
+//                                          .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+//                                          .put( String.class, payload ) );
+//        logNode( node );
+//
+//        refreshIndex( context.getOrgName(), context.getAppName() );
+//
+//        node = mapper.readTree( resource().path( "/management/organizations/" + context.getOrgName() )
+//                                          .queryParam( "access_token", accessToken )
+//                                          .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+//                                          .get( String.class ) );
+//        logNode( node );
+//        Assert.assertEquals( 6,
+//                node.get( "organization" ).get( OrganizationsResource.ORGANIZATION_PROPERTIES ).get( "securityLevel" )
+//                    .asInt() );
+//    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4efb625f/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 fc74eb6..86335d8 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
@@ -79,7 +79,7 @@ public class ClientSetup implements TestRule {
 
         String username = name + UUIDUtils.newTimeUUID();
 //TODO: also create a new application
-        Organization organization = new Organization( username,username,username+"@usergrid.com",username,username  );
+        Organization organization = new Organization( username,username,username+"@usergrid.com",username,username,null  );
 
         //ApiResponse response = restClient.management().orgs().post( mapOrganization(username,username,username+"@usergrid.com",username,username ) );
         organization = restClient.management().orgs().post( organization );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4efb625f/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/DumbClient.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/DumbClient.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/DumbClient.java
index c9f2ccb..afaa753 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/DumbClient.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/DumbClient.java
@@ -50,15 +50,7 @@ public class DumbClient extends AbstractRestIT {
     public void stuff(){
 
         String name = "stuff"+ UUIDUtils.newTimeUUID();
-        User user = new User( "derp","derp", "derp"  );
-        //so user could have an instance of save, then the save does a deep copy of all properties and saves over the previous versions.
-        //Save is part of the entities.
-
-
-//        clientSetup.getRestClient().org(  ).getApp( "" ).users().post( user );
-//        clientSetup.getRestClient().org(  ).getApp( "" ).users().get(user.getUuid());
-//        clientSetup.getRestClient().org(  ).getApp( "" ).users().put(user);
-
+       // User user = new User( "derp","derp", "derp"  );
 
 
         //Organization org = clientSetup.getRestClient().management().orgs().post(  )
@@ -66,8 +58,7 @@ public class DumbClient extends AbstractRestIT {
        // OrganizationResource response =  clientSetup.getRestClient().management().orgs().organization( "" );
         //assertNotNull( response );
         //EntityResponse itr  =  client.org( "test" ).getApp( "test" ).users().getEntityResponse();
-
-        //        for(Entity entity: itr){
+        //for(Entity entity: itr){
     }
 
     public Map<String,String> mapOrganization(String orgName, String username, String email, String name, String password){

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4efb625f/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 ef0720a..209c83f 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
@@ -17,18 +17,14 @@
 
 package org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt;
 
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
 import javax.ws.rs.core.MediaType;
 
 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.User;
 import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
-import org.apache.usergrid.utils.MapUtils;
 
 
 /**
@@ -42,10 +38,6 @@ public class OrgResource  extends NamedResource {
         super( "orgs", context, parent );
     }
 
-    //TODO: change this so that it reflects the management endpoint
-    //    public ApplicationResource getApp(final String app){
-    //        return new ApplicationResource( app, context ,this );
-    //    }
 
     public OrganizationResource organization (final String orgname){
         return new OrganizationResource( orgname,context,parent );
@@ -53,21 +45,15 @@ public class OrgResource  extends NamedResource {
 
     //TODO: why take in a map? Just use base resource and call post from there,
     //TODO: Why ApiResponse when we could just type what we expect back.
+    //TODO: wouldn't a user be part of an organization in this sense? They get passed in together, they should be torn out together
     public Organization post(Organization organization){
         ApiResponse response = getResource().type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
                      .post( ApiResponse.class,organization );
 
-        LinkedHashMap linkedHashMap = ( LinkedHashMap ) response.getData();
-        //organization.putAll( response.getData());
-        //Organization organization1 //= ( Organization ) linkedHashMap.get( "organization" ); //.get( "organization" );
-
-        organization.putAll( ( Map<? extends String, ?> ) linkedHashMap.get("organization") );
-       // organization.pu
-       // organization.putAll( linkedHashMap.get( "organization" ) );
+        organization.setResponse(response);
+        User user = new User( response );
 
         return organization;
     }
 
-
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4efb625f/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
index 9063787..617ccd2 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
@@ -76,7 +76,7 @@ public class Entity implements Serializable, Map<String,Object> {
 
     @JsonSerialize( include = JsonSerialize.Inclusion.NON_NULL )
     public UUID getUuid(){
-        return  UUID.fromString( (String) get("uuid") ); //get( "uuid" );
+        return  UUID.fromString( (String) get("uuid") );
     }
 
 
@@ -161,6 +161,10 @@ public class Entity implements Serializable, Map<String,Object> {
 //    }
 
 
+    public Entity addProperty(String key, Object value){
+        put(key,value);
+        return this;
+    }
     public void setProperties( Map<String, Object> properties ) {
         putAll( properties );
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4efb625f/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Organization.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Organization.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Organization.java
index bb2c71b..ce373e8 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Organization.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Organization.java
@@ -19,6 +19,7 @@ package org.apache.usergrid.rest.test.resource2point0.model;
 
 
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.UUID;
@@ -34,20 +35,13 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
  */
 public class Organization extends Entity {
 
-
-//    private String organization;
-//    private String username;
-//    private String email;
-//    private String name;
-//    private String password;
-//    private String passwordHistorySize;
-
-
     public Organization() {
 
     }
+    //TODO: create constructor here so that it can regenerate itself from a ApiResponse/factory
 
-    public Organization( String orgName, String username, String email, String ownerName, String password ){
+
+    public Organization( String orgName, String username, String email, String ownerName, String password, Map<String,Object> properties ){
 
         this.put( "organization", orgName );
         this.put( "username", username);
@@ -55,6 +49,9 @@ public class Organization extends Entity {
         //TODO: create clearer distinction between ownerName and username in the backend.
         this.put( "name", ownerName);
         this.put( "password", password);
+
+        if(properties != null)
+            setProperties( properties );
     }
 
     @JsonSerialize( include = JsonSerialize.Inclusion.NON_NULL )
@@ -85,4 +82,13 @@ public class Organization extends Entity {
     public Object getPasswordHistorySize() {
         return  (Integer) this.get("passwordHistorySize");
     }
+
+
+    public void setResponse( final ApiResponse response ) {
+        LinkedHashMap linkedHashMap = ( LinkedHashMap ) response.getData();
+        //organization.putAll( response.getData());
+        //Organization organization1 //= ( Organization ) linkedHashMap.get( "organization" ); //.get( "organization" );
+
+        this.putAll( ( Map<? extends String, ?> ) linkedHashMap.get("organization") );
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4efb625f/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/User.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/User.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/User.java
index f5b5858..cc0bf0c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/User.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/User.java
@@ -17,6 +17,8 @@
 package org.apache.usergrid.rest.test.resource2point0.model;
 
 
+import java.util.LinkedHashMap;
+import java.util.Map;
 import java.util.UUID;
 
 import org.apache.usergrid.rest.test.resource.TestContext;
@@ -25,75 +27,70 @@ import com.fasterxml.jackson.databind.JsonNode;
 
 
 /**
- * Created by ApigeeCorporation on 12/10/14.
+ * Models the user class for response from REST calls.
  */
-public class User {
-
-    protected String user;
-    protected String password;
-    protected String email;
-    protected String token;
-    protected UUID uuid;
-
-
-    /**
-     * @param user
-     * @param password
-     * @param email
-     */
-    public User( String user, String password, String email ) {
-        this.user = user;
-        this.password = password;
-        this.email = email;
+public class User extends Entity {
+
+    public User (ApiResponse response){
+        setResponse( response );
     }
+    //TODO: create another constructor to take in the nessesary things to post to a user.
 
-    /**
-     * Manually set our token for this user.
-     * @param token
-     */
-    public void setToken(String token){
-        this.token = token;
+    public Boolean getActivated(){
+        return (Boolean) this.get( "activated" );
     }
 
-    /** @return the user */
-    public String getUser() {
-        return user;
+    public Boolean getAdminUser(){
+        return (Boolean) this.get( "adminUser" );
     }
 
+    public UUID getApplicationId(){
+        return  UUID.fromString( (String) get("applicationId") );
+    }
 
-    /** @return the password */
-    public String getPassword() {
-        return password;
+    public Boolean getConfirmed(){
+        return (Boolean) this.get("confirmed");
     }
 
+    public Boolean getDisabled(){
+        return (Boolean) this.get("disabled");
+    }
 
-    /** @return the email */
-    public String getEmail() {
-        return email;
+    public String getDisplayEmailAddress(){
+        return (String) this.get("displayEmailAddress");
     }
 
+    public String getEmail(){
+        return (String) this.get("email");
+    }
 
-    public String getToken() {
-        return this.token;
+    public String getHtmlDisplayEmailAddress(){
+        return (String) this.get("htmldisplayEmailAddress");
     }
 
+    public String getName(){
+        return (String) this.get("name");
+    }
 
-    /** @return the uuid */
-    public UUID getUuid() {
-        return uuid;
+    public Map<String,Object> getProperties(){
+        return (Map<String,Object>) this.get("properties");
     }
 
-    public void setUUID(UUID uuid) {
-        this.uuid = uuid;
+    public String getUsername(){
+        return (String) this.get("username");
     }
 
-    public boolean isLoggedIn() {
-        return this.token != null;
+    public UUID getUuid(){
+        return UUID.fromString( (String) get("uuid") );
     }
 
-    /** Log out */
-    public void logout() {
-        token = null;
+    //For the owner , should have different cases that looks at the different types it could be
+    public User setResponse( final ApiResponse response ) {
+        LinkedHashMap linkedHashMap = ( LinkedHashMap ) response.getData();
+
+        this.putAll( ( Map<? extends String, ?> ) linkedHashMap.get("owner") );
+
+        return this;
     }
 
 }