Commit 7cdccc4d by 吴博

feat: [none] addcase

parent c39b7f00
......@@ -3,7 +3,11 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.pcloud.universe</groupId>
<artifactId>universe-commons-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<groupId>com.lemon</groupId>
<artifactId>Lemon</artifactId>
<version>1.0-SNAPSHOT</version>
......@@ -21,6 +25,7 @@
<aspectj.version>1.9.8</aspectj.version>
<jackson.version>2.6.5</jackson.version>
<universe-error-alarm.version>3.0.1-SNAPSHOT</universe-error-alarm.version>
</properties>
......@@ -71,6 +76,15 @@
<dependencies>
<dependency>
<groupId>com.pcloud.universe</groupId>
<artifactId>universe-error-alarm</artifactId>
<version>${universe-error-alarm.version}</version>
</dependency>
<!-- JSON类型操作坐标-->
<dependency>
<groupId>com.alibaba</groupId>
......
......@@ -22,8 +22,9 @@ public class Rays7ServerCase extends BaseCase {
// String token = "430f837c00f9978dffec9d4c0c05c751";
// 创建post请求
HttpPost post= new HttpPost(url);
post.setHeader("Content-Type", "application/json");
post.setEntity(new StringEntity(json));
post.setHeader("Content-Type", "application/json;charset=UTF-8");
post.setHeader("Authorization", "Bearer");
post.setEntity(new StringEntity(json, "UTF-8"));
DefaultHttpClient client = new DefaultHttpClient();
// 执行get请求,并使用response来存放执行后返回的响应内容
HttpResponse response = client.execute(post);
......@@ -48,7 +49,9 @@ public class Rays7ServerCase extends BaseCase {
public Object[][] datas0() {
//Object[m][n] m代表执行次数,n代表参数个数
Object[][] datas = {
{0, "", "http://192.168.8.40:8270/aibrain/v1.0/digitalRange/testManager", "{\"event\":\"SDK_MSG_REPORT\",\"origin\":\"WECHAT_OFFICIAL\",\"wxSdkMsgDTO\":{\"content\":{\"textMsgDTO\":{\"content\":\"泛悦城\"}},\"contentType\":\"Text\",\"digitalPersonId\":1,\"msgId\":\"24123340480981103\",\"msgRemoteId\":\"24123340480981103\",\"sdkCode\":\"66059\",\"senderSdkCode\":\"o9vkPwnl1Nd4JdBDSpcujb4d4JsU\",\"userId\":182833195}}","{\"errCode\":0,\"message\":\"操作成功!\"}"}, // RAYS跳RAYS
{0, "", "https://adviser.raysgo.com/aibrain/v1.0/digitalRange/testManager",
"{\"event\":\"SDK_MSG_REPORT\",\"origin\":\"WECHAT_H5\",\"wxSdkMsgDTO\":{\"clientHost\":\"192.168.92.114\",\"clientPort\":59634,\"content\":{\"textMsgDTO\":{\"content\":\"答案2\"}},\"contentType\":\"Text\",\"conversationId\":\"143773987\",\"digitalPersonId\":2174,\"language\":\"zh-CN\",\"messageMetaId\":4252464657572101,\"msgRemoteId\":\"4252464657572100\",\"sdkCode\":\"23\",\"senderSdkCode\":\"143773987\",\"serverHost\":\"192.168.92.118\",\"serverPort\":9000,\"userId\":143773987}}"
,"{\"errCode\":0,\"message\":\"操作成功!\"}"}, // RAYS跳RAYS
};
return datas;
}
......
package com.lemon.utils;
import com.lemon.cases.BaseCase;
import com.lemon.pojo.TestRecord;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ScalarHandler;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import java.math.BigInteger;
import java.sql.Connection;
/**
......@@ -12,8 +16,11 @@ import java.sql.Connection;
* @author: ray
* @create: 2022-09-27 14:20
**/
public class SqlUtils {
public static Logger log = Logger.getLogger(BaseCase.class);
/**
* 传入sql语句执行sql查询,并且返回查询结果
*
......@@ -34,7 +41,7 @@ public class SqlUtils {
conn = JDBCUtils.getConnection();
// 查询操作,使用query
result = runner.query(conn, sql, new ScalarHandler<>());
System.out.println(result);
log.info("querySingle:" + sql + "rsult:"+ result);
} catch (Exception e) {
e.printStackTrace();
} finally {
......@@ -44,4 +51,67 @@ public class SqlUtils {
}
public static void insertTestRecord(TestRecord testRecord) {
/**
* public class TestRecord {
* private Long id;
* private String inquiry;
* private String inputContent;
* private String outputContent;
* private Integer state;
* private String testVersion;
* private Date createTime;
* private Date updateTime;
* private Integer isDelete;
* private Long caseId;
* private String caseDesc;
* private String expectContent;
*/
/**
* CREATE TABLE `test_record` (
* `id` bigint(20) NOT NULL COMMENT '主鍵id',
* `inquiry` varchar(255) DEFAULT NULL COMMENT '用户输入',
* `input_content` varchar(2000) DEFAULT NULL COMMENT '接口入参',
* `output_content` varchar(2000) DEFAULT NULL COMMENT '接口出参',
* `state` tinyint(4) DEFAULT NULL COMMENT '用例状态 0 未通过 1通过',
* `test_version` varchar(255) DEFAULT NULL COMMENT '测试版本',
* `create_time` datetime DEFAULT NULL COMMENT '创建时间',
* `update_time` datetime DEFAULT NULL COMMENT '更新时间',
* `is_delete` tinyint(4) DEFAULT NULL COMMENT '删除状态',
* `case_id` bigint(20) DEFAULT NULL COMMENT '案例ID',
* `case_desc` varchar(255) DEFAULT NULL COMMENT '案例描述',
* `expect_content` varchar(2000) DEFAULT NULL COMMENT '预期结果',
* PRIMARY KEY (`id`)
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
*/
Connection conn = null;
try {
//创建queryRunner对象
QueryRunner runner = new QueryRunner();
//调用查询方法,传入数据库连接、SQL语句、返回值类型
conn = JDBCUtils.getConnection();
// 插入操作,使用update
String sql = "INSERT INTO test_record (inquiry, input_content, output_content, state, test_version, create_time, update_time, is_delete, case_id, case_desc, expect_content) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
// 插入数据并获取生成的主键
BigInteger generatedId = (BigInteger)runner.insert(conn, sql, new ScalarHandler<BigInteger>(),
testRecord.getInquiry(),
testRecord.getInputContent(),
testRecord.getOutputContent(),
testRecord.getState(),
testRecord.getTestVersion(),
testRecord.getCreateTime(),
testRecord.getUpdateTime(),
testRecord.getIsDelete(),
testRecord.getCaseId(),
testRecord.getCaseDesc(),
testRecord.getExpectContent()
);
// 设置生成的主键到 testRecord 对象
testRecord.setId(generatedId.longValue());
} catch (Exception e) {
e.printStackTrace();
} finally {
JDBCUtils.close(conn);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment