Commit 6ccafa64 by xyy

新增ai能力case

parent 2325e33c
package com.xiaomai.cases.polar.training;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.basetest.BaseTestImpl;
import com.xiaomai.cases.lunar.user.UserTools;
import com.xiaomai.client.DataUserInfo;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import javax.annotation.Resource;
public class TestAiChat extends BaseTestImpl {
@Resource(name="trainingTools")
TrainingTools trainingTools;
@Resource(name="userTools")
UserTools userTools;
DataUserInfo info = new DataUserInfo();
String memberId;
@BeforeMethod
@Override
public void beforeTest(){
setTestInfo(ApiModule.Polar_Training, "API_aiChat", LoginAccount.GYM_PROD, Terminal.B, "xyy");
super.beforeTest();
}
@Test(description = "获取AI小助理>进入日常会话>获取场景历史数据>进行AI聊天>清除聊天上下文>删除聊天记录")
public void testGetTrainingPlanContent() throws InterruptedException {
//1.获取日常问答的modelId,personModelId
String modelId = XMJSONPath.readPath(trainingTools.listModelPerson(),"$.result[0].modelId");
String personModelId = XMJSONPath.readPath(trainingTools.listModelPerson(),"$.result[0].id");
//2.获取日常问答的会话id
String conversationId = trainingTools.getAiConversationId(modelId,personModelId);
//3.查询当前会话的历史数据
int num = Integer.parseInt(XMJSONPath.readPath(trainingTools.getConversationMessagePage(conversationId),"$.result.total"));
JSONObject body = new JSONObject();
body.put("conversationId",conversationId);
body.put("question","你好");
//调用请求
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Thread.sleep(2000);
Assert.assertTrue(Integer.parseInt(XMJSONPath.readPath(trainingTools.getConversationMessagePage(conversationId),"$.result.total"))==num+2);
//4.清除聊天上下文
trainingTools.clearConversationContext(conversationId);
Assert.assertTrue(Integer.parseInt(XMJSONPath.readPath(trainingTools.getConversationMessagePage(conversationId),"$.result.total"))==num+2);
//5.删除聊天记录
trainingTools.clearConversationHistory(conversationId);
Assert.assertTrue(Integer.parseInt(XMJSONPath.readPath(trainingTools.getConversationMessagePage(conversationId),"$.result.total"))==0);
}
}
package com.xiaomai.cases.polar.training;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.basetest.BaseTestImpl;
import com.xiaomai.cases.lunar.user.UserTools;
import com.xiaomai.client.DataUserInfo;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import javax.annotation.Resource;
public class TestGetTrainingPlanContent extends BaseTestImpl {
@Resource(name="trainingTools")
TrainingTools trainingTools;
@Resource(name="userTools")
UserTools userTools;
DataUserInfo info = new DataUserInfo();
String memberId;
@BeforeMethod
@Override
public void beforeTest(){
setTestInfo(ApiModule.Polar_Training, "API_getTrainingPlanContent", LoginAccount.GYM_PROD, Terminal.B, "xyy");
super.beforeTest();
}
@Test(description = "智能生成训练计划>查看训练详情>编辑训练计划>C端查看动作详情>删除训练计划")
public void testGetTrainingPlanContent() throws InterruptedException {
info.setTerminal(Terminal.minApp);
info.setLoginUser(LoginAccount.GYM_MINIAPPC);
//1.获取会员id
memberId = userTools.getMemberInfo(info).getString("memberId");
//2.获取胸部id
String bodyPartId = XMJSONPath.readPath(trainingTools.getBodyPartList(),"$.result[0].id");
//3.获取b端训练计划列表数据条数
int num = Integer.parseInt(XMJSONPath.readPath(trainingTools.trainingPlanRecordPage(memberId,""),"$.result.total"));
//4.智能生成中
String generateId = trainingTools.generateTrainingPlan(bodyPartId,memberId);
JSONObject body = new JSONObject();
body.put("id",generateId);
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("studioId",xmAppApi.getLoginInfo().getStudioId());
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
//调用请求
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
Thread.sleep(2000);
Assert.assertNotNull(XMJSONPath.readPath(xmAppApi.getBodyInJSON(),"$.result"));
//5.保存并发送训练计划
String exerciseId = XMJSONPath.readPath(trainingTools.getListByName("胸"),"$.result[0].id");
String exerciseName = XMJSONPath.readPath(trainingTools.getListByName("胸"),"$.result[0].name");
String recordId = trainingTools.trainingPlanRecordCreate(memberId,exerciseId,exerciseName);
Assert.assertTrue(Integer.parseInt(XMJSONPath.readPath(trainingTools.trainingPlanRecordPage(memberId,""),"$.result.total"))==num+1);
//查看c端动作详情信息与b端提交的数据匹配
Assert.assertEquals(XMJSONPath.readPath(trainingTools.findTrainExerciseDetailById(exerciseId,recordId,info),"$.result.name"),exerciseName);
Assert.assertEquals(XMJSONPath.readPath(trainingTools.findTrainExerciseDetailById(exerciseId,recordId,info),"$.result.trainingBodyPartList[0].id"),bodyPartId);
//6.清理数据
//删除训练计划
trainingTools.trainingPlanRecordDelete(recordId);
//检验训练计划列表数据跟初始保持一致
Assert.assertTrue(Integer.parseInt(XMJSONPath.readPath(trainingTools.trainingPlanRecordPage(memberId,""),"$.result.total"))==num);
}
}
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