Package org.richfaces.photoalbum.model

Examples of org.richfaces.photoalbum.model.User


        userBean.getUser().setEmail("mail@mail.net");

        ua.updateUser(userBean.getUser());

        User updatedUser = (User) em.createNamedQuery(Constants.USER_LOGIN_QUERY)
            .setParameter(Constants.USERNAME_PARAMETER, "Noname")
            .setParameter(Constants.PASSWORD_PARAMETER, "8cb2237d0679ca88db6464eac60da96345513964").getSingleResult();

        Assert.assertTrue("mail: " + updatedUser.getEmail() + " = 'mail@mail.net'",
            "mail@mail.net".equals(updatedUser.getEmail()));
    }
View Full Code Here


        utx.commit();
    }

    @Test
    public void isShelfAdded() throws Exception {
        User user = helper.getAllUsers(em).get(0);

        Shelf newShelf = new Shelf();

        newShelf.setName("new shelf");
        newShelf.setDescription("a new shelf");
View Full Code Here

    @Test
    public void arePredefinedShelvesFound() throws Exception {
        // predefined shelf: is shared and owned by a predefined user

        User preDefined = helper.getAllUsers(em).get(0);
        User notPreDefined = helper.getAllUsers(em).get(1);

        Shelf shelf = helper.getAllShelves(em).get(0); // this is a predefined shelf

        Shelf shelf1 = new Shelf();
        Shelf shelf2 = new Shelf();
View Full Code Here

     *
     * @param shelf - shelf to delete
     * @throws PhotoAlbumException
     */
    public void deleteShelf(Shelf shelf) throws PhotoAlbumException {
        User owner = em.find(User.class, shelf.getOwner().getId());
        try {
            em.remove(em.merge(shelf));
            owner.removeShelf(shelf);
            em.merge(owner);
            em.flush();

            //shelf.setOwner(owner);
        } catch (Exception e) {
            owner.addShelf(shelf);
            throw new PhotoAlbumException(e.getMessage());
        }
    }
View Full Code Here

     * @Param user - user to refresh
     * @return user if success
     * @throws PhotoAlbumException
     */
    public User refreshUser() {
        User user = em.find(User.class, userBean.getUser().getId());
        em.refresh(user);
        return user;
    }
View Full Code Here

        utx.commit();
    }

    @Test
    public void isUserLoggedIn() throws Exception {
        User user = (User) em.createNamedQuery(Constants.USER_LOGIN_QUERY).setParameter(Constants.USERNAME_PARAMETER, "Noname")
            .setParameter(Constants.PASSWORD_PARAMETER, "8cb2237d0679ca88db6464eac60da96345513964").getSingleResult();

        Assert.assertNotNull(user);

        User loggedInUser = bean.logIn("Noname", "8cb2237d0679ca88db6464eac60da96345513964");

        Assert.assertNotNull(loggedInUser);
        Assert.assertNotNull(bean.getUser());
        Assert.assertEquals(loggedInUser, bean.getUser());
    }
View Full Code Here

        utx.commit();
    }

    @Test
    public void isUserAdded() throws Exception {
        User newUser = new User();

        int originalSize = helper.getAllUsers(em).size();

        newUser.setFirstName("Mike");
        newUser.setSecondName("Johnson");
        newUser.setEmail("mike.johnson@mail.co.uk");
        newUser.setLogin("jmike");
        newUser.setPasswordHash("8cb2237d0679ca88db6464eac60da96345513964");
        newUser.setBirthDate(new Date()); // TODO String -> Date
        newUser.setSex(Sex.MALE);
        newUser.setHasAvatar(false);
        newUser.setPreDefined(false);

        ua.register(newUser);
        List<User> users = helper.getAllUsers(em);
        Assert.assertTrue(users.contains(newUser));
        Assert.assertEquals(originalSize + 1, users.size());
View Full Code Here

        Assert.assertEquals(originalSize + 1, users.size());
    }

    @Test
    public void canUserLogIn() throws Exception {
        User anotherUser = new User();

        anotherUser.setFirstName("John");
        anotherUser.setSecondName("Tailor");
        anotherUser.setEmail("john.tailor@mail.co.uk");
        anotherUser.setLogin("tailorj");
        anotherUser.setPasswordHash("8cb2237d0679ca88db6464eac60da96345513964");
        anotherUser.setBirthDate(new Date()); // TODO String -> Date
        anotherUser.setSex(Sex.MALE);
        anotherUser.setHasAvatar(false);
        anotherUser.setPreDefined(false);

        ua.register(anotherUser);

        User loggedInUser = userBean.logIn("tailorj", "8cb2237d0679ca88db6464eac60da96345513964");

        Assert.assertEquals(anotherUser, loggedInUser);
    }
View Full Code Here

            }
        }
    }

    private boolean isShouldExpireUser(HttpSession session) {
        User user = userBean.getUser();
        return userBean.isLoggedIn() && user != null && userTracker.containsUserId(user.getId())
            && !userTracker.containsUser(user.getId(), session.getId());
    }
View Full Code Here

    }

    @Test
    public void isCommentAdded() throws Exception {
        Image image = helper.getAllImages(em).get(0);
        User user = em.createQuery("select u from User u where u.id = :id", User.class).setParameter("id", (long) 1)
            .getSingleResult();

        int originalSize = helper.getAllComments(em).size();

        Comment comment = new Comment();
View Full Code Here

TOP

Related Classes of org.richfaces.photoalbum.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.