@Test public void usersToUserDTOsShouldMapOnlyNonNullUsers(){ List<User> users = new ArrayList<>(); users.add(user); users.add(null); List<UserDTO> userDTOS = userMapper.usersToUserDTOs(users); assertThat(userDTOS).isNotEmpty(); assertThat(userDTOS).size().isEqualTo(1); }
public List<UserDTO> usersToUserDTOs(List<User> users) { return users.stream() .filter(Objects::nonNull) .map(this::userToUserDTO) .collect(Collectors.toList()); }
UserMapper { public List<UserDTO> usersToUserDTOs(List<User> users) { return users.stream() .filter(Objects::nonNull) .map(this::userToUserDTO) .collect(Collectors.toList()); } }
UserMapper { public List<UserDTO> usersToUserDTOs(List<User> users) { return users.stream() .filter(Objects::nonNull) .map(this::userToUserDTO) .collect(Collectors.toList()); }  }
UserMapper { public List<UserDTO> usersToUserDTOs(List<User> users) { return users.stream() .filter(Objects::nonNull) .map(this::userToUserDTO) .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); }
UserMapper { public List<UserDTO> usersToUserDTOs(List<User> users) { return users.stream() .filter(Objects::nonNull) .map(this::userToUserDTO) .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);  }