Package net.petrikainulainen.spring.testmvc.user.dto

Examples of net.petrikainulainen.spring.testmvc.user.dto.UserDTO


    @Test
    public void getLoggedInUSerWhenUserIsNotLoggedIn() {
        when(securityContextUtilMock.getPrincipal()).thenReturn(null);

        UserDTO loggedInUser = controller.getLoggedInUser();

        verify(securityContextUtilMock, times(1)).getPrincipal();
        verifyNoMoreInteractions(securityContextUtilMock);

        assertNull(loggedInUser);
View Full Code Here


        UserDetails principal = securityContextUtil.getPrincipal();
        return createDTO(principal);
    }

    private UserDTO createDTO(UserDetails principal) {
        UserDTO dto = null;
        if (principal != null) {
            String username = principal.getUsername();
            SecurityRole role = getRole(principal.getAuthorities());

            dto = new UserDTO(username, role);
        }

        LOGGER.debug("Created user dto: {}", dto);

        return dto;
View Full Code Here

        UserDetails principal = new User(USERNAME, PASSWORD, authorities);

        when(securityContextUtilMock.getPrincipal()).thenReturn(principal);

        UserDTO loggedInUser = controller.getLoggedInUser();

        verify(securityContextUtilMock, times(1)).getPrincipal();
        verifyNoMoreInteractions(securityContextUtilMock);

        assertEquals(USERNAME, loggedInUser.getUsername());
        assertEquals(SecurityRole.ROLE_USER, loggedInUser.getRole());
    }
View Full Code Here

TOP

Related Classes of net.petrikainulainen.spring.testmvc.user.dto.UserDTO

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.