Search in sources :

Example 6 with Authority

use of com.arnaugarcia.uplace.domain.Authority in project uplace.es by Uplace.

the class UserResourceIntTest method testUserToUserDTO.

@Test
public void testUserToUserDTO() {
    user.setId(DEFAULT_ID);
    user.setCreatedBy(DEFAULT_LOGIN);
    user.setCreatedDate(Instant.now());
    user.setLastModifiedBy(DEFAULT_LOGIN);
    user.setLastModifiedDate(Instant.now());
    Set<Authority> authorities = new HashSet<>();
    Authority authority = new Authority();
    authority.setName(AuthoritiesConstants.USER);
    authorities.add(authority);
    user.setAuthorities(authorities);
    UserDTO userDTO = userMapper.userToUserDTO(user);
    assertThat(userDTO.getId()).isEqualTo(DEFAULT_ID);
    assertThat(userDTO.getLogin()).isEqualTo(DEFAULT_LOGIN);
    assertThat(userDTO.getFirstName()).isEqualTo(DEFAULT_FIRSTNAME);
    assertThat(userDTO.getLastName()).isEqualTo(DEFAULT_LASTNAME);
    assertThat(userDTO.getEmail()).isEqualTo(DEFAULT_EMAIL);
    assertThat(userDTO.isActivated()).isEqualTo(true);
    assertThat(userDTO.getImageUrl()).isEqualTo(DEFAULT_IMAGEURL);
    assertThat(userDTO.getLangKey()).isEqualTo(DEFAULT_LANGKEY);
    assertThat(userDTO.getCreatedBy()).isEqualTo(DEFAULT_LOGIN);
    assertThat(userDTO.getCreatedDate()).isEqualTo(user.getCreatedDate());
    assertThat(userDTO.getLastModifiedBy()).isEqualTo(DEFAULT_LOGIN);
    assertThat(userDTO.getLastModifiedDate()).isEqualTo(user.getLastModifiedDate());
    assertThat(userDTO.getAuthorities()).containsExactly(AuthoritiesConstants.USER);
    assertThat(userDTO.toString()).isNotNull();
}
Also used : Authority(com.arnaugarcia.uplace.domain.Authority) UserDTO(com.arnaugarcia.uplace.service.dto.UserDTO) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Authority (com.arnaugarcia.uplace.domain.Authority)6 User (com.arnaugarcia.uplace.domain.User)4 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 UserDTO (com.arnaugarcia.uplace.service.dto.UserDTO)1 WithMockUser (org.springframework.security.test.context.support.WithMockUser)1