### Question:
MovieServiceImpl implements MovieService { @Override public MovieResultModel createMovie(final MovieDto movieDto) { final String url = String.format(CREATE_URL, serviceProperties.getMovieServiceUrl(), LocaleContextHolder.getLocale().getLanguage()); try { return restTemplate.postForEntity(url, movieDto, MovieResultModel.class).getBody(); } catch (final Exception ex) { final String errorMessage = String.format("An error occured while creating movie %s: %s", movieDto.getTitle(), 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_createMovie_success() throws Exception { final MovieResultModel expectedResult = mock(MovieResultModel.class); final MovieDto movieDto = new MovieDto(); final String url = MOVIE_SERVICE_URL + MOVIE_CREATE_PATH; when(movieResultModelResponse.getBody()).thenReturn(expectedResult); when(movieResultModelResponse.getStatusCode()).thenReturn(HttpStatus.OK); when(restTemplate.postForEntity(url, movieDto, MovieResultModel.class)) .thenReturn(movieResultModelResponse); final MovieResultModel result = movieService.createMovie(movieDto); assertEquals(expectedResult, result); }
@Test(expected = MoviePersistenceException.class) public void test_createMovie_exception() throws Exception { final MovieDto movieDto = new MovieDto(); final String url = MOVIE_SERVICE_URL + MOVIE_CREATE_PATH; when(restTemplate.postForEntity(url, movieDto, MovieResultModel.class)) .thenThrow(new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR)); movieService.createMovie(movieDto); }