Filter filter = new Filter();
filter.addSortField(mock(SortField.class));
filter.addSortField(mock(SortField.class));
CriteriaBuilder builder = mock(CriteriaBuilder.class);
Root root = mock(Root.class);
Order order1 = mock(Order.class);
Order order2 = mock(Order.class);
when(filter.getSortFields().get(0).getOrder(builder, root)).thenReturn(order1);
when(filter.getSortFields().get(1).getOrder(builder, root)).thenReturn(order2);
CriteriaQuery query = mock(CriteriaQuery.class);
filter.constructQuery(builder, query, root);
verify(query).orderBy(Arrays.asList(order1, order2));