CLOUD-1928: Filtered out tasks were taken into account for skip-count, sometimes resulting in skipping too little actual matching tasks

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@53939 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Frederik Heremans
2013-08-12 11:47:19 +00:00
parent 8a5a47077b
commit a91f6e2535
2 changed files with 28 additions and 1 deletions

View File

@@ -88,6 +88,7 @@ public abstract class AbstractWorkflowRestApiTest extends BaseWebScriptTest
protected static final String URL_USER_TASKS_PROPERTIES = "api/task-instances?authority={0}&properties={1}";
protected static final String URL_TASKS_DUE_BEFORE = "api/task-instances?dueBefore={0}";
protected static final String URL_TASKS_DUE_AFTER = "api/task-instances?dueAfter={0}";
protected static final String URL_TASKS_DUE_AFTER_AND_SKIP = "api/task-instances?dueAfter={0}&skipCount={1}";
protected static final String URL_WORKFLOW_TASKS = "api/workflow-instances/{0}/task-instances";
protected static final String URL_WORKFLOW_DEFINITIONS = "api/workflow-definitions";
protected static final String URL_WORKFLOW_DEFINITION = "api/workflow-definitions/{0}";
@@ -270,6 +271,32 @@ public abstract class AbstractWorkflowRestApiTest extends BaseWebScriptTest
}
}
assertFalse("Found wf:submitAdhocTask when they were supposed to be excluded", adhocTasksPresent);
// CLOUD-1928: Check skip-count works toghether with filter, start another process
personManager.setUser(USER1);
params.clear();
params.put(WorkflowModel.ASSOC_ASSIGNEE, personManager.get(USER2));
dueDateCal.add(Calendar.DAY_OF_YEAR, 2);
params.put(WorkflowModel.PROP_DUE_DATE, dueDateCal.getTime());
params.put(WorkflowModel.PROP_PRIORITY, 1);
params.put(WorkflowModel.ASSOC_PACKAGE, workflowService.createPackage(null));
WorkflowPath adhocPath2 = workflowService.startWorkflow(adhocDef.getId(), params);
String workflowId2 = adhocPath2.getInstance().getId();
workflows.add(workflowId2);
WorkflowTask startTask2 = workflowService.getStartTask(workflowId2);
workflowService.endTask(startTask2.getId(), null);
// Filter based on due-date and skip first result. Should return nothing instead of
// the second task, since only one matches and one is skipped
// Due after tomorrow, started task shouldn't be in it
String url = MessageFormat.format(URL_TASKS_DUE_AFTER_AND_SKIP, ISO8601DateFormat.format(dueDateCal.getTime()), 1);
json = getDataFromRequest(url);
JSONArray resultArray = json.getJSONArray("data");
assertEquals(0, resultArray.length());
}
public void testTaskInstancesForWorkflowGet() throws Exception

View File

@@ -180,7 +180,7 @@ public class TaskInstancesGet extends AbstractWorkflowWebscript
{
// Total-count needs to be based on matching tasks only, so we can't just use allTasks.size() for this
totalCount++;
if(i >= skipCount && (maxItems < 0 || maxItems > results.size()))
if(totalCount > skipCount && (maxItems < 0 || maxItems > results.size()))
{
// Only build the actual detail if it's in the range of items we need. This will
// drastically improve performance over paging after building the model