接口

package com.tougu.apitest.LiveRoom;


import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;


import org.json.JSONObject;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;


import com.al.api.net.HttpFactory;
import com.al.api.test.base.APIBase;
import com.al.common.Configuration;
import com.al.common.config.JDBCDriver;
import com.al.core.annotation.DataFactory;
import com.al.core.dataprovider.ProviderFactory;
import com.al.core.nassert.NAssert;
import com.al.core.report.NReporter;
import com.al.db.DbUtils;
import com.google.common.collect.Maps;
import com.pazq.apitest.common.LoginCommonMethods;


/**
 * 作者: 日期:20180119
 * 测试用例方法 - AttentionAdviser
 * FAT测试数据:
 * UAT测试数据:
 */
@DataFactory(dataPathKey = "LiveRoom")
public class AttentionAdviser extends APIBase{
 


  @BeforeClass
  public void beforeClass() {
  }
  
  @Test(dataProvider = "ExcelRowsDP", dataProviderClass = ProviderFactory.class)
  @DataFactory(dataName = "normal", author = "AA", category = "关注投顾接口")


  public void getBeforeSignStatus(Map<String,String> caseData) {
 
 String tokenId;
 //用户先通过统一登录获取对应的tokenId
 Map<String, String> data = Maps.newHashMap();
 data.put("account", conf.get("account"));
 data.put("pwd", conf.get("pwd"));
 data.put("servername", "login");
 data.put("appName", conf.get("appName"));
 data.put("appChannel",conf.get("appChannel"));
 data.put("kbChannel", conf.get("kbChannel"));
 
 tokenId=LoginCommonMethods.loginByAccount(conf.get("loginCommonUrl"), data);
 
 
 //发送请求
 Map<String, String> data1 = Maps.newHashMap();
 data1.put("appName", conf.get("appName"));
 data1.put("tokenId", tokenId);
 data1.put("advisterUnionId",caseData.get("follow_adviser_uid"));
 HttpFactory hf = HttpFactory.newInstance();
 hf.post(conf.get("LiveRoomCommonUrl")+conf.get("attentionAdviser"),data1);
 NReporter.saveJSON("tttttttttttttttttttttttttttttt"+hf.getRequest(), hf.getResponse());
 
 //校验返回信息
 checkPoint(hf, caseData);
  }


  
  public void checkPoint(HttpFactory hf, Map<String, String> caseData){
  if(hf.getStatus()==200){
  NAssert.assertEquals(hf.getStatus(), 200, "验证请求状态码");
   JSONObject jo = new JSONObject(hf.getResponse());
   follow_status=getDataUser(conf,caseData);
   System.out.println("11111111111111111111111111"+follow_status);
   if(follow_status.equals("01")) {
NAssert.assertEquals(jo.getString("responseCode"), caseData.get("responseCode"), "校验responseCode");
NAssert.assertEquals(jo.getString("responseMsg"), caseData.get("responseMsg"), "校验responseMsg");
  }else{
  NAssert.assertEquals(hf.getStatus(), 400, "验证请求状态码");
  }
   
}
  }
  
  /**
* 数据库查询 - totalSize
*/
//   int totalSize;
   String follow_status;
public String getDataUser(Configuration conf, Map<String, String> caseData) {
// 重置user库数据
NReporter.info("查询数据库信息");
String sql="select m.follow_status from sis_live_follow_adviser m where m.follow_adviser_uid='"+caseData.get("follow_adviser_uid")+"'and m.user_code='"+caseData.get("user_code")+"'";
Connection conuserdb = DbUtils.getConnection(JDBCDriver.ORACLE, conf.get("livedburl"), conf.get("livedbuser"), conf.get("livedbpsw"));
NReporter.info("执行SQL语句:" + sql);
ResultSet rs = DbUtils.getResultSet(conuserdb, sql);
try {
while(rs.next()){
follow_status=rs.getString("follow_status");
// totalSize=rs.getInt(1);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
DbUtils.closeConnection(conuserdb);

return follow_status;
}
  
  @AfterClass
  public void afterClass() {
  }


}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值