### Question:
AlertGroupService extends BaseService { public Map<String, Object> grantUser(User loginUser, int alertgroupId, String userIds) { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, false); if (checkAdmin(loginUser, result)){ return result; } userAlertGroupService.deleteByAlertGroupId(alertgroupId); if (StringUtils.isEmpty(userIds)) { putMsg(result, Status.SUCCESS); return result; } String[] userIdsArr = userIds.split(","); Date now = new Date(); List<UserAlertGroup> alertGroups = new ArrayList<>(userIds.length()); for (String userId : userIdsArr) { UserAlertGroup userAlertGroup = new UserAlertGroup(); userAlertGroup.setAlertgroupId(alertgroupId); userAlertGroup.setUserId(Integer.parseInt(userId)); userAlertGroup.setCreateTime(now); userAlertGroup.setUpdateTime(now); alertGroups.add(userAlertGroup); } if (CollectionUtils.isNotEmpty(alertGroups)) { userAlertGroupService.saveBatch(alertGroups); } putMsg(result, Status.SUCCESS); return result; }  HashMap<String, Object> queryAlertgroup(); Map<String, Object> listPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize); Map<String, Object> createAlertgroup(User loginUser, String groupName, AlertType groupType, String desc); Map<String, Object> updateAlertgroup(User loginUser, int id, String groupName, AlertType groupType, String desc); @Transactional(rollbackFor = RuntimeException.class) Map<String, Object> delAlertgroupById(User loginUser, int id); Map<String, Object> grantUser(User loginUser, int alertgroupId, String userIds); boolean existGroupName(String groupName);  }### Answer:
@Test public void testGrantUser() { Integer groupId = 1; ArgumentCaptor<Integer> groupArgument = ArgumentCaptor.forClass(Integer.class); Mockito.when(userAlertGroupService.deleteByAlertGroupId(anyInt())).thenReturn(true); Map<String, Object> result = alertGroupService.grantUser(getLoginUser(), groupId, "123,321"); Mockito.verify(userAlertGroupService).deleteByAlertGroupId(groupArgument.capture()); logger.info(result.toString()); assertEquals(groupArgument.getValue(), groupId); assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); }