use of org.alfresco.rest.framework.core.ResourceWithMetadata in project alfresco-remote-api by Alfresco.
the class SerializeTests method testInvokeMultiPartEntity.
@Test
public void testInvokeMultiPartEntity() throws IOException {
ResourceWithMetadata entityResource = locator.locateEntityResource(api, "multiparttest", HttpMethod.POST);
assertNotNull(entityResource);
MultiPartResourceAction.Create<?> resource = (MultiPartResourceAction.Create<?>) entityResource.getResource();
File file = TempFileProvider.createTempFile("ParamsExtractorTests-", ".txt");
PrintWriter writer = new PrintWriter(file);
writer.println("Multipart Mock test2.");
writer.close();
MultiPartRequest reqBody = MultiPartBuilder.create().setFileData(new FileData(file.getName(), file, MimetypeMap.MIMETYPE_TEXT_PLAIN)).build();
MockHttpServletRequest mockRequest = new MockHttpServletRequest("POST", "");
mockRequest.setContent(reqBody.getBody());
mockRequest.setContentType(reqBody.getContentType());
String out = writeResponse(helper.processAdditionsToTheResponse(mock(WebScriptResponse.class), api, null, NOT_USED, resource.create(new FormData(mockRequest), NOT_USED, callBack)));
assertTrue("There must be json output", StringUtils.startsWith(out, "{\"entry\":"));
}
use of org.alfresco.rest.framework.core.ResourceWithMetadata in project alfresco-remote-api by Alfresco.
the class WriterTests method testWriters.
@Test
public void testWriters() throws IOException {
ResourceDictionary resourceDic = locator.getDictionary();
Map<String, ResourceWithMetadata> apiResources = resourceDic.getAllResources().get(api);
String writtenOut = testWriter(defaultMetaWriter, apiResources.get("/sheep"), apiResources);
assertTrue(writtenOut.startsWith("{\"list\":{\"pagination\":{\"count\":5"));
// ResourceMetaDataWriter wadlWriter = new WebScriptOptionsMetaData();
// writtenOut = testWriter(wadlWriter, apiResources.get("/sheep"), apiResources);
// assertTrue(writtenOut.startsWith("{\"list\":{\"pagination\":{\"count\":4"));
}
Aggregations