@VisibleForTesting
    void validateExperienceOutRange(List<MemberLevelDO> list, Long id, Integer level, Integer experience) {
        for (MemberLevelDO levelDO : list) {
            if (levelDO.getId().equals(id)) {
                continue;
            }

            if (levelDO.getLevel() < level) {
                // 经验大于前一个等级
                if (experience <= levelDO.getExperience()) {
                    throw exception(LEVEL_EXPERIENCE_MIN, levelDO.getName(), levelDO.getExperience());
                }
            } else if (levelDO.getLevel() > level) {
                //小于下一个级别
                if (experience >= levelDO.getExperience()) {
                    throw exception(LEVEL_EXPERIENCE_MAX, levelDO.getName(), levelDO.getExperience());
                }
            }
        }
    }
@Test
    public void testUpdateLevel_experienceOutRange() {
        // 准备参数
        int level = 10;
        int experience = 10;
        Long id = randomLongId();
        String name = randomString();

        // mock 数据
        memberlevelMapper.insert(randomLevelDO(o -> {
            o.setLevel(level);
            o.setExperience(experience);
            o.setName(name);
        }));
        List<MemberLevelDO> list = memberlevelMapper.selectList();

        // 调用，校验异常
        assertServiceException(() -> levelService.validateExperienceOutRange(list, id, level + 1, experience - 1), LEVEL_EXPERIENCE_MIN, name, level);
        // 调用，校验异常
        assertServiceException(() -> levelService.validateExperienceOutRange(list, id, level - 1, experience + 1), LEVEL_EXPERIENCE_MAX, name, level);
    }