コード例 #1
0
 /**
  * Title: initMockData<br>
  * Description: 初始化测试数据 <br>
  *
  * @author xiebin
  * @date 2015年12月11日上午11:42:24
  * @param interFaceInfo
  */
 public void initMockData(InterFaceInfo interFaceInfo) {
   int ifId = interFaceInfo.getId();
   // 初始化测试数据
   List<ReturnCode> returnList = retrunCodeService.getReturnCodeByIfId(ifId);
   // 遍历返回码 更新测试数据
   for (ReturnCode rscdObj : returnList) {
     IfSysMock mock = (IfSysMock) SpringContextHolder.getBean(IfSysMock.class);
     mock.setIfId(ifId);
     mock.setRspCodeId(rscdObj.getId());
     // 测试数据表中确认是否已经存在对应返回码的测试数据
     List<IfSysMock> ifMockList = ifSysMockService.getMockInfoByIfIdAndRspCdId(mock);
     if (ifMockList == null || ifMockList.size() == 0) {
       // 获取接口请求字段的JSON展示字符串
       InterFaceField interFaceField =
           (InterFaceField) SpringContextHolder.getBean(InterFaceField.class);
       interFaceField.setIfId(ifId);
       interFaceField.setFieldFlag("1");
       String reqJson = interFaceFieldService.getJsonStr(interFaceField);
       // 获取接口响应字段的JSON展示字符串
       interFaceField.setFieldFlag("2");
       String rspJson = interFaceFieldService.getJsonStr(interFaceField);
       mock.setRequestJson(reqJson);
       mock.setResponseJson(rspJson);
       // 如果还没有测试数据 则默认添加一条
       ifSysMockService.addIfSysMock(mock);
     }
   }
 }
コード例 #2
0
  @Before("serviceAspect()")
  public void doBefore(JoinPoint joinPoint) {
    debug("dobefore log");
    String targetName = joinPoint.getTarget().getClass().getName();
    if ("com.gigold.pay.autotest.threadpool.IfsysCheckThreadPool".equalsIgnoreCase(targetName)) {
      try {
        jrn = jrnGrneratorService.generateJrn();
      } catch (Exception e) {
        debug("ifSysMockHistoryServiceAspect doBefore 生成批次号有异常");
        e.printStackTrace();
      }
    } else {
      Date d = new Date();
      IfSysMockHistory ifSysMockHistory =
          (IfSysMockHistory) SpringContextHolder.getBean(IfSysMockHistory.class);
      // 设置请求日期
      Object argsObj = joinPoint.getArgs()[0];
      IfSysMock ifSysMock = null;
      if (argsObj instanceof IfSysMock) {
        ifSysMock = (IfSysMock) argsObj;
      }
      if (ifSysMock == null) {
        debug("ifSysMockHistoryServiceAspect doBefore ifSysMock为null");
        return;
      }

      ifSysMockHistory.setIfId(ifSysMock.getIfId());
      ifSysMockHistory.setMockId(ifSysMock.getId());
      // 设置测试结果
      ifSysMockHistory.setTestResult(ifSysMock.getTestResult());
      // 设置流水号
      ifSysMockHistory.setJrn(jrn);
      // 设置测试日期
      ifSysMockHistory.setTestDt(ymd.format(d));
      // 设置测试时间
      ifSysMockHistory.setTestTm(hms.format(d));
      boolean flag = ifSysMockHistoryService.addIfSysMockHistory(ifSysMockHistory);
      if (!flag) {
        debug("ifSysMockHistoryService.addIfSysMockHistory 方法出现异常");
      }
    }
  }