### Question:
MongoUserManager extends UserManager { @Override public void removeUser(UserId userId) { DBObject query = createDBObject(); query.put(_ID, userId.getInternal()); MongoDBUtil.deleteFromMongo(query, databaseName, namespace, USER_COLL_NAME, isSafeWrite); MongoDBUtil.deleteFromMongo(query, databaseName, namespace, BAG_COLL_NAME, isSafeWrite); MongoDBUtil.deleteFromMongo(query, databaseName, namespace, REL_COLL_NAME, isSafeWrite); MongoDBUtil.deleteFromMongo(query, databaseName, namespace, UNLOCK_COLL_NAME, isSafeWrite); } 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 testRemoveUser() { UserId userId = new UserId("test-001"); manager.removeUser(userId); User user = manager.createDefaultUser(); user.set_id(userId); user.setUsername("test-001"); for ( int i=0; i<1; i++ ) { user.addTool(makeBuffTool(i)); } user.setBag(makeBag(user, 3)); user.addRelation(makeRelation(user)); manager.saveUser(user, true); manager.saveUserBag(user, true); manager.saveUserRelation(user.getRelations()); User expect = manager.queryUser(userId); manager.queryUserBag(expect); manager.queryUserRelation(expect); assertEquals(60, expect.getBag().getMaxCount()); assertEquals(1, expect.getRelations().size()); manager.removeUser(user.getUsername()); User actual = manager.queryUser(userId); assertNull(actual); actual = manager.queryUserRelation(user); assertNull(actual); Bag bag = manager.queryUserBag(user); assertEquals(null, bag); }
@Test public void testRemoveUser2() { manager.removeUser(new UserId("not-exist-id")); manager.removeUser("not-exist-name"); }