Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)

128984 amorarasu: MNT-16469: Merged 5.0.N (5.0.4) to 5.1.N (5.1.2)
      128478 amorarasu: MNT-16468: Merged V4.2-BUG-FIX (4.2.7) to 5.0.N (5.0.4)
         128228, 128380 amorarasu: MNT-16439: Merged V4.2.4 (4.2.4.23) to V4.2-BUG-FIX (4.2.7)
            128107 amorarasu: MNT-16040: skipCount does not appear to work for Workflow tasks REST api
         - Updated Activiti to version 5.19.0.3


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@128985 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ancuta Morarasu
2016-07-26 15:19:21 +00:00
parent c83640151e
commit a991968b63
4 changed files with 93 additions and 1 deletions

View File

@@ -1995,6 +1995,81 @@ public class TaskWorkflowApiTest extends EnterpriseWorkflowTestApi
}
}
@Test
public void testGetTasksWithPagingAndVariablesLimit() throws Exception
{
RequestContext requestContext = initApiClientWithTestUser();
List<ProcessInstance> startedProcesses = new ArrayList<ProcessInstance>();
// system.workflow.engine.activiti.taskvariableslimit is set to 200 in test-resources/alfresco-global.properties
try
{
// MNT-16040: Create tasks with a number of variables just below the taskvariableslimit and test that skipCount is working as expected.
int numberOfTasks = 15;
for (int i = 0; i < numberOfTasks; i++)
{
startedProcesses.add(startAdhocProcess(requestContext.getRunAsUser(), requestContext.getNetworkId(), null));
}
TaskService taskService = activitiProcessEngine.getTaskService();
List<Task> taskList = new ArrayList<Task>();
for (int i = 0; i < numberOfTasks; i++)
{
Task task = taskService.createTaskQuery().processInstanceId(startedProcesses.get(i).getProcessInstanceId()).singleResult();
taskService.setPriority(task.getId(), (i + 1) * 10);
// Add an extra variable to the task, there are other 12 added, so a total of 13 variables for each task.
taskService.setVariableLocal(task.getId(), "test1", "test1");
taskList.add(task);
}
TasksClient tasksClient = publicApiClient.tasksClient();
// Test without skipCount
Map<String, String> params = new HashMap<String, String>();
params.put("where", "(includeProcessVariables = true AND includeTaskVariables = true)");
JSONObject taskListJSONObject = tasksClient.findTasks(params);
assertNotNull(taskListJSONObject);
JSONObject paginationJSON = (JSONObject) taskListJSONObject.get("pagination");
assertEquals(15l, paginationJSON.get("count"));
assertEquals(15l, paginationJSON.get("totalItems"));
assertEquals(0l, paginationJSON.get("skipCount"));
assertEquals(false, paginationJSON.get("hasMoreItems"));
JSONArray jsonEntries = (JSONArray) taskListJSONObject.get("entries");
assertEquals(15, jsonEntries.size());
// Test with skipCount
params.clear();
params.put("skipCount", "5");
params.put("where", "(includeProcessVariables = true AND includeTaskVariables = true)");
taskListJSONObject = tasksClient.findTasks(params);
assertNotNull(taskListJSONObject);
paginationJSON = (JSONObject) taskListJSONObject.get("pagination");
assertEquals(10l, paginationJSON.get("count"));
assertEquals(15l, paginationJSON.get("totalItems"));
assertEquals(5l, paginationJSON.get("skipCount"));
assertEquals(false, paginationJSON.get("hasMoreItems"));
jsonEntries = (JSONArray) taskListJSONObject.get("entries");
assertEquals(10, jsonEntries.size());
params.clear();
params.put("maxItems", "10");
params.put("where", "(includeProcessVariables = true AND includeTaskVariables = true)");
taskListJSONObject = tasksClient.findTasks(params);
assertNotNull(taskListJSONObject);
paginationJSON = (JSONObject) taskListJSONObject.get("pagination");
assertEquals(10l, paginationJSON.get("count"));
assertEquals(15l, paginationJSON.get("totalItems"));
assertEquals(0l, paginationJSON.get("skipCount"));
assertEquals(true, paginationJSON.get("hasMoreItems"));
jsonEntries = (JSONArray) taskListJSONObject.get("entries");
assertEquals(10, jsonEntries.size());
}
finally
{
cleanupProcessInstance(startedProcesses.toArray(new ProcessInstance[] {}));
}
}
protected void validateVariables(JSONObject entry, RequestContext requestContext) {
JSONObject taskObject = (JSONObject) entry.get("entry");
JSONArray variables = (JSONArray) taskObject.get("variables");