usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [1/2] incubator-usergrid git commit: add overload
Date Wed, 03 Jun 2015 17:02:23 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o-dev c57edaa30 -> 0cd12bfee


add overload


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

Branch: refs/heads/two-dot-o-dev
Commit: 77a6fdd515419966c28a5d2d7fadd63a0b578215
Parents: 68c65f0
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Wed Jun 3 11:01:55 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Wed Jun 3 11:01:55 2015 -0600

----------------------------------------------------------------------
 .../org/apache/usergrid/rest/NotificationsIT.java   |  6 ++++--
 .../rest/test/resource2point0/AbstractRestIT.java   |  7 +++++++
 .../rest/test/resource2point0/RestClient.java       |  9 +++++----
 .../resource2point0/endpoints/NamedResource.java    | 16 +++++++++++++++-
 4 files changed, 31 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/77a6fdd5/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
index cf6edb0..fb1d2ad 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
@@ -28,7 +28,9 @@ import java.util.concurrent.TimeUnit;
 import javax.ws.rs.core.MediaType;
 import org.apache.commons.lang3.time.StopWatch;
 import org.apache.usergrid.rest.test.resource2point0.*;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.NamedResource;
 import org.apache.usergrid.rest.test.resource2point0.model.*;
+import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
 import org.junit.After;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -77,10 +79,10 @@ public class NotificationsIT extends org.apache.usergrid.rest.test.resource2poin
         // create notifier
         Entity notifier = new Entity().chainPut("name", "mynotifier").chainPut("provider",
"noop");
 
-        Entity notifierNode =this.app().collection("notifier").post(notifier);
+        ApiResponse notifierNode = this.pathResource(getOrgAppPath("notifier")).postEntity(notifier);
 
         //logger.debug("Notifier is: " + notifierNode.toString());
-        assertEquals("noop", notifierNode.getResponse().getEntities().get(0).get("provider").toString());
+        assertEquals("noop", notifierNode.getEntities().get(0).get("provider").toString());
 
         int numDevices = 2;
         int numNotifications = 5; // to send to each device

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/77a6fdd5/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 86bb577..37e4f99 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
@@ -29,6 +29,7 @@ import com.sun.jersey.test.framework.WebAppDescriptor;
 import com.sun.jersey.test.framework.spi.container.TestContainerFactory;
 import org.apache.usergrid.rest.TomcatRuntime;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.ApplicationsResource;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.NamedResource;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.ManagementResource;
 import org.apache.usergrid.rest.test.resource2point0.model.Token;
@@ -133,6 +134,12 @@ public class AbstractRestIT extends JerseyTest {
         return clientSetup.restClient.management();
     }
 
+    protected NamedResource pathResource(String path){ return clientSetup.restClient.pathResource(path);}
+
+    protected String getOrgAppPath(String additionalPath){
+        return clientSetup.orgName + "/" + clientSetup.appName + "/" + (additionalPath !=null
? additionalPath : "");
+    }
+
     protected ClientContext context(){
         return this.clientSetup.getRestClient().getContext();
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/77a6fdd5/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
index 5e6c5d5..152e546 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
@@ -16,11 +16,8 @@
  */
 package org.apache.usergrid.rest.test.resource2point0;
 
-import org.apache.usergrid.rest.test.resource2point0.endpoints.SystemResource;
-import org.apache.usergrid.rest.test.resource2point0.endpoints.TokenResource;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.*;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.ManagementResource;
-import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
-import org.apache.usergrid.rest.test.resource2point0.endpoints.UrlResource;
 import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
 
 import com.fasterxml.jackson.databind.JsonNode;
@@ -108,6 +105,10 @@ public class RestClient implements UrlResource {
                 .accept( MediaType.APPLICATION_JSON ).post();
     }
 
+    public NamedResource pathResource(String path){
+        return new NamedResource(path,context,this);
+    }
+
     public void superuserSetup() {
         //TODO: change this when we upgrade to new version of jersey
         HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( "superuser","superpassword"
);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/77a6fdd5/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 b048cee..41dcc18 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
@@ -41,7 +41,7 @@ import com.sun.jersey.api.representation.Form;
  * Base class that is extended by named endpoints.
  * The NamedResource stores the parent of the class, the context in which the class operates
and then Name of this resource
  */
-public abstract class NamedResource implements UrlResource {
+public class NamedResource implements UrlResource {
 
     protected final String name;
     protected final ClientContext context;
@@ -192,6 +192,20 @@ public abstract class NamedResource implements UrlResource {
                             .post(gt.getRawClass(), requestEntity);
 
     }
+    //For edge cases like Organizations and Tokens
+    public ApiResponse postEntity(Entity requestEntity, boolean useToken) {
+        return getResource(useToken).type(MediaType.APPLICATION_JSON_TYPE)
+            .accept( MediaType.APPLICATION_JSON )
+            .post(ApiResponse.class, requestEntity);
+
+    }
+    //For edge cases like Organizations and Tokens
+    public ApiResponse postEntity(Entity requestEntity) {
+        return getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
+            .accept( MediaType.APPLICATION_JSON )
+            .post(ApiResponse.class, requestEntity);
+
+    }
 
     public <T> T post(Class<T> type, QueryParameters queryParameters) {
         WebResource resource = getResource();


Mime
View raw message