You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2015/01/22 16:48:32 UTC
[14/19] incubator-usergrid git commit: Beginnings of a REST test.
Beginnings of a REST test.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/4384975f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/4384975f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/4384975f
Branch: refs/heads/USERGRID-323-Win-phone
Commit: 4384975fa91d2c7e5ffad06f9adf4a16855d3839
Parents: 7335f94
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Jan 20 16:30:53 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Jan 20 16:30:53 2015 -0500
----------------------------------------------------------------------
.../rest/applications/ApplicationResource.java | 32 +++++++++---
.../applications/ApplicationDeleteTest.java | 54 ++++++++++++++++++++
2 files changed, 80 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4384975f/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
index 6144940..6a3c94c 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
@@ -38,6 +38,13 @@ import javax.ws.rs.core.PathSegment;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
+import org.apache.usergrid.rest.ApiResponse;
+import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
+import org.apache.usergrid.services.ServiceAction;
+import org.apache.usergrid.services.ServiceResults;
+import org.apache.usergrid.services.assets.data.AssetUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
@@ -495,15 +502,28 @@ public class ApplicationResource extends ServiceResource {
@DELETE
- @RequireApplicationAccess
+ @RequireOrganizationAccess
@Override
- public JSONWithPadding executeDelete( @Context UriInfo ui,
- @QueryParam("callback") @DefaultValue("callback") String callback )
- throws Exception {
+ public JSONWithPadding executeDelete( @Context UriInfo ui,
+ @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
+
+ if ( applicationId == null ) {
+ throw new IllegalArgumentException("Application ID not specified in request");
+ }
+
+ ApplicationInfo app = management.getApplicationInfo( applicationId );
+ if ( app == null ) {
+ throw new EntityNotFoundException("Application ID " + applicationId + " not found");
+ }
+
+ emf.deleteApplication( applicationId );
- logger.debug( "ApplicationResource.executeDelete" );
+ ApiResponse response = createApiResponse();
+ response.setAction( "delete" );
+ response.setApplication( services.getApplication() );
+ response.setParams( ui.getQueryParameters() );
- throw new NotImplementedException( "Application delete is not allowed yet" );
+ return new JSONWithPadding( response, callback );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4384975f/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteTest.java
new file mode 100644
index 0000000..e74b324
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.applications;
+
+
+import org.apache.usergrid.rest.AbstractRestIT;
+import org.apache.usergrid.rest.TestContextSetup;
+import org.junit.Rule;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class ApplicationDeleteTest extends AbstractRestIT {
+ private static final Logger log = LoggerFactory.getLogger(ApplicationDeleteTest.class);
+
+ @Rule
+ public TestContextSetup context = new TestContextSetup( this );
+
+ @Test
+ public void testBasicOperation() throws Exception {
+
+ // create a user
+
+ // crete an organization
+
+ // create an application
+
+ // create a collection with two entities
+
+ // test that we can query those entities
+
+ // delete the application
+
+ // test that we cannot delete the application a second time
+
+ // test that we can no longer query for those entities
+ }
+}