Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tiku_APP_APITest
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shuai
tiku_APP_APITest
Commits
92cd6b12
Commit
92cd6b12
authored
Dec 04, 2019
by
Thinkpad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
843647f8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
620 additions
and
0 deletions
+620
-0
DataAllMr - 副本.xls
tiku_App/TestData/DataAllMr - 副本.xls
+0
-0
getAbilitys.java
tiku_App/src/com/offcn/api/tk/app3/getAbilitys.java
+155
-0
getGrowths.java
tiku_App/src/com/offcn/api/tk/app3/getGrowths.java
+143
-0
getMockInfo.java
tiku_App/src/com/offcn/api/tk/app3/getMockInfo.java
+155
-0
positioninfo.java
tiku_App/src/com/offcn/api/tk/app3/positioninfo.java
+167
-0
No files found.
tiku_App/TestData/DataAllMr.xls
→
tiku_App/TestData/DataAllMr
- 副本
.xls
View file @
92cd6b12
No preview for this file type
tiku_App/src/com/offcn/api/tk/app3/getAbilitys.java
0 → 100644
View file @
92cd6b12
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 48.数据报告----能力图谱接口
*
* @author puhui
*
*/
public
class
getAbilitys
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
user_id
;
//用户id
public
String
exam_id
;
//考试id
public
String
is_position
;
//是否通过职位信息对比
public
String
user_position_id
;
//用户职位信息id
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
cleanUser_FromDB
();
//清除注册用户根据user_id
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
user_id
=
MapUtil
.
getParameter
(
parameter
,
"user_id"
).
trim
();
exam_id
=
MapUtil
.
getParameter
(
parameter
,
"exam_id"
).
trim
();
is_position
=
MapUtil
.
getParameter
(
parameter
,
"is_position"
).
trim
();
user_position_id
=
MapUtil
.
getParameter
(
parameter
,
"user_position_id"
).
trim
();
if
((!
user_id
.
equals
(
""
))
&&
user_id
.
equals
(
"code"
))
{
user_id
=
ListUtil
.
getListValue
(
user_idList
,
0
);
parameter
=
parameter
.
replace
(
"\"user_id\":code"
,
"\"user_id\":\""
+
user_id
+
"\""
);
}
if
((!
exam_id
.
equals
(
""
))
&&
exam_id
.
equals
(
"code"
))
{
exam_id
=
L_exam_id
;
parameter
=
parameter
.
replace
(
"\"exam_id\":code"
,
"\"exam_id\":\""
+
exam_id
+
"\""
);
}
if
((!
user_position_id
.
equals
(
""
))
&&
user_position_id
.
equals
(
"code"
))
{
user_position_id
=
L_position_id
;
parameter
=
parameter
.
replace
(
"\"user_position_id\":code"
,
"\"user_position_id\":\""
+
user_position_id
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Response
re
=
RequestDataUtils
.
Post_token
(
data
,
Url
,
tk_token
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
StringUtils
.
decodeUnicode
(
re
.
asString
());
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
json
!=
null
){
//如果自定义结果包含多个希望结果,也就是有逗号,那么就切割,包含比较。
if
(
data
.
get
(
"custom"
).
toString
().
contains
(
","
)){
String
[]
strCustomStrings
=
data
.
get
(
"custom"
).
toString
().
split
(
","
);
for
(
int
i
=
0
;
i
<
strCustomStrings
.
length
;
i
++){
if
(!
json
.
contains
(
strCustomStrings
[
i
])){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
strCustomStrings
[
i
]
+
"."
;
break
;
}
}
}
else
{
//如果只有一个希望结果,就直接包含比较。
if
(!
json
.
contains
(
data
.
get
(
"custom"
).
toString
())){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
data
.
get
(
"custom"
).
toString
()
+
"."
;
}
}
}
if
(
"接口响应成功!"
.
equals
(
msg
)){
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/getGrowths.java
0 → 100644
View file @
92cd6b12
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 54.数据报告----成长轨迹接口
*
* @author puhui
*
*/
public
class
getGrowths
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
user_id
;
//用户id
public
String
exam_id
;
//考试id
public
String
is_position
;
//是否通过职位信息对比
public
String
user_position_id
;
//用户职位信息id
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
cleanUser_FromDB
();
//清除注册用户根据user_id
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
user_id
=
MapUtil
.
getParameter
(
parameter
,
"user_id"
).
trim
();
exam_id
=
MapUtil
.
getParameter
(
parameter
,
"exam_id"
).
trim
();
is_position
=
MapUtil
.
getParameter
(
parameter
,
"is_position"
).
trim
();
user_position_id
=
MapUtil
.
getParameter
(
parameter
,
"user_position_id"
).
trim
();
if
((!
user_id
.
equals
(
""
))
&&
user_id
.
equals
(
"code"
))
{
user_id
=
ListUtil
.
getListValue
(
user_idList
,
0
);
parameter
=
parameter
.
replace
(
"\"user_id\":code"
,
"\"user_id\":\""
+
user_id
+
"\""
);
}
if
((!
exam_id
.
equals
(
""
))
&&
exam_id
.
equals
(
"code"
))
{
exam_id
=
L_exam_id
;
parameter
=
parameter
.
replace
(
"\"exam_id\":code"
,
"\"exam_id\":\""
+
exam_id
+
"\""
);
}
if
((!
user_position_id
.
equals
(
""
))
&&
user_position_id
.
equals
(
"code"
))
{
user_position_id
=
L_position_id
;
parameter
=
parameter
.
replace
(
"\"user_position_id\":code"
,
"\"user_position_id\":\""
+
user_position_id
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Response
re
=
RequestDataUtils
.
Post_token
(
data
,
Url
,
tk_token
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
StringUtils
.
decodeUnicode
(
re
.
asString
());
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
)!=
null
){
String
custom
=
data
.
get
(
"custom"
).
toString
();
String
[]
ArrayString
=
StringUtils
.
getArrayString
(
custom
,
","
);
if
(!
StringUtils
.
VerificationString
(
jp
.
getString
(
"data"
),
ArrayString
)){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"data"
)
+
"."
;
}
}
if
(
"接口响应成功!"
.
equals
(
msg
)){
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/getMockInfo.java
0 → 100644
View file @
92cd6b12
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 45.数据报告----模考追踪
*
* @author puhui
*
*/
public
class
getMockInfo
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
user_id
;
//用户id
public
String
exam_id
;
//考试id
public
String
is_position
;
//是否通过职位信息对比
public
String
user_position_id
;
//用户职位id
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
cleanUser_FromDB
();
//清除注册用户根据user_id
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
user_id
=
MapUtil
.
getParameter
(
parameter
,
"user_id"
).
trim
();
exam_id
=
MapUtil
.
getParameter
(
parameter
,
"exam_id"
).
trim
();
is_position
=
MapUtil
.
getParameter
(
parameter
,
"is_position"
).
trim
();
user_position_id
=
MapUtil
.
getParameter
(
parameter
,
"user_position_id"
).
trim
();
if
((!
user_id
.
equals
(
""
))
&&
user_id
.
equals
(
"code"
))
{
user_id
=
ListUtil
.
getListValue
(
user_idList
,
0
);
parameter
=
parameter
.
replace
(
"\"user_id\":code"
,
"\"user_id\":\""
+
user_id
+
"\""
);
}
if
((!
exam_id
.
equals
(
""
))
&&
exam_id
.
equals
(
"code"
))
{
exam_id
=
L_exam_id
;
parameter
=
parameter
.
replace
(
"\"exam_id\":code"
,
"\"exam_id\":\""
+
exam_id
+
"\""
);
}
if
((!
user_position_id
.
equals
(
""
))
&&
user_position_id
.
equals
(
"code"
))
{
user_position_id
=
L_position_id
;
parameter
=
parameter
.
replace
(
"\"user_position_id\":code"
,
"\"user_position_id\":\""
+
user_position_id
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Response
re
=
RequestDataUtils
.
Post_token
(
data
,
Url
,
tk_token
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
StringUtils
.
decodeUnicode
(
re
.
asString
());
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
json
!=
null
){
//如果自定义结果包含多个希望结果,也就是有逗号,那么就切割,包含比较。
if
(
data
.
get
(
"custom"
).
toString
().
contains
(
","
)){
String
[]
strCustomStrings
=
data
.
get
(
"custom"
).
toString
().
split
(
","
);
for
(
int
i
=
0
;
i
<
strCustomStrings
.
length
;
i
++){
if
(!
json
.
contains
(
strCustomStrings
[
i
])){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
strCustomStrings
[
i
]
+
"."
;
break
;
}
}
}
else
{
//如果只有一个希望结果,就直接包含比较。
if
(!
json
.
contains
(
data
.
get
(
"custom"
).
toString
())){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
data
.
get
(
"custom"
).
toString
()
+
"."
;
}
}
}
if
(
"接口响应成功!"
.
equals
(
msg
)){
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/positioninfo.java
0 → 100644
View file @
92cd6b12
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 82.用户报考职位信息保存
*
* @author puhui
*
*/
public
class
positioninfo
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
user_id
;
//用户id
public
String
exam_id
;
//考试id
public
String
office_id
;
//招录机关id
public
String
department_id
;
//用人司局id
public
String
position_id
;
//报考职位id
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
cleanUser_FromDB
();
//清除注册用户根据user_id
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
user_id
=
MapUtil
.
getParameter
(
parameter
,
"user_id"
).
trim
();
exam_id
=
MapUtil
.
getParameter
(
parameter
,
"exam_id"
).
trim
();
office_id
=
MapUtil
.
getParameter
(
parameter
,
"office_id"
).
trim
();
department_id
=
MapUtil
.
getParameter
(
parameter
,
"department_id"
).
trim
();
position_id
=
MapUtil
.
getParameter
(
parameter
,
"position_id"
).
trim
();
if
((!
user_id
.
equals
(
""
))
&&
user_id
.
equals
(
"code"
))
{
user_id
=
ListUtil
.
getListValue
(
user_idList
,
0
);
parameter
=
parameter
.
replace
(
"\"user_id\":code"
,
"\"user_id\":\""
+
user_id
+
"\""
);
}
if
((!
exam_id
.
equals
(
""
))
&&
exam_id
.
equals
(
"code"
))
{
exam_id
=
L_exam_id
;
parameter
=
parameter
.
replace
(
"\"exam_id\":code"
,
"\"exam_id\":\""
+
exam_id
+
"\""
);
}
if
((!
office_id
.
equals
(
""
))
&&
office_id
.
equals
(
"code"
))
{
office_id
=
L_office_id
;
parameter
=
parameter
.
replace
(
"\"office_id\":code"
,
"\"office_id\":\""
+
office_id
+
"\""
);
}
if
((!
department_id
.
equals
(
""
))
&&
department_id
.
equals
(
"code"
))
{
department_id
=
L_department_id
;
parameter
=
parameter
.
replace
(
"\"department_id\":code"
,
"\"department_id\":\""
+
department_id
+
"\""
);
}
if
((!
position_id
.
equals
(
""
))
&&
position_id
.
equals
(
"code"
))
{
position_id
=
L_position_id
;
parameter
=
parameter
.
replace
(
"\"position_id\":code"
,
"\"position_id\":\""
+
position_id
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Response
re
=
RequestDataUtils
.
Post_token
(
data
,
Url
,
tk_token
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
StringUtils
.
decodeUnicode
(
re
.
asString
());
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
json
!=
null
){
//如果自定义结果包含多个希望结果,也就是有逗号,那么就切割,包含比较。
if
(
data
.
get
(
"custom"
).
toString
().
contains
(
","
)){
String
[]
strCustomStrings
=
data
.
get
(
"custom"
).
toString
().
split
(
","
);
for
(
int
i
=
0
;
i
<
strCustomStrings
.
length
;
i
++){
if
(!
json
.
contains
(
strCustomStrings
[
i
])){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
strCustomStrings
[
i
]
+
"."
;
break
;
}
}
}
else
{
//如果只有一个希望结果,就直接包含比较。
if
(!
json
.
contains
(
data
.
get
(
"custom"
).
toString
())){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
data
.
get
(
"custom"
).
toString
()
+
"."
;
}
}
}
if
(
"数据库添加成功"
.
equals
(
msg
)){
position_id
=
MapUtil
.
killQuotes
(
position_id
,
"\""
);
L_position_id
=
position_id
;
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
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