### Question:
MovieServiceImpl implements MovieService { public boolean hasLiked(final UUID movieId, final String account) { try { return movieLikeRepository.findById(movieId + "-" + account).isPresent(); } catch (final Exception ex) { final String errorMessage = String.format("An error occured while checking like for movie %s: %s", movieId, ex.getMessage()); log.error(errorMessage, ex); throw new MoviePersistenceException(errorMessage, ex); } }  @Override MoviePagedResultModel searchMovies(final Optional<String> text, final Optional<Integer> pageNumber,
        final Optional<String> sortField, final boolean isAscending); @Override MovieDto getMovie(final UUID id); @Override MovieDto createMovie(MovieDto movieDto); @Override MovieDto updateMovie(final MovieDto movieDto); @Override void deleteMovie(final UUID id); @Override void likeMovie(final UUID movieId, final String account); @Override void unlikeMovie(final UUID movieId, final String account); boolean hasLiked(final UUID movieId, final String account); @Scheduled(fixedRateString = "${searchIndex.fixedRate}") void updateSearchIndex();  }### Answer:
@Test public void test_hasLiked_notLiked() { final UUID movieId = UUID.randomUUID(); final String account = "test_account"; when(movieLikeRepository.findById(movieId + "-" + account)).thenReturn(Optional.empty()); final boolean result = movieService.hasLiked(movieId, account); assertFalse(result); }
@Test public void test_hasLiked_liked() { final UUID movieId = UUID.randomUUID(); final String account = "test_account"; when(movieLikeRepository.findById(movieId + "-" + account)).thenReturn(Optional.of(new MovieLike())); final boolean result = movieService.hasLiked(movieId, account); assertTrue(result); }
@Test(expected = MoviePersistenceException.class) public void test_hasLiked_exception() { final UUID movieId = UUID.randomUUID(); final String account = "test_account"; when(movieLikeRepository.findById(movieId + "-" + account)).thenThrow(new RuntimeException()); movieService.hasLiked(movieId, account); }