usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [4/8] usergrid git commit: rest test
Date Fri, 04 Sep 2015 13:42:04 GMT
rest test


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

Branch: refs/heads/two-dot-o-dev
Commit: ba8922b7c268917993d6ce1ac9d542b9ac92821c
Parents: 657dad3
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Thu Sep 3 15:43:35 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Thu Sep 3 15:43:35 2015 -0600

----------------------------------------------------------------------
 .../apache/usergrid/rest/SystemResourceIT.java  | 16 +++++++++
 .../test/resource/endpoints/NamedResource.java  | 34 ++++++++++++--------
 .../test/resource/endpoints/SystemResource.java | 25 ++++++++++++++
 3 files changed, 62 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/ba8922b7/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
index bb53e83..5c89422 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
@@ -23,7 +23,10 @@ import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 
+import java.util.LinkedHashMap;
+
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 
 /**
@@ -47,6 +50,19 @@ public class SystemResourceIT extends AbstractRestIT {
         assertNotNull( "ok", ( String ) result.get( "status" ) );
     }
 
+    @Test
+    public void testDeleteAllApplicationEntities() {
+        QueryParameters queryParameters = new QueryParameters();
+        queryParameters.addParam( "access_token", clientSetup.getSuperuserToken().getAccessToken()
);
+        queryParameters.addParam("confirmApplicationId", this.clientSetup.getAppUuid());
+
+        org.apache.usergrid.rest.test.resource.model.ApiResponse result = clientSetup.getRestClient().system().applications(this.clientSetup.getAppUuid()).delete(
queryParameters);
+
+        assertNotNull( result );
+        assertNotNull( "ok",result.getStatus() );
+        assertTrue((int)((LinkedHashMap)result.getData()).get("count")==4);
+    }
+
 
     @Test
     public void testBoostrapAlreadyRun() {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ba8922b7/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
index 03f6b72..1a9c776 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
@@ -169,7 +169,7 @@ public class NamedResource implements UrlResource {
      */
     //For edge cases like Organizations and Tokens
     public ApiResponse post(Map map) {
-        return post( true, ApiResponse.class, map, null, false );
+        return post(true, ApiResponse.class, map, null, false);
 
     }
 
@@ -275,17 +275,17 @@ public class NamedResource implements UrlResource {
         if(useBasicAuthentication){
             //added httpBasicauth filter to all setup calls because they all do verification
this way.
             HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( "superuser","superpassword"
);
-            resource.addFilter( httpBasicAuthFilter );
+            resource.addFilter(httpBasicAuthFilter);
         }
 
         GenericType<T> gt = new GenericType<>((Class) type);
-        return builder.post( gt.getRawClass() );
+        return builder.post(gt.getRawClass());
 
     }
 
     //For edge cases like Organizations and Tokens without any payload
     public <T> T get(Class<T> type) {
-        return get(type,null,true);
+        return get(type, null, true);
 
     }
 
@@ -308,7 +308,7 @@ public class NamedResource implements UrlResource {
         GenericType<T> gt = new GenericType<>((Class) type);
         return resource.type(MediaType.APPLICATION_JSON_TYPE)
             .accept( MediaType.APPLICATION_JSON )
-            .get( gt.getRawClass() );
+            .get(gt.getRawClass());
 
     }
 
@@ -322,34 +322,34 @@ public class NamedResource implements UrlResource {
     }
 
     public ApiResponse post( FormDataMultiPart multiPartForm ) {
-        return post( true, multiPartForm );
+        return post(true, multiPartForm);
     }
 
     public ApiResponse put( boolean useToken, byte[] data, MediaType type ) {
         WebResource resource = getResource(useToken);
-        return resource.type( type ).put( ApiResponse.class, data );
+        return resource.type( type ).put(ApiResponse.class, data);
     }
 
     public ApiResponse put( byte[] data, MediaType type ) {
-        return put( true, data, type );
+        return put(true, data, type);
     }
 
     public ApiResponse put( boolean useToken, FormDataMultiPart multiPartForm ) {
         WebResource resource = getResource(useToken);
-        return resource.type( MediaType.MULTIPART_FORM_DATA_TYPE ).put( ApiResponse.class,
multiPartForm );
+        return resource.type( MediaType.MULTIPART_FORM_DATA_TYPE ).put(ApiResponse.class,
multiPartForm);
     }
 
     public ApiResponse put( FormDataMultiPart multiPartForm ) {
-        return put( true, multiPartForm );
+        return put(true, multiPartForm);
     }
 
     public InputStream getAssetAsStream( boolean useToken ) {
         WebResource resource = getResource(useToken);
-        return resource.accept( MediaType.APPLICATION_OCTET_STREAM_TYPE ).get( InputStream.class
);
+        return resource.accept( MediaType.APPLICATION_OCTET_STREAM_TYPE ).get(InputStream.class);
     }
 
     public InputStream getAssetAsStream() {
-        return getAssetAsStream( true );
+        return getAssetAsStream(true);
     }
 
     public ApiResponse delete( ) {
@@ -357,6 +357,14 @@ public class NamedResource implements UrlResource {
     }
 
     public ApiResponse delete( boolean useToken ) {
-        return getResource(useToken).delete( ApiResponse.class );
+        return getResource(useToken).delete(ApiResponse.class);
+    }
+
+    public ApiResponse delete( boolean useToken, QueryParameters queryParameters ) {
+        WebResource resource = getResource(useToken);
+        if(queryParameters!=null) {
+            resource = addParametersToResource(resource, queryParameters);
+        }
+        return resource.delete( ApiResponse.class );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ba8922b7/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
index cb8a369..c6a0586 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
@@ -20,10 +20,15 @@ package org.apache.usergrid.rest.test.resource.endpoints;
 
 import javax.ws.rs.core.MediaType;
 
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.Entity;
+import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 
+import java.util.UUID;
+
 
 /**
  * Handles making rest calls to system resources.
@@ -40,4 +45,24 @@ public class SystemResource extends NamedResource {
     }
 
 
+    public ApplicationsResource applications(String appid) {
+        return new ApplicationsResource(appid,context,this);
+    }
+    public class ApplicationsResource extends NamedResource {
+        public ApplicationsResource(final String appid, final ClientContext context, final
UrlResource parent ) {
+            super( "applications/"+appid,context, parent );
+        }
+        public ApiResponse delete(QueryParameters queryParameters){
+
+            WebResource resource = getResource();
+            resource = addParametersToResource( resource, queryParameters );
+
+            //added httpBasicauth filter to all setup calls because they all do verification
this way.
+            HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( "superuser","superpassword"
);
+            resource.addFilter(httpBasicAuthFilter);
+
+            return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON
)
+                .delete(ApiResponse.class);
+        }
+    }
 }


Mime
View raw message