### Question:
MongoUserManager extends UserManager { @Override public boolean saveUserRelation(Collection<Relation> relations) { DBObject setObj = createDBObject(); DBObject unsetObj = createDBObject(); boolean changed = false; UserId userId = null; for (Iterator<Relation> iter = relations.iterator(); iter.hasNext();) { Relation relation = iter.next(); userId = relation.get_id(); Set<String> flags = relation.clearChangeMark(); for (Iterator<String> flagIter = flags.iterator(); flagIter.hasNext();) { String userName = flagIter.next(); People p = relation.findPeopleByUserName(userName); if ( p != null ) { p.setId(userId); setObj.put(concat(relation.getType().tag(), DOT, p.getUsername()), createMapDBObject(p)); changed = true; } else { unsetObj.put(concat(relation.getType().tag(), DOT, userName), ONE); changed = true; } } } if ( changed ) { DBObject query = createDBObject(_ID, userId.getInternal()); DBObject relObj = createDBObject(); relObj.put(OP_SET, setObj); relObj.put(OP_UNSET, unsetObj); MongoDBUtil.saveToMongo(query, relObj, databaseName, namespace, REL_COLL_NAME, isSafeWrite); } return changed; } MongoUserManager();  MongoUserManager(String databaseName, String namespace, boolean isSafeWrite); @Override boolean saveUser(User user, boolean isNewUser); @Override boolean saveUserBag(User user, boolean isNewBag); @Override boolean saveUserRelation(Collection<Relation> relations); @Override Map<RelationType, Collection<People>> saveFriendWinOrLose(User user, User friend, boolean winning); @Override User queryUser(String userName); @Override User queryUserByRoleName(String roleName); @Override User queryUser(UserId userId); @Override String queryUserGuildId(UserId userId); @Override boolean checkUserNameExist(String userName); @Override boolean checkRoleNameExist(String roleName); @Override boolean checkEmailVerified(UserId userId); @Override UserLoginStatus checkUserLoginStatus(UserId userId); @Override BasicUser queryBasicUser(String userName); @Override BasicUser queryBasicUserByRoleName(String roleName); @Override ArrayList<BasicUser> queryBasicUserByRoleNameRegex(String roleName); @Override BasicUser queryBasicUser(UserId userId); @Override Bag queryUserBag(User user); @Override Bag queryUserBag(UserId userId); @Override User queryUserRelation(User user); @Override Collection<Unlock> queryUserUnlock(User user); @Override synchronized boolean addUserNewUnlock(User user, Unlock unlock); @Override void removeUser(UserId userId); @Override void removeUser(String userName); @Override void removeUserByRoleName(String roleName); @Override boolean removeUserGuildId(UserId userId); @Override String convertUserToString(User user); @Override String convertBagToString(Bag bag); @Override User convertStringToUser(String userStr); @Override Bag convertStringToBag(String bagStr); final User constructUserObject(DBObject userObj); static final String LOGIN_USERNAME; static final String LOGIN_ROLENAME; static final String LOGIN_STATUS; static final String EMAIL_VERIFIED; }### Answer:
@Test public void testSaveRelation3() { UserId userId = new UserId("test001"); ArrayList<Relation> rlist = new ArrayList<Relation>(RelationType.values().length); rlist.add(makeRelation(3, RelationType.FRIEND, userId)); manager.saveUserRelation(rlist); People p = makePeople("test-1"); assertTrue( rlist.get(0).removePeople(p) != null ); manager.saveUserRelation(rlist); }