Search in sources :

Example 36 with GetRequest

use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.

the class RuleServiceTest method testGetRuleset.

public void testGetRuleset() throws Exception {
    JSONObject parentRule = createRule(testWorkNodeRef);
    String[] parentRuleIds = new String[] { parentRule.getJSONObject("data").getString("id") };
    JSONObject jsonRule = createRule(testNodeRef);
    String[] ruleIds = new String[] { jsonRule.getJSONObject("data").getString("id") };
    Action linkRulesAction = actionService.createAction(LinkRules.NAME);
    linkRulesAction.setParameterValue(LinkRules.PARAM_LINK_FROM_NODE, testNodeRef);
    actionService.executeAction(linkRulesAction, testNodeRef2);
    Response linkedFromResponse = sendRequest(new GetRequest(formatRulesetUrl(testNodeRef)), 200);
    JSONObject linkedFromResult = new JSONObject(linkedFromResponse.getContentAsString());
    checkRuleset(linkedFromResult, 1, ruleIds, 1, parentRuleIds, true, false);
    Response linkedToResponse = sendRequest(new GetRequest(formatRulesetUrl(testNodeRef2)), 200);
    JSONObject linkedToResult = new JSONObject(linkedToResponse.getContentAsString());
    checkRuleset(linkedToResult, 1, ruleIds, 1, parentRuleIds, false, true);
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) Action(org.alfresco.service.cmr.action.Action) JSONObject(org.json.JSONObject) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)

Example 37 with GetRequest

use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.

the class RuleServiceTest method testGetActionDefinitions.

public void testGetActionDefinitions() throws Exception {
    Response response = sendRequest(new GetRequest(URL_ACTIONDEFINITIONS), 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 actionDefinition = data.getJSONObject(i);
        assertTrue(actionDefinition.has("name"));
        assertTrue(actionDefinition.has("displayLabel"));
        assertTrue(actionDefinition.has("description"));
        assertTrue(actionDefinition.has("adHocPropertiesAllowed"));
        assertTrue(actionDefinition.has("parameterDefinitions"));
        assertTrue(actionDefinition.has("applicableTypes"));
    }
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) JSONObject(org.json.JSONObject) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest) JSONArray(org.json.JSONArray) ParameterConstraint(org.alfresco.service.cmr.action.ParameterConstraint)

Example 38 with GetRequest

use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.

the class RuleServiceTest method testGetActionConditionDefinitions.

public void testGetActionConditionDefinitions() throws Exception {
    Response response = sendRequest(new GetRequest(URL_ACTIONCONDITIONDEFINITIONS), 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 actionConditionDefinition = data.getJSONObject(i);
        assertTrue(actionConditionDefinition.has("name"));
        assertTrue(actionConditionDefinition.has("displayLabel"));
        assertTrue(actionConditionDefinition.has("description"));
        assertTrue(actionConditionDefinition.has("adHocPropertiesAllowed"));
        assertTrue(actionConditionDefinition.has("parameterDefinitions"));
    }
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) JSONObject(org.json.JSONObject) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest) JSONArray(org.json.JSONArray) ParameterConstraint(org.alfresco.service.cmr.action.ParameterConstraint)

Example 39 with GetRequest

use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest 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);
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) JSONObject(org.json.JSONObject) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)

Example 40 with GetRequest

use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest 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"));
    }
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) JSONObject(org.json.JSONObject) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest) JSONArray(org.json.JSONArray) ParameterConstraint(org.alfresco.service.cmr.action.ParameterConstraint)

Aggregations

GetRequest (org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)182 Response (org.springframework.extensions.webscripts.TestWebScriptServer.Response)171 JSONObject (org.json.JSONObject)141 JSONArray (org.json.JSONArray)89 PostRequest (org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest)25 HashMap (java.util.HashMap)23 JSONTokener (org.json.JSONTokener)23 DeleteRequest (org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest)21 PutRequest (org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest)17 NodeRef (org.alfresco.service.cmr.repository.NodeRef)14 Serializable (java.io.Serializable)13 WorkflowDefinition (org.alfresco.service.cmr.workflow.WorkflowDefinition)13 QName (org.alfresco.service.namespace.QName)13 ArrayList (java.util.ArrayList)12 WorkflowPath (org.alfresco.service.cmr.workflow.WorkflowPath)12 Date (java.util.Date)11 WorkflowTask (org.alfresco.service.cmr.workflow.WorkflowTask)11 JSONStringer (org.json.JSONStringer)7 Calendar (java.util.Calendar)6 UserTransaction (javax.transaction.UserTransaction)6