guns spring 单元测试[通俗易懂]

guns spring 单元测试[通俗易懂]guns spring 单元测试

大家好,又见面了,我是你们的朋友全栈君。

package com.stylefeng.guns;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.common.exception.BizExceptionEnum;
import com.stylefeng.guns.core.exception.GunsException;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.server.model.DeliveryOrder;
import com.stylefeng.guns.modular.server.model.DeliveryOrderLine;
import com.stylefeng.guns.modular.server.service.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = GunsApplication.class)
public class TestTest {
    @Autowired IEntryOrderService entryOrderService;
    @Autowired
    IDeliveryOrderService deliveryOrderService;
    @Autowired
    IDeliveryOrderLineService deliveryOrderLineService;
    @Test
    public void test(){
        try{
            String no = entryOrderService.getNextEntryOrderNo(1003);
            System.out.println("获取入库单号 : " + no);
        }
        catch(BadSqlGrammarException e){
            System.out.println("exception : " + e);
            if(e.getCause().toString().contains("raise_application_error")){
                String msg = entryOrderService.getError();
                BizExceptionEnum.SESSION_LAST_ERROR.setMessage(msg);
                throw new GunsException(BizExceptionEnum.SESSION_LAST_ERROR);
            }
            BizExceptionEnum.SESSION_LAST_ERROR.setMessage(e.getMessage());
            throw new GunsException(BizExceptionEnum.SESSION_LAST_ERROR);
        }catch (Exception e){
            BizExceptionEnum.SESSION_LAST_ERROR.setMessage(e.getMessage());
            throw new GunsException(BizExceptionEnum.SESSION_LAST_ERROR);
        }
    }
    @Test
    public void test1(){
//        List<DeliveryOrder> deliveryOrderList = deliveryOrderService.selectList(
//                new EntityWrapper<DeliveryOrder>()
//                .eq("part_count",0)
//                .eq("rowstate",1)
//        );
//        for (DeliveryOrder deliveryOrder: deliveryOrderList){
//            if (ToolUtil.isEmpty(deliveryOrder.getPartList())){
//                List<DeliveryOrderLine> deliveryOrderLineList = deliveryOrderLineService.selectList(
//                        new EntityWrapper<DeliveryOrderLine>()
//                        .eq("order_no",deliveryOrder.getOrderNo())
//                        .eq("logistics_company_id",deliveryOrder.getLogisticsCompanyId())
//                        .orderBy("ean_no",true)
//                );
//                String partList = "";
//                Integer totalQt = 0;
//                if (deliveryOrderLineList.size() > 0) {
//                    for (DeliveryOrderLine item : deliveryOrderLineList) {
//                        partList = partList
//                                + item.getEanNo().trim()+ "^"
//                                +item.getQuantity().toString()
//                                + "^" + "10003"
//                                + "^" + deliveryOrder.getWarehouse()
//                                + "^" + deliveryOrder.getOwnerId()
//                                + "^" + deliveryOrder.getExprCompany()
//                                + ",";
//                        totalQt = totalQt + item.getQuantity();
//                    }
//                    partList = partList.substring(0, partList.length() - 1);
//                }
//                deliveryOrder.setGoodsCount(totalQt);
//                deliveryOrder.setPartCount(deliveryOrderLineList.size());
//                deliveryOrder.setPartList(ToolUtil.toStr(ToolUtil.toHash(partList)));
//                deliveryOrderService.updateById(deliveryOrder);
//            }
//        }
//        HttpServletResponse response = HttpKit.getResponse();
//        try {
//            // 网络pdf文件全路径
//            String pdfUrl ="http://182.254.230.150:8089/helloworld.pdf";
//            URL url = new URL(pdfUrl);
//            HttpURLConnection conn = (HttpURLConnection)url.openConnection();
//            conn.setConnectTimeout(5*1000);
//            InputStream inputStream = conn.getInputStream();
//            response.setHeader("Content-Disposition", "attachment;fileName=helloword.pdf");
//            response.setContentType("multipart/form-data");
//            OutputStream outputStream = response.getOutputStream();
//            IOUtils.write(IOUtils.toByteArray(inputStream), outputStream);
//            System.out.println(outputStream);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
    }
}

 

转载于:https://my.oschina.net/u/3556610/blog/3022405

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/106931.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 软件工程师待遇怎么样?软件工程师薪水到底有多高?「建议收藏」

    软件工程师待遇怎么样?软件工程师薪水到底有多高?「建议收藏」随着技术不断进步,行业对软件开发技能的需求急剧上升。在此情况下,软件工程师(程序员)薪水上涨便很正常。通常来说,个人薪水是高是低,则与自身积累的经验、所处的地点以及产业分不开。据国际调研机构IDC在报告中公开的数据:2018年,全球有2230万名的软件工程师;其中,全职程序员1165万名,兼职人员635万名,非专业人员430万名。美国拥有最多的软件工程师,651017人;其次是中国,183…

    2022年9月2日
    3
  • 二进制表示小数「建议收藏」

    二进制表示小数「建议收藏」二进制表示小数二进制表示小数TableofContents1.题目2.方法3.思路1题目给定一个数将其转换为二进制(均用字符串表示),如果这个数的小数部分不能在32个字符之内来精确地表

    2022年8月4日
    3
  • vscode连接力扣题库

    vscode连接力扣题库vscode连接力扣题库下载力扣插件回到力扣,点击题库,打开开发者工具(f12),点击网络,再次点击题库,点击标头,下滑找到cookie,复制cookie的值回到vscode,点击力扣图标,点击登录图标(如图),选择cookie登录,将刚刚复制的cookie值粘贴在这里即可…

    2022年10月23日
    0
  • 微服务架构技术有哪些_微服务架构组件

    微服务架构技术有哪些_微服务架构组件目录一、微服务架构实现需求二、微服务架构实现技术选型:参考标准的两个维度+微服务实现框架对比(一)技术选型的两个参考标准1.核心组件完备性2.关键要素实现难度(二)微服务实现框架对比SpringBoot/CloudDubbogRPC新锐微服务框架:Istio(ServiceMesh的设计理念)参考书籍、文献和资料:一、微服务架构实现需求技…

    2022年10月21日
    0
  • 【有效】2016/2013/2010 软件的安装解决方法[通俗易懂]

    【有效】2016/2013/2010 软件的安装解决方法[通俗易懂]office相关个性化软件KMS支持2016/2013/2010版本链接:https://pan.baidu.com/s/1atqgWz1wiJnVO8WTLJyShQ提取码:6lpq链接有效麻烦点个赞~

    2022年5月3日
    33
  • sqlpro studio 2021激活码[最新免费获取]

    (sqlpro studio 2021激活码)这是一篇idea技术相关文章,由全栈君为大家提供,主要知识点是关于2021JetBrains全家桶永久激活码的内容IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html1STL5S9V8F-eyJsaWN…

    2022年3月27日
    247

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号