M220j Ticket: Paging

Hi,

I was doing this ticket. As per the requirement, I was able to pass all the test in the test class PagingTest(Results - Attached) but still when I ran the ticket for the Paging, the same isn’t passing for me and I can see any network error or the console error in this case. Could you please let me know the solution for this.

*/
public List getMoviesByGenre(String sortKey, int limit, int skip, String… genres) {
// query filter
Bson castFilter = Filters.in(“genres”, genres);
// sort key
Bson sort = Sorts.descending(sortKey);
List movies = new ArrayList<>();
// TODO > Ticket: Paging - implement the necessary cursor methods to support simple
// pagination like skip and limit in the code below
moviesCollection.find(castFilter).sort(sort).limit(limit).skip(skip).iterator()
.forEachRemaining(movies::add);

    return movies;
}

This is the code which I have been using

Hi @abhishek_sikka,

The first few lines of the code in my handouts file are as below:

public List<Document> getMoviesByGenre(String sortKey, int limit, int skip, String... genres) {
    // query filter
    Bson castFilter = Filters.in("genres", genres);
    // sort key
    Bson sort = Sorts.descending(sortKey);
    List<Document> movies = new ArrayList<>();

There is difference in first and last line in my code. Can you please check after updating this?

Kanika

Thank you for response. I didn’t change provided in handout code and mine looks exactly like yours (with Document type defined in diamond). However my issue same as described by abhishek_sikka