Mocking a sorted list by a Comparator (EasyMock)
<p>How to write unit tests for a sorting function (that use Comparator), when the sorted object is a mock object?</p>

<p><em>Just a little example:</em> I have a Libary with movies. Three classes: Library, Movie, myCmpMovies(implements Comparator). 
I am testing the class Library levaing it isolated. For this target, I am mocking the class Movie, to test all methods from Library. </p>

<p>Using EasyMock.</p>

<p>I am sorting a list of movies in this way:</p>

<pre><code>class Library{
    ArrayList&lt;Movie&gt; movies;
    public List&lt;Movie&gt; getSortedMoviesByDatesAndNames() {
        List&lt;Movie&gt; movies = this.getMovies();
        Comparator myCmpMovies = new myCmpMovies();
        Collections.sort(movies, myCmpMovies);
        return movies;
    }
}
</code></pre>

<p>Now, I am testing this method with a unit test. The mock object is Movie. I am just trying something like:</p>

<pre><code>    @Test
    public List&lt;Movie&gt; TestGetSortedMoviesByDatesAndNames() {
        movie1= createMock(Movie.class);
        movie2= createMock(Movie.class);
        movie3= createMock(Movie.class);

        ....
    }
</code></pre>

<p>I know there are a few questions about this topic, but I think those are not the same problem.</p>

<p>Thanks in advance.</p>