### Question:
MovieServiceImpl implements MovieService { @Override public boolean hasLiked(final String account, final UUID movieId) { final String url = String.format(HAS_LIKED_URL, serviceProperties.getMovieServiceUrl(), movieId, account, LocaleContextHolder.getLocale().getLanguage()); try { return restTemplate.getForEntity(url, Boolean.class).getBody(); } catch (final Exception ex) { final String errorMessage = String.format( "An error occured while checking if account %s has liked movie %s: %s", account, movieId, 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_hasLiked_true() { final String account = "test_account"; final UUID movieId = UUID.randomUUID(); final String url = MOVIE_SERVICE_URL + String.format(MOVIE_HAS_LIKED_PATH, movieId, account); when(booleanResponse.getBody()).thenReturn(true); when(restTemplate.getForEntity(url, Boolean.class)).thenReturn(booleanResponse); final boolean result = movieService.hasLiked(account, movieId); assertTrue(result); }
@Test public void test_hasLiked_false() { final String account = "test_account"; final UUID movieId = UUID.randomUUID(); final String url = MOVIE_SERVICE_URL + String.format(MOVIE_HAS_LIKED_PATH, movieId, account); when(booleanResponse.getBody()).thenReturn(false); when(restTemplate.getForEntity(url, Boolean.class)).thenReturn(booleanResponse); final boolean result = movieService.hasLiked(account, movieId); assertFalse(result); }
@Test(expected = MoviePersistenceException.class) public void test_hasLiked_exception() { final String account = "test_account"; final UUID movieId = UUID.randomUUID(); final String url = MOVIE_SERVICE_URL + String.format(MOVIE_HAS_LIKED_PATH, movieId, account); when(restTemplate.getForEntity(url, Boolean.class)).thenThrow(new RuntimeException()); movieService.hasLiked(account, movieId); }