Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xm-sportstest
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiamai-test
xm-sportstest
Commits
6ccafa64
Commit
6ccafa64
authored
Dec 19, 2024
by
xyy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增ai能力case
parent
2325e33c
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
0 deletions
+138
-0
src/main/java/com/xiaomai/cases/polar/training/TestAiChat.java
+61
-0
src/main/java/com/xiaomai/cases/polar/training/TestGetTrainingPlanContent.java
+77
-0
src/main/java/com/xiaomai/cases/polar/training/TrainingTools.java
+0
-0
No files found.
src/main/java/com/xiaomai/cases/polar/training/TestAiChat.java
0 → 100644
View file @
6ccafa64
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
);
}
}
src/main/java/com/xiaomai/cases/polar/training/TestGetTrainingPlanContent.java
0 → 100644
View file @
6ccafa64
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
);
}
}
src/main/java/com/xiaomai/cases/polar/training/TrainingTools.java
View file @
6ccafa64
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment