Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oto
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
龚小红
oto
Commits
21e11411
Commit
21e11411
authored
Nov 26, 2021
by
郭姣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
企业后台登录、架构名单录入、管理后台驾驶舱接口编写
parent
424ab629
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
570 additions
and
413 deletions
+570
-413
Enterprise.java
...t/java/com/kjj/cases/assistant/enterprise/Enterprise.java
+406
-0
ManageCorp.java
src/test/java/com/kjj/cases/live/Corp/ManageCorp.java
+0
-390
BasicConfig.java
src/test/java/com/kjj/config/BasicConfig.java
+24
-17
BaseUtils.java
src/test/java/com/kjj/utils/BaseUtils.java
+139
-0
wechatTestNG.xml
src/test/wechatTestNG.xml
+1
-6
No files found.
src/test/java/com/kjj/cases/assistant/enterprise/Enterprise.java
0 → 100644
View file @
21e11411
package
com
.
kjj
.
cases
.
assistant
.
enterprise
;
import
com.kjj.cases.admin.Authorization
;
import
com.kjj.utils.ThreadSleepUtils
;
import
io.restassured.response.Response
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.kjj.config.BasicConfig
;
import
static
com
.
kjj
.
utils
.
BaseUtils
.*;
public
class
Enterprise
implements
Authorization
{
@BeforeClass
public
void
setUp
()
{
ssoLogin
();
superUserLogin
();
}
public
long
companyPageID
;
//管理后台公司管理员数据驾驶页面ID
public
long
officePageID
;
//管理后台营业部管理员数据驾驶页面ID
public
long
data
;
//获取企业后台上传架构名单任务ID
public
Object
departmentId1
;
//获取企业后台架构名单营业部ID
public
Object
departmentId2
;
public
Object
employeeId1
;
public
Object
employeeId2
;
@Test
(
description
=
"企业后台_获取当前用户公司列表"
,
priority
=
1
)
public
void
企业后台
_
获取当前用户公司列表
(){
Response
comListRes
=
network
.
getResponse
(
BasicConfig
.
CORP_listSimple
);
Object
dataRes
=
comListRes
.
jsonPath
().
getJsonObject
(
"data.size()"
);
Object
data
=
comListRes
.
jsonPath
().
getJsonObject
(
"data"
);
Assert
.
assertEquals
(
dataRes
,
2
,
network
.
message
(
BasicConfig
.
CORP_listSimple
,
"获取公司列表个数错误"
,
comListRes
.
body
().
asString
()));
System
.
out
.
println
(
data
);
}
@Test
(
description
=
"管理后台_新增公司管理员驾驶舱页面"
,
priority
=
2
)
public
void
管理后台
_
新增公司管理员驾驶舱页面
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"companyId"
,
26
);
//自动化专用公司
params
.
put
(
"pageName"
,
"公司管理员数据总览"
);
params
.
put
(
"pageUrl"
,
"https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=ddb124ec-69f3-40a6-880c-4fa9114dbce7&accessToken=20434f6a58d62fb2c1caaac570dbf2e4"
);
params
.
put
(
"staffType"
,
2
);
Response
response
=
network
.
postResponse
(
params
,
BasicConfig
.
MANAGER_cockpitSaveOrUpdate
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitSaveOrUpdate
,
"新增公司管理员数据驾驶舱页面失败"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"管理后台_新增营业部管理员驾驶舱页面"
,
priority
=
3
)
public
void
管理后台
_
新增营业部管理员驾驶舱页面
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"companyId"
,
26
);
//自动化专用公司
params
.
put
(
"pageName"
,
"营业部管理员数据总览"
);
params
.
put
(
"pageUrl"
,
"https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=ddb124ec-69f3-40a6-880c-4fa9114dbce7&accessToken=20434f6a58d62fb2c1caaac570dbf2e4"
);
params
.
put
(
"staffType"
,
3
);
Response
response
=
network
.
postResponse
(
params
,
BasicConfig
.
MANAGER_cockpitSaveOrUpdate
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitSaveOrUpdate
,
"新增营业部管理员数据驾驶舱页面失败"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"管理后台_查看数据驾驶舱页面"
,
priority
=
4
)
public
void
管理后台
_
查看数据驾驶舱页面
(){
//查看公司管理员数据驾驶舱页面
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"companyId"
,
26
);
//自动化专用公司
params
.
put
(
"staffType"
,
2
);
Response
response
=
network
.
getResponse
(
params
,
BasicConfig
.
MANAGER_cockpitList
);
int
hideState
=
response
.
jsonPath
().
getInt
(
"data.get(0).hideState"
);
companyPageID
=
response
.
jsonPath
().
getLong
(
"data.get(0).id"
);
Assert
.
assertEquals
(
hideState
,
0
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitList
,
"页面展示状态错误"
,
response
.
body
().
asString
()));
//查看营业部管理员数据驾驶舱页面
params
.
clear
();
params
.
put
(
"companyId"
,
26
);
//自动化专用公司
params
.
put
(
"staffType"
,
3
);
Response
officeRes
=
network
.
getResponse
(
params
,
BasicConfig
.
MANAGER_cockpitList
);
int
hideState2
=
response
.
jsonPath
().
getInt
(
"data.get(0).hideState"
);
officePageID
=
officeRes
.
jsonPath
().
getLong
(
"data.get(0).id"
);
System
.
out
.
println
(
officePageID
);
Assert
.
assertEquals
(
hideState2
,
0
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitList
,
"页面展示状态错误"
,
officeRes
.
body
().
asString
()));
}
@Test
(
description
=
"管理后台_编辑公司管理员数据驾驶舱"
,
priority
=
5
)
public
void
管理后台
_
编辑公司管理员数据驾驶舱
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"companyId"
,
26
);
//自动化专用公司
params
.
put
(
"id"
,
companyPageID
);
params
.
put
(
"pageName"
,
"数据总览_编辑"
);
params
.
put
(
"pageUrl"
,
"https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=ddb124ec-69f3-40a6-880c-4fa9114dbce7&accessToken=20434f6a58d62fb2c1caaac570dbf2e4"
);
params
.
put
(
"staffType"
,
2
);
Response
response
=
network
.
postResponse
(
params
,
BasicConfig
.
MANAGER_cockpitSaveOrUpdate
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitSaveOrUpdate
,
"编辑数据驾驶舱页面失败"
,
response
.
body
().
asString
()));
//查看编辑后的内容
params
.
clear
();
params
.
put
(
"companyId"
,
26
);
//自动化专用公司
params
.
put
(
"staffType"
,
2
);
Response
listRes
=
network
.
getResponse
(
params
,
BasicConfig
.
MANAGER_cockpitList
);
String
pageName
=
listRes
.
jsonPath
().
getString
(
"data.get(0).pageName"
);
Assert
.
assertEquals
(
pageName
,
"数据总览_编辑"
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitList
,
"编辑驾驶舱失败"
,
listRes
.
body
().
asString
()));
}
@Test
(
description
=
"企业后台_公司管理员数据驾驶舱"
,
priority
=
6
)
public
void
企业后台
_
公司管理员数据驾驶舱
(){
Response
response
=
network
.
getResponse
(
BasicConfig
.
CORP_pageList
);
Object
data
=
response
.
jsonPath
().
getJsonObject
(
"data"
);
Assert
.
assertNotNull
(
data
,
network
.
message
(
BasicConfig
.
CORP_pageList
,
"数据驾驶舱为空"
,
response
.
body
().
asString
()));
}
//数据驾驶舱页面隐藏
@Test
(
description
=
"管理后台_隐藏公司管理员数据驾驶舱页面"
,
priority
=
7
)
public
void
管理后台
_
隐藏公司管理员数据驾驶舱页面
()
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"hideState"
,
1
);
params
.
put
(
"id"
,
companyPageID
);
Response
response
=
network
.
postResponse
(
params
,
BasicConfig
.
MANAGER_cockpitSwitchStatus
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitSwitchStatus
,
"隐藏页面失败"
,
response
.
body
().
asString
()));
params
.
clear
();
params
.
put
(
"companyId"
,
26
);
//自动化专用公司
params
.
put
(
"staffType"
,
2
);
Response
listRes
=
network
.
getResponse
(
params
,
BasicConfig
.
MANAGER_cockpitList
);
int
hideState
=
listRes
.
jsonPath
().
getInt
(
"data.get(0).hideState"
);
Assert
.
assertEquals
(
hideState
,
1
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitList
,
"页面未隐藏"
,
listRes
.
body
().
asString
()));
}
@Test
(
description
=
"管理后台_隐藏营业部管理员数据驾驶舱页面"
,
priority
=
8
)
public
void
管理后台
_
隐藏营业部管理员数据驾驶舱页面
()
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"hideState"
,
1
);
params
.
put
(
"id"
,
officePageID
);
Response
response
=
network
.
postResponse
(
params
,
BasicConfig
.
MANAGER_cockpitSwitchStatus
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitSwitchStatus
,
"隐藏页面失败"
,
response
.
body
().
asString
()));
params
.
clear
();
params
.
put
(
"companyId"
,
26
);
//自动化专用公司
params
.
put
(
"staffType"
,
3
);
Response
listRes
=
network
.
getResponse
(
params
,
BasicConfig
.
MANAGER_cockpitList
);
int
hideState
=
listRes
.
jsonPath
().
getInt
(
"data.get(0).hideState"
);
Assert
.
assertEquals
(
hideState
,
1
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitList
,
"页面未隐藏"
,
listRes
.
body
().
asString
()));
}
@Test
(
description
=
"企业后台_超管数据驾驶舱页面隐藏"
,
priority
=
9
)
public
void
企业后台
_
超管数据驾驶舱页面隐藏
(){
Response
response
=
network
.
getResponse
(
BasicConfig
.
CORP_pageList
);
Object
data
=
response
.
jsonPath
().
getJsonObject
(
"data.size()"
);
Assert
.
assertEquals
(
data
,
0
,
network
.
message
(
BasicConfig
.
CORP_pageList
,
"数据驾驶舱为空"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"企业后台_公司管理员数据驾驶舱页面隐藏"
,
priority
=
10
)
public
void
企业后台
_
公司管理员数据驾驶舱页面隐藏
(){
companyUserLogin
();
ThreadSleepUtils
.
sleep
(
3000
);
Response
response
=
network
.
getResponse
(
BasicConfig
.
CORP_pageList
);
Object
data
=
response
.
jsonPath
().
getJsonObject
(
"data.size()"
);
Assert
.
assertEquals
(
data
,
0
,
network
.
message
(
BasicConfig
.
CORP_pageList
,
"数据驾驶舱为空"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"企业后台_营业部管理员数据驾驶舱页面隐藏"
,
priority
=
11
)
public
void
企业后台
_
营业部管理员数据驾驶舱页面隐藏
(){
officeUserLogin
();
ThreadSleepUtils
.
sleep
(
3000
);
Response
response
=
network
.
getResponse
(
BasicConfig
.
CORP_pageList
);
Object
data
=
response
.
jsonPath
().
getJsonObject
(
"data.size()"
);
Assert
.
assertEquals
(
data
,
0
,
network
.
message
(
BasicConfig
.
CORP_pageList
,
"数据驾驶舱为空"
,
response
.
body
().
asString
()));
}
//数据驾驶舱页面取消隐藏
@Test
(
description
=
"管理后台_取消隐藏公司管理员数据驾驶舱页面"
,
priority
=
12
)
public
void
管理后台
_
取消隐藏公司管理员数据驾驶舱页面
()
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"hideState"
,
0
);
params
.
put
(
"id"
,
companyPageID
);
Response
response
=
network
.
postResponse
(
params
,
BasicConfig
.
MANAGER_cockpitSwitchStatus
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitSwitchStatus
,
"取消隐藏公司管理员页面失败"
,
response
.
body
().
asString
()));
params
.
clear
();
params
.
put
(
"companyId"
,
26
);
//自动化专用公司
params
.
put
(
"staffType"
,
2
);
Response
listRes
=
network
.
getResponse
(
params
,
BasicConfig
.
MANAGER_cockpitList
);
int
hideState
=
listRes
.
jsonPath
().
getInt
(
"data.get(0).hideState"
);
Assert
.
assertEquals
(
hideState
,
0
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitList
,
"公司管理员页面仍然隐藏"
,
listRes
.
body
().
asString
()));
}
@Test
(
description
=
"管理后台_取消隐藏营业部管理员数据驾驶舱页面"
,
priority
=
13
)
public
void
管理后台
_
取消隐藏营业部管理员数据驾驶舱页面
()
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"hideState"
,
0
);
params
.
put
(
"id"
,
officePageID
);
Response
response
=
network
.
postResponse
(
params
,
BasicConfig
.
MANAGER_cockpitSwitchStatus
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitSwitchStatus
,
"取消隐藏营业部驾驶舱页面失败"
,
response
.
body
().
asString
()));
params
.
clear
();
params
.
put
(
"companyId"
,
26
);
//自动化专用公司
params
.
put
(
"staffType"
,
3
);
Response
listRes
=
network
.
getResponse
(
params
,
BasicConfig
.
MANAGER_cockpitList
);
int
hideState
=
listRes
.
jsonPath
().
getInt
(
"data.get(0).hideState"
);
Assert
.
assertEquals
(
hideState
,
0
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitList
,
"营业部驾驶舱页面仍然隐藏"
,
listRes
.
body
().
asString
()));
}
@Test
(
description
=
"管理后台_删除公司管理员数据驾驶舱页面"
,
priority
=
14
)
public
void
管理后台
_
删除公司管理员数据驾驶舱页面
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"id"
,
companyPageID
);
Response
response
=
network
.
postResponse
(
params
,
BasicConfig
.
MANAGER_cockpitDelete
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitSwitchStatus
,
"删除页面失败"
,
response
.
body
().
asString
()));
params
.
clear
();
params
.
put
(
"companyId"
,
26
);
//自动化专用公司
params
.
put
(
"staffType"
,
2
);
Response
listRes
=
network
.
getResponse
(
params
,
BasicConfig
.
MANAGER_cockpitList
);
Object
listData
=
listRes
.
jsonPath
().
getJsonObject
(
"data.size"
);
Assert
.
assertEquals
(
listData
,
0
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitList
,
"删除页面失败"
,
listRes
.
body
().
asString
()));
}
@Test
(
description
=
"管理后台_删除管理员数据驾驶舱页面"
,
priority
=
15
)
public
void
管理后台
_
删除营业部管理员数据驾驶舱页面
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"id"
,
officePageID
);
Response
response
=
network
.
postResponse
(
params
,
BasicConfig
.
MANAGER_cockpitDelete
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitSwitchStatus
,
"删除营业部数据驾驶舱页面失败"
,
response
.
body
().
asString
()));
params
.
clear
();
params
.
put
(
"companyId"
,
26
);
//自动化专用公司
params
.
put
(
"staffType"
,
3
);
Response
listRes
=
network
.
getResponse
(
params
,
BasicConfig
.
MANAGER_cockpitList
);
Object
listData
=
listRes
.
jsonPath
().
getJsonObject
(
"data.size"
);
Assert
.
assertEquals
(
listData
,
0
,
network
.
message
(
params
,
BasicConfig
.
MANAGER_cockpitList
,
"删除营业部数据驾驶舱页面失败"
,
listRes
.
body
().
asString
()));
}
@Test
(
description
=
"企业后台_公司管理员数据驾驶舱为空"
,
priority
=
16
)
public
void
企业后台
_
公司管理员数据驾驶舱为空
(){
Response
response
=
network
.
getResponse
(
BasicConfig
.
CORP_pageList
);
Object
data
=
response
.
jsonPath
().
getJsonObject
(
"data.size()"
);
Assert
.
assertEquals
(
data
,
0
,
network
.
message
(
BasicConfig
.
CORP_pageList
,
"数据驾驶舱不为空"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"企业后台_营业部管理员数据驾驶舱为空"
,
priority
=
17
)
public
void
企业后台
_
营业部管理员数据驾驶舱为空
(){
officeUserLogin
();
ThreadSleepUtils
.
sleep
(
2000
);
Response
response
=
network
.
getResponse
(
BasicConfig
.
CORP_pageList
);
Object
data
=
response
.
jsonPath
().
getJsonObject
(
"data.size()"
);
Assert
.
assertEquals
(
data
,
0
,
network
.
message
(
BasicConfig
.
CORP_pageList
,
"数据驾驶舱不为空"
,
response
.
body
().
asString
()));
}
/**
批量上传架构名单
**/
@Test
(
description
=
"导入架构名单"
,
priority
=
18
)
public
void
导入架构名单
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
//导入的架构名单内容为工号KJJ002一条数据,营业部为余杭区营业部
params
.
put
(
"excelUrl"
,
"https://yun.dui88.com/kjy/corp/media/file/20211116/82d1352f96526be537e1635c42a37231.xlsx"
);
params
.
put
(
"fileName"
,
"自动化架构名单.xlsx"
);
Response
response
=
network
.
postResponse
(
params
,
BasicConfig
.
CORP_batchImport
);
data
=
response
.
jsonPath
().
getLong
(
"data"
);
boolean
success
=
response
.
jsonPath
().
getBoolean
(
"success"
);
Assert
.
assertNotNull
(
data
,
network
.
message
(
params
,
BasicConfig
.
CORP_batchImport
,
"上传架构名单失败"
,
response
.
body
().
asString
()));
Assert
.
assertTrue
(
success
,
network
.
message
(
params
,
BasicConfig
.
CORP_batchImport
,
"上传架构名单失败"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"获取导入结果"
,
priority
=
19
)
public
void
获取导入结果
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"taskId"
,
data
);
Response
response
=
network
.
getResponse
(
params
,
BasicConfig
.
CORP_importResult
);
String
errorMsg
=
response
.
jsonPath
().
getString
(
"errorMsg"
);
Assert
.
assertNull
(
errorMsg
,
network
.
message
(
params
,
BasicConfig
.
CORP_importResult
,
"导入结果记录错误"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"导入记录列表"
,
priority
=
20
)
public
void
导入记录列表
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"pageSize"
,
5
);
params
.
put
(
"pageIndex"
,
1
);
params
.
put
(
"taskType"
,
1
);
Response
response
=
network
.
getResponse
(
params
,
BasicConfig
.
CORP_recordList
);
Object
list
=
response
.
jsonPath
().
getJsonObject
(
"data.list"
);
Assert
.
assertNotNull
(
list
,
network
.
message
(
params
,
BasicConfig
.
CORP_recordList
,
"查看上传记录失败"
,
response
.
body
().
asString
()));
}
/**
组织架构—架构明细
**/
@Test
(
description
=
"获取当前公司营业部列表"
,
priority
=
21
)
public
void
获取当前公司营业部列表
(){
Response
response
=
network
.
getResponse
(
BasicConfig
.
CORP_simpleList
);
//通过批量上传的营业部,余杭区营业部
departmentId1
=
response
.
jsonPath
().
getJsonObject
(
"data.get(0).id"
);
//企业后台固定的营业部,西湖区营业部
departmentId2
=
response
.
jsonPath
().
getJsonObject
(
"data.get(1).id"
);
int
dataSize
=
response
.
jsonPath
().
getInt
(
"data.size()"
);
Assert
.
assertEquals
(
dataSize
,
2
,
network
.
message
(
BasicConfig
.
CORP_simpleList
,
"当前公司营业部列表获取错误"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"获取公司员工统计信息"
,
priority
=
22
)
public
void
获取公司员工统计信息
(){
Response
response
=
network
.
getResponse
(
BasicConfig
.
CORP_employeeStat
);
//账号总量
int
accountCount
=
response
.
jsonPath
().
getInt
(
"data.accountCount"
);
//已激活数量
int
activateCount
=
response
.
jsonPath
().
getInt
(
"data.activateCount"
);
//已录入数量
int
importCount
=
response
.
jsonPath
().
getInt
(
"data.importCount"
);
Assert
.
assertEquals
(
accountCount
,
3
,
network
.
message
(
BasicConfig
.
CORP_employeeStat
,
"账号总量记录错误"
,
response
.
body
().
asString
()));
Assert
.
assertEquals
(
activateCount
,
0
,
network
.
message
(
BasicConfig
.
CORP_employeeStat
,
"已激活数量记录错误"
,
response
.
body
().
asString
()));
Assert
.
assertEquals
(
importCount
,
2
,
network
.
message
(
BasicConfig
.
CORP_employeeStat
,
"已录入数量记录错误"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"分页查询员工列表"
,
priority
=
23
)
public
void
分页查询员工列表
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"pageSize"
,
8
);
params
.
put
(
"pageIndex"
,
1
);
params
.
put
(
"deptId"
,
departmentId1
);
Response
response
=
network
.
getResponse
(
params
,
BasicConfig
.
CORP_employeeList
);
int
dataSize
=
response
.
jsonPath
().
getInt
(
"data.list.size()"
);
Assert
.
assertEquals
(
dataSize
,
1
,
network
.
message
(
params
,
BasicConfig
.
CORP_employeeList
,
"员工数据量错误"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"编辑营业部"
,
priority
=
24
)
public
void
编辑营业部
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"deptName"
,
"余杭区营业部-编辑"
);
params
.
put
(
"id"
,
departmentId1
);
Response
response
=
network
.
postResponse
(
params
,
BasicConfig
.
CORP_deptEdit
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
CORP_deptEdit
,
"编辑营业部名称失败"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"新增成员"
,
priority
=
26
)
public
void
新增成员
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"deptId"
,
departmentId1
);
params
.
put
(
"employeeName"
,
"李四"
);
params
.
put
(
"jobNumber"
,
"KJJ001"
);
Response
response
=
network
.
postResponse
(
params
,
BasicConfig
.
CORP_employeeSaveOrUpdate
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
CORP_employeeSaveOrUpdate
,
"新增成员失败"
,
response
.
body
().
asString
()));
//验证已录入数量增加1
Response
statRes
=
network
.
getResponse
(
BasicConfig
.
CORP_employeeStat
);
int
importCount
=
statRes
.
jsonPath
().
getInt
(
"data.importCount"
);
Assert
.
assertEquals
(
importCount
,
3
,
network
.
message
(
BasicConfig
.
CORP_employeeStat
,
"已录入数量记录错误"
,
statRes
.
body
().
asString
()));
//获取新增成员的id信息
params
.
clear
();
params
.
put
(
"pageSize"
,
8
);
params
.
put
(
"pageIndex"
,
1
);
params
.
put
(
"deptId"
,
departmentId1
);
Response
infoRes
=
network
.
getResponse
(
params
,
BasicConfig
.
CORP_employeeList
);
//新增成员的id
employeeId1
=
infoRes
.
jsonPath
().
getJsonObject
(
"data.list[0].id"
);
//批量上传的成员的id
employeeId2
=
infoRes
.
jsonPath
().
getJsonObject
(
"data.list[1].id"
);
int
employeeSize
=
infoRes
.
jsonPath
().
getInt
(
"data.list.size()"
);
Assert
.
assertEquals
(
employeeSize
,
2
,
network
.
message
(
params
,
BasicConfig
.
CORP_employeeList
,
"成员新增失败"
,
infoRes
.
body
().
asString
()));
}
@Test
(
description
=
"编辑成员"
,
priority
=
27
)
public
void
编辑成员
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"deptId"
,
departmentId2
);
params
.
put
(
"employeeName"
,
"李四-编辑"
);
params
.
put
(
"employeePhone"
,
"17899999999"
);
params
.
put
(
"id"
,
employeeId2
);
params
.
put
(
"jobNumber"
,
"KJJ001"
);
params
.
put
(
"jobPost"
,
"测试业务员"
);
Response
response
=
network
.
postResponse
(
params
,
BasicConfig
.
CORP_employeeSaveOrUpdate
);
ThreadSleepUtils
.
sleep
(
1000
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
CORP_employeeSaveOrUpdate
,
"编辑成员失败"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"删除成员"
,
priority
=
28
)
public
void
删除成员
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"id"
,
employeeId1
);
Response
response
=
network
.
postResponse
(
params
,
BasicConfig
.
CORP_employeeDel
);
boolean
empData1
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
empData1
,
network
.
message
(
params
,
BasicConfig
.
CORP_employeeDel
,
"删除成员李四失败"
,
response
.
body
().
asString
()));
params
.
clear
();
params
.
put
(
"id"
,
employeeId2
);
Response
infoRes
=
network
.
postResponse
(
params
,
BasicConfig
.
CORP_employeeDel
);
boolean
empData2
=
infoRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
empData2
,
network
.
message
(
params
,
BasicConfig
.
CORP_employeeDel
,
"删除成员王五失败"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"删除营业部"
,
priority
=
29
)
public
void
删除营业部
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"id"
,
departmentId1
);
Response
response
=
network
.
postResponse
(
params
,
BasicConfig
.
CORP_deptDel
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
CORP_deptDel
,
"删除营业部失败"
,
response
.
body
().
asString
()));
}
}
src/test/java/com/kjj/cases/live/Corp/ManageCorp.java
deleted
100644 → 0
View file @
424ab629
package
com
.
kjj
.
cases
.
live
.
Corp
;
import
com.kjj.bean.corp.Auth
;
import
com.kjj.bean.corp.Corp
;
import
com.kjj.bean.corp.Page
;
import
com.kjj.bean.corp.Staff
;
import
com.kjj.cases.admin.Authorization
;
import
com.kjj.config.BasicConfig
;
import
com.kjj.utils.BaseUtils
;
import
com.kjj.utils.JsonUtil
;
import
com.kjj.utils.ThreadSleepUtils
;
import
io.restassured.response.Response
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
java.util.*
;
public
class
ManageCorp
implements
Authorization
{
private
static
String
companyNameOfTimeStamp
;
public
static
long
companyId
;
// 企业列表首页第一个企业ID
private
static
final
String
authName
=
"权限等级1"
;
public
static
long
authId
;
private
static
List
<
Auth
>
authList
=
new
ArrayList
<>();
private
static
List
<
Page
>
pageList
=
new
ArrayList
<>();
private
static
List
<
Staff
>
staffList
=
new
ArrayList
<>();
private
static
final
String
pageUrl
=
"https://kjj-mng.duibatest.com.cn/#/enterprise/list"
;
private
static
long
pageId
;
private
static
final
String
pageName
=
"自动化页面1"
;
private
static
final
String
staffName
=
"自动化员工"
;
private
static
final
String
staffPhone
=
"13700000000"
;
public
static
long
staffId
;
@BeforeClass
public
void
setUp
(){
BaseUtils
.
ssoLogin
();
}
// // 企业管理
// @Test(description = "新建企业", priority = 1)
// public void 新建企业() {
// Map<String, Object> saveCorpPar = new HashMap<>();
// saveCorpPar.put("companyName", initCompanyName);
// Response saveCorpRes = network.postResponse(saveCorpPar, BasicConfig.MANAGER_corp_saveCorp);
// try {
// boolean data = saveCorpRes.jsonPath().getBoolean("data");
// Assert.assertTrue(data, network.message(saveCorpPar, BasicConfig.MANAGER_corp_saveCorp, "新建企业失败", saveCorpRes.body().asString()));
// }catch (NullPointerException e){
// e.printStackTrace();
// Assert.fail(network.message(saveCorpPar, BasicConfig.MANAGER_corp_saveCorp,"获取数据失败", saveCorpRes.body().asString()));
// }
// }
@Test
(
description
=
"查询企业列表"
,
priority
=
2
)
public
void
查询企业列表
()
{
Response
selectCorpListRes
=
network
.
getResponse
(
BasicConfig
.
MANAGER_corp_CorpLists
);
try
{
List
<
Corp
>
corpLists
=
JsonUtil
.
parseResponseToPageBean
(
selectCorpListRes
,
Corp
.
class
);
Assert
.
assertNotNull
(
corpLists
.
size
(),
network
.
message
(
BasicConfig
.
MANAGER_corp_CorpLists
,
"获取企业列表为空"
,
selectCorpListRes
.
body
().
asString
()));
companyId
=
corpLists
.
get
(
0
).
getId
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
BasicConfig
.
MANAGER_corp_CorpLists
,
"获取数据失败"
,
selectCorpListRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"编辑企业信息"
,
priority
=
3
)
public
void
编辑企业信息
()
{
/**
* 以时间戳的不同来使公司名称不重复
*/
// 给companyNameOfTimeStamp变量赋值
getCurrentTimeStamp
();
String
companyName
=
"自动化企业"
+
companyNameOfTimeStamp
;
Map
<
String
,
Object
>
editCorpPar
=
new
HashMap
<>();
editCorpPar
.
put
(
"companyName"
,
companyName
);
editCorpPar
.
put
(
"id"
,
companyId
);
Response
editCorpRes
=
network
.
postResponse
(
editCorpPar
,
BasicConfig
.
MANAGER_corp_saveCorp
);
try
{
boolean
data
=
editCorpRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
editCorpPar
,
BasicConfig
.
MANAGER_corp_saveCorp
,
"编辑企业信息失败"
,
editCorpRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
editCorpPar
,
BasicConfig
.
MANAGER_corp_saveCorp
,
"获取数据失败"
,
editCorpRes
.
body
().
asString
()));
}
System
.
out
.
println
(
companyName
);
}
@Test
(
description
=
"按照名称搜索企业"
,
priority
=
4
)
public
void
按照名称搜索企业
()
{
// sleep 2秒
// 等待企业信息的变更生效
ThreadSleepUtils
.
sleep
(
2000
);
Map
<
String
,
Object
>
searchCorpPar
=
new
HashMap
<>();
searchCorpPar
.
put
(
"companyName"
,
companyNameOfTimeStamp
);
Response
searchCorpRes
=
network
.
getResponse
(
searchCorpPar
,
BasicConfig
.
MANAGER_corp_searchCorp
);
try
{
List
<
Map
<
String
,
Object
>>
searchResults
=
searchCorpRes
.
jsonPath
().
getList
(
"data"
);
if
(
searchResults
.
size
()
!=
1
){
Assert
.
fail
(
network
.
message
(
searchCorpPar
,
BasicConfig
.
MANAGER_corp_searchCorp
,
"搜索结果数量错误"
,
searchCorpRes
.
body
().
asString
()));
}
Map
<
String
,
Object
>
searchResult
=
searchResults
.
get
(
0
);
System
.
out
.
println
(
searchResult
);
Assert
.
assertEquals
(
searchResult
.
get
(
"id"
),
(
int
)
companyId
,
network
.
message
(
searchCorpPar
,
BasicConfig
.
MANAGER_corp_searchCorp
,
"搜索结果错误"
,
searchCorpRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
searchCorpPar
,
BasicConfig
.
MANAGER_corp_searchCorp
,
"获取数据失败"
,
searchCorpRes
.
body
().
asString
()));
}
}
// 权限管理
@Test
(
description
=
"新增权限等级"
,
priority
=
6
)
public
void
新增权限等级
(){
Map
<
String
,
Object
>
saveAuthPar
=
new
HashMap
<>();
saveAuthPar
.
put
(
"companyId"
,
companyId
);
saveAuthPar
.
put
(
"authName"
,
"权限等级"
);
Response
saveAuthRes
=
network
.
postResponse
(
saveAuthPar
,
BasicConfig
.
MANAGER_corp_saveAuth
);
try
{
boolean
data
=
saveAuthRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
saveAuthPar
,
BasicConfig
.
MANAGER_corp_saveAuth
,
"新增权限等级失败"
,
saveAuthRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
saveAuthPar
,
BasicConfig
.
MANAGER_corp_saveAuth
,
"获取数据失败"
,
saveAuthRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"查询权限列表"
,
priority
=
7
)
public
void
查询权限列表
()
{
Map
<
String
,
Object
>
authListsPar
=
new
HashMap
<>();
authListsPar
.
put
(
"companyId"
,
companyId
);
Response
authListsRes
=
network
.
getResponse
(
authListsPar
,
BasicConfig
.
MANAGER_corp_authLists
);
try
{
authList
=
JsonUtil
.
parseResponseToListBean
(
authListsRes
,
Auth
.
class
);
Auth
newAuth
=
authList
.
get
(
authList
.
size
()-
1
);
Assert
.
assertEquals
(
newAuth
.
getAuthName
(),
"权限等级"
,
network
.
message
(
authListsPar
,
BasicConfig
.
MANAGER_corp_authLists
,
"列表最新权限等级名称与实际添加不符"
,
authListsRes
.
body
().
asString
()));
authId
=
newAuth
.
getId
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
authListsPar
,
BasicConfig
.
MANAGER_corp_authLists
,
"获取数据失败"
,
authListsRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"编辑权限等级信息"
,
priority
=
9
)
public
void
编辑权限等级信息
()
{
Map
<
String
,
Object
>
saveAuthPar
=
new
HashMap
<>();
saveAuthPar
.
put
(
"companyId"
,
companyId
);
saveAuthPar
.
put
(
"authName"
,
authName
);
saveAuthPar
.
put
(
"id"
,
authId
);
Response
saveAuthRes
=
network
.
postResponse
(
saveAuthPar
,
BasicConfig
.
MANAGER_corp_saveAuth
);
try
{
boolean
data
=
saveAuthRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
saveAuthPar
,
BasicConfig
.
MANAGER_corp_saveAuth
,
"编辑权限等级信息失败"
,
saveAuthRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
saveAuthPar
,
BasicConfig
.
MANAGER_corp_saveAuth
,
"获取数据失败"
,
saveAuthRes
.
body
().
asString
()));
}
}
// 页面管理
@Test
(
description
=
"新增页面"
,
priority
=
10
)
public
void
新增页面
()
{
Map
<
String
,
Object
>
addPagePar
=
new
HashMap
<>();
addPagePar
.
put
(
"companyId"
,
companyId
);
addPagePar
.
put
(
"pageName"
,
"自动化页面"
);
addPagePar
.
put
(
"pageUrl"
,
pageUrl
);
addPagePar
.
put
(
"authId"
,
authId
);
Response
addPageRes
=
network
.
postResponse
(
addPagePar
,
BasicConfig
.
MANAGER_corp_savePage
);
try
{
boolean
data
=
addPageRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
addPagePar
,
BasicConfig
.
MANAGER_corp_savePage
,
"新增页面失败"
,
addPageRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
addPagePar
,
BasicConfig
.
MANAGER_corp_savePage
,
"获取数据失败"
,
addPageRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"获取页面列表"
,
priority
=
11
)
public
void
获取页面列表
()
{
Map
<
String
,
Object
>
pageListsPar
=
new
HashMap
<>();
pageListsPar
.
put
(
"companyId"
,
companyId
);
pageListsPar
.
put
(
"authId"
,
authId
);
Response
pageListsRes
=
network
.
getResponse
(
pageListsPar
,
BasicConfig
.
MANAGER_corp_pageLists
);
try
{
pageList
=
JsonUtil
.
parseResponseToListBean
(
pageListsRes
,
Page
.
class
);
Assert
.
assertEquals
(
pageList
.
get
(
0
).
getPageName
(),
"自动化页面"
,
network
.
message
(
pageListsPar
,
BasicConfig
.
MANAGER_corp_pageLists
,
"列表最新数据页面名称与实际添加不符"
,
pageListsRes
.
body
().
asString
()));
pageId
=
pageList
.
get
(
0
).
getId
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
pageListsPar
,
BasicConfig
.
MANAGER_corp_pageLists
,
"获取数据失败"
,
pageListsRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"编辑页面信息"
,
priority
=
12
)
public
void
编辑页面信息
()
{
Map
<
String
,
Object
>
addPagePar
=
new
HashMap
<>();
addPagePar
.
put
(
"companyId"
,
companyId
);
addPagePar
.
put
(
"pageName"
,
pageName
);
addPagePar
.
put
(
"pageUrl"
,
pageUrl
);
addPagePar
.
put
(
"authId"
,
authId
);
addPagePar
.
put
(
"id"
,
pageId
);
Response
addPageRes
=
network
.
postResponse
(
addPagePar
,
BasicConfig
.
MANAGER_corp_savePage
);
try
{
boolean
data
=
addPageRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
addPagePar
,
BasicConfig
.
MANAGER_corp_savePage
,
"编辑页面信息失败"
,
addPageRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
addPagePar
,
BasicConfig
.
MANAGER_corp_savePage
,
"获取数据失败"
,
addPageRes
.
body
().
asString
()));
}
}
// 人员管理
@Test
(
description
=
"新增人员"
,
priority
=
13
)
public
void
新增人员
()
{
Map
<
String
,
Object
>
addStaffPar
=
new
HashMap
<>();
addStaffPar
.
put
(
"staffName"
,
"员工1"
);
addStaffPar
.
put
(
"staffPhone"
,
staffPhone
);
addStaffPar
.
put
(
"authId"
,
authId
);
addStaffPar
.
put
(
"companyId"
,
companyId
);
Response
addStaffRes
=
network
.
postResponse
(
addStaffPar
,
BasicConfig
.
MANAGER_corp_saveStaff
);
try
{
boolean
data
=
addStaffRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
addStaffPar
,
BasicConfig
.
MANAGER_corp_saveStaff
,
"新增员工失败"
,
addStaffRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
addStaffPar
,
BasicConfig
.
MANAGER_corp_saveStaff
,
"获取数据失败"
,
addStaffRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"查询员工列表"
,
priority
=
14
)
public
void
查询员工列表
()
{
Map
<
String
,
Object
>
staffListPar
=
new
HashMap
<>();
staffListPar
.
put
(
"companyId"
,
companyId
);
Response
staffListRes
=
network
.
getResponse
(
staffListPar
,
BasicConfig
.
MANAGER_corp_staffList
);
try
{
staffList
=
JsonUtil
.
parseResponseToPageBean
(
staffListRes
,
Staff
.
class
);
Staff
newStaff
=
staffList
.
get
(
0
);
Assert
.
assertEquals
(
newStaff
.
getStaffName
(),
"员工1"
,
network
.
message
(
staffListPar
,
BasicConfig
.
MANAGER_corp_staffList
,
"最新员工姓名与实际添加不符"
,
staffListRes
.
body
().
asString
()));
staffId
=
newStaff
.
getId
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
staffListPar
,
BasicConfig
.
MANAGER_corp_staffList
,
"获取数据失败"
,
staffListRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"编辑员工信息"
,
priority
=
15
)
public
void
编辑员工信息
()
{
Map
<
String
,
Object
>
addStaffPar
=
new
HashMap
<>();
addStaffPar
.
put
(
"staffName"
,
staffName
);
addStaffPar
.
put
(
"staffPhone"
,
staffPhone
);
addStaffPar
.
put
(
"authId"
,
authId
);
addStaffPar
.
put
(
"id"
,
staffId
);
addStaffPar
.
put
(
"companyId"
,
companyId
);
Response
addStaffRes
=
network
.
postResponse
(
addStaffPar
,
BasicConfig
.
MANAGER_corp_saveStaff
);
try
{
boolean
data
=
addStaffRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
addStaffPar
,
BasicConfig
.
MANAGER_corp_saveStaff
,
"编辑员工信息失败"
,
addStaffRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
addStaffPar
,
BasicConfig
.
MANAGER_corp_saveStaff
,
"获取数据失败"
,
addStaffRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"判断员工手机号是否已存在"
,
priority
=
16
)
public
void
判断员工手机号是否已存在
()
{
Map
<
String
,
Object
>
phoneExistPar
=
new
HashMap
<>();
phoneExistPar
.
put
(
"companyId"
,
companyId
);
phoneExistPar
.
put
(
"phone"
,
staffPhone
);
Response
phoneExistRes
=
network
.
getResponse
(
phoneExistPar
,
BasicConfig
.
MANAGER_corp_phoneExist
);
try
{
boolean
data
=
phoneExistRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
phoneExistPar
,
BasicConfig
.
MANAGER_corp_phoneExist
,
"未校验到号码已重复"
,
phoneExistRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
phoneExistPar
,
BasicConfig
.
MANAGER_corp_phoneExist
,
"获取数据失败"
,
phoneExistRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"同一公司员工手机号不可重复"
,
priority
=
17
)
public
void
同一公司员工手机号不可重复
()
{
Map
<
String
,
Object
>
addStaffPar
=
new
HashMap
<>();
addStaffPar
.
put
(
"staffName"
,
"员工2"
);
addStaffPar
.
put
(
"staffPhone"
,
staffPhone
);
addStaffPar
.
put
(
"authId"
,
authId
);
addStaffPar
.
put
(
"companyId"
,
companyId
);
Response
addStaffRes
=
network
.
postResponse
(
addStaffPar
,
BasicConfig
.
MANAGER_corp_saveStaff
);
try
{
boolean
success
=
addStaffRes
.
jsonPath
().
getBoolean
(
"success"
);
Assert
.
assertFalse
(
success
,
network
.
message
(
addStaffPar
,
BasicConfig
.
MANAGER_corp_saveStaff
,
"同一手机号重复注册员工成功"
,
addStaffRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
addStaffPar
,
BasicConfig
.
MANAGER_corp_saveStaff
,
"获取数据失败"
,
addStaffRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"隐藏页面"
,
priority
=
18
)
public
void
隐藏页面
()
{
Map
<
String
,
Object
>
pageStatePar
=
new
HashMap
<>();
pageStatePar
.
put
(
"id"
,
pageId
);
pageStatePar
.
put
(
"hideState"
,
1
);
Response
pageStateRes
=
network
.
postResponse
(
pageStatePar
,
BasicConfig
.
MANAGER_corp_changePageState
);
try
{
boolean
data
=
pageStateRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
pageStatePar
,
BasicConfig
.
MANAGER_corp_changePageState
,
"隐藏页面失败"
,
pageStateRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
pageStatePar
,
BasicConfig
.
MANAGER_corp_changePageState
,
"获取数据失败"
,
pageStateRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"删除所有页面"
,
priority
=
19
)
public
void
删除所有页面
()
{
Map
<
String
,
Object
>
delPagePar
=
new
HashMap
<>();
Response
delPageRes
;
for
(
Page
page
:
pageList
){
delPagePar
.
clear
();
delPagePar
.
put
(
"id"
,
page
.
getId
());
delPageRes
=
network
.
postResponse
(
delPagePar
,
BasicConfig
.
MANAGER_corp_delPageById
);
try
{
boolean
data
=
delPageRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
delPagePar
,
BasicConfig
.
MANAGER_corp_delPageById
,
"删除页面失败"
,
delPageRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
delPagePar
,
BasicConfig
.
MANAGER_corp_delPageById
,
"获取数据失败"
,
delPageRes
.
body
().
asString
()));
}
}
}
@Test
(
description
=
"切换员工状态"
,
priority
=
20
)
public
void
切换员工状态
()
{
Map
<
String
,
Object
>
changeStaffStatePar
=
new
HashMap
<>();
changeStaffStatePar
.
put
(
"id"
,
staffId
);
changeStaffStatePar
.
put
(
"staffEnable"
,
2
);
Response
changeStaffStateRes
=
network
.
postResponse
(
changeStaffStatePar
,
BasicConfig
.
MANAGER_corp_changeStaffState
);
try
{
boolean
data
=
changeStaffStateRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
changeStaffStatePar
,
BasicConfig
.
MANAGER_corp_changeStaffState
,
"禁用员工失败"
,
changeStaffStateRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
changeStaffStatePar
,
BasicConfig
.
MANAGER_corp_changeStaffState
,
"获取数据失败"
,
changeStaffStateRes
.
body
().
asString
()));
}
}
// 删除员工列表第一个员工
@Test
(
description
=
"删除所有员工"
,
priority
=
21
)
public
void
删除所有员工
()
{
Map
<
String
,
Object
>
delStaffPar
=
new
HashMap
<>();
Response
delStaffRes
;
for
(
Staff
staff
:
staffList
){
delStaffPar
.
clear
();
delStaffPar
.
put
(
"id"
,
staff
.
getId
());
delStaffRes
=
network
.
postResponse
(
delStaffPar
,
BasicConfig
.
MANAGER_corp_delStaff
);
try
{
boolean
data
=
delStaffRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
delStaffPar
,
BasicConfig
.
MANAGER_corp_delStaff
,
"删除员工失败"
,
delStaffRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
delStaffPar
,
BasicConfig
.
MANAGER_corp_delStaff
,
"获取数据失败"
,
delStaffRes
.
body
().
asString
()));
}
}
}
@Test
(
description
=
"删除权限等级"
,
priority
=
22
)
public
void
删除权限等级
()
{
Map
<
String
,
Object
>
delAuthPar
=
new
HashMap
<>();
Response
delAuthRes
;
for
(
Auth
auth
:
authList
){
delAuthPar
.
clear
();
delAuthPar
.
put
(
"id"
,
auth
.
getId
());
delAuthRes
=
network
.
postResponse
(
delAuthPar
,
BasicConfig
.
MANAGER_corp_deleteAuthById
);
try
{
boolean
data
=
delAuthRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
delAuthPar
,
BasicConfig
.
MANAGER_corp_deleteAuthById
,
"删除权限等级失败"
,
delAuthRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
delAuthPar
,
BasicConfig
.
MANAGER_corp_deleteAuthById
,
"获取数据失败"
,
delAuthRes
.
body
().
asString
()));
}
}
}
public
void
getCurrentTimeStamp
()
{
// 将companyNameOfTimeStamp赋值操作单独封装成一个方法
// 保证在多次使用该变量时他的值不会发生变化
companyNameOfTimeStamp
=
String
.
valueOf
(
new
Date
().
getTime
());
}
}
src/test/java/com/kjj/config/BasicConfig.java
View file @
21e11411
...
...
@@ -96,7 +96,7 @@ public class BasicConfig {
public
static
final
String
MANAGER_HOST
=
"https://kjj-mng.duibatest.com.cn"
;
public
static
final
String
MOBILE_HOST
=
"https://live.duibatest.com.cn"
;
public
static
final
String
MOBILE_SPOKEHOST
=
"https://tt.duibatest.com.cn"
;
public
static
final
String
CORP_HOST
=
"https://kjj-corp.duibatest.com.cn"
;
// *************** 开启&结束直播 ***************
public
static
final
String
ANCHOR_OPEN
=
MOBILE_HOST
+
"/conf/live/open"
;
public
static
final
String
ANCHOR_getConfDetail
=
MOBILE_HOST
+
"/conf/pre/getConfDetail"
;
...
...
@@ -1182,20 +1182,27 @@ public class BasicConfig {
public
static
final
String
MANAGER_qa_pageList
=
MANAGER_HOST
+
"/kjy/manager/qa/pageList"
;
public
static
final
String
MANAGER_qa_del
=
MANAGER_HOST
+
"/kjy/manager/qa/del"
;
// 企业后台
public
static
final
String
MANAGER_corp_saveCorp
=
MANAGER_HOST
+
"/kjy/manager/corp/company/saveOrUpdate"
;
public
static
final
String
MANAGER_corp_CorpLists
=
MANAGER_HOST
+
"/kjy/manager/corp/company/selectList"
;
public
static
final
String
MANAGER_corp_searchCorp
=
MANAGER_HOST
+
"/kjy/manager/corp/company/search"
;
public
static
final
String
MANAGER_corp_saveAuth
=
MANAGER_HOST
+
"/kjy/manager/corp/company/auth/saveOrUpdate"
;
public
static
final
String
MANAGER_corp_authLists
=
MANAGER_HOST
+
"/kjy/manager/corp/company/auth/selectList"
;
public
static
final
String
MANAGER_corp_deleteAuthById
=
MANAGER_HOST
+
"/kjy/manager/corp/company/auth/deleteById"
;
public
static
final
String
MANAGER_corp_savePage
=
MANAGER_HOST
+
"/kjy/manager/corp/company/page/saveOrUpdate"
;
public
static
final
String
MANAGER_corp_pageLists
=
MANAGER_HOST
+
"/kjy/manager/corp/company/page/selectList"
;
public
static
final
String
MANAGER_corp_saveStaff
=
MANAGER_HOST
+
"/kjy/manager/corp/company/staff/saveOrUpdate"
;
public
static
final
String
MANAGER_corp_staffList
=
MANAGER_HOST
+
"/kjy/manager/corp/company/staff/selectList"
;
public
static
final
String
MANAGER_corp_phoneExist
=
MANAGER_HOST
+
"/kjy/manager/corp/company/staff/phoneExist"
;
public
static
final
String
MANAGER_corp_changePageState
=
MANAGER_HOST
+
"/kjy/manager/corp/company/page/changeState"
;
public
static
final
String
MANAGER_corp_delPageById
=
MANAGER_HOST
+
"/kjy/manager/corp/company/page/deleteById"
;
public
static
final
String
MANAGER_corp_changeStaffState
=
MANAGER_HOST
+
"/kjy/manager/corp/company/staff/changeState"
;
public
static
final
String
MANAGER_corp_delStaff
=
MANAGER_HOST
+
"/kjy/manager/corp/company/staff/deleteById"
;
// 管理后台—企业后台
public
static
final
String
MANAGER_cockpitSaveOrUpdate
=
MANAGER_HOST
+
"/kjy/manager/corp/cockpit/saveOrUpdate"
;
public
static
final
String
MANAGER_cockpitList
=
MANAGER_HOST
+
"/kjy/manager/corp/cockpit/list"
;
public
static
final
String
MANAGER_cockpitSwitchStatus
=
MANAGER_HOST
+
"/kjy/manager/corp/cockpit/switchStatus"
;
public
static
final
String
MANAGER_cockpitDelete
=
MANAGER_HOST
+
"/kjy/manager/corp/cockpit/delete"
;
//企业后台
public
static
final
String
CORP_pageList
=
CORP_HOST
+
"/kjy/corp/page/list"
;
public
static
final
String
CORP_batchImport
=
CORP_HOST
+
"/kjy/corp/employee/batch/import"
;
public
static
final
String
CORP_importResult
=
CORP_HOST
+
"/kjy/corp/import/result"
;
public
static
final
String
CORP_recordList
=
CORP_HOST
+
"/kjy/corp/import/record/list"
;
public
static
final
String
CORP_getCaptcha
=
CORP_HOST
+
"/kjy/corp/getCaptcha"
;
public
static
final
String
CORP_getCaptchaForAutoTest
=
CORP_HOST
+
"/kjy/corp/getCaptchaForAutoTest"
;
public
static
final
String
CORP_login
=
CORP_HOST
+
"/kjy/corp/login"
;
public
static
final
String
CORP_switchover
=
CORP_HOST
+
"/kjy/corp/company/switchover"
;
public
static
final
String
CORP_listSimple
=
CORP_HOST
+
"/kjy/corp/company/list/simple"
;
public
static
final
String
CORP_simpleList
=
CORP_HOST
+
"/kjy/corp/dept/simple/list"
;
public
static
final
String
CORP_employeeStat
=
CORP_HOST
+
"/kjy/corp/employee/stat"
;
public
static
final
String
CORP_employeeList
=
CORP_HOST
+
"/kjy/corp/employee/list"
;
public
static
final
String
CORP_deptEdit
=
CORP_HOST
+
"/kjy/corp/dept/edit"
;
public
static
final
String
CORP_employeeSaveOrUpdate
=
CORP_HOST
+
"/kjy/corp/employee/saveOrUpdate"
;
public
static
final
String
CORP_employeeDel
=
CORP_HOST
+
"/kjy/corp/employee/del"
;
public
static
final
String
CORP_deptDel
=
CORP_HOST
+
"/kjy/corp/dept/del"
;
}
src/test/java/com/kjj/utils/BaseUtils.java
View file @
21e11411
...
...
@@ -195,4 +195,143 @@ public class BaseUtils {
Assert
.
assertNotNull
(
data
,
network
.
message
(
myCountParam
,
BasicConfig
.
USER_myCount
,
"抽奖码数量错误"
,
myCountRes
.
body
().
asString
()));
}
}
/**
* 超管登录企业后台
*/
public
static
void
superUserLogin
(){
// 调用登录接口
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"phone"
,
"15136361308"
);
Response
response
=
network
.
getResponse
(
params
,
BasicConfig
.
CORP_getCaptcha
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
CORP_getCaptcha
,
"获取验证码失败"
,
response
.
body
().
asString
()));
//专用于自动化获取验证码
params
.
clear
();
params
.
put
(
"phone"
,
"15136361308"
);
Response
autoTestRes
=
network
.
getResponse
(
params
,
BasicConfig
.
CORP_getCaptchaForAutoTest
);
long
captcha
=
autoTestRes
.
jsonPath
().
getLong
(
"data"
);
System
.
out
.
println
(
captcha
);
//登录接口
ThreadSleepUtils
.
sleep
(
1000
);
params
.
clear
();
params
.
put
(
"phone"
,
"15136361308"
);
params
.
put
(
"captcha"
,
captcha
);
Response
loginRes
=
network
.
postResponse
(
params
,
BasicConfig
.
CORP_login
);
boolean
success
=
loginRes
.
jsonPath
().
getBoolean
(
"success"
);
Assert
.
assertTrue
(
success
,
network
.
message
(
params
,
BasicConfig
.
CORP_login
,
"登录失败"
,
loginRes
.
body
().
asString
()));
//获取cookie
String
header
=
loginRes
.
getHeader
(
"Set-Cookie"
);
String
cookieStr
=
header
.
split
(
";"
)[
0
];
String
[]
cookieKeyValue
=
cookieStr
.
split
(
"="
);
network
.
agentCookies
.
put
(
cookieKeyValue
[
0
],
cookieKeyValue
[
1
]);
//存入cookies
//选择接口 CORP_switchover
params
.
clear
();
Response
switchRes
=
network
.
postResponse
(
params
,
BasicConfig
.
CORP_switchover
+
"?companyId=Kj20MjE1"
);
boolean
switchData
=
switchRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
switchData
,
network
.
message
(
params
,
BasicConfig
.
CORP_switchover
,
"选择公司失败"
,
switchRes
.
body
().
asString
()));
//重复获取一次cookie,覆盖现有cookie
header
=
switchRes
.
getHeader
(
"Set-Cookie"
);
cookieStr
=
header
.
split
(
";"
)[
0
];
cookieKeyValue
=
cookieStr
.
split
(
"="
);
network
.
agentCookies
.
put
(
cookieKeyValue
[
0
],
cookieKeyValue
[
1
]);
//存入cookies
network
.
agentCookies
.
put
(
"companyId"
,
"Kj20MjE1"
);
}
/**
* 公司管理员登录企业后台
*/
public
static
void
companyUserLogin
(){
// 调用登录接口
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"phone"
,
"15136361307"
);
Response
response
=
network
.
getResponse
(
params
,
BasicConfig
.
CORP_getCaptcha
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
CORP_getCaptcha
,
"获取验证码失败"
,
response
.
body
().
asString
()));
//专用于自动化获取验证码
params
.
clear
();
params
.
put
(
"phone"
,
"15136361307"
);
Response
autoTestRes
=
network
.
getResponse
(
params
,
BasicConfig
.
CORP_getCaptchaForAutoTest
);
long
captcha
=
autoTestRes
.
jsonPath
().
getLong
(
"data"
);
System
.
out
.
println
(
captcha
);
//登录接口
ThreadSleepUtils
.
sleep
(
1000
);
params
.
clear
();
params
.
put
(
"phone"
,
"15136361307"
);
params
.
put
(
"captcha"
,
captcha
);
Response
loginRes
=
network
.
postResponse
(
params
,
BasicConfig
.
CORP_login
);
boolean
success
=
loginRes
.
jsonPath
().
getBoolean
(
"success"
);
Assert
.
assertTrue
(
success
,
network
.
message
(
params
,
BasicConfig
.
CORP_login
,
"登录失败"
,
loginRes
.
body
().
asString
()));
//获取cookie
String
header
=
loginRes
.
getHeader
(
"Set-Cookie"
);
String
cookieStr
=
header
.
split
(
";"
)[
0
];
String
[]
cookieKeyValue
=
cookieStr
.
split
(
"="
);
network
.
agentCookies
.
put
(
cookieKeyValue
[
0
],
cookieKeyValue
[
1
]);
//存入cookies
//选择接口 CORP_switchover
params
.
clear
();
Response
switchRes
=
network
.
postResponse
(
params
,
BasicConfig
.
CORP_switchover
+
"?companyId=Kj20MjE1"
);
boolean
switchData
=
switchRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
switchData
,
network
.
message
(
params
,
BasicConfig
.
CORP_switchover
,
"选择公司失败"
,
switchRes
.
body
().
asString
()));
//重复获取一次cookie,覆盖现有cookie
header
=
switchRes
.
getHeader
(
"Set-Cookie"
);
cookieStr
=
header
.
split
(
";"
)[
0
];
cookieKeyValue
=
cookieStr
.
split
(
"="
);
network
.
agentCookies
.
put
(
cookieKeyValue
[
0
],
cookieKeyValue
[
1
]);
//存入cookies
//put company Id
network
.
agentCookies
.
put
(
"companyId"
,
"Kj20MjE1"
);
}
/**
* 营业部管理员登录企业后台
*/
public
static
void
officeUserLogin
(){
// 调用登录接口
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"phone"
,
"15136361306"
);
Response
response
=
network
.
getResponse
(
params
,
BasicConfig
.
CORP_getCaptcha
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
BasicConfig
.
CORP_getCaptcha
,
"获取验证码失败"
,
response
.
body
().
asString
()));
//专用于自动化获取验证码
params
.
clear
();
params
.
put
(
"phone"
,
"15136361306"
);
Response
autoTestRes
=
network
.
getResponse
(
params
,
BasicConfig
.
CORP_getCaptchaForAutoTest
);
long
captcha
=
autoTestRes
.
jsonPath
().
getLong
(
"data"
);
System
.
out
.
println
(
captcha
);
//登录接口
ThreadSleepUtils
.
sleep
(
1000
);
params
.
clear
();
params
.
put
(
"phone"
,
"15136361306"
);
params
.
put
(
"captcha"
,
captcha
);
Response
loginRes
=
network
.
postResponse
(
params
,
BasicConfig
.
CORP_login
);
boolean
success
=
loginRes
.
jsonPath
().
getBoolean
(
"success"
);
Assert
.
assertTrue
(
success
,
network
.
message
(
params
,
BasicConfig
.
CORP_login
,
"登录失败"
,
loginRes
.
body
().
asString
()));
//获取cookie
String
header
=
loginRes
.
getHeader
(
"Set-Cookie"
);
String
cookieStr
=
header
.
split
(
";"
)[
0
];
String
[]
cookieKeyValue
=
cookieStr
.
split
(
"="
);
network
.
agentCookies
.
put
(
cookieKeyValue
[
0
],
cookieKeyValue
[
1
]);
//存入cookies
//选择接口 CORP_switchover
params
.
clear
();
Response
switchRes
=
network
.
postResponse
(
params
,
BasicConfig
.
CORP_switchover
+
"?companyId=Kj20MjE1"
);
boolean
switchData
=
switchRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
switchData
,
network
.
message
(
params
,
BasicConfig
.
CORP_switchover
,
"选择公司失败"
,
switchRes
.
body
().
asString
()));
//重复获取一次cookie,覆盖现有cookie
header
=
switchRes
.
getHeader
(
"Set-Cookie"
);
cookieStr
=
header
.
split
(
";"
)[
0
];
cookieKeyValue
=
cookieStr
.
split
(
"="
);
network
.
agentCookies
.
put
(
cookieKeyValue
[
0
],
cookieKeyValue
[
1
]);
//存入cookies
//put company Id
network
.
agentCookies
.
put
(
"companyId"
,
"Kj20MjE1"
);
}
}
src/test/wechatTestNG.xml
View file @
21e11411
...
...
@@ -78,12 +78,7 @@
</test>
<test
preserve-order=
"true"
name =
"邀请函和趣味测评"
>
<classes>
<class
name=
"com.kjj.cases.assistant.markettools.InvitationLetter"
/>
</classes>
</test>
<test
preserve-order=
"true"
name =
"使用攻略和设置中心"
>
<classes>
<class
name=
"com.kjj.cases.assistant.menu.PersonalCenter"
/>
<class
name=
"com.kjj.cases.assistant.enterprise.Enterprise"
/>
</classes>
</test>
</suite>
...
...
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