@Test public void userDTOToUserMapWithNullUserShouldReturnNull(){ assertThat(userMapper.userDTOToUser(null)).isNull(); }
public User userDTOToUser(UserDTO userDTO) { if (userDTO == null) { return null; } else { User user = new User(); user.setId(userDTO.getId()); user.setLogin(userDTO.getLogin()); user.setFirstName(userDTO.getFirstName()); user.setLastName(userDTO.getLastName()); user.setEmail(userDTO.getEmail()); user.setImageUrl(userDTO.getImageUrl()); user.setActivated(userDTO.isActivated()); user.setLangKey(userDTO.getLangKey()); Set<Authority> authorities = this.authoritiesFromStrings(userDTO.getAuthorities()); user.setAuthorities(authorities); return user; } }
UserMapper { public User userDTOToUser(UserDTO userDTO) { if (userDTO == null) { return null; } else { User user = new User(); user.setId(userDTO.getId()); user.setLogin(userDTO.getLogin()); user.setFirstName(userDTO.getFirstName()); user.setLastName(userDTO.getLastName()); user.setEmail(userDTO.getEmail()); user.setImageUrl(userDTO.getImageUrl()); user.setActivated(userDTO.isActivated()); user.setLangKey(userDTO.getLangKey()); Set<Authority> authorities = this.authoritiesFromStrings(userDTO.getAuthorities()); user.setAuthorities(authorities); return user; } } }
UserMapper { public User userDTOToUser(UserDTO userDTO) { if (userDTO == null) { return null; } else { User user = new User(); user.setId(userDTO.getId()); user.setLogin(userDTO.getLogin()); user.setFirstName(userDTO.getFirstName()); user.setLastName(userDTO.getLastName()); user.setEmail(userDTO.getEmail()); user.setImageUrl(userDTO.getImageUrl()); user.setActivated(userDTO.isActivated()); user.setLangKey(userDTO.getLangKey()); Set<Authority> authorities = this.authoritiesFromStrings(userDTO.getAuthorities()); user.setAuthorities(authorities); return user; } }  }
UserMapper { public User userDTOToUser(UserDTO userDTO) { if (userDTO == null) { return null; } else { User user = new User(); user.setId(userDTO.getId()); user.setLogin(userDTO.getLogin()); user.setFirstName(userDTO.getFirstName()); user.setLastName(userDTO.getLastName()); user.setEmail(userDTO.getEmail()); user.setImageUrl(userDTO.getImageUrl()); user.setActivated(userDTO.isActivated()); user.setLangKey(userDTO.getLangKey()); Set<Authority> authorities = this.authoritiesFromStrings(userDTO.getAuthorities()); user.setAuthorities(authorities); return user; } }  List<UserDTO> usersToUserDTOs(List<User> users); UserDTO userToUserDTO(User user); List<User> userDTOsToUsers(List<UserDTO> userDTOs); User userDTOToUser(UserDTO userDTO); User userFromId(String id); }
UserMapper { public User userDTOToUser(UserDTO userDTO) { if (userDTO == null) { return null; } else { User user = new User(); user.setId(userDTO.getId()); user.setLogin(userDTO.getLogin()); user.setFirstName(userDTO.getFirstName()); user.setLastName(userDTO.getLastName()); user.setEmail(userDTO.getEmail()); user.setImageUrl(userDTO.getImageUrl()); user.setActivated(userDTO.isActivated()); user.setLangKey(userDTO.getLangKey()); Set<Authority> authorities = this.authoritiesFromStrings(userDTO.getAuthorities()); user.setAuthorities(authorities); return user; } }  List<UserDTO> usersToUserDTOs(List<User> users); UserDTO userToUserDTO(User user); List<User> userDTOsToUsers(List<UserDTO> userDTOs); User userDTOToUser(UserDTO userDTO); User userFromId(String id);  }