注册企业接口传入的是一个request,查询企业接口传入的是一个integer;根据名称和国家名称模糊匹配接口传入的是一个Map;
针对三种不同的传参我怎么作接口测试呢?
 1 package com.web.crm.services;

 import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; @Service
public class test {
@Autowired
private ICustomerInterface CustomerInterface;
@Autowired
private IShippingPortcodeInterface ShippingPortcodeInterface; //test
@SuppressWarnings({ "rawtypes" })
public List<TestResult> test(){
//返回结果
List<TestResult> result = new ArrayList<TestResult>();
/**
* 功能描述:注册企业
* CustomerResponse registerCustomer(CustomerRequest<?> request)
* 接口请求带request 案例
*/
//实例化一个请求
CustomerRequest request = new CustomerRequest();
//实例化一个参数
CusCustomerEntity customerEntity = new CusCustomerEntity();
customerEntity.setCusName("微软");
//将参数写人请求
request.setEntity(customerEntity);
//实例化一个参数
CusEmployeeEntity CusEmployeeEntity = new CusEmployeeEntity();
CusEmployeeEntity.setEmpTypeId(123);
CusEmployeeEntity.setCompanyEmail("yiy11@12.com");
CusEmployeeEntity.setMobilePhone("13400065433");
//将参数写人请求
request.setEmployeeEntity(CusEmployeeEntity);
//实例化一个响应
CustomerResponse response = new CustomerResponse();
//将请求传入被测接口方法
response=CustomerInterface.registerCustomer(request);
//逻辑判断getResultCode是否10000
if (StringUtils.equals(response.getResultCode(), ReturnResult.SUCCESS.getResultCode())) {
result.add(new TestResult(AlertMessageLevel.SUCCESS, "注册企业", response.getResultCode(), response
.getResultMessage()));
} else {
result.add(new TestResult(AlertMessageLevel.ERROR, "注册企业", response.getResultCode(), response
.getResultMessage()));
} /**
* 功能描述:查询企业
* CustomerResponse getCustomerById(Integer id)
* 接口请求可以直接入参 案例
*/
//定义入参类型并赋值
Integer id=1;
//实例化一个响应
CustomerResponse response1 = new CustomerResponse();
//将定义参数传入被测接口方法
response1=CustomerInterface.getCustomerById(id);
//逻辑判断getResultCode是否10000
if (StringUtils.equals(response1.getResultCode(), ReturnResult.SUCCESS.getResultCode())) {
result.add(new TestResult(AlertMessageLevel.SUCCESS, "查询企业", response1.getResultCode(), response1
.getResultMessage()));
} else {
result.add(new TestResult(AlertMessageLevel.ERROR, "查询企业", response1.getResultCode(), response1
.getResultMessage()));
} /**
* 功能描述:根据名称和国家名称模糊匹配
* ShippingPortcodeResponse queryAllPortcodeCountry(java.util.Map<java.lang.String,java.lang.Object> paramMap)
* 接口请求带Map 案例
*/
Map<java.lang.String,java.lang.Object> wy = new HashMap<java.lang.String,java.lang.Object>();
wy.put("1", 1);
ShippingPortcodeResponse response2 = new ShippingPortcodeResponse();
response2 = ShippingPortcodeInterface.queryAllPortcodeCountry(wy);
if (StringUtils.equals(response2.getResultCode(), ReturnResult.SUCCESS.getResultCode())) {
result.add(new TestResult(AlertMessageLevel.SUCCESS, "根据名称和国家名称模糊匹配", response2.getResultCode(), response2
.getResultMessage()));
} else {
result.add(new TestResult(AlertMessageLevel.ERROR, "根据名称和国家名称模糊匹配", response2.getResultCode(), response2
.getResultMessage()));
} return result;
}}

接口测试中三种传参请求(Map、request、Integer)解析的更多相关文章

  1. C++学习3--编程基础(vector、string、三种传参)

    知识点学习 Vector容器 vector是C++标准程序库中的一个类,其定义于头文件中,与其他STL组件一样,ventor属于STD名称空间: ventor是C++标准程序库里最基本的容器,设计之初 ...

  2. 浅谈C++三种传参方式

    浅谈C++三种传参方式 C++给函数传参中,主要有三种方式:分别是值传递.指针传递和引用传递. 下面通过讲解和实例来说明三种方式的区别. 值传递 我们都知道,在函数定义括号中的参数是形参,是给函数内专 ...

  3. vector作为参数的三种传参方式

    c++中常用的vector容器作为参数时,有三种传参方式,分别如下(为说明问题,用二维vector): function1(std::vector<std::vector<int> ...

  4. Vue-router的三种传参方式

    第一种传递参数:name传参 两步完成name传参并显示在模板中: 第一在router/index.js中配置name属性, routes: [ { path: '/', name: 'HelloWo ...

  5. vue路由router的三种传参方式

    方法三: 传参页面传递参数方式: this.$router.push({ path: 'indexTwoDetails', query: { "id": id } }) 接受参数页 ...

  6. vector做形参时的三种传参方式

    vector在做形参的时候传参的方式和普通的变量是一样的,要么传值.要么传引用.要么传指针. 现在分别定义三个以vector为形参的函数: (1) fun1(vector <int> v) ...

  7. vue的三种传参方式

    <template> <div> <router-link :to="{'name':'x',params:{'type':'users'}}"> ...

  8. c# 三种传参方式 in,out,ref

    in:默认方式,传值不返回 out:不传值 但是会返回新值给予传参对象 ref:传存储地址,所以传参前必须赋值初始化,传值后的运算结果直接作用在传参上 Out和ref的效果差不多

  9. jquery mobile changepage的三种传参方法介绍

    本来觉得changePage 那么多option,传几个参数应该没问题结果翻遍国内外网站,基本方法只有三种 1,显性传参,就是利用url这个地址把参数带上,然后到changepage后的新页面,用函数 ...

随机推荐

  1. DataGridView修改HeaderText

    dataGridView_htList为一个 DataGridView(ht为HoverTree的缩写)方法一:dataGridView_htList.Columns["HtAddTime& ...

  2. 介绍开源的.net通信框架NetworkComms框架 源码分析(十四)StreamTools

    原文网址: http://www.cnblogs.com/csdev Networkcomms 是一款C# 语言编写的TCP/UDP通信框架  作者是英国人  以前是收费的 目前作者已经开源  许可是 ...

  3. Windows Server 2012 配置多用户远程桌面

    前段时间因为需要多用户同时远程连接 windows server 2012,但找了半天也没找到远程桌面管理,最后从搜索中找到如下方法,经测试可行! 打开注册表,进入路径: [HKEY_LOCAL_MA ...

  4. serialize()序列化

  5. MySQL Workbench返回所有的记录

    使用MySQL Workbench查询数据库,当返回的记录较多时,不能显示所有的记录,因为MySQL Workbench默认只返回1000条记录. 为了显示所有的记录,可以在查询语句后面加一句: LI ...

  6. Android发送短信

    // 发送短信 public void sendMsg(){ String content = edtSend.getText().toString(); SmsManager smsManager ...

  7. GNOME on Arch Linux

    Arch Linux上Gnome桌面截图欣赏: 相比而言,Debian的壁纸一直好像格调不够啊:

  8. 编译gcc

    下载源码 自GNU FTP站下载GCC. 自Infrastructure页面下载四个库的源代码,即GMP.MPFR.MPC以及ISL(ISL非必需). 也可以不手工下载,执行源码中的./contrib ...

  9. [javaSE] 反射-Class类的使用

    JAVA-Reflect 专题 ①Class类的使用 ②方法的反射 ③成员变量的反射 ④构造函数的反射 ⑤java类的加载机制 Ⅰ在面向对象的世界里,万事万物皆为对象 类是对象,类是java.lang ...

  10. 向量自回归模型VS风险价值模型(VAR&VaR)

    单从外观上看,VAR&VaR两个模型很容易混淆,但就模型方法和用处两者截然不同,R语言作为数据分析的有力工具,其函数包库中包含各种各样的统计模型.通过vars包可以调用向量自回归模型,通过Pe ...