### Question:
MovieServiceImpl implements MovieService { @Override public MovieDto createMovie(MovieDto movieDto) { movieDto.setId(UUID.randomUUID()); movieDto.setCreationTimestamp(Instant.now()); movieDto.setUpdateTimestamp(Instant.now()); final Movie movie = movieMapper.movieDtoToMovie(movieDto); movie.setRevision(UUID.randomUUID().toString()); movie.setUpdated(true); movie.setDeleted(false); movie.setTotalLikes(0); movie.setPendingLikes(new HashSet<>()); movie.setPendingUnlikes(new HashSet<>()); try { movieRepository.save(movie); } catch (final Exception ex) { final String errorMessage = String.format("An error occured while creating a new movie: %s", ex.getMessage()); log.error(errorMessage, ex); throw new MoviePersistenceException(errorMessage, ex); } movieIndexHelper.indexMovie(movie); return movieDto; }  @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_createMovie_success() throws Exception { final MovieDto movieDto = new MovieDto(); final Movie movie = new Movie(); when(movieMapper.movieDtoToMovie(movieDto)).thenReturn(movie); final MovieDto result = movieService.createMovie(movieDto); verify(movieRepository).save(movie); verify(movieIndexHelper).indexMovie(movie); assertEquals(movieDto, result); assertNotNull(result.getCreationTimestamp()); assertNotNull(result.getUpdateTimestamp()); assertNotNull(result.getId()); assertNotNull(movie.getRevision()); assertEquals(0, movie.getTotalLikes()); assertTrue(movie.isUpdated()); assertFalse(movie.isDeleted()); assertNotNull(movie.getPendingLikes()); assertEquals(0, movie.getPendingLikes().size()); assertNotNull(movie.getPendingUnlikes().size()); }
@Test(expected = MoviePersistenceException.class) public void test_createMovie_exception() throws Exception { final MovieDto movieDto = new MovieDto(); final Movie movie = new Movie(); when(movieMapper.movieDtoToMovie(movieDto)).thenReturn(movie); when(movieRepository.save(movie)).thenThrow(new RuntimeException()); movieService.createMovie(movieDto); }