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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • tess4j正确的使用 OCR

    tess4j正确的使用 OCR在官网上下载下来的tess4j的zip,初见时看的云里雾里的,原以为是个jar,直接引用就好了,结果竟是个zip。网上查一下用法,各种说法,各种菜,全是误导,自己不懂就敢瞎说…实际上使用时需要注意一下几点:一、引jar包打开压缩包,在dist下边有tess4j的jar,这个jar包在lib下也可以找到,这是关键jar。此外还需要其他好多依赖jar包,这些都可以在lib下找到。l

    2022年5月25日
    100
  • 使用cloudsim进行云计算仿真步骤_公司分析中最重要的是

    使用cloudsim进行云计算仿真步骤_公司分析中最重要的是CloudSimExample1展示如何创建一个只包含一个主机的数据中心,并且在其上运行一个云任务。首先附上CloudSimExample1全部代码:packageorg.cloudbus.cloudsim.examples;/**Title:CloudSimToolkit*Description:CloudSim(CloudSimulation…

    2022年10月13日
    0
  • iOS唯一标示符引导

    iOS唯一标示符引导

    2021年5月11日
    128
  • FPN(feature pyramid networks)算法讲解「建议收藏」

    FPN(feature pyramid networks)算法讲解「建议收藏」这篇论文是CVPR2017年的文章,采用特征金字塔做目标检测,有许多亮点,特来分享。论文:featurepyramidnetworksforobjectdetection论文链接:https://arxiv.org/abs/1612.03144论文概述:作者提出的多尺度的objectdetection算法:FPN(featurepyramidnetworks)。原来多数的

    2022年4月28日
    42
  • pycharm创建flask项目没有子文件夹和app文件_python flask框架

    pycharm创建flask项目没有子文件夹和app文件_python flask框架打开Pycharm的File菜单,选择创建新的项目,在弹出对话框中,我们可以看到很多的案例,Flask、Django等等,我们选择Flask创建Flask项目。选择创建之后一个Flask项目就出现在我们眼前:默认文件目录结构为:app.py程序入口,static用于存放静态文件,如js、css、img等,templates用于放置html模板文件在Pycharm菜单栏有个run,我们可以选择run来启动Flask服务,默认打开的是5000端口打开浏览器输入http://lo.

    2022年8月29日
    2
  • Linux下的5款主流高可用集群软件介绍[通俗易懂]

    Linux下的5款主流高可用集群软件介绍[通俗易懂]Linux集群主要分成三大类:高可用集群(HighAvailabilityCluster)、负载均衡集群(LoadBalanceCluster)、科学计算集群(HighPerformanceComputingCluster)。其中高可用集群具有保障应用程序持续提供服务的能力,可以将因软、硬件、人为造成的故障对业务的影响降低到最小程度。在高可用集群中,最常见的就是两个节点做成的HA集群,有很多通俗的名称,比如“双机热备”、“双机互备”、“双机”。而在Linux平台下常见的高可用集群软件有

    2022年10月16日
    0

发表回复

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

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