### Question:
QueueService extends BaseService { public Map<String, Object> updateQueue(User loginUser, int id, String queue, String queueName) { Map<String, Object> result = new HashMap<>(); if (checkAdmin(loginUser, result)) { return result; } if (StringUtils.isEmpty(queue)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, "queue"); return result; } if (StringUtils.isEmpty(queueName)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, "queueName"); return result; } Queue queueObj = queueMapper.selectById(id); if (queueObj == null) { putMsg(result, Status.QUEUE_NOT_EXIST, id); return result; } if (queue.equals(queueObj.getQueue()) && queueName.equals(queueObj.getQueueName())) { putMsg(result, Status.NEED_NOT_UPDATE_QUEUE); return result; } if (!queueName.equals(queueObj.getQueueName()) && checkQueueNameExist(queueName)) { putMsg(result, Status.QUEUE_NAME_EXIST, queueName); return result; } if (!queue.equals(queueObj.getQueue()) && checkQueueExist(queue)) { putMsg(result, Status.QUEUE_VALUE_EXIST, queue); return result; } if (checkIfQueueIsInUsing(queueObj.getQueueName(), queueName)) { Integer relatedUserNums = userMapper.updateUserQueue(queueObj.getQueueName(), queueName); logger.info("old queue have related {} user, exec update user success.", relatedUserNums); } Date now = new Date(); queueObj.setQueue(queue); queueObj.setQueueName(queueName); queueObj.setUpdateTime(now); queueMapper.updateById(queueObj); putMsg(result, Status.SUCCESS); return result; }  Map<String, Object> queryList(User loginUser); Map<String, Object> queryList(User loginUser, String searchVal, Integer pageNo, Integer pageSize); Map<String, Object> createQueue(User loginUser, String queue, String queueName); Map<String, Object> updateQueue(User loginUser, int id, String queue, String queueName); Result verifyQueue(String queue, String queueName);  }### Answer:
@Test public void testUpdateQueue(){ Mockito.when(queueMapper.selectById(1)).thenReturn(getQueue()); Mockito.when(queueMapper.queryAllQueueList("test", null)).thenReturn(getQueueList()); Mockito.when(queueMapper.queryAllQueueList(null, "test")).thenReturn(getQueueList()); Mockito.when(userMapper.queryUserListByQueue(queueName)).thenReturn(getUserList()); Map<String, Object> result = queueService.updateQueue(getLoginUser(),0,"queue",queueName); logger.info(result.toString()); Assert.assertEquals(Status.QUEUE_NOT_EXIST.getCode(),((Status)result.get(Constants.STATUS)).getCode()); result = queueService.updateQueue(getLoginUser(),1,queueName,queueName); logger.info(result.toString()); Assert.assertEquals(Status.NEED_NOT_UPDATE_QUEUE.getCode(),((Status)result.get(Constants.STATUS)).getCode()); result = queueService.updateQueue(getLoginUser(),1,"test",queueName); logger.info(result.toString()); Assert.assertEquals(Status.QUEUE_VALUE_EXIST.getCode(),((Status)result.get(Constants.STATUS)).getCode()); result = queueService.updateQueue(getLoginUser(),1,"test1","test"); logger.info(result.toString()); Assert.assertEquals(Status.QUEUE_NAME_EXIST.getCode(),((Status)result.get(Constants.STATUS)).getCode()); result = queueService.updateQueue(getLoginUser(),1,"test1","test1"); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getCode(),((Status)result.get(Constants.STATUS)).getCode()); }