Package org.libreplan.business.users.entities

Examples of org.libreplan.business.users.entities.User


        throws InstanceNotFoundException {

        Criteria c = getSession().createCriteria(User.class);
        c.add(Restrictions.eq("loginName", loginName).ignoreCase());
        c.add(Restrictions.eq("disabled", false));
        User user = (User) c.uniqueResult();

        if (user == null) {
            throw new InstanceNotFoundException(loginName,
                User.class.getName());
        } else {
View Full Code Here


    @Test
    @Transactional
    public void testBasicSave() throws InstanceNotFoundException {

        User user = createUser(getUniqueName());

        userDAO.save(user);

        User user2 = userDAO.find(user.getId());
        assertEquals(user, user2);

    }
View Full Code Here

        };

        IOnTransaction<Void> updateUser1 = new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                User user = null;
                try {
                    user = userDAO.findByLoginName(loginName1);
                } catch (InstanceNotFoundException e) {
                    fail("InstanceNotFoundException not expected");
                }
                user.setLoginName(loginName2);
                userDAO.save(user);
                return null;
            }
        };
View Full Code Here

        };

        IOnTransaction<Void> updateUser1 = new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                User user = null;
                try {
                    user = userDAO.findByLoginName(loginName1);
                } catch (InstanceNotFoundException e) {
                    fail("InstanceNotFoundException not expected");
                }
                user.getRoles().add(getSecondUserRole());
                userDAO.save(user);
                return null;
            }
        };
View Full Code Here

    }

    @Test
    @Transactional
    public void testFindByName() throws InstanceNotFoundException {
        User user = createUser(getUniqueName());
        user.setDisabled(true);
        userDAO.save(user);

        assertEquals(userDAO.findByLoginName(user.getLoginName()),user);
        try {
            userDAO.findByLoginNameNotDisabled(user.getLoginName());
            fail("InstanceNotFoundException was expected");
        }
        catch(InstanceNotFoundException e) {
            assertEquals((String)e.getKey(),user.getLoginName());
        }
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testListNotDisabled() {
        User user1 = createUser(getUniqueName());
        user1.setDisabled(true);
        userDAO.save(user1);
        User user2 = createUser(getUniqueName());
        user2.setDisabled(false);
        userDAO.save(user2);

        List<User> list = userDAO.listNotDisabled();
        assertTrue(list.contains(user2));
        assertFalse(list.contains(user1));
View Full Code Here

    @Test
    @Transactional
    public void testListProfiles() throws InstanceNotFoundException{

        User user = createUser(getUniqueName());
        userDAO.save(user);

        Profile profile = createProfile(getUniqueName());
        profileDAO.save(profile);

        int previous = user.getProfiles().size();
        user.addProfile(profile);
        userDAO.save(user);
        assertEquals(previous + 1, userDAO.find(user.getId()).getProfiles().size());

        previous = user.getProfiles().size();
        user.removeProfile(profile);
        userDAO.save(user);
        assertEquals(previous - 1, userDAO.find(user.getId()).getProfiles().size());
    }
View Full Code Here

                    public Integer execute() {
                        return userDAO.getUnboundUsers(null).size();
                    }
                });

        User user = createUser(getUniqueName());
        user.setWorker(givenStoredWorkerRelatedTo(user));

        int size = transactionService
                .runOnAnotherReadOnlyTransaction(new IOnTransaction<Integer>() {
                    @Override
                    public Integer execute() {
View Full Code Here

                    public Integer execute() {
                        return userDAO.getUnboundUsers(null).size();
                    }
                });

        User user = createUser(getUniqueName());
        final Worker worker = givenStoredWorkerRelatedTo(user);
        user.setWorker(worker);

        int size = transactionService
                .runOnAnotherReadOnlyTransaction(new IOnTransaction<Integer>() {
                    @Override
                    public Integer execute() {
View Full Code Here

        for (PredefinedUsers u : PredefinedUsers.values()) {

            String encodedPassword = dbPasswordEncoderService.encodePassword(
                u.getClearPassword(), u.getLoginName());
            User user = userDAO.findByLoginName(u.getLoginName());

            assertEquals(user.getPassword(), encodedPassword);

        }

    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.users.entities.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.