美文网首页
对资源中patch的测试

对资源中patch的测试

作者: xmlovecm | 来源:发表于2016-10-28 14:46 被阅读0次

    DHC中,要获得bearer_token

    1、HTTPS://ucbetapi.101.com/v0.93//bearer_tokens
    2、URL的body为
    {
    "login_name":"esp_lifecycle",
    "password":"d4876ded8c0df211825893ae8a3c6df9"
    }
    3、Authorization为NDR_MAC
    4、结果中选取access_token 项目


    1.jpg

    5、在你要测试的地方


    2.jpg
    键入你得到的access_token的值

    数据库表中category_datas表

    相当于是字典查ndresource中某个对象中ndcode是否在这个字典中,在这个字典中则表示,这个ndcode是对的

    patch接口的测试需求

    (patch需求)[http://wiki.sdp.nd/index.php?title=LCMS_API_INNER_001]
    步骤:
    1、从代码中找到@RequestMapping("/v0.6/subInstruction")
    2、在数据库中找某个资源id来进行更改测试SELECT * FROM ndresource WHERE primary_category='res_type' and enable='1',设置url的地址

    57988593e876cb50bc6d639d770f24fc.jpg
    3、设置合理的URL的body
    4、在eclipse中运行代码

    eclipse调试

    1、F5跳入函数内部执行F6单步调试
    2、debug下,这个是忽略所有的断点,相当于start方式启动运行


    未命名.jpg

    3、跳到下一下断点,最好不用 F8而是用


    5.jpg

    questions资源在这个数据库中

    question数据库.jpg

    项目代码中通常通过res_type来判断使用哪个数据库进行操作

    根据不同res_type选择不同的数据库

    private JdbcTemplate getJdbcTemplate(String resType) {
            if (CommonServiceHelper.isQuestionDb(resType)) {
                return questionJdbcTemplate;
            }
            return defaultJdbcTemplate;
        }
    

    //判断资源是否是question,和SourceCourseWareObjectType,是则返回false

    public static boolean isQuestionDb(String resType){
            if (!(resType.equals(IndexSourceType.QuestionType.getName()) || resType
                    .equals(IndexSourceType.SourceCourseWareObjectType.getName()))) {
                return false;
            }
            return true;
        }
    

    在测试的过程中代码的理解

    1、CommonHelper.inputParamValid4Patch(questionViewModel);中对viewmodel做了些校验
    2、QuestionModel questionModel = CommonHelper.convertViewModelIn(questionViewModel, QuestionModel.class,ResourceNdCode.questions, true);将viewmodel转为model,要注意有些值进入model是有限制的
    3、项目代码中,都是从入参model中先拿出值,存到数据库中去,再getDetail,从数据库将这些值,返回给你。相当于是先入库,再出库

    public ResourceModel patch(String resourceType, ResourceModel resourceModel, DbName dbName, boolean isObvious) {
            // 0、校验资源是否存在
            Education oldBean = checkResourceExist(resourceType, resourceModel.getIdentifier());
    
            // 1、判断资源编码是否唯一
            if(StringUtils.isNotEmpty(resourceModel.getNdresCode())){
                boolean flagCode = isDuplicateCode(resourceType,resourceModel.getIdentifier(),resourceModel.getNdresCode());
                if(flagCode){
                    throw new LifeCircleException(HttpStatus.INTERNAL_SERVER_ERROR,LifeCircleErrorMessageMapper.CheckDuplicateCodeFail);
                }
            }
    
            // 2、基本属性的处理
            dealBasicInfoPatch(resourceType, resourceModel, oldBean, isObvious);
    
            // 3、categories属性处理
            if(resourceModel != null && CollectionUtils.isNotEmpty(resourceModel.getCategoryList())) {
                dealCategoryPatch(resourceType, resourceModel);
            }
    
            // 4、tech_info属性处理
            if(resourceModel != null && CollectionUtils.isNotEmpty(resourceModel.getTechInfoList())){
                dealTechInfoPatch(resourceType, resourceModel);
            }
    
            // 5、同步推送至报表系统
            ResourceModel rtModel = getDetail(resourceType, resourceModel.getIdentifier(), IncludesConstant.getIncludesList());
            nds.notifyReport4Resource(resourceType,rtModel,OperationType.UPDATE);
            return  rtModel;
        }
    

    相关文章

      网友评论

          本文标题:对资源中patch的测试

          本文链接:https://www.haomeiwen.com/subject/vukeuttx.html