Package org.ops4j.pax.exam.sample2.model

Examples of org.ops4j.pax.exam.sample2.model.User


        List<Movie> result = new ArrayList<Movie>(ids.size());
        for (Integer id : ids) {
            result.add(importService.importMovie(id));
        }

        final Movie movie = movieService.findById(603);
        userService.rate(micha, movie, 5, "Best of the series");
        return result;
    }
View Full Code Here


        return movies;
    }

    private String importMovieFailsafe(Integer id) {
        try {
            Movie movie = doImportMovie(id);
            return movie.getTitle();
        }
        // CHECKSTYLE:SKIP : catch all wanted
        catch (Exception e) {
            return e.getMessage();
        }
View Full Code Here

    }

    private Movie doImportMovie(Integer movieId) {
        logger.info("Importing movie " + movieId);

        Movie movie = new Movie();
        movie.setId(movieId);

        Map<String, ?> data = loadMovieData(movieId);
        if (data.containsKey("not_found")) {
            throw new RuntimeException("Data for Movie " + movieId + " not found.");
        }
View Full Code Here

        Map<String, ?> data = loadPersonData(personId);
        if (data.containsKey("not_found")) {
            throw new RuntimeException("Data for Person " + personId + " not found.");
        }
        movieDbJsonMapper.mapToPerson(data, person);
        Person persistentPerson = em.find(Person.class, person.getId());
        if (persistentPerson == null) {
            em.persist(person);
        }
    }
View Full Code Here

        em.persist(user);
        return user;
    }

    public Rating rate(User user, Movie movie, int stars, String comment) {
        Rating rating = new Rating();
        rating.setUser(user);
        rating.setMovie(movie);
        rating.setStars(stars);
        rating.setComment(comment);
        em.persist(rating);
        return rating;
    }
View Full Code Here

            String jobName = (String) entry.get("job");
            if ("Actor".equals(jobName)) {
                Actor actor = new Actor();
                actor.setId(id);
                doImportPerson(actor);
                Role role = new Role();
                role.setActor(actor);
                role.setMovie(movie);
                role.setName((String) entry.get("character"));
                em.persist(role);
                movie.getRoles().add(role);
            }
            else if ("Director".equals(jobName)) {
                Director director = new Director();
View Full Code Here

    private UserService userService;

    @Test
    public void authenticateValidUser() {
        userService.register("bilbo", "Bilbo Baggins", "treasure");
        User user = userService.authenticate("bilbo", "treasure");
        assertThat(user, is(notNullValue()));
        assertThat(user.getId(), is("bilbo"));
        assertThat(user.getName(), is("Bilbo Baggins"));
        assertThat(user.getPassword(), is("treasure"));
    }
View Full Code Here

    @Inject
    private MovieDbImportService importService;

    public List<Movie> populateDatabase() {

        User micha = userService.register("micha", "Micha", "password");
        userService.register("ollie", "Olliver", "password");
        userService.addFriend(micha, "ollie");

        List<Integer> ids = asList(19995, 194, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609,
            13, 20526, 11, 1893, 1892, 1894, 168, 193, 200, 157, 152, 201, 154, 12155, 58, 285,
View Full Code Here

        String jpql = "select count(u) from User u";
        return em.createQuery(jpql, Long.class).getSingleResult();
    }

    public User authenticate(String login, String password) {
        User user = em.find(User.class, login);
        if (user != null) {
            if (password.equals(user.getPassword())) {
                return user;
            }
        }
        return null;
    }
View Full Code Here

    public User register(String login, String name, String password) {
        if (findByLogin(login) != null) {
            throw new MovieDbException("login is already taken");
        }
        User user = new User();
        user.setId(login);
        user.setName(name);
        user.setPassword(password);
        em.persist(user);
        return user;
    }
View Full Code Here

TOP

Related Classes of org.ops4j.pax.exam.sample2.model.User

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.