@Test
  /**/ public final void whenResourcesAreRetrievedSortedAscById_thenResultsAreOrderedCorrectly() {
    final List<T> resourcesOrderedById =
        getAPI().findAllSorted(SearchField.id.toString(), Sort.Direction.ASC.name());

    assertTrue(new OrderById<T>().isOrdered(resourcesOrderedById));
  }
  @Test
  public final void whenResourcesAreRetrievedSorted_then200IsReceived() {
    final Response response =
        getAPI().findAllSortedAsResponse(SearchField.name.name(), Sort.Direction.ASC.name(), null);

    assertThat(response.getStatusCode(), is(200));
  }
  @Test
  /**/ public final void whenResourcesAreRetrievedSorted_thenResourcesAreIndeedOrdered() {
    getAPI().createAsURI(createNewEntity());
    getAPI().createAsURI(createNewEntity());

    // When
    final List<T> resourcesSorted =
        getAPI().findAllSorted(SearchField.name.name(), Sort.Direction.ASC.name());

    // Then
    assertTrue(new OrderByName<T>().isOrdered(resourcesSorted));
  }
 /** {@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 whenResourcesAreRetrievedPaginatedAndSorted_thenNoExceptions() {
   getAPI().findAllPaginatedAndSorted(0, 41, SearchField.name.name(), Sort.Direction.ASC.name());
 }