usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [22/50] [abbrv] incubator-usergrid git commit: Cleared up and added some comments to the tests in organizationIt Added comment to one of the methods in AbstractRestIt.
Date Tue, 13 Jan 2015 19:15:24 GMT
Cleared up and added some comments to the tests in organizationIt
Added comment to one of the methods in AbstractRestIt.


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

Branch: refs/heads/two-dot-o-import
Commit: 6f1685dd13d5097b876ed94671600fb80cd43084
Parents: 860de10
Author: grey <greyes@apigee.com>
Authored: Wed Jan 7 10:56:57 2015 -0800
Committer: grey <greyes@apigee.com>
Committed: Wed Jan 7 10:56:57 2015 -0800

----------------------------------------------------------------------
 .../rest/management/OrganizationsIT.java        | 37 +++++++++++---------
 .../test/resource2point0/AbstractRestIT.java    | 11 ++++--
 .../endpoints/mgmt/OrganizationResource.java    |  4 +--
 3 files changed, 32 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6f1685dd/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 0a7a82b..dd2bbe9 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
@@ -61,6 +61,7 @@ public class OrganizationsIT extends AbstractRestIT {
     @Test
     public void createOrgAndOwner() throws Exception {
 
+        //Created a uuid username because I am creating a organization
         String username = "createOrgAndOwner" + UUIDUtils.newTimeUUID();
         String name = username;
         String password = "password";
@@ -85,8 +86,6 @@ public class OrganizationsIT extends AbstractRestIT {
 
         assertNotNull( token );
 
-        assertNotNull( clientSetup.getRestClient().getContext().getToken() );
-
         //Assert that the get returns the correct org and owner.
         Organization returnedOrg = clientSetup.getRestClient().management().orgs().organization(
orgName ).get();
 
@@ -94,6 +93,7 @@ public class OrganizationsIT extends AbstractRestIT {
 
         User returnedUser = returnedOrg.getOwner();
 
+        //Assert that the property was retained in the owner of the organization.
         assertEquals( "Apigee", returnedUser.getProperties().get( "company" ) );
     }
 
@@ -118,23 +118,28 @@ public class OrganizationsIT extends AbstractRestIT {
         Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post(
orgPayload );
         this.refreshIndex();
 
-        assertNotNull( orgCreatedResponse );
+        //Ensure that the token from the newly created organization works.
+        Token tokenPayload = new Token( "password", username, password );
+        Token tokenReturned = clientSetup.getRestClient().management().token().post( tokenPayload
);
+
+        assertNotNull( tokenReturned );
 
+        assertNotNull( orgCreatedResponse );
 
+        //Try to create a organization with the same name as an organization that already
exists, ensure that it fails
         Organization orgTestDuplicatePayload =
                 new Organization( orgName, username + "test", email + "test", name + "test",
password, null );
         try {
-            Organization orgTestDuplicateResponse = clientSetup.getRestClient()
-                                                               .management().orgs().post(
orgTestDuplicatePayload );
+            clientSetup.getRestClient().management().orgs().post( orgTestDuplicatePayload
);
             fail("Should not have been able to create duplicate organization");
         }
         catch ( UniformInterfaceException ex ) {
             errorParse( 400,duplicateUniquePropertyExistsErrorMessage, ex );
         }
 
-        // Post to get token of what should be a non existent user.
+        // Post to get token of what should be a non existent user due to the failure of
creation above
 
-        Token tokenPayload = new Token( "password", username + "test", password );
+        tokenPayload = new Token( "password", username + "test", password );
         Token tokenError = null;
         try {
             tokenError = clientSetup.getRestClient().management().token().post( tokenPayload
);
@@ -146,11 +151,6 @@ public class OrganizationsIT extends AbstractRestIT {
         }
 
         assertNull( tokenError );
-
-        tokenPayload = new Token( "password", username, password );
-        Token tokenReturned = clientSetup.getRestClient().management().token().post( tokenPayload
);
-
-        assertNotNull( tokenReturned );
     }
 
 
@@ -199,7 +199,7 @@ public class OrganizationsIT extends AbstractRestIT {
             fail( "Should not have created organization" );
         }
         catch ( UniformInterfaceException ex ) {
-            //TODO: Should throw a 404 not a 400.
+            //TODO: Should throw a 404 not a 400?
             errorParse( 400,invalidGrantErrorMessage,ex );
         }
 
@@ -220,12 +220,14 @@ public class OrganizationsIT extends AbstractRestIT {
     @Test
     public void testOrgPOSTParams() throws IOException {
 
+        //Create organization defaults
         String username = "testCreateDuplicateOrgEmail" + UUIDUtils.newTimeUUID();
         String name = username;
         String password = "password";
         String orgName = username;
         String email = username + "@usergrid.com";
 
+        //Append them to the end as query parameters
         QueryParameters queryParameters = new QueryParameters();
         queryParameters.setKeyValue( "organization",orgName );
         queryParameters.setKeyValue( "username",username );
@@ -234,6 +236,7 @@ public class OrganizationsIT extends AbstractRestIT {
         queryParameters.setKeyValue( "name",name );
         queryParameters.setKeyValue( "password",password );
 
+        //Post the organization and verify it worked
         Organization organization = clientSetup.getRestClient().management().orgs().post(
queryParameters );
 
         this.refreshIndex();
@@ -260,6 +263,7 @@ public class OrganizationsIT extends AbstractRestIT {
         form.add( "name", "testOrgPOSTForm" );
         form.add( "password", "password" );
 
+        //Post the organization and verify it worked.
         Organization organization = clientSetup.getRestClient().management().orgs().post(
form );
 
         this.refreshIndex();
@@ -270,17 +274,19 @@ public class OrganizationsIT extends AbstractRestIT {
 
 
     /**
-     * Returns error from unimplemented delete method
+     * Returns error from unimplemented delete method by trying to call the delete organization
endpoint
      * @throws IOException
      */
     @Test
     public void noOrgDelete() throws IOException {
 
         try {
+            //Delete default organization
             clientSetup.getRestClient().management().orgs().organization( clientSetup.getOrganizationName()
).delete();
             fail( "Delete is not implemented yet" );
         }catch(UniformInterfaceException uie){
             assertEquals(500,uie.getResponse().getStatus());
+            //TODO: I think the below is what it should return,but instead it expects the
above
            // assertEquals( ClientResponse.Status.NOT_IMPLEMENTED ,uie.getResponse().getStatus());
         }
     }
@@ -292,12 +298,11 @@ public class OrganizationsIT extends AbstractRestIT {
      */
     @Test
     public void testCreateOrgUserAndReturnCorrectUsername() throws Exception {
-        String username = "testCreateOrgUserAndReturnCorrectUsername"+UUIDUtils.newTimeUUID();
-
         RestClient restClient = clientSetup.getRestClient();
 
         //Create adminUser values
         Entity adminUserPayload = new Entity();
+        String username = "testCreateOrgUserAndReturnCorrectUsername"+UUIDUtils.newTimeUUID();
         adminUserPayload.put( "username", username );
         adminUserPayload.put( "name", username );
         adminUserPayload.put( "email", username+"@usergrid.com" );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6f1685dd/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 370823d..102fb12 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
@@ -130,8 +130,15 @@ public class AbstractRestIT extends JerseyTest {
     }
 
 
-    public void errorParse(Integer expectedStatus, String expectedErrorMessage, UniformInterfaceException
uie){
-        assertEquals((Integer)400,expectedStatus);
+    /**
+     * Takes in the expectedStatus message and the expectedErrorMessage then compares it
to the UniformInterfaceException
+     * to make sure that we got what we expected.
+     * @param expectedStatus
+     * @param expectedErrorMessage
+     * @param uie
+     */
+    public void errorParse(int expectedStatus, String expectedErrorMessage, UniformInterfaceException
uie){
+        assertEquals(expectedStatus,uie.getResponse().getStatus());
         JsonNode errorJson = uie.getResponse().getEntity( JsonNode.class );
         assertEquals( expectedErrorMessage, errorJson.get( "error" ).asText() );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6f1685dd/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 85451bd..a436358 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
@@ -67,14 +67,14 @@ public class OrganizationResource extends NamedResource {
         return org;
     }
 
-    //Doesn't return anything useful.
+    //Doesn't return anything useful server side so this was made as a void. .
     public void put( Organization organization ){
         Map<String,Object> response = getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
                                                        .accept(MediaType.APPLICATION_JSON).put(
Organization.class,
                         organization );
 
     }
-
+    
     public ApplicationResource app(){
         return new ApplicationResource(  context ,this );
     }


Mime
View raw message