### Question:
UserMapper { public List<User> userDTOsToUsers(List<UserDTO> userDTOs) { return userDTOs.stream() .filter(Objects::nonNull) .map(this::userDTOToUser) .collect(Collectors.toList()); }  List<UserDTO> usersToUserDTOs(List<User> users); UserDTO userToUserDTO(User user); List<User> userDTOsToUsers(List<UserDTO> userDTOs); User userDTOToUser(UserDTO userDTO); User userFromId(String id);  }### Answer:
@Test public void userDTOsToUsersShouldMapOnlyNonNullUsers(){ List<UserDTO> usersDto = new ArrayList<>(); usersDto.add(userDto); usersDto.add(null); List<User> users = userMapper.userDTOsToUsers(usersDto); assertThat(users).isNotEmpty(); assertThat(users).size().isEqualTo(1); }
@Test public void userDTOsToUsersWithAuthoritiesStringShouldMapToUsersWithAuthoritiesDomain(){ Set<String> authoritiesAsString = new HashSet<>(); authoritiesAsString.add("ADMIN"); userDto.setAuthorities(authoritiesAsString); List<UserDTO> usersDto = new ArrayList<>(); usersDto.add(userDto); List<User> users = userMapper.userDTOsToUsers(usersDto); assertThat(users).isNotEmpty(); assertThat(users).size().isEqualTo(1); assertThat(users.get(0).getAuthorities()).isNotNull(); assertThat(users.get(0).getAuthorities()).isNotEmpty(); assertThat(users.get(0).getAuthorities().iterator().next().getName()).isEqualTo("ADMIN"); }
@Test public void userDTOsToUsersMapWithNullAuthoritiesStringShouldReturnUserWithEmptyAuthorities(){ userDto.setAuthorities(null); List<UserDTO> usersDto = new ArrayList<>(); usersDto.add(userDto); List<User> users = userMapper.userDTOsToUsers(usersDto); assertThat(users).isNotEmpty(); assertThat(users).size().isEqualTo(1); assertThat(users.get(0).getAuthorities()).isNotNull(); assertThat(users.get(0).getAuthorities()).isEmpty(); }