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
876aa3fa
Commit
876aa3fa
authored
Jun 20, 2019
by
wff66504
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
20190620
parent
1bf3849d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
839 additions
and
3 deletions
+839
-3
CaseMakeWff.xls
tiku_App/TestData/CaseMakeWff.xls
+0
-0
DataAllWff.xls
tiku_App/TestData/DataAllWff.xls
+0
-0
joinMock.java
tiku_App/src/com/offcn/api/tk/app2/joinMock.java
+2
-2
signUpMock.java
tiku_App/src/com/offcn/api/tk/app2/signUpMock.java
+1
-1
checkPaperApplyStatus.java
..._App/src/com/offcn/api/tk/app3/checkPaperApplyStatus.java
+162
-0
checkPushExam.java
tiku_App/src/com/offcn/api/tk/app3/checkPushExam.java
+157
-0
finishResponse.java
tiku_App/src/com/offcn/api/tk/app3/finishResponse.java
+165
-0
getExpoundingPaperBlocks.java
...p/src/com/offcn/api/tk/app3/getExpoundingPaperBlocks.java
+165
-0
getNormalPaperReport.java
tiku_App/src/com/offcn/api/tk/app3/getNormalPaperReport.java
+161
-0
testng1.java
tiku_App/src/test/testng1.java
+26
-0
No files found.
tiku_App/TestData/CaseMakeWff.xls
View file @
876aa3fa
No preview for this file type
tiku_App/TestData/DataAllWff.xls
View file @
876aa3fa
No preview for this file type
tiku_App/src/com/offcn/api/tk/app2/joinMock.java
View file @
876aa3fa
...
@@ -65,7 +65,7 @@ public class joinMock extends TK implements API {
...
@@ -65,7 +65,7 @@ public class joinMock extends TK implements API {
parameter
=
parameter
.
replace
(
"\"user_id\":code"
,
"\"user_id\":\""
+
user_id
+
"\""
);
parameter
=
parameter
.
replace
(
"\"user_id\":code"
,
"\"user_id\":\""
+
user_id
+
"\""
);
}
}
if
((!
mock_subject_id
.
equals
(
""
))
&&
mock_subject_id
.
equals
(
"code"
))
{
if
((!
mock_subject_id
.
equals
(
""
))
&&
mock_subject_id
.
equals
(
"code"
))
{
mock_subject_id
=
"
12
3"
;
mock_subject_id
=
"
4
3"
;
parameter
=
parameter
.
replace
(
"\"mock_subject_id\":code"
,
"\"mock_subject_id\":\""
+
mock_subject_id
+
"\""
);
parameter
=
parameter
.
replace
(
"\"mock_subject_id\":code"
,
"\"mock_subject_id\":\""
+
mock_subject_id
+
"\""
);
}
}
if
((!
mock_id
.
equals
(
""
))
&&
mock_id
.
equals
(
"code"
))
{
if
((!
mock_id
.
equals
(
""
))
&&
mock_id
.
equals
(
"code"
))
{
...
@@ -73,7 +73,7 @@ public class joinMock extends TK implements API {
...
@@ -73,7 +73,7 @@ public class joinMock extends TK implements API {
parameter
=
parameter
.
replace
(
"\"mock_id\":code"
,
"\"mock_id\":\""
+
mock_id
+
"\""
);
parameter
=
parameter
.
replace
(
"\"mock_id\":code"
,
"\"mock_id\":\""
+
mock_id
+
"\""
);
}
}
if
((!
mock_sub_id
.
equals
(
""
))
&&
mock_sub_id
.
equals
(
"code"
))
{
if
((!
mock_sub_id
.
equals
(
""
))
&&
mock_sub_id
.
equals
(
"code"
))
{
mock_sub_id
=
"
42
"
;
mock_sub_id
=
"
0
"
;
parameter
=
parameter
.
replace
(
"\"mock_sub_id\":code"
,
"\"mock_sub_id\":\""
+
mock_sub_id
+
"\""
);
parameter
=
parameter
.
replace
(
"\"mock_sub_id\":code"
,
"\"mock_sub_id\":\""
+
mock_sub_id
+
"\""
);
}
}
data
.
put
(
"parameter"
,
parameter
);
data
.
put
(
"parameter"
,
parameter
);
...
...
tiku_App/src/com/offcn/api/tk/app2/signUpMock.java
View file @
876aa3fa
...
@@ -73,7 +73,7 @@ public class signUpMock extends TK implements API {
...
@@ -73,7 +73,7 @@ public class signUpMock extends TK implements API {
parameter
=
parameter
.
replace
(
"\"mock_id\":code"
,
"\"mock_id\":\""
+
mock_id
+
"\""
);
parameter
=
parameter
.
replace
(
"\"mock_id\":code"
,
"\"mock_id\":\""
+
mock_id
+
"\""
);
}
}
if
((!
mock_sub_id
.
equals
(
""
))
&&
mock_sub_id
.
equals
(
"code"
))
{
if
((!
mock_sub_id
.
equals
(
""
))
&&
mock_sub_id
.
equals
(
"code"
))
{
mock_sub_id
=
"4
2
"
;
mock_sub_id
=
"4
3
"
;
parameter
=
parameter
.
replace
(
"\"mock_sub_id\":code"
,
"\"mock_sub_id\":\""
+
mock_sub_id
+
"\""
);
parameter
=
parameter
.
replace
(
"\"mock_sub_id\":code"
,
"\"mock_sub_id\":\""
+
mock_sub_id
+
"\""
);
}
}
data
.
put
(
"parameter"
,
parameter
);
data
.
put
(
"parameter"
,
parameter
);
...
...
tiku_App/src/com/offcn/api/tk/app3/checkPaperApplyStatus.java
0 → 100644
View file @
876aa3fa
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
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
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
/**
*
* @Description: 10.真题试卷-纯主观题试卷是否可作答校验
* @author: wff
* @date: 2019年6月11日 上午11:26:23
* @version V1.0
*/
public
class
checkPaperApplyStatus
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
paper_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
);
paper_id
=
MapUtil
.
getParameter
(
parameter
,
"paper_id"
).
trim
();
if
((!
paper_id
.
equals
(
""
))
&&
paper_id
.
equals
(
"code"
))
{
paper_id
=
paper_id_L
;
parameter
=
parameter
.
replace
(
"\"paper_id\":code"
,
"\"paper_id\":\""
+
paper_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
(
"paper_id"
,
paper_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
(
"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
)){
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("]", ""));
}
}
//
}
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/checkPushExam.java
0 → 100644
View file @
876aa3fa
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
/**
*
* @Description: 27.App推送-校验考试上下架状态和练习册上下架状
* @author: wff
* @date: 2019年6月20日 下午6:59:16
* @version V1.0
*/
public
class
checkPushExam
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
exam_ids
;
//需要校验的考试id,请按照一定的顺序,逗号隔开传参
public
String
practice_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_ids
=
MapUtil
.
getParameter
(
parameter
,
"exam_ids"
).
trim
();
practice_id
=
MapUtil
.
getParameter
(
parameter
,
"practice_id"
).
trim
();
if
((!
exam_ids
.
equals
(
""
))
&&
exam_ids
.
equals
(
"code"
))
{
// record_id = record_id_L;
exam_ids
=
L_exam_id
;
parameter
=
parameter
.
replace
(
"\"exam_ids\":code"
,
"\"exam_ids\":\""
+
exam_ids
+
"\""
);
}
if
((!
practice_id
.
equals
(
""
))
&&
practice_id
.
equals
(
"code"
))
{
practice_id
=
"597"
;
parameter
=
parameter
.
replace
(
"\"practice_id\":code"
,
"\"practice_id\":\""
+
practice_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_ids"
,
exam_ids
);
jsonAsMap
.
put
(
"practice_id"
,
practice_id
);
jsonAsMap
.
put
(
"appid"
,
tikuString
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setHeaders
(
headers
);
myRequest
.
setRequest
(
Request
);
myRequest
.
setFormParameter
(
jsonAsMap
);
myRequest
.
setUrl
(
Url
);
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
)){
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/finishResponse.java
0 → 100644
View file @
876aa3fa
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
/**
*
* @Description: 20.模考大赛-主观题试卷更新用户完成作答状态
* @author: wff
* @date: 2019年6月20日 下午2:57:02
* @version V1.0
*/
public
class
finishResponse
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
record_id
;
//record_sub_id
public
String
user_id
;
//用户id
public
String
mock_subject_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
);
record_id
=
MapUtil
.
getParameter
(
parameter
,
"record_id"
).
trim
();
user_id
=
MapUtil
.
getParameter
(
parameter
,
"user_id"
).
trim
();
mock_subject_id
=
MapUtil
.
getParameter
(
parameter
,
"mock_subject_id"
).
trim
();
if
((!
record_id
.
equals
(
""
))
&&
record_id
.
equals
(
"code"
))
{
// record_id = record_id_L;
record_id
=
"1"
;
parameter
=
parameter
.
replace
(
"\"record_id\":code"
,
"\"record_id\":\""
+
record_id
+
"\""
);
}
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
((!
mock_subject_id
.
equals
(
""
))
&&
mock_subject_id
.
equals
(
"code"
))
{
mock_subject_id
=
"43"
;
parameter
=
parameter
.
replace
(
"\"mock_subject_id\":code"
,
"\"mock_subject_id\":\""
+
mock_subject_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
(
"record_id"
,
record_id
);
jsonAsMap
.
put
(
"user_id"
,
user_id
);
jsonAsMap
.
put
(
"mock_subject_id"
,
mock_subject_id
);
jsonAsMap
.
put
(
"appid"
,
tikuString
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setHeaders
(
headers
);
myRequest
.
setRequest
(
Request
);
myRequest
.
setFormParameter
(
jsonAsMap
);
myRequest
.
setUrl
(
Url
);
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
)){
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/getExpoundingPaperBlocks.java
0 → 100644
View file @
876aa3fa
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
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
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
/**
*
* @Description: 11.真题试卷-申论真题获取试卷模块信息
* @author: wff
* @date: 2019年6月11日 上午11:26:23
* @version V1.0
*/
public
class
getExpoundingPaperBlocks
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
user_id
;
//用户id
public
String
paper_id
;
//试卷id
public
String
exam_id
;
//考试id(nwn可传0)
public
String
channel
;
//做题平台来源(1:题库;2:NWN),不传默认为1
@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
);
paper_id
=
MapUtil
.
getParameter
(
parameter
,
"paper_id"
).
trim
();
if
((!
paper_id
.
equals
(
""
))
&&
paper_id
.
equals
(
"code"
))
{
paper_id
=
paper_id_L
;
parameter
=
parameter
.
replace
(
"\"paper_id\":code"
,
"\"paper_id\":\""
+
paper_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
(
"paper_id"
,
paper_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
(
"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
)){
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("]", ""));
}
}
//
}
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/getNormalPaperReport.java
0 → 100644
View file @
876aa3fa
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
/**
*
* @Description: 16.真题试卷-获取试卷报告页接口
* @author: wff
* @date: 2019年6月20日 上午11:34:42
* @version V1.0
*/
public
class
getNormalPaperReport
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
record_id
;
//record_sub_id
public
String
orgin
;
//来源 0为来自练习册,1为来自正常做题试卷,2扫描二维码试卷做题,3为来自模考大赛做题试卷
public
String
channel
;
//1题库 2nwn
public
String
orgin_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
);
record_id
=
MapUtil
.
getParameter
(
parameter
,
"record_id"
).
trim
();
orgin
=
MapUtil
.
getParameter
(
parameter
,
"orgin"
).
trim
();
channel
=
MapUtil
.
getParameter
(
parameter
,
"channel"
).
trim
();
orgin_id
=
MapUtil
.
getParameter
(
parameter
,
"orgin_id"
).
trim
();
if
((!
record_id
.
equals
(
""
))
&&
record_id
.
equals
(
"code"
))
{
record_id
=
record_id_L
;
parameter
=
parameter
.
replace
(
"\"record_id\":code"
,
"\"record_id\":\""
+
record_id
+
"\""
);
}
if
((!
orgin_id
.
equals
(
""
))
&&
orgin_id
.
equals
(
"code"
))
{
orgin_id
=
paper_id_L
;
parameter
=
parameter
.
replace
(
"\"orgin_id\":code"
,
"\"orgin_id\":\""
+
orgin_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
(
"record_id"
,
record_id
);
jsonAsMap
.
put
(
"orgin"
,
orgin
);
jsonAsMap
.
put
(
"channel"
,
channel
);
jsonAsMap
.
put
(
"orgin_id"
,
orgin_id
);
jsonAsMap
.
put
(
"appid"
,
tikuString
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setHeaders
(
headers
);
myRequest
.
setRequest
(
Request
);
myRequest
.
setFormParameter
(
jsonAsMap
);
myRequest
.
setUrl
(
Url
);
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
)){
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/test/testng1.java
View file @
876aa3fa
package
test
;
package
test
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
...
@@ -18,4 +21,27 @@ public class testng1 {
...
@@ -18,4 +21,27 @@ public class testng1 {
System
.
out
.
println
(
"Verify User : "
+
username
+
":"
+
password
);
System
.
out
.
println
(
"Verify User : "
+
username
+
":"
+
password
);
assert
username
.
equals
(
password
);
assert
username
.
equals
(
password
);
}
}
public
static
void
main
(
String
[]
args
)
{
Map
<
String
,
String
>
hashMap
=
new
HashMap
<
String
,
String
>();
hashMap
.
put
(
"cn"
,
"中国"
);
hashMap
.
put
(
"us"
,
"米国"
);
hashMap
.
put
(
"en"
,
"英国"
);
System
.
out
.
println
(
hashMap
);
/**
* Map 集合没有方法转成字符串,
* 可以按照自己的方法将其拼接成字符串
* 1、遍历map集合
*/
String
str
=
""
;
//用于存放遍历出来的字符串
Iterator
iterator
=
hashMap
.
keySet
().
iterator
();
while
(
iterator
.
hasNext
())
{
//2、拼接字符串
str
+=
hashMap
.
get
(
iterator
.
next
()).
toString
()+
","
;
}
System
.
out
.
println
(
str
);
}
}
}
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