@Test /**/ public final void whenResourcesAreRetrievedSortedDescById_thenResultsAreOrderedCorrectly() { final List<T> resourcesOrderedById = getAPI().findAllSorted(SearchField.id.toString(), Sort.Direction.DESC.name()); assertTrue(new OrderById<T>().reverse().isOrdered(resourcesOrderedById)); }
/** {@inheritDoc} */ @Override public Page<T> findPaginated( @RequestParam(value = "page", required = false, defaultValue = "1") Integer page, @RequestParam(value = "size", required = false, defaultValue = "10") Integer size, @RequestParam(value = "direction", required = false, defaultValue = "") String direction, @RequestParam(value = "properties", required = false) String properties) { Assert.isTrue(page > 0, "Page index must be greater than 0"); Assert.isTrue( direction.isEmpty() || direction.equalsIgnoreCase(Sort.Direction.ASC.toString()) || direction.equalsIgnoreCase(Sort.Direction.DESC.toString()), "Direction should be ASC or DESC"); if (direction.isEmpty()) { return this.service.findAll(new PageRequest(page - 1, size)); } else { Assert.notNull(properties); return this.service.findAll( new PageRequest( page - 1, size, new Sort(Sort.Direction.fromString(direction.toUpperCase()), properties.split(",")))); } }
@Test /**/ public final void whenResourcesAreRetrievedSortedDescById_thenNoExceptions() { getAPI().findAllSorted(SearchField.id.toString(), Sort.Direction.DESC.name()); }