Package com.apress.progwt.client.domain

Examples of com.apress.progwt.client.domain.User


        this.userDAO = userDAO;
    }

    public void testGetUserByUsername() {
        String USER = "test";
        User u = userDAO.getUserByUsername(USER);
        assertEquals(USER, u.getUsername());

    }
View Full Code Here


    }

    public void testSave() {

        User u = new User();
        u.setUsername(A);
        u.setPassword(A);
        u.setNickname(A);

        List<User> list = userDAO.getAllUsers();

        userDAO.save(u);

        User saved = userDAO.getUserByUsername(A);

        assertEquals(A, saved.getUsername());
        assertNotSame(0, saved.getId());
        assertFalse(saved.isSupervisor());
        assertTrue(saved.isEnabled());
        assertTrue(saved.isAccountNonExpired());

        List<User> listPost = userDAO.getAllUsers();

        assertEquals(listPost.size(), list.size() + 1);
        log.debug("User list size " + list.size());
View Full Code Here

    public void testEdit() {
        String A = "dsafd";
        String B = "sdfn&S*AS";

        User u = new User();
        u.setUsername(A);
        u.setPassword(B);
        u.setNickname(A);
        List<User> list = userDAO.getAllUsers();

        userDAO.save(u);

        User saved = userDAO.getUserByUsername(A);

        assertEquals(A, saved.getUsername());
        assertNotSame(0, saved.getId());
        assertFalse(saved.isSupervisor());
        assertTrue(saved.isEnabled());
        assertTrue(saved.isAccountNonExpired());

        List<User> listPost = userDAO.getAllUsers();

        assertEquals(listPost.size(), list.size() + 1);
        log.debug("User list size " + list.size());

        // now do some edits
        //
        saved.setUsername(B);
        saved.setSupervisor(true);
        assertEquals(B, saved.getUsername());
        saved = userDAO.save(saved);
        assertEquals(B, saved.getUsername());

        for (User uuu : userDAO.getAllUsers()) {
            System.out.println("AAAAAA " + uuu);
        }
        User editted = userDAO.getUserByUsername(B);

        assertNotNull(editted);
        assertEquals(B, editted.getUsername());
        assertSame(saved.getId(), editted.getId());
        assertTrue(saved.isSupervisor());
        assertTrue(saved.isEnabled());
        assertTrue(saved.isAccountNonExpired());

    }
View Full Code Here

        long pre = userDAO.getUserCount();

        assertEquals(pre, list.size());

        User u = new User();
        u.setUsername(A);
        u.setPassword(B);
        u.setNickname(A);
        userDAO.save(u);

        assertEquals(pre + 1, userDAO.getUserCount());

    }
View Full Code Here

        assertEquals(pre + 1, userDAO.getUserCount());

    }

    public void testGetUserByNicknameFetchAll() {
        User u = new User();
        u.setUsername(A);
        u.setPassword(A);
        u.setNickname(A);
        // List<User> list = userDAO.getAllUsers();

        userDAO.save(u);

        User saved = userDAO.getUserByNicknameFetchAll(A);

        assertTrue(Hibernate.isInitialized(saved.getSchoolRankings()));

        User test = userDAO.getUserByNicknameFetchAll("test");
        assertTrue(Hibernate.isInitialized(test.getSchoolRankings()));

        for (Application sap : test.getSchoolRankings()) {
            assertTrue(Hibernate.isInitialized(sap));
            assertTrue(Hibernate.isInitialized(sap.getSchool()));

        }
View Full Code Here

    private SearchService searchService;
    private UserService userService;

    public void assertUserIsAuthenticated(User toCheck)
            throws SecurityException {
        User loggedIn = userService.getCurrentUser();
        if (loggedIn == null || !loggedIn.equals(toCheck)) {
            throw new SecurityException("Logged in: " + loggedIn
                    + " Requested: " + toCheck);
        }
    }
View Full Code Here

     * transactional testing.
     */
    public SiteCommand executeAndSaveCommand(SiteCommand command,
            boolean useUserCache) throws SiteException {

        User loggedIn = userService.getCurrentUser(useUserCache);

        if (loggedIn == null) {
            log.warn(command + " attempted by anonymous ");
        }

        if (!command.haveYouSecuredYourselfAndFilteredUserInput()) {
            throw new BusinessException("Command " + command
                    + " hasn't secured.");
        }
        if (!userService.getToken(loggedIn).equals(command.getToken())) {
            log.warn("Possible XSRF: |" + command.getToken()
                    + "| expected |" + userService.getToken(loggedIn)
                    + "|");
            throw new SiteSecurityException("Invalid Session "
                    + command.getToken());
        } else {
            log.info("Tokens equal: " + userService.getToken(loggedIn));
        }
        if (loggedIn != null) {
            log.info(command + " " + loggedIn.getUsername());
        }

        log.info("Going to execute Command...");

        command.execute(this);
View Full Code Here

        return schoolDAO.getAllSchools(0, 2500);
    }

    public PostsList getForum(ForumTopic forumTopic, int start, int max) {
        if (forumTopic instanceof User) {
            User user = (User) forumTopic;
            return schoolDAO.getUserThreads(user.getId(), start, max);
        } else if (forumTopic instanceof School) {
            School school = (School) forumTopic;
            return schoolDAO.getSchoolThreads(school.getId(), start, max);
        } else if (forumTopic instanceof ForumPost) {
            ForumPost post = (ForumPost) forumTopic;
View Full Code Here

    /**
     * TODO protect?
     */
    public void save(Loadable loadable) {
        if (loadable instanceof User) {
            User user = (User) loadable;
            userService.save(user);
        } else {
            schoolDAO.save(loadable);
        }
    }
View Full Code Here

            Object obj = defaultCompassHit.getData();
            // log.debug("DATA: " + defaultCompassHit.getData());

            if (obj instanceof User) {
                User usr = (User) obj;
                res.getUsers().add(usr);
            }
            if (obj instanceof School) {
                School sch = (School) obj;
                res.getSchools().add(sch);
View Full Code Here

TOP

Related Classes of com.apress.progwt.client.domain.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.