title: Spring boot testing error: java.lang.IllegalArgumentException: Page must not be null
body: <p>I am trying to test the following controller:  </p>
  
  <pre><code>@RepositoryRestController
  @RequestMapping("movies")
  public class MovieController {
  
      private MovieService movieService;
      private PagedResourcesAssembler&lt;Movie&gt; pagedAssembler;
      private MovieResourceAssembler movieResourceAssembler;
  
      @Autowired
      public void setMovieService(MovieService movieService) {
          this.movieService = movieService;
      }
  
      @Autowired
      public void setPagedAssembler(PagedResourcesAssembler&lt;Movie&gt; pagedAssembler) {
          this.pagedAssembler = pagedAssembler;
      }
  
      @Autowired
      public void setMovieResourceAssembler(MovieResourceAssembler movieResourceAssembler) {
          this.movieResourceAssembler = movieResourceAssembler;
      }
  
      // Return all movies with pagination
      @GetMapping
      public ResponseEntity&lt;?&gt; getAllMovies(Pageable pageable) {
          Page&lt;Movie&gt; moviePage = this.movieService.getAllMovies(pageable);
          // Remove some unnecessary fields
          //this.movieService.removeUndesirableFieldsFromListing(moviePage);
          return ResponseEntity.ok(this.pagedAssembler.toResource(moviePage, this.movieResourceAssembler));
      }
   }
  </code></pre>
  
  <p>and here's the test:  </p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  @AutoConfigureMockMvc
  public class MovieControllerTest {
  
      @Autowired
      private MockMvc mockMvc;
  
      @MockBean
      private MovieService movieService;
  
      @Test
      public void getAllMovies_PageableGiven_ShouldReturnMoviesPage() throws Exception {
          List&lt;Movie&gt; movieList = new ArrayList&lt;&gt;();
          movieList.add(new Movie());
          movieList.add(new Movie());
          Page&lt;Movie&gt; moviePage = new PageImpl&lt;&gt;(movieList);
          given(this.movieService.getAllMovies(PageRequest.of(0,2)))
                  .willReturn(moviePage);
          this.mockMvc.perform(get("http://localhost:8080/api/movies?page=1"))
                  .andExpect(status().isOk());
      }
  }
  </code></pre>
  
  <p>i got the following error:  </p>
  
  <blockquote>
    <p>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Page must not be null!</p>
  </blockquote>