@Test public void testTransformUserCollection() { User mockUserOne = mock(User.class); User mockUserTwo = mock(User.class); List<User> userList = new ArrayList<User>(5); userList.add(mockUserOne); userList.add(mockUserTwo); Collection<UserModel> userModelList = userModelDataMapper.transform(userList); assertThat(userModelList.toArray()[0], is(instanceOf(UserModel.class))); assertThat(userModelList.toArray()[1], is(instanceOf(UserModel.class))); assertThat(userModelList.size(), is(2)); }
public UserModel transform(User user) { if (user == null) { throw new IllegalArgumentException("Cannot transform a null value"); } UserModel userModel = new UserModel(user.getUserId()); userModel.setCoverUrl(user.getCoverUrl()); userModel.setFullName(user.getFullName()); userModel.setEmail(user.getEmail()); userModel.setDescription(user.getDescription()); userModel.setFollowers(user.getFollowers()); return userModel; }
UserModelDataMapper { public UserModel transform(User user) { if (user == null) { throw new IllegalArgumentException("Cannot transform a null value"); } UserModel userModel = new UserModel(user.getUserId()); userModel.setCoverUrl(user.getCoverUrl()); userModel.setFullName(user.getFullName()); userModel.setEmail(user.getEmail()); userModel.setDescription(user.getDescription()); userModel.setFollowers(user.getFollowers()); return userModel; } }
UserModelDataMapper { public UserModel transform(User user) { if (user == null) { throw new IllegalArgumentException("Cannot transform a null value"); } UserModel userModel = new UserModel(user.getUserId()); userModel.setCoverUrl(user.getCoverUrl()); userModel.setFullName(user.getFullName()); userModel.setEmail(user.getEmail()); userModel.setDescription(user.getDescription()); userModel.setFollowers(user.getFollowers()); return userModel; }  }
UserModelDataMapper { public UserModel transform(User user) { if (user == null) { throw new IllegalArgumentException("Cannot transform a null value"); } UserModel userModel = new UserModel(user.getUserId()); userModel.setCoverUrl(user.getCoverUrl()); userModel.setFullName(user.getFullName()); userModel.setEmail(user.getEmail()); userModel.setDescription(user.getDescription()); userModel.setFollowers(user.getFollowers()); return userModel; }  UserModel transform(User user); Collection<UserModel> transform(Collection<User> usersCollection); }
UserModelDataMapper { public UserModel transform(User user) { if (user == null) { throw new IllegalArgumentException("Cannot transform a null value"); } UserModel userModel = new UserModel(user.getUserId()); userModel.setCoverUrl(user.getCoverUrl()); userModel.setFullName(user.getFullName()); userModel.setEmail(user.getEmail()); userModel.setDescription(user.getDescription()); userModel.setFollowers(user.getFollowers()); return userModel; }  UserModel transform(User user); Collection<UserModel> transform(Collection<User> usersCollection);  }