usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject incubator-usergrid git commit: Created OrgOwner state class to hold the org and owner that get created out of a Organization Resource. Refactored existing classes to use it.
Date Mon, 15 Dec 2014 15:15:57 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/UG-rest-test-framework-overhaul 4efb625f4 -> ccc2713d0


Created OrgOwner state class to hold the org and owner that get created out of a Organization
Resource.
Refactored existing classes to use it.


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

Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: ccc2713d012a24e372c89b84e3bd2a9902d4e718
Parents: 4efb625
Author: grey <greyes@apigee.com>
Authored: Mon Dec 15 07:15:53 2014 -0800
Committer: grey <greyes@apigee.com>
Committed: Mon Dec 15 07:15:53 2014 -0800

----------------------------------------------------------------------
 .../rest/management/OrganizationsIT.java        |  5 ++-
 .../rest/test/resource2point0/ClientSetup.java  |  3 +-
 .../rest/test/resource2point0/DumbClient.java   | 22 ----------
 .../endpoints/mgmt/OrgResource.java             |  8 ++--
 .../test/resource2point0/state/OrgOwner.java    | 46 ++++++++++++++++++++
 5 files changed, 57 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ccc2713d/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 4cfebd9..ae6a396 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
@@ -39,6 +39,7 @@ 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 org.apache.usergrid.rest.test.resource2point0.state.OrgOwner;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import com.sun.jersey.api.client.ClientResponse;
@@ -83,7 +84,9 @@ public class OrganizationsIT extends AbstractRestIT {
         //TODO:seperate entity properties from organization properties.
         //organization.addProperty( "" ).addProperty(  )
 
-        organization = clientSetup.getRestClient().management().orgs().post( organization
);
+        OrgOwner orgOwner = clientSetup.getRestClient().management().orgs().post( organization
);
+
+        assertNotNull( orgOwner );
 
 
 //        Map payload =

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ccc2713d/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 86335d8..fa0afdd 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
@@ -31,6 +31,7 @@ import org.junit.runners.model.Statement;
 import org.apache.usergrid.persistence.index.utils.UUIDUtils;
 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.state.OrgOwner;
 import org.apache.usergrid.rest.test.security.TestAdminUser;
 import org.apache.usergrid.utils.MapUtils;
 
@@ -81,8 +82,8 @@ public class ClientSetup implements TestRule {
 //TODO: also create a new application
         Organization organization = new Organization( username,username,username+"@usergrid.com",username,username,null
 );
 
+        OrgOwner orgOwner = restClient.management().orgs().post( organization );
         //ApiResponse response = restClient.management().orgs().post( mapOrganization(username,username,username+"@usergrid.com",username,username
) );
-        organization = restClient.management().orgs().post( organization );
         System.out.println();
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ccc2713d/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 afaa753..e56be2d 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
@@ -16,19 +16,11 @@
  */
 package org.apache.usergrid.rest.test.resource2point0;
 
-import java.util.Map;
-import java.util.UUID;
-
 import org.junit.Ignore;
-import org.junit.Rule;
 import org.junit.Test;
 
 import org.apache.usergrid.persistence.index.utils.UUIDUtils;
-import org.apache.usergrid.rest.test.resource2point0.model.User;
-import org.apache.usergrid.utils.MapUtils;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 
 
 /**
@@ -38,14 +30,6 @@ import static org.junit.Assert.assertNotNull;
 
 public class DumbClient extends AbstractRestIT {
 
-    //TODO: maybe this should just take in the raw uri.
-    //TODO:fix this so it can work a lot like the context.
-    //@Rule
-    //public final RestClient client = new RestClient( getBaseURI().toString() );
-
-
-
-
     @Test
     public void stuff(){
 
@@ -61,12 +45,6 @@ public class DumbClient extends AbstractRestIT {
         //for(Entity entity: itr){
     }
 
-    public Map<String,String> mapOrganization(String orgName, String username, String
email, String name, String password){
-
-        return MapUtils.hashMap( "organization", orgName ).map( "username", username )
-                       .map( "email", email ).map( "name", name )
-                       .map( "password", password);
-    }
 
     @Ignore
     public void stateful(){

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ccc2713d/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 209c83f..a8cb5f8 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
@@ -25,6 +25,7 @@ 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.rest.test.resource2point0.state.OrgOwner;
 
 
 /**
@@ -46,14 +47,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){
+    public OrgOwner post(Organization organization){
         ApiResponse response = getResource().type( MediaType.APPLICATION_JSON_TYPE ).accept(
MediaType.APPLICATION_JSON )
                      .post( ApiResponse.class,organization );
 
+
         organization.setResponse(response);
-        User user = new User( response );
 
-        return organization;
+
+        return new OrgOwner(organization,new User( response ));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ccc2713d/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/state/OrgOwner.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/state/OrgOwner.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/state/OrgOwner.java
new file mode 100644
index 0000000..ddca816
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/state/OrgOwner.java
@@ -0,0 +1,46 @@
+/*
+ * 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.state;
+
+
+import org.apache.usergrid.rest.test.resource2point0.model.Organization;
+import org.apache.usergrid.rest.test.resource2point0.model.User;
+
+
+/**
+ * Holds an instance of the Organization and Owner.
+ */
+public class OrgOwner {
+    Organization organization;
+    User user;
+
+    public OrgOwner( final Organization organization, final User user ) {
+        this.organization = organization;
+        this.user = user;
+    }
+
+
+    public Organization getOrganization() {
+        return organization;
+    }
+
+
+    public User getUser() {
+        return user;
+    }
+}


Mime
View raw message