@Test public void testTransformUser() { User user = createFakeUser(); UserModel userModel = userModelDataMapper.transform(user); assertThat(userModel, is(instanceOf(UserModel.class))); assertThat(userModel.getUserId(), is(FAKE_USER_ID)); assertThat(userModel.getFullName(), is(FAKE_FULLNAME)); }
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);  }