Ticket: Paging - expected:<[Only the Dead]> but was:<[Wolf Hall]>


After spending 2hrs in this lesson, here is my frustration and doubt:

  • As the title says, my test result was expected:<[Only the Dead]> but was:<[Wolf Hall]> even with the right implementation
  • I excluded the collection from my cluster and imported again, but this did NOT worked, my mflix.movies collection has 45993 documents.
  • Helped by this topic I put sort by id too and it RESOLVED JUST THE ASSERT with skip = 980 from the unit test, so I saw that if I sort by _id I’ve broken the first assert with skip = 0.

This solution just helped with unit test, I can’t generate the exercise code.

So I made this conditional that solved my problem. I understand that this is not the right approach and isn`t the way that the excercise expects, but somebody got this exercise solved from today(25/01/20) onward in the “right” way?

My code:

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);
    Bson sortId = Sorts.ascending("_id");
    List<Document> movies = new ArrayList<>();
    // TODO > Ticket: Paging - implement the necessary cursor methods to support simple
    // pagination like skip and limit in the code below
    if(skip > 0){
    } else {

Hi @Greg_99532,

Your code seems incomplete as Paging means you need to skip some movies depending on the page you are on and might limit some movies as well.
If I am missing anything from your code, please let me know.


Actualy I omited the answer there with “[answer]” if you want i post the code here. Anyway as I debuged the code with the unit test i saw that the first element with skip parameter = 980 is title -> Wolf Hall and just the second element is the right answer, title -> Only the Dead.

Shared a direct message with you.


I got a different result
org.junit.ComparisonFailure: Expected title field does match: Please check your getMoviesByGenre() movies sort order.
Expected :Only the Dead
Actual :Killing Jesus

in my case the title is “Killing Jesus” and the second is “Only the Dead”

I would suggest checking the sort order would help. Also, you can always practice on the data in cluster, you can use Aggregation Pipeline Builder to build queries.