Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)

99763: Merged 5.0.N (5.0.2) to HEAD-BUG-FIX (5.1/Cloud)
      99694: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.2)
         99487: Merged DEV to V4.2-BUG-FIX (4.2.5)
            99401: MNT-13567: [Workflow Public API] : incorrect hasMoreItems value
               - Comparison operator was changed to take in account SkipCount > totalItems condition.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@100490 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-03-27 22:55:57 +00:00
parent 9034d57c09
commit 6095d2399e
5 changed files with 16 additions and 6 deletions

View File

@@ -65,7 +65,7 @@ public class DeploymentsImpl extends WorkflowRestImpl implements Deployments
page.add(new Deployment(deployment));
}
return CollectionWithPagingInfo.asPaged(paging, page, page.size() != totalCount, totalCount);
return CollectionWithPagingInfo.asPaged(paging, page, (page.size() + paging.getSkipCount()) < totalCount, totalCount);
}
@Override

View File

@@ -232,7 +232,7 @@ public class ProcessDefinitionsImpl extends WorkflowRestImpl implements ProcessD
page.add(createProcessDefinitionRest((ProcessDefinitionEntity) processDefinition));
}
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), page, page.size() != totalCount, totalCount);
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), page, (page.size() + parameters.getPaging().getSkipCount()) < totalCount, totalCount);
}
@Override

View File

@@ -496,7 +496,7 @@ public class ProcessesImpl extends WorkflowRestImpl implements Processes
page.add(processInfo);
}
return CollectionWithPagingInfo.asPaged(paging, page, (page.size() + paging.getSkipCount()) != totalCount, totalCount);
return CollectionWithPagingInfo.asPaged(paging, page, (page.size() + paging.getSkipCount()) < totalCount, totalCount);
}
@Override

View File

@@ -596,7 +596,7 @@ public class TasksImpl extends WorkflowRestImpl implements Tasks
throw new InvalidArgumentException("Invalid status parameter: " + status);
}
return CollectionWithPagingInfo.asPaged(paging, page, page.size() != totalCount, totalCount);
return CollectionWithPagingInfo.asPaged(paging, page, (page.size() + paging.getSkipCount()) < totalCount, totalCount);
}
protected void addVariables(Task task, Boolean includeProcessVariables, Boolean includeTaskVariables,
@@ -705,7 +705,7 @@ public class TasksImpl extends WorkflowRestImpl implements Tasks
throw new InvalidArgumentException("Invalid status parameter: " + status);
}
return CollectionWithPagingInfo.asPaged(paging, page, page.size() != totalCount, totalCount);
return CollectionWithPagingInfo.asPaged(paging, page, (page.size() + paging.getSkipCount()) < totalCount, totalCount);
}
@Override

View File

@@ -172,6 +172,16 @@ public class ProcessesImplTest extends TestCase
assertFalse(actualProcesses.hasMoreItems());
}
@Test
public void testHasMoreFalseAsPerMnt13567() throws Exception
{
CollectionWithPagingInfo<ProcessInfo> actualProcesses = queryActiveProcessesAndAssertResult(ACTIVE_WORKFLOWS_INITIAL_AMOUNT, ACTIVE_WORKFLOWS_INITIAL_AMOUNT);
assertFalse(actualProcesses.hasMoreItems());
actualProcesses = queryActiveProcessesAndAssertResult(ACTIVE_WORKFLOWS_INITIAL_AMOUNT + 1, ACTIVE_WORKFLOWS_INITIAL_AMOUNT);
assertFalse(actualProcesses.hasMoreItems());
}
private CollectionWithPagingInfo<ProcessInfo> queryActiveProcessesAndAssertResult(int skipCount, int maxItems)
{
Query query = ResourceWebScriptHelper.getWhereClause(QUERY_STATUS_ACTIVE);
@@ -182,7 +192,7 @@ public class ProcessesImplTest extends TestCase
assertNotNull(result);
assertNotNull(result.getCollection());
int remainingProcessesAmount = ACTIVE_WORKFLOWS_INITIAL_AMOUNT - skipCount;
int remainingProcessesAmount = skipCount > ACTIVE_WORKFLOWS_INITIAL_AMOUNT ? 0 : ACTIVE_WORKFLOWS_INITIAL_AMOUNT - skipCount;
if (maxItems >= remainingProcessesAmount)
{
assertEquals(remainingProcessesAmount, result.getCollection().size());