use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class RuleServiceTest method testGetRuleDetails.
public void testGetRuleDetails() throws Exception {
JSONObject jsonRule = createRule(testNodeRef);
String ruleId = jsonRule.getJSONObject("data").getString("id");
Response response = sendRequest(new GetRequest(formateRuleUrl(testNodeRef, ruleId)), 200);
JSONObject result = new JSONObject(response.getContentAsString());
checkRuleComplete(result);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class RuleServiceTest method createRule.
private JSONObject createRule(NodeRef ruleOwnerNodeRef, String title) throws Exception {
JSONObject jsonRule = buildTestRule(title);
Response response = sendRequest(new PostRequest(formatRulesUrl(ruleOwnerNodeRef, false), jsonRule.toString(), "application/json"), 200);
JSONObject result = new JSONObject(response.getContentAsString());
return result;
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class RuleServiceTest method testGetRuleTypes.
public void testGetRuleTypes() throws Exception {
Response response = sendRequest(new GetRequest(URL_RULETYPES), 200);
JSONObject result = new JSONObject(response.getContentAsString());
assertNotNull(result);
assertTrue(result.has("data"));
JSONArray data = result.getJSONArray("data");
for (int i = 0; i < data.length(); i++) {
JSONObject ruleType = data.getJSONObject(i);
assertTrue(ruleType.has("name"));
assertTrue(ruleType.has("displayLabel"));
assertTrue(ruleType.has("url"));
}
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class RuleServiceTest method testUpdateRule.
public void testUpdateRule() throws Exception {
JSONObject jsonRule = createRule(testNodeRef);
String ruleId = jsonRule.getJSONObject("data").getString("id");
Response getResponse = sendRequest(new GetRequest(formateRuleUrl(testNodeRef, ruleId)), 200);
JSONObject before = new JSONObject(getResponse.getContentAsString());
// do some changes
before.put("description", "this is modified description for test_rule");
// do some changes for action object
JSONObject beforeAction = before.getJSONObject("action");
// no changes for actions list
beforeAction.remove("actions");
// clear conditions
beforeAction.put("conditions", new JSONArray());
Response putResponse = sendRequest(new PutRequest(formateRuleUrl(testNodeRef, ruleId), before.toString(), "application/json"), 200);
JSONObject after = new JSONObject(putResponse.getContentAsString());
// sent and retrieved objects should be the same (except ids and urls)
// this means that all changes was saved
checkUpdatedRule(before, after);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class RuleServiceTest method testGetActionConstraint.
public void testGetActionConstraint() throws Exception {
List<ParameterConstraint> constraints = actionService.getParameterConstraints();
if (constraints.size() == 0) {
return;
}
String name = constraints.get(0).getName();
Response response = sendRequest(new GetRequest(formateActionConstraintUrl(name)), 200);
JSONObject result = new JSONObject(response.getContentAsString());
assertNotNull(result);
assertTrue(result.has("data"));
JSONObject data = result.getJSONObject("data");
assertTrue(data.has("name"));
assertTrue(data.has("values"));
JSONArray values = data.getJSONArray("values");
for (int i = 0; i < values.length(); i++) {
JSONObject value = values.getJSONObject(i);
assertTrue(value.has("value"));
assertTrue(value.has("displayLabel"));
}
}
Aggregations