### Question:
UserMapper implements DataMapper<User, UserDto> { @Override public Collection<UserDto> mapEntitiesToDtos(Collection<User> users) { Collection<UserDto> dtos = new ArrayList<>(); users.forEach(user -> dtos.add(mapEntityToDto(user))); return dtos; } @Autowired  UserMapper(AppEnvironment appEnvironment); @Override User mapDtoToEntity(UserDto dto); @Override UserDto mapEntityToDto(User user); @Override Collection<User> mapDtosToEntities(Collection<UserDto> userDtos); @Override Collection<UserDto> mapEntitiesToDtos(Collection<User> users);  }### Answer:
@Test public void test_mapEntitiesToDtos() { Collection<User> users = Arrays.asList(user1, user2); Collection<UserDto> dtos = userMapper.mapEntitiesToDtos(users); Assert.assertEquals(2, users.size()); Assert.assertEquals(users.size(), dtos.size()); Iterator<User> userIt = users.iterator(); Iterator<UserDto> dtoIt = dtos.iterator(); while (userIt.hasNext() && dtoIt.hasNext()) { assertUserWithDto(userIt.next(), dtoIt.next()); } }