注册企业接口传入的是一个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. Topcoder SRM 627 div1 HappyLettersDiv1 : 字符串

    Problem Statement      The Happy Letter game is played as follows: At the beginning, several players ...

  2. Software license key and activation

    http://stackoverflow.com/questions/16222674/software-license-key-and-activationhttps://github.com/La ...

  3. 孙鑫MFC学习笔记13:文档

    1.CArchive类保存内存数据 2.CAchive类重载了>>与<<操作符,类似C++文件流 3.在OnNewDocument中通过SetTitle设置标题 4.字符串资源 ...

  4. 几种常见语言的命名空间(Namespace)特性

    命名空间提供了一种从逻辑上组织类的方式,防止命名冲突. 几种常见语言 C++ 命名空间是可以嵌套的 嵌套的命名空间是指定义在其他命名空间中的命名空间.嵌套的命名空间是一个嵌套的作用域,内层命名空间声明 ...

  5. qt (5.60/5.70) 编译 QOCI 驱动

    转载请注明原文链接http://www.cnblogs.com/majianming/p/5925105.html 在学习qt过程中,遇到了编译oracle驱动的问题,在开源协议下没有编译好的,那就只 ...

  6. 解决远程连接mysql很慢的方法(mysql_connect 打开连接慢)

    http://www.jb51.net/article/27616.htm   有次同事提出开发使用的mysql数据库连接很慢,因为我们的mysql开发数据库是单独一台机器部署的,所以认为可能是网络连 ...

  7. selenium webdriver读取excel进行数据驱动测试

    最近做自动化需要从文件读取数据做参数化,网上发现一个不错的解决方案. 准备:新建一个excel文件,文件名为测试类名,sheet名为测试方法名         excel第一行为标题,从第二行开始为测 ...

  8. 让.NET 4.0支持TLS1.2协议

    The default System.Net.ServicePointManager.SecurityProtocol in both .NET 4.0/4.5 is SecurityProtocol ...

  9. Linux修改SSH端口,并禁止Root远程登陆

    1.更改ssh远程登录端口: #vi /etc/ssh/ssh_config将port改为你想要的端口,例如8888.默认是#port 22,把#号删掉改为 port 8888即可. 还要更改以下文件 ...

  10. Spring4学习笔记 - 配置Bean - 自动装配 关系 作用域 引用外部属性文件

    1 Autowire自动装配 1.1 使用:只需在<bean>中使用autowire元素 <bean id="student" class="com.k ...