### Question:
MovieServiceImpl implements MovieService { @Override public MoviePagedResultModel searchMovies(final String text, final int pageNumber, final String sortField, final boolean isAscending) { final String url = String.format(SEARCH_URL, serviceProperties.getMovieServiceUrl(), text, pageNumber, sortField, isAscending, LocaleContextHolder.getLocale().getLanguage()); try { return restTemplate.getForEntity(url, MoviePagedResultModel.class).getBody(); } catch (final Exception ex) { final String errorMessage = String.format("An error occured while searching for movies: %s", ex.getMessage()); log.error(errorMessage, ex); throw new MoviePersistenceException(errorMessage, ex); } }  @Override MoviePagedResultModel searchMovies(final String text, final int pageNumber, final String sortField,
        final boolean isAscending); @Override MovieResultModel createMovie(final MovieDto movieDto); @Override MovieDto getMovie(final UUID id); @Override boolean isAuthorizedOnMovie(final String account, final UUID movieId); @Override boolean isAuthorizedOnMovie(final String account, final MovieDto movieDto); @Override MovieResultModel updateMovie(final MovieDto movieDto); @Override void deleteMovie(final UUID movieId); @Override void likeMovie(final String account, final UUID movieId); @Override void unlikeMovie(final String account, final UUID movieId); @Override boolean hasLiked(final String account, final UUID movieId);  }### Answer:
@Test public void test_searchMovies_success() throws Exception { final MoviePagedResultModel expectedResult = mock(MoviePagedResultModel.class); final String url = MOVIE_SERVICE_URL + MOVIE_SEARCH_URL; when(searchResponse.getBody()).thenReturn(expectedResult); when(searchResponse.getStatusCode()).thenReturn(HttpStatus.OK); when(restTemplate.getForEntity(url, MoviePagedResultModel.class)).thenReturn(searchResponse); final MoviePagedResultModel result = movieService.searchMovies("test_text", 2, "rating", true); assertEquals(expectedResult, result); }
@Test(expected = MoviePersistenceException.class) public void test_searchMovies_exception() throws Exception { final String url = MOVIE_SERVICE_URL + MOVIE_SEARCH_URL; when(restTemplate.getForEntity(url, MoviePagedResultModel.class)) .thenThrow(new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR)); movieService.searchMovies("test_text", 2, "rating", true); }