Package org.neo4j.cineasts.domain

Examples of org.neo4j.cineasts.domain.Movie


    }

    @Test
    public void testRateMovie() {
        final User me = userRepository.save(new User("me", "me", "me"));
        final Movie movie = movieRepository.save(new Movie("1","Movie"));
        userRepository.rate(movie, me, 5, "cool");
        final User loaded = userRepository.findOne(me.getId());
        assertEquals(1,loaded.getRatings().size());
    }
View Full Code Here


        for (Integer id : ids) {
            result.add(importService.importMovie(String.valueOf(id)));
        }

        //me.rate(repository.getMovie("13"),5,"Inspiring");
        final Movie movie = movieRepository.findById("603");
        me.rate(template, movie,5,"Best of the series");
        return result;
    }
View Full Code Here

    public String singleMovieView(final Model model, @PathVariable String movieId) {
        User user = addUser(model);
        MovieRepository.MovieData movieData = cineastsRepository.getMovieData( movieId );
        model.addAttribute("id", movieId);
        if (movieData != null) {
            Movie movie = movieData.getMovie();
            model.addAttribute("movie", movie);
            final Integer stars = movieData.getAverageRating();
            model.addAttribute("stars", stars);
            Rating rating = null;
            if (user!=null) rating = movie.getRelationshipTo(user, Rating.class, "RATED");
            if (rating == null) rating = new Rating().rate(stars==null?0:stars,null);
            model.addAttribute("userRating",rating);
        }
        return "/movies/show";
    }
View Full Code Here

        return "/movies/show";
    }

    @RequestMapping(value = "/movies/{movieId}", method = RequestMethod.POST, headers = "Accept=text/html")
    public String updateMovie(Model model, @PathVariable String movieId, @RequestParam(value = "rated",required = false) Integer stars, @RequestParam(value = "comment",required = false) String comment) {
        Movie movie = cineastsRepository.getMovie(movieId);
        User user = userDetailsService.getUserFromSession();
        cineastsRepository.rateMovie(movie,user, stars==null ? -1 : stars,comment!=null ? comment.trim() : null);
        return singleMovieView(model,movieId);
    }
View Full Code Here


    @RequestMapping(value = "/movies/{movieId}", method = RequestMethod.GET, headers = "Accept=text/html")
    public String singleMovieView(final Model model, @PathVariable String movieId) {
        User user = addUser(model);
        Movie movie = movieRepository.findById(movieId);
        model.addAttribute("id", movieId);
        if (movie != null) {
            model.addAttribute("movie", movie);
            final int stars = movie.getStars();
            model.addAttribute("stars", stars);
            Rating rating = null;
            if (user!=null) rating = movie.getRelationshipTo(user, Rating.class, "RATED");
            if (rating == null) rating = new Rating().rate(stars, null);
            model.addAttribute("userRating",rating);
        }
        return "/movies/show";
    }
View Full Code Here

        return "/movies/show";
    }

    @RequestMapping(value = "/movies/{movieId}", method = RequestMethod.POST, headers = "Accept=text/html")
    public String updateMovie(Model model, @PathVariable String movieId, @RequestParam(value = "rated",required = false) Integer stars, @RequestParam(value = "comment",required = false) String comment) {
        Movie movie = movieRepository.findById(movieId);
        User user = userDetailsService.getUserFromSession();
        userDetailsService.rate(user, movie, stars, comment);
        return singleMovieView(model,movieId);
    }
View Full Code Here

    @Autowired UserRepository userRepository;
    @Autowired Neo4jOperations template;

    @Test
    public void testGetMovie() throws Exception {
        Movie movie = movieRepository.save(new Movie("1", "Test-Movie"));
        Movie found = movieRepository.findById("1");
        assertEquals("movie found by id", movie, found);
    }
View Full Code Here

        assertEquals("movie found by id", movie, found);
    }

    @Test
    public void testGetMovieRecommendations() throws Exception {
        Movie movie = movieRepository.save(new Movie("1", "Test-Movie"));
        Movie movie2 = movieRepository.save(new Movie("2", "Test-Movie2"));
        User user = userRepository.save(new User("me", "me", "me"));
        user.rate(template,movie,3,"me");
        User friend = userRepository.save(new User("friend", "friend", "friend"));
        friend.rate(template, movie, 5, "friend");
        friend.rate(template, movie2, 3, "friend2");
View Full Code Here

        assertEquals("one recommendation", movie2, recommendations.get(0).getMovie());
        assertEquals("one recommendation", 3, recommendations.get(0).getRating());
    }
    @Test
    public void testRateMovie() throws Exception {
        Movie movie = movieRepository.save(new Movie("1", "Test-Movie"));
        User user = userRepository.save(new User("me", "me", "me"));
        user.rate(template, movie, 5, "comment");
        movie = movieRepository.findById("1");
        final Rating rating = IteratorUtil.first(movie.getRatings());
        assertEquals("rating stars", 5, rating.getStars());
        assertEquals("rating comment", "comment", rating.getComment());
        assertEquals("rating user", user, rating.getUser());
        assertEquals("rating movie", movie, rating.getMovie());
    }
View Full Code Here

        assertEquals("rating movie", movie, rating.getMovie());
    }

    @Test
    public void testFindTwoMovies() throws Exception {
        Movie movie1 = movieRepository.save(new Movie("1", "Test-Movie1"));
        Movie movie2 = movieRepository.save(new Movie("2", "Test-Movie2"));
        Movie movie3 = movieRepository.save(new Movie("3", "Another-Movie3"));
        List<Movie> found = movieRepository.findByTitleLike("Test*", new PageRequest(0, 2)).getContent();
        assertEquals("2 movies found", 2, found.size());
        assertEquals("2 correct movies found by query", new HashSet<Movie>(asList(movie1, movie2)), new HashSet<Movie>(found));
    }
View Full Code Here

TOP

Related Classes of org.neo4j.cineasts.domain.Movie

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.