use of org.alfresco.rest.framework.tests.api.mocks.GoatEntityResource in project alfresco-remote-api by Alfresco.
the class InspectorTests method testInspectEntity.
@Test
public void testInspectEntity() {
List<ResourceMetadata> metainfo = ResourceInspector.inspect(SheepEntityResource.class);
assertTrue("Must be one ResourceMetadata", metainfo.size() == 1);
ResourceMetadata metaData = metainfo.get(0);
assertNotNull(metaData);
assertNotNull("SheepEntityResource supports GET", metaData.getOperation(HttpMethod.GET));
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.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);
assertTrue("SheepNoActionEntityResource has no actions.", metainfo.isEmpty());
metainfo = ResourceInspector.inspect(GoatEntityResource.class);
assertTrue("Must be one ResourceMetadata", metainfo.size() == 1);
metaData = metainfo.get(0);
assertNotNull(metaData);
assertNotNull("GoatEntityResource supports GET", metaData.getOperation(HttpMethod.GET));
op = metaData.getOperation(HttpMethod.GET);
List<ResourceParameter> params = op.getParameters();
assertTrue("readById method should have 1 url param", params.size() == 1);
metainfo = ResourceInspector.inspect(FlockEntityResource.class);
assertTrue("Must be one ResourceMetadata", metainfo.size() == 1);
metaData = metainfo.get(0);
assertNotNull(metaData);
assertNotNull("FlockEntityResource supports GET", metaData.getOperation(HttpMethod.GET));
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);
assertNotNull(metaData);
assertNotNull("MultiPartTestEntityResource support POST", metaData.getOperation(HttpMethod.POST));
assertNull("MultiPartTestEntityResource does not supports GET", metaData.getOperation(HttpMethod.GET));
assertNull("MultiPartTestEntityResource does not supports PUT", metaData.getOperation(HttpMethod.PUT));
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());
}
Aggregations