public virtual void testSorting() { string processDefinitionId = ProcessDefinitionId; startProcesses(5); HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId); assertEquals(1, query.orderByActivityId().asc().list().size()); assertEquals(1, query.orderByActivityId().desc().list().size()); assertEquals(1, query.orderByActivityId().asc().count()); assertEquals(1, query.orderByActivityId().desc().count()); }
private void setSortOptions(HistoricActivityStatisticsQuery query, string sortOrder, string sortBy) { bool sortOptionsValid = (!string.ReferenceEquals(sortBy, null) && !string.ReferenceEquals(sortOrder, null)) || (string.ReferenceEquals(sortBy, null) && string.ReferenceEquals(sortOrder, null)); if (!sortOptionsValid) { throw new InvalidRequestException(Status.BAD_REQUEST, "Only a single sorting parameter specified. sortBy and sortOrder required"); } if (!string.ReferenceEquals(sortBy, null)) { if (sortBy.Equals("activityId")) { query.orderByActivityId(); } else { throw new InvalidRequestException(Status.BAD_REQUEST, "sortBy parameter has invalid value: " + sortBy); } } if (!string.ReferenceEquals(sortOrder, null)) { if (sortOrder.Equals("asc")) { query.asc(); } else { if (sortOrder.Equals("desc")) { query.desc(); } else { throw new InvalidRequestException(Status.BAD_REQUEST, "sortOrder parameter has invalid value: " + sortOrder); } } } }