use of com.vaadin.flow.data.provider.QuerySortOrder in project flow by vaadin.
the class VaadinSpringDataHelpersTest method toSpringDataSort_generatesAscendingAndDescendingSpringSort.
@Test
public void toSpringDataSort_generatesAscendingAndDescendingSpringSort() {
List<QuerySortOrder> querySortOrders = QuerySortOrder.asc("name").thenDesc("age").build();
Query<?, ?> query = new Query<>(0, 1, querySortOrders, null, null);
Sort sort = VaadinSpringDataHelpers.toSpringDataSort(query);
Assert.assertNotNull(sort);
Assert.assertEquals(2L, sort.stream().count());
Sort.Order nameOrder = sort.getOrderFor("name");
Assert.assertNotNull(nameOrder);
Assert.assertTrue(nameOrder.isAscending());
Sort.Order ageOrder = sort.getOrderFor("age");
Assert.assertNotNull(ageOrder);
Assert.assertTrue(ageOrder.isDescending());
}
use of com.vaadin.flow.data.provider.QuerySortOrder in project flow by vaadin.
the class VaadinSpringDataHelpersTest method toSpringPageRequest_generatesSpringPageRequestWithPagingAndSort.
@Test
public void toSpringPageRequest_generatesSpringPageRequestWithPagingAndSort() {
List<QuerySortOrder> querySortOrders = QuerySortOrder.asc("name").build();
Query<?, ?> query = new Query<>(100, 50, querySortOrders, null, null);
PageRequest pageRequest = VaadinSpringDataHelpers.toSpringPageRequest(query);
Assert.assertNotNull(pageRequest);
Assert.assertEquals(50, pageRequest.getPageSize());
Assert.assertEquals(2, pageRequest.getPageNumber());
Sort.Order order = pageRequest.getSort().getOrderFor("name");
Assert.assertNotNull(order);
Assert.assertTrue(order.isAscending());
}
Aggregations