Package org.jtalks.common.model.entity

Examples of org.jtalks.common.model.entity.User


    /**
     * {@inheritDoc}
     */
    @Override
    public User getCommonUserByUsername(String username) throws NotFoundException {
        User user = this.getDao().getCommonUserByUsername(username);
        if (user == null) {
            String msg = "Common User [" + username + "] not found.";
            LOGGER.info(msg);
            throw new NotFoundException(msg);
        }
View Full Code Here


        assertNull(result);
    }

    @Test
    public void getCommonUserByUsernameShouldFindOne() {
        User expected = givenCommonUserWithUsernameStoredInDb("username");

        User actual = dao.getCommonUserByUsername("username");
        assertNotNull(actual);
        assertReflectionEquals(actual, expected);
    }
View Full Code Here

    @Test
    public void getCommonUserByUsernameShouldNotFind() {
        givenCommonUserWithUsernameStoredInDb("username");

        User actual = dao.getCommonUserByUsername("wrong username there is no such user");
        assertNull(actual);
    }
View Full Code Here

        assertNull(actual);
    }

    @Test
    public void getCommonUserByUsernameShouldNotFindInEmptyDb() {
        User actual = dao.getCommonUserByUsername("username");
        assertNull(actual);
    }
View Full Code Here

     *
     * @param username a username to store the user with, other properties will be pretty random
     * @return a user that was stored in the database and removed from the Hibernate session
     */
    private User givenCommonUserWithUsernameStoredInDb(String username) {
        User expected = new User(username, "mail@mail.com", "pass", null);//salt will be null anyway after retrieval
        session.save(expected);
        session.clear();
        return expected;
    }
View Full Code Here

   
    /**
     * Check permissions to edit or create simple(static) pages.
     */
    private void checkPermissionToCreateAndEditPage() {
        User currentUser = userService.getCurrentUser();
        userService.checkPermissionToCreateAndEditSimplePage(currentUser.getId());
    }
View Full Code Here

    @Test
    public void copyUserGroupShouldCopyCorrectlyIfAllFieldsFilled() {
        Group group = new Group("name", "description");
        group.setId(1);
        group.setUuid("uuid");
        List<User> users = Arrays.asList(new User("username", "email@mail.com", "pass"),
                new User("username1", "email1@mail.com", "pass1"));
        group.setUsers(users);
        JCUser newUser =  new JCUser("username", "email@mail.com", "pass");

        Group copy = JCUser.copyUserGroup(group, newUser);
View Full Code Here

        userService.getCommonUserByUsername("username");
    }

    @Test
    public void getCommonUserByUsernameShouldReturnOne() throws NotFoundException {
        User expectedUser = new User("username", null, null, null);
        doReturn(expectedUser).when(userDao).getCommonUserByUsername("username");

        User actualUser = userService.getCommonUserByUsername("username");
        assertSame(expectedUser, actualUser);
    }
View Full Code Here

        if (newUser) {
            user = new JCUser(authInfo.get("username"), authInfo.get("email"), passwordHash);
            user.setRegistrationDate(new DateTime());
            user.setAutosubscribe(DEFAULT_AUTOSUBSCRIBE);
            user.setSendPmNotification(DEFAULT_SEND_PM_NOTIFICATION);
            User commonUser = this.getDao().getCommonUserByUsername(authInfo.get("username"));
            if (commonUser != null) {
                copyFieldsFromUserToJCUser(commonUser, user);
                // user already exist in database (poulpe uses the same database),
                // we need to delete common User and create JCUser
                try {
View Full Code Here

     * @param userDto coming from enclosing methods, this object is built by Spring MVC
     * @return stored user
     */
    public JCUser storeRegisteredUser(UserDto userDto) {
        // check if user already saved by plugin as common user
        User commonUser = this.getDao().getCommonUserByUsername(userDto.getUsername());
        if (commonUser != null) {
            // in this case we must delete old common user and save user as JCUser,
            // because hibernate doesn't allow upgrade common User to JCUser
            try {
                Session session = ((GenericDao) ((Advised) this.getDao()).getTargetSource().getTarget()).session();
View Full Code Here

TOP

Related Classes of org.jtalks.common.model.entity.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.