usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [1/2] incubator-usergrid git commit: Added ApiResourceCollection to tests and wired them into the get call for collections. Fixed a test to show what it would look like using the ApiResponse.
Date Tue, 02 Dec 2014 20:38:22 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-256-ApiResponseImplementation 06f98cac0 -> d11974d4a


Added ApiResourceCollection to tests and wired them into the get call for collections.
Fixed a test to show what it would look like using 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/29f666cc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/29f666cc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/29f666cc

Branch: refs/heads/USERGRID-256-ApiResponseImplementation
Commit: 29f666ccb8ba7fc78776b58ae3565d8fe4c884e5
Parents: 06f98ca
Author: grey <greyes@apigee.com>
Authored: Tue Dec 2 11:09:31 2014 -0800
Committer: grey <greyes@apigee.com>
Committed: Tue Dec 2 11:09:31 2014 -0800

----------------------------------------------------------------------
 .../collection/CollectionsResourceIT.java          | 17 ++++++++++++-----
 .../rest/test/resource/app/Collection.java         | 15 ++++++++++++---
 2 files changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/29f666cc/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
index 408e0f5..d60caf0 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
@@ -74,9 +74,15 @@ public class CollectionsResourceIT extends AbstractRestIT {
     }
 
 
+    /**
+     * Posts an empty payload to an empty collection and expects nothing back
+     * @throws IOException
+     */
     @Test
     public void postToEmptyCollection() throws IOException {
         Map<String, String> payload = new HashMap<String, String>();
+        //for whatever reason this does a getEntity before returning the post, i think this
is a bug needs to be fixed.
+        //after api response stuff is handled. We should only be getting the raw response.
 
         JsonNode node = context.collection( "cities" ).post( payload );
         assertNull( getEntity( node, 0 ) );
@@ -94,12 +100,13 @@ public class CollectionsResourceIT extends AbstractRestIT {
 //                                                   .post( String.class, payload ));
        // assertNull( node );
 
-        RevisedApiResponse<Collection> collection = context.collection( "cities" ).getResponse();
-//        ApiResponse apiResponse = resource().path( "/test-organization/test-app/cities"
).queryParam( "access_token", access_token )
-//                                            .accept( MediaType.APPLICATION_JSON ).type(
MediaType.APPLICATION_JSON_TYPE )
-//                                            .get( ApiResponse.class );
+        JsonNode node = context.collection( "cities" ).post( payload );
+
+        assertNull(node);
+
+        ApiResponseCollection<Collection> collection = context.collection( "cities"
).getCollectionResponse();
 
-       // assertNotNull( apiResponse );
+        assertNotNull( collection );
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/29f666cc/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Collection.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Collection.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Collection.java
index 47f720b..2990cfe 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Collection.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Collection.java
@@ -22,6 +22,7 @@ import java.util.Map;
 
 import org.apache.usergrid.rest.ApiResponse;
 import org.apache.usergrid.rest.RevisedApiResponse;
+import org.apache.usergrid.rest.test.resource.CollectionResource;
 import org.apache.usergrid.rest.test.resource.NamedResource;
 import org.apache.usergrid.rest.test.resource.SetResource;
 import org.apache.usergrid.utils.MapUtils;
@@ -77,12 +78,20 @@ public class Collection extends SetResource {
     public JsonNode post(Map entityData) throws IOException{
 
         JsonNode response = this.postInternal( entityData );
-
+//I think this is wrong
         return getEntity( response, 0 );
     }
 
-    public RevisedApiResponse getResponse()  {
-        return this.getResponse();
+
+    /**
+     * Creates a ApiResponseCollection which takes in an api response returns it as a collection
of the type handed in
+     * @return
+     * @throws IOException
+     */
+    public ApiResponseCollection<Collection> getCollectionResponse() throws IOException
 {
+        CollectionResource collectionResource = new CollectionResource( this.getName(),this.getParent()
);
+        ApiResponseCollection<Collection> collectionRevisedApiResponse = new ApiResponseCollection<>(collectionResource,this.getResponse()
);
+        return collectionRevisedApiResponse;
     }
 
 }


Mime
View raw message