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
fe7f42c2
Commit
fe7f42c2
authored
Aug 08, 2019
by
Thinkpad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mr20190808
parent
b046c3cb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
980 additions
and
18 deletions
+980
-18
CaseMakeMr.xls
tiku_App/TestData/CaseMakeMr.xls
+0
-0
DataAllMr.xls
tiku_App/TestData/DataAllMr.xls
+0
-0
checkCode.java
tiku_App/src/com/offcn/api/tk/app3/checkCode.java
+198
-0
getCode.java
tiku_App/src/com/offcn/api/tk/app3/getCode.java
+191
-0
getExpoundingPaperBlocks.java
...p/src/com/offcn/api/tk/app3/getExpoundingPaperBlocks.java
+31
-18
getImageInfo.java
tiku_App/src/com/offcn/api/tk/app3/getImageInfo.java
+186
-0
getMockList_2.java
tiku_App/src/com/offcn/api/tk/app3/getMockList_2.java
+182
-0
signUpMock.java
tiku_App/src/com/offcn/api/tk/app3/signUpMock.java
+192
-0
No files found.
tiku_App/TestData/CaseMakeMr.xls
View file @
fe7f42c2
No preview for this file type
tiku_App/TestData/DataAllMr.xls
View file @
fe7f42c2
No preview for this file type
tiku_App/src/com/offcn/api/tk/app3/checkCode.java
0 → 100644
View file @
fe7f42c2
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.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 52、校验验证码
*
* @author mr
*
*/
public
class
checkCode
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
phone
;
//手机号
public
String
code
;
//手机验证码
@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
);
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
code
=
MapUtil
.
getParameter
(
parameter
,
"code"
).
trim
();
if
((!
phone
.
equals
(
""
))
&&
phone
.
equals
(
"code"
))
{
phone
=
phoneNeb
;
parameter
=
parameter
.
replace
(
"\"phone\":code"
,
"\"phone\":\""
+
phone
+
"\""
);
}
if
((!
code
.
equals
(
""
))
&&
code
.
equals
(
"code"
))
{
code
=
phone_code
;
parameter
=
parameter
.
replace
(
"\"code\":code"
,
"\"code\":\""
+
code
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"Authorization"
,
tk_token
);
Map
<
String
,
String
>
jsonAsMap
=
new
HashMap
<
String
,
String
>();
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
String
tikuString
=
MapUtil
.
getParameter
(
parameter
,
"appid"
).
trim
();
tikuString
=
MapUtil
.
killQuotes
(
tikuString
,
"\""
);
jsonAsMap
.
put
(
"phone"
,
phone
);
jsonAsMap
.
put
(
"code"
,
code
);
jsonAsMap
.
put
(
"appid"
,
tikuString
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setUrl
(
Url
);
myRequest
.
setHeaders
(
headers
);
myRequest
.
setFormParameter
(
jsonAsMap
);
myRequest
.
setRequest
(
Request
);
Response
re
=
RequestDataUtils
.
RestAssuredApi
(
data
,
myRequest
);
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
(
"retcode"
)
+
"."
;
}
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
(
"retcode"
)
+
"."
;
}
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
)){
phone_code
=
jp
.
getString
(
"data.code"
);
System
.
out
.
println
(
phone_code
);
//是否验证数据库
if
(!
isProduct
)
{
try
{
ResultSet
rs_bankcard
=
this
.
selectFromDB
(
" t_code c "
,
" c.phone = '"
+
phone
+
"' "
);
rs_bankcard
.
last
();
if
(
rs_bankcard
.
getRow
()>=
1
){
// code = MapUtil.killQuotes(code, "\"");
// phone_code=code;
// parameter = MapUtil.getValue("parameter", data);
String
act_code
=
rs_bankcard
.
getString
(
"code"
);
if
(!
act_code
.
equals
(
phone_code
)){
result
=
result
&&
false
;
failReason
=
failReason
+
"t_code info code is not in DB;"
;
}
}
}
catch
(
Exception
e
)
{
result
=
result
&&
false
;
failReason
=
failReason
+
"cannot verify t_code info in DB;"
;
e
.
printStackTrace
();
}
}
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/getCode.java
0 → 100644
View file @
fe7f42c2
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.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 51、h5获取验证码
*
* @author mr
*
*/
public
class
getCode
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
phone
;
//手机号
@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
);
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
if
((!
phone
.
equals
(
""
))
&&
phone
.
equals
(
"code"
))
{
phone
=
phoneNeb
;
parameter
=
parameter
.
replace
(
"\"phone\":code"
,
"\"phone\":\""
+
phone
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"Authorization"
,
tk_token
);
Map
<
String
,
String
>
jsonAsMap
=
new
HashMap
<
String
,
String
>();
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
String
tikuString
=
MapUtil
.
getParameter
(
parameter
,
"appid"
).
trim
();
tikuString
=
MapUtil
.
killQuotes
(
tikuString
,
"\""
);
jsonAsMap
.
put
(
"phone"
,
phone
);
jsonAsMap
.
put
(
"appid"
,
tikuString
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setUrl
(
Url
);
myRequest
.
setHeaders
(
headers
);
myRequest
.
setFormParameter
(
jsonAsMap
);
myRequest
.
setRequest
(
Request
);
Response
re
=
RequestDataUtils
.
RestAssuredApi
(
data
,
myRequest
);
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
(
"retcode"
)
+
"."
;
}
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
(
"retcode"
)
+
"."
;
}
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
)){
phone_code
=
jp
.
getString
(
"data.code"
);
System
.
out
.
println
(
phone_code
);
//是否验证数据库
if
(!
isProduct
)
{
try
{
ResultSet
rs_bankcard
=
this
.
selectFromDB
(
" t_code c "
,
" c.phone = '"
+
phone
+
"' "
);
rs_bankcard
.
last
();
if
(
rs_bankcard
.
getRow
()>=
1
){
// code = MapUtil.killQuotes(code, "\"");
// phone_code=code;
// parameter = MapUtil.getValue("parameter", data);
String
act_code
=
rs_bankcard
.
getString
(
"code"
);
if
(!
act_code
.
equals
(
phone_code
)){
result
=
result
&&
false
;
failReason
=
failReason
+
"t_code info code is not in DB;"
;
}
}
}
catch
(
Exception
e
)
{
result
=
result
&&
false
;
failReason
=
failReason
+
"cannot verify t_code info in DB;"
;
e
.
printStackTrace
();
}
}
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/getExpoundingPaperBlocks.java
View file @
fe7f42c2
...
...
@@ -6,6 +6,7 @@ import io.restassured.response.Response;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
...
...
@@ -19,8 +20,8 @@ import com.offcn.TestUnti.ListUtil;
/**
*
* @Description: 11.真题试卷-申论真题获取试卷模块信息
* @author: wff
* @date: 2019年
6月1
1日 上午11:26:23
* @author: wff
->mr
* @date: 2019年
7月3
1日 上午11:26:23
* @version V1.0
*/
...
...
@@ -31,6 +32,7 @@ public class getExpoundingPaperBlocks extends TK implements API {
public
String
paper_id
;
//试卷id
public
String
exam_id
;
//考试id(nwn可传0)
public
String
channel
;
//做题平台来源(1:题库;2:NWN),不传默认为1
public
String
nwn_paper_id
;
//nwn系统试卷id
@Override
...
...
@@ -45,12 +47,28 @@ public class getExpoundingPaperBlocks extends TK implements API {
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
user_id
=
MapUtil
.
getParameter
(
parameter
,
"user_id"
).
trim
();
paper_id
=
MapUtil
.
getParameter
(
parameter
,
"paper_id"
).
trim
();
exam_id
=
MapUtil
.
getParameter
(
parameter
,
"exam_id"
).
trim
();
channel
=
MapUtil
.
getParameter
(
parameter
,
"channel"
).
trim
();
nwn_paper_id
=
MapUtil
.
getParameter
(
parameter
,
"nwn_paper_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
((!
paper_id
.
equals
(
""
))
&&
paper_id
.
equals
(
"code"
))
{
paper_id
=
paper_id_L
;
paper_id
=
"4321"
;
parameter
=
parameter
.
replace
(
"\"paper_id\":code"
,
"\"paper_id\":\""
+
paper_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
((!
nwn_paper_id
.
equals
(
""
))
&&
nwn_paper_id
.
equals
(
"code"
))
{
nwn_paper_id
=
"4321"
;
parameter
=
parameter
.
replace
(
"\"nwn_paper_id\":code"
,
"\"nwn_paper_id\":\""
+
nwn_paper_id
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
...
...
@@ -67,7 +85,11 @@ public class getExpoundingPaperBlocks extends TK implements API {
String
tikuString
=
MapUtil
.
getParameter
(
parameter
,
"appid"
).
trim
();
tikuString
=
MapUtil
.
killQuotes
(
tikuString
,
"\""
);
jsonAsMap
.
put
(
"user_id"
,
user_id
);
jsonAsMap
.
put
(
"paper_id"
,
paper_id
);
jsonAsMap
.
put
(
"exam_id"
,
exam_id
);
jsonAsMap
.
put
(
"channel"
,
channel
);
jsonAsMap
.
put
(
"nwn_paper_id"
,
nwn_paper_id
);
jsonAsMap
.
put
(
"appid"
,
tikuString
);
MyRequest
myRequest
=
new
MyRequest
();
...
...
@@ -139,27 +161,18 @@ public class getExpoundingPaperBlocks extends TK implements API {
}
}
if
(
"接口响应成功!"
.
equals
(
msg
)){
List
<
String
>
list
=
jp
.
getList
(
"data.children.children"
);
System
.
out
.
println
(
list
);
if
(
list
!=
null
&&
list
.
size
()>
0
&&
list
.
get
(
0
)!=
null
)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
String
shelfIds
=
jp
.
getString
(
"data.children.children[0].shelf_id"
);
String
[]
shelfId
=
shelfIds
.
split
(
","
);
for
(
String
string
:
shelfId
)
{
L_shelf_id
=
string
.
replace
(
"["
,
""
).
replace
(
"]"
,
""
).
trim
();
// System.out.println(string.replace("[", "").replace("]", ""));
}
}
//
}
if
(
"success"
.
equals
(
msg
)){
L_record_id
=
jp
.
getString
(
"data.recordId"
);
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
return
json
;
}
}
tiku_App/src/com/offcn/api/tk/app3/getImageInfo.java
0 → 100644
View file @
fe7f42c2
This diff is collapsed.
Click to expand it.
tiku_App/src/com/offcn/api/tk/app3/getMockList_2.java
0 → 100644
View file @
fe7f42c2
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.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 48.模考web报名页获取模考列表
*
* @author mr
*
*/
public
class
getMockList_2
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
exam_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
);
exam_id
=
MapUtil
.
getParameter
(
parameter
,
"exam_id"
).
trim
();
if
((!
exam_id
.
equals
(
""
))
&&
exam_id
.
equals
(
"code"
))
{
exam_id
=
L_exam_id
;
parameter
=
parameter
.
replace
(
"\"exam_id\":code"
,
"\"exam_id\":\""
+
exam_id
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"Authorization"
,
tk_token
);
Map
<
String
,
String
>
jsonAsMap
=
new
HashMap
<
String
,
String
>();
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
String
tikuString
=
MapUtil
.
getParameter
(
parameter
,
"appid"
).
trim
();
tikuString
=
MapUtil
.
killQuotes
(
tikuString
,
"\""
);
jsonAsMap
.
put
(
"exam_id"
,
exam_id
);
jsonAsMap
.
put
(
"appid"
,
tikuString
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setUrl
(
"/apiv3/mock/mockweb/getMockList"
);
myRequest
.
setHeaders
(
headers
);
myRequest
.
setFormParameter
(
jsonAsMap
);
myRequest
.
setRequest
(
Request
);
Response
re
=
RequestDataUtils
.
RestAssuredApi
(
data
,
myRequest
);
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
(
"retcode"
)
+
"."
;
}
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
(
"retcode"
)
+
"."
;
}
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
(
"0"
.
equals
(
code
)){
// L_mock_sub_id=jp.getString("data.mock.mocklist.mock_sub_id[0]");
// L_mock_id=jp.getString("data.mock.mocklist.mock_id[0]");
// System.out.println(L_mock_sub_id);
// System.out.println(L_mock_id);
// List<String> list=jp.getList("data.mock.mocklist.mock_sub_id");
// System.out.println(list);
// if (list!=null && list.size()>0 && list.get(0)!=null) {
// for(int i=0;i<list.size();i++){
// String mock_subIds =jp.getString("data.mock.mocklist.mock_sub_id");
// String[] mock_subId = mock_subIds.split(",");
// for (String string : mock_subId) {
// L_mock_sub_id = string.replace("[", "").replace("]", "").trim();
// }
// }
// }
List
<
String
>
list
=
jp
.
getList
(
"data.mock.mocklist.mock_sub_id"
);
if
(
list
!=
null
&&
list
.
size
()>
0
&&
list
.
get
(
0
)!=
null
)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
L_mock_sub_id
=
jp
.
getString
(
"data.mock.mocklist.mock_sub_id["
+
i
+
"]"
);
L_mock_id
=
jp
.
getString
(
"data.mock.mocklist.mock_id["
+
i
+
"]"
);
}
}
System
.
out
.
println
(
L_mock_sub_id
);
System
.
out
.
println
(
L_mock_id
);
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/signUpMock.java
0 → 100644
View file @
fe7f42c2
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.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 49.模考web报名页报名
*
* @author mr
*
*/
public
class
signUpMock
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
exam_id
;
//考试项目id
public
String
phone
;
//手机号
public
String
mock_sub_id
;
//子模考id
public
String
mock_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
);
exam_id
=
MapUtil
.
getParameter
(
parameter
,
"exam_id"
).
trim
();
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
mock_sub_id
=
MapUtil
.
getParameter
(
parameter
,
"mock_sub_id"
);
mock_id
=
MapUtil
.
getParameter
(
parameter
,
"mock_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
((!
phone
.
equals
(
""
))
&&
phone
.
equals
(
"code"
))
{
phone
=
phoneNeb
;
parameter
=
parameter
.
replace
(
"\"phone\":code"
,
"\"phone\":\""
+
phone
+
"\""
);
}
if
((!
mock_sub_id
.
equals
(
""
))
&&
mock_sub_id
.
equals
(
"code"
)){
mock_sub_id
=
L_mock_sub_id
;
parameter
=
parameter
.
replace
(
"\"mock_sub_id\":code"
,
"\"mock_sub_id\":\""
+
mock_sub_id
+
"\""
);
}
if
((!
mock_id
.
equals
(
""
))
&&
mock_id
.
equals
(
"code"
))
{
mock_id
=
L_mock_id
;
parameter
=
parameter
.
replace
(
"\"mock_id\":code"
,
"\"mock_id\":\""
+
mock_id
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"Authorization"
,
tk_token
);
Map
<
String
,
String
>
jsonAsMap
=
new
HashMap
<
String
,
String
>();
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
String
tikuString
=
MapUtil
.
getParameter
(
parameter
,
"appid"
).
trim
();
tikuString
=
MapUtil
.
killQuotes
(
tikuString
,
"\""
);
jsonAsMap
.
put
(
"exam_id"
,
exam_id
);
jsonAsMap
.
put
(
"phone"
,
phone
);
jsonAsMap
.
put
(
"mock_sub_id"
,
mock_sub_id
);
jsonAsMap
.
put
(
"mock_id"
,
mock_id
);
jsonAsMap
.
put
(
"appid"
,
tikuString
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setUrl
(
Url
);
myRequest
.
setHeaders
(
headers
);
myRequest
.
setFormParameter
(
jsonAsMap
);
myRequest
.
setRequest
(
Request
);
Response
re
=
RequestDataUtils
.
RestAssuredApi
(
data
,
myRequest
);
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
(
"retcode"
)
+
"."
;
}
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
(
"retcode"
)
+
"."
;
}
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
)){
// L_mock_sub_id=jp.getString("data.mocklist.mock_sub_id[0]");
// L_mock_id=jp.getString("data.mocklist.mock_id[0]");
// List<String> list=jp.getList("data.mocklist");
// System.out.println(list);
// if (list!=null && list.size()>0 && list.get(0)!=null) {
// for(int i=0;i<list.size();i++){
// String mock_sub_id =jp.getString("data.mocklist[0].mock_sub_id");
// String[] shelfId = mock_sub_id.split(",");
// for (String string : shelfId) {
// L_mock_sub_id = string.replace("[", "").replace("]", "").trim();
// }
// }
////
// }
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
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