### Question:
MovieServiceImpl implements MovieService { @Override public MovieDto getMovie(final UUID id) throws MovieNotFoundException { try { final Movie movie = movieRepository.findById(id.toString()).orElseThrow(() -> new MovieNotFoundException()); if (movie.isDeleted()) { throw new MovieNotFoundException(); } return movieMapper.movieToMovieDto(movie); } catch (final MovieNotFoundException ex) { throw ex; } catch (final Exception ex) { final String errorMessage = String.format("An error occured while reading movie %s: %s", id, 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(expected = MovieNotFoundException.class) public void test_getMovie_notFound() throws Exception { final UUID id = UUID.randomUUID(); when(movieRepository.findById(id.toString())).thenReturn(Optional.empty()); movieService.getMovie(id); }
@Test(expected = MovieNotFoundException.class) public void test_getMovie_deleted() throws Exception { final UUID id = UUID.randomUUID(); final Movie movie = new Movie(); movie.setDeleted(true); when(movieRepository.findById(id.toString())).thenReturn(Optional.of(movie)); movieService.getMovie(id); }
@Test public void test_getMovie_found() throws Exception { final UUID id = UUID.randomUUID(); final Movie movie = new Movie(); final MovieDto movieDto = new MovieDto(); when(movieRepository.findById(id.toString())).thenReturn(Optional.of(movie)); when(movieMapper.movieToMovieDto(movie)).thenReturn(movieDto); final MovieDto result = movieService.getMovie(id); assertEquals(movieDto, result); }
@Test(expected = MoviePersistenceException.class) public void test_getMovie_exception() throws Exception { final UUID id = UUID.randomUUID(); when(movieRepository.findById(id.toString())).thenThrow(new RuntimeException()); movieService.getMovie(id); }