mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
126474 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 122419 gjames: RA-827 More testing of custom status codes git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126818 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -32,6 +32,7 @@ import org.alfresco.rest.framework.core.ResourceParameter;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -47,12 +48,13 @@ public class GrassEntityResource implements EntityResourceAction.ReadById<Grass>
|
||||
}
|
||||
|
||||
@Operation("cut")
|
||||
@WebApiDescription(title = "Cut the grass",successStatus = Status.STATUS_NOT_IMPLEMENTED)
|
||||
public String cutLawn(String id, Void notused, Parameters parameters) {
|
||||
return "All done";
|
||||
}
|
||||
|
||||
@Operation("grow")
|
||||
@WebApiDescription(title = "Grow the grass")
|
||||
@WebApiDescription(title = "Grow the grass",successStatus = Status.STATUS_ACCEPTED)
|
||||
@WebApiParam(name = "Grass", title = "The grass.",required=true, kind = ResourceParameter.KIND.HTTP_BODY_OBJECT)
|
||||
public String growTheLawn(String id, Grass grass, Parameters parameters) {
|
||||
return "Growing well";
|
||||
|
@@ -26,9 +26,11 @@
|
||||
|
||||
package org.alfresco.rest.framework.tests.api.mocks;
|
||||
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
|
||||
/**
|
||||
@@ -40,6 +42,7 @@ public class MultiPartTestEntityResource
|
||||
{
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Creates a multipart", successStatus = Status.STATUS_ACCEPTED)
|
||||
public MultiPartTestResponse create(FormData formData, Parameters parameters)
|
||||
{
|
||||
return new MultiPartTestResponse(formData.getParameters().get("filename")[0]);
|
||||
|
@@ -29,12 +29,14 @@ package org.alfresco.rest.framework.tests.api.mocks;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.core.ResourceParameter;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
|
||||
/**
|
||||
* Implements Get
|
||||
@@ -55,6 +57,7 @@ public class SheepBlackSheepResource implements RelationshipResourceAction.Read<
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Deletes only black Sheep", successStatus = Status.STATUS_CONFLICT)
|
||||
public void delete(String entityResourceId, String id, Parameters parameters)
|
||||
{
|
||||
}
|
||||
|
@@ -33,11 +33,13 @@ import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
|
||||
@EntityResource(name=SheepEntityResource.ENTITY_KEY,title="Sheep")
|
||||
public class SheepEntityResource implements EntityResourceAction.Read<Sheep>,EntityResourceAction.ReadById<Sheep>, EntityResourceAction.Update<Sheep>, EntityResourceAction.Delete
|
||||
{
|
||||
public static final String ENTITY_KEY = "sheep";
|
||||
|
||||
@Override
|
||||
public void delete(String id, Parameters parameters)
|
||||
{
|
||||
@@ -56,7 +58,7 @@ public class SheepEntityResource implements EntityResourceAction.Read<Sheep>,Ent
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Gets all the Sheep")
|
||||
@WebApiDescription(title = "Gets all the Sheep", successStatus = Status.STATUS_ACCEPTED)
|
||||
@WebApiParameters({
|
||||
@WebApiParam(name = "siteId", title = "Site id", description="What ever."),
|
||||
@WebApiParam(name = "who", title = "Who", kind=ResourceParameter.KIND.HTTP_HEADER),
|
||||
|
@@ -38,6 +38,7 @@ import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||
import org.alfresco.rest.framework.resource.content.FileBinaryResource;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
|
||||
@EntityResource(name="flock",title="A resource used for testing binary properties")
|
||||
public class FlockEntityResource implements BinaryResourceAction.Read, BinaryResourceAction.Delete, BinaryResourceAction.Update<Flock>
|
||||
@@ -62,7 +63,7 @@ public class FlockEntityResource implements BinaryResourceAction.Read, BinaryRes
|
||||
|
||||
//versions/1/flock/xyz/photo GET
|
||||
@Override
|
||||
@WebApiDescription(title = "Reads a photo as a Stream")
|
||||
@WebApiDescription(title = "Reads a photo as a Stream", successStatus = Status.STATUS_FOUND)
|
||||
@BinaryProperties("photo")
|
||||
public BinaryResource readProperty(String entityId, Parameters parameters) throws EntityNotFoundException
|
||||
{
|
||||
|
@@ -99,7 +99,9 @@ public class InspectorTests
|
||||
assertNotNull("SheepEntityResource supports PUT", metaData.getOperation(HttpMethod.PUT));
|
||||
assertNotNull("SheepEntityResource supports DELETE", metaData.getOperation(HttpMethod.DELETE));
|
||||
assertNull("SheepEntityResource does not support POST", metaData.getOperation(HttpMethod.POST));
|
||||
ResourceOperation op = metaData.getOperation(HttpMethod.PUT);
|
||||
ResourceOperation op = metaData.getOperation(HttpMethod.GET);
|
||||
assertEquals("Sheep ReadALL should return ACCEPTED", Status.STATUS_ACCEPTED, op.getSuccessStatus());
|
||||
op = metaData.getOperation(HttpMethod.PUT);
|
||||
assertTrue("SheepEntityResource must support Sheep", Sheep.class.equals(metaData.getObjectType(op)));
|
||||
|
||||
metainfo = ResourceInspector.inspect(SheepNoActionEntityResource.class);
|
||||
@@ -122,7 +124,6 @@ public class InspectorTests
|
||||
assertNotNull("FlockEntityResource supports PUT", metaData.getOperation(HttpMethod.PUT));
|
||||
assertNotNull("FlockEntityResource supports DELETE", metaData.getOperation(HttpMethod.DELETE));
|
||||
assertNull("FlockEntityResource does not support POST", metaData.getOperation(HttpMethod.POST));
|
||||
|
||||
metainfo = ResourceInspector.inspect(MultiPartTestEntityResource.class);
|
||||
assertTrue("Must be one ResourceMetadata",metainfo.size()==1);
|
||||
metaData = metainfo.get(0);
|
||||
@@ -133,6 +134,7 @@ public class InspectorTests
|
||||
assertNull("MultiPartTestEntityResource does not supports DELETE", metaData.getOperation(HttpMethod.DELETE));
|
||||
op = metaData.getOperation(HttpMethod.POST);
|
||||
assertTrue("MultiPartTestEntityResource must support MultiPartTestResponse", MultiPartTestResponse.class.equals(metaData.getObjectType(op)));
|
||||
assertEquals("MultiPartTestEntityResource should return ACCEPTED", Status.STATUS_ACCEPTED, op.getSuccessStatus());
|
||||
|
||||
}
|
||||
|
||||
@@ -166,6 +168,7 @@ public class InspectorTests
|
||||
}
|
||||
assertNotNull("SheepBlackSheepResource supports DELETE", metaData.getOperation(HttpMethod.DELETE));
|
||||
op = metaData.getOperation(HttpMethod.DELETE);
|
||||
assertEquals("SheepBlackSheepResource should return STATUS_CONFLICT", Status.STATUS_CONFLICT, op.getSuccessStatus());
|
||||
params = op.getParameters();
|
||||
assertTrue("DELETE method on a relations should have 2 url params.", params.size() == 2);
|
||||
|
||||
@@ -315,6 +318,7 @@ public class InspectorTests
|
||||
assertNotNull(op);
|
||||
assertTrue(HttpMethod.GET.equals(op.getHttpMethod()));
|
||||
assertTrue("Gets all the Sheep".equals(op.getTitle()));
|
||||
assertEquals("Sheep ReadALL should return ACCEPTED", Status.STATUS_ACCEPTED, op.getSuccessStatus());
|
||||
assertTrue("".equals(op.getDescription()));
|
||||
assertNotNull(op.getParameters());
|
||||
assertTrue(op.getParameters().size() == 7);
|
||||
@@ -463,6 +467,7 @@ public class InspectorTests
|
||||
assertNotNull("GrassEntityResource supports POST", resourceMetadata.getOperation(HttpMethod.POST));
|
||||
assertNull("GrassEntityResource does not support DELETE", resourceMetadata.getOperation(HttpMethod.DELETE));
|
||||
ResourceOperation op = resourceMetadata.getOperation(HttpMethod.POST);
|
||||
assertEquals("grow should return ACCEPTED", Status.STATUS_ACCEPTED, op.getSuccessStatus());
|
||||
Class paramType = resourceMetadata.getObjectType(op);
|
||||
Object paramObj = paramType.newInstance();
|
||||
result = (String) ResourceInspectorUtil.invokeMethod(actionMethod,grassEntityResource, "xyz", paramObj, Params.valueOf("notUsed", null));
|
||||
@@ -473,6 +478,7 @@ public class InspectorTests
|
||||
assertNull("GrassEntityResource does not support GET", resourceMetadata.getOperation(HttpMethod.GET));
|
||||
op = resourceMetadata.getOperation(HttpMethod.POST);
|
||||
assertNull(resourceMetadata.getObjectType(op));
|
||||
assertEquals("cut should return ACCEPTED", Status.STATUS_NOT_IMPLEMENTED, op.getSuccessStatus());
|
||||
result = (String) ResourceInspectorUtil.invokeMethod(actionMethod,grassEntityResource, "xyz", null, Params.valueOf("notUsed", null));
|
||||
assertEquals("All done",result);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user