use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class SubscriptionServiceRestApiTest method getFollowing.
protected List<String> getFollowing(String user) throws Exception {
String url = getUrl(URL_FOLLOWING, user);
Response response = sendRequest(new GetRequest(url), Status.STATUS_OK);
JSONObject resultObject = new JSONObject(response.getContentAsString());
assertTrue(resultObject.has("people"));
List<String> result = new ArrayList<String>();
JSONArray people = resultObject.getJSONArray("people");
for (int i = 0; i < people.length(); i++) {
JSONObject person = people.getJSONObject(i);
assertTrue(person.has("userName"));
assertTrue(person.has("firstName"));
assertTrue(person.has("lastName"));
result.add(person.getString("userName"));
}
return result;
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class SubscriptionServiceRestApiTest method isSubscriptionListPrivate.
protected boolean isSubscriptionListPrivate(String user) throws Exception {
String url = getUrl(URL_PRIVATE, user);
Response response = sendRequest(new GetRequest(url), Status.STATUS_OK);
JSONObject resultObject = new JSONObject(response.getContentAsString());
assertTrue(resultObject.has("private"));
return resultObject.getBoolean("private");
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class ThumbnailServiceTest method testThumbnailDefinitions.
public void testThumbnailDefinitions() throws Exception {
// Check for pdfToSWF transformation before doing test
if (this.contentService.getTransformer(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_FLASH) != null) {
String url = "/api/node/" + pdfNode.getStoreRef().getProtocol() + "/" + pdfNode.getStoreRef().getIdentifier() + "/" + pdfNode.getId() + "/content/thumbnaildefinitions";
Response response = sendRequest(new GetRequest(url), 200);
JSONArray array = new JSONArray(response.getContentAsString());
assertNotNull(array);
assertFalse(array.length() == 0);
boolean hasMedium = false;
boolean hasWebPreview = false;
for (int i = 0; i < array.length(); i++) {
if (array.getString(i).equals("medium") == true) {
hasMedium = true;
} else if (array.getString(i).equals("webpreview") == true) {
hasWebPreview = true;
}
}
assertTrue(hasMedium);
assertTrue(hasWebPreview);
}
String url = "/api/node/" + jpgNode.getStoreRef().getProtocol() + "/" + jpgNode.getStoreRef().getIdentifier() + "/" + jpgNode.getId() + "/content/thumbnaildefinitions";
Response response = sendRequest(new GetRequest(url), 200);
JSONArray array = new JSONArray(response.getContentAsString());
assertNotNull(array);
assertFalse(array.length() == 0);
boolean hasMedium = false;
boolean hasWebPreview = false;
for (int i = 0; i < array.length(); i++) {
if (array.getString(i).equals("medium") == true) {
hasMedium = true;
} else if (array.getString(i).equals("webpreview") == true) {
hasWebPreview = true;
}
}
assertTrue(hasMedium);
assertFalse(hasWebPreview);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class ThumbnailServiceTest method testUpdateThumbnail.
public void testUpdateThumbnail() throws Exception {
// Do a image transformation
String url = "/api/node/" + jpgNode.getStoreRef().getProtocol() + "/" + jpgNode.getStoreRef().getIdentifier() + "/" + jpgNode.getId() + "/content/thumbnails";
JSONObject tn = new JSONObject();
tn.put("thumbnailName", "doclib");
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
System.out.println(response.getContentAsString());
// Check getAll whilst we are here
Response getAllResp = sendRequest(new GetRequest(getThumbnailsURL(jpgNode)), 200);
JSONArray getArr = new JSONArray(getAllResp.getContentAsString());
assertNotNull(getArr);
assertEquals(1, getArr.length());
assertEquals("doclib", getArr.getJSONObject(0).get("thumbnailName"));
// Now we know that thumbnail was created
sendRequest(new GetRequest(getThumbnailsURL(jpgNode) + "/incorrectname"), 404);
// Request for update of thumbnail, that is absent
sendRequest(new PutRequest(getThumbnailsURL(jpgNode) + "/incorrectname", "", "application/json"), 404);
// Request for update of correct thumbnail
sendRequest(new PutRequest(getThumbnailsURL(jpgNode) + "/doclib", "", "application/json"), 200);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class ThumbnailServiceTest method testCreateAsyncThumbnail.
public void testCreateAsyncThumbnail() throws Exception {
// Check for pdfToSWF transformation before doing test
if (this.contentService.getTransformer(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_FLASH) != null) {
String url = "/api/node/" + pdfNode.getStoreRef().getProtocol() + "/" + pdfNode.getStoreRef().getIdentifier() + "/" + pdfNode.getId() + "/content/thumbnails?as=true";
JSONObject tn = new JSONObject();
tn.put("thumbnailName", "webpreview");
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
assertEquals("", response.getContentAsString().trim());
getWait(pdfNode, "webpreview");
}
// Do a image transformation (medium)
String url = "/api/node/" + jpgNode.getStoreRef().getProtocol() + "/" + jpgNode.getStoreRef().getIdentifier() + "/" + jpgNode.getId() + "/content/thumbnails?as=true";
JSONObject tn = new JSONObject();
tn.put("thumbnailName", "medium");
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
assertEquals("", response.getContentAsString().trim());
getWait(jpgNode, "medium");
}
Aggregations