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/10 17:59:39 UTC

incubator-usergrid git commit: Added ability to create new Organizations. Added getResource to RootResource as stub. Added example of path in UrlResource Reworked to have separate org endpoint and made the Organization Resource be a separate part. that o

Repository: incubator-usergrid
Updated Branches:
  refs/heads/UG-rest-test-framework-overhaul 9af4135ae -> 7dd658bf4


Added ability to create new Organizations.
Added getResource to RootResource as stub.
Added example of path in UrlResource
Reworked to have separate org endpoint and made the Organization Resource be a separate part. that only works on the orange endpoint.
Moved TokenResource to highlight that it is a management endpoint.


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

Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 7dd658bf4073839ba4e6315dc50444626d218c73
Parents: 9af4135
Author: grey <gr...@apigee.com>
Authored: Wed Dec 10 08:59:37 2014 -0800
Committer: grey <gr...@apigee.com>
Committed: Wed Dec 10 08:59:37 2014 -0800

----------------------------------------------------------------------
 .../rest/test/resource2point0/DumbClient.java   | 21 ++---------
 .../resource2point0/endpoints/RootResource.java |  7 ++++
 .../endpoints/TokenResource.java                | 32 ----------------
 .../resource2point0/endpoints/UrlResource.java  |  1 +
 .../endpoints/mgmt/ManagementResource.java      |  5 +--
 .../endpoints/mgmt/OrgResource.java             | 39 ++++++++++++++++++++
 .../endpoints/mgmt/OrganizationResource.java    | 13 +++----
 .../endpoints/mgmt/TokenResource.java           | 34 +++++++++++++++++
 8 files changed, 93 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7dd658bf/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 5f247d0..9e6ba20 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
@@ -32,6 +32,7 @@ import org.apache.usergrid.rest.test.resource2point0.endpoints.ApplicationResour
 import org.apache.usergrid.rest.test.resource2point0.endpoints.Collection;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.RootResource;
+import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource2point0.model.Entity;
 import org.apache.usergrid.rest.test.resource2point0.model.EntityResponse;
 import org.apache.usergrid.utils.MapUtils;
@@ -49,7 +50,7 @@ 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
+    //@Rule
     public final RestClient client = new RestClient( getBaseURI().toString() );
 
 
@@ -57,25 +58,11 @@ public class DumbClient extends AbstractRestIT {
     public void stuff(){
 
         String name = "stuff"+ UUIDUtils.newTimeUUID();
-        c
-
+        ApiResponse response = client.management().orgs().post( mapOrganization(name,name,name+"@apigee.com",name,name  ) );
+        assertNotNull( response );
         //EntityResponse itr  =  client.org( "test" ).getApp( "test" ).users().getEntityResponse();
-//        OrganizationResource organizationResource = client.org( "borg" );
-//        assertNotNull( organizationResource );
-//        assertEquals( getBaseURI().toString()+"borg",client.getPath());
-//
-//
-//        ApplicationResource applicationResource = client.org( "morg" ).getApp( "app" );
-//        assertNotNull( applicationResource );
-//        assertEquals( getBaseURI().toString()+"borg/morg",client.getPath());
-
-
-        //can't post an org to an organization endpoint you derp. I think it has to be to management.
-        //client.post(mapOrganization(name,name,name+"@apigee.com",name,name  ));
 
         //        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/7dd658bf/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/RootResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/RootResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/RootResource.java
index 300ba0f..b7a51d1 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/RootResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/RootResource.java
@@ -20,6 +20,8 @@ package org.apache.usergrid.rest.test.resource2point0.endpoints;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.ManagementResource;
 import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
 
+import com.sun.jersey.api.client.WebResource;
+
 
 /**
  * Contains the root element for classes. Contains the client context that holds a token for the management calls,
@@ -55,6 +57,11 @@ public class RootResource implements UrlResource {
         return serverUrl;
     }
 
+    @Override
+    public WebResource getResource() {
+        //TODO: fix this to return the proper resource in the scope we expect it, might not be needed here.
+        return null;
+    }
 
     /**
      * Get the management resource

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7dd658bf/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
deleted file mode 100644
index 67532da..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/TokenResource.java
+++ /dev/null
@@ -1,32 +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.state.ClientContext;
-
-
-/**
- * Called by the ManagementResource. This contains anything token related that comes back to the ManagementResource.
- */
-public class TokenResource extends NamedResource {
-    public TokenResource( final ClientContext context, final UrlResource parent ) {
-        super( "management", context, parent );
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7dd658bf/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/UrlResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/UrlResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/UrlResource.java
index 70d48c1..fc3b31f 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/UrlResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/UrlResource.java
@@ -29,6 +29,7 @@ public interface UrlResource {
 
     /**
      * Get the url path to this resource
+     * example: http://localhost:8080/management/orgs/<org_name>
      * @return
      */
     public String getPath();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7dd658bf/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
index 846d761..6ac3b00 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
@@ -33,8 +33,7 @@ public class ManagementResource extends NamedResource {
         return new TokenResource( context, this );
     }
 
-    public OrganizationResource orgs(String name) {
-        return new OrganizationResource( name ,context,this );
+    public OrgResource orgs() {
+        return new OrgResource( context, this );
     }
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7dd658bf/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
new file mode 100644
index 0000000..43473e6
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrgResource.java
@@ -0,0 +1,39 @@
+package org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt;
+
+
+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.state.ClientContext;
+
+
+/**
+ * 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 );
+    }
+
+    //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 );
+    }
+
+    public ApiResponse post(Map<String,String> organization){
+
+        return getResource().type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
+                            .post( ApiResponse.class, organization );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7dd658bf/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 92cc60e..1319a0c 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
@@ -26,7 +26,7 @@ public class OrganizationResource 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 OrganizationResource( final String name, final ClientContext context, final UrlResource parent ) {
-        super( name, context, parent. );
+        super( name, context, parent );
     }
 
     //TODO: change this so that it reflects the management endpoint
@@ -34,11 +34,10 @@ public class OrganizationResource extends NamedResource {
 //        return new ApplicationResource( app, context ,this );
 //    }
 
-    public void post(Map<String,String> organization){
-
-        getResource().type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
-                     .post( ApiResponse.class, organization );
-    }
-
+//    public ApiResponse post(Map<String,String> organization){
+//
+//        return getResource().type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
+//                     .post( ApiResponse.class, organization );
+//    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7dd658bf/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/TokenResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/TokenResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/TokenResource.java
new file mode 100644
index 0000000..be567cb
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/TokenResource.java
@@ -0,0 +1,34 @@
+/*
+ * 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.mgmt;
+
+
+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.state.ClientContext;
+
+
+/**
+ * Called by the ManagementResource. This contains anything token related that comes back to the ManagementResource.
+ */
+public class TokenResource extends NamedResource {
+    public TokenResource( final ClientContext context, final UrlResource parent ) {
+        super( "token", context, parent );
+    }
+
+
+}