protected PaginatedList<DTO> findPaginatedWithQueryFilterAndSort(Bson query,
                                                                     Predicate<DTO> filter,
                                                                     Bson sort,
                                                                     int page,
                                                                     int perPage) {
        return findPaginatedWithQueryFilterAndSortWithGrandTotal(
                query,
                filter,
                sort,
                DBQuery.empty(),
                page,
                perPage);
    }
@Test
    public void findPaginatedWithQueryFilterAndSort() {
        dbService.save(newDto("hello1"));
        dbService.save(newDto("hello2"));
        dbService.save(newDto("hello3"));
        dbService.save(newDto("hello4"));
        dbService.save(newDto("hello5"));
        dbService.save(newDto("hello6"));
        dbService.save(newDto("hello7"));

        final Predicate<TestDTO> filter = view -> view.title.matches("hello[23456]");

        final PaginatedList<TestDTO> page1 = dbService.findPaginatedWithQueryFilterAndSort(DBQuery.empty(), filter, DBSort.asc("title"), 1, 2);

        assertThat(page1.pagination().count()).isEqualTo(2);
        assertThat(page1.pagination().total()).isEqualTo(5);
        assertThat(page1.delegate())
                .extracting("title")
                .containsExactly("hello2", "hello3");

        final PaginatedList<TestDTO> page2 = dbService.findPaginatedWithQueryFilterAndSort(DBQuery.empty(), filter, DBSort.asc("title"), 2, 2);

        assertThat(page2.pagination().count()).isEqualTo(2);
        assertThat(page2.pagination().total()).isEqualTo(5);
        assertThat(page2.delegate())
                .extracting("title")
                .containsExactly("hello4", "hello5");

        final PaginatedList<TestDTO> page3 = dbService.findPaginatedWithQueryFilterAndSort(DBQuery.empty(), filter, DBSort.asc("title"), 3, 2);

        assertThat(page3.pagination().count()).isEqualTo(1);
        assertThat(page3.pagination().total()).isEqualTo(5);
        assertThat(page3.delegate())
                .extracting("title")
                .containsExactly("hello6");

        final PaginatedList<TestDTO> page4 = dbService.findPaginatedWithQueryFilterAndSort(DBQuery.empty(), filter, DBSort.asc("title"), 2, 4);

        assertThat(page4.pagination().count()).isEqualTo(1);
        assertThat(page4.pagination().total()).isEqualTo(5);
        assertThat(page4.delegate())
                .extracting("title")
                .containsExactly("hello6");

        final PaginatedList<TestDTO> page1reverse = dbService.findPaginatedWithQueryFilterAndSort(DBQuery.empty(), filter, DBSort.desc("title"), 1, 2);

        assertThat(page1reverse.pagination().count()).isEqualTo(2);
        assertThat(page1reverse.pagination().total()).isEqualTo(5);
        assertThat(page1reverse.delegate())
                .extracting("title")
                .containsExactly("hello6", "hello5");
    }