Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
java-devop-sentry
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
zhouzihao
java-devop-sentry
Commits
30ac403a
Commit
30ac403a
authored
Mar 13, 2020
by
zhouzihao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev-添加车动态接口测试的实现
parent
e3a699e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
0 deletions
+66
-0
src/main/java/com/vandyo/sentry/core/Tmp.java
src/main/java/com/vandyo/sentry/core/Tmp.java
+1
-0
src/main/java/com/vandyo/sentry/core/cases/CarStatusDecorator.java
...java/com/vandyo/sentry/core/cases/CarStatusDecorator.java
+65
-0
No files found.
src/main/java/com/vandyo/sentry/core/Tmp.java
View file @
30ac403a
...
@@ -29,6 +29,7 @@ public class Tmp {
...
@@ -29,6 +29,7 @@ public class Tmp {
case1
=
new
CarListDecorator
(
case1
);
case1
=
new
CarListDecorator
(
case1
);
case1
=
new
CarInfoDecorator
(
case1
);
case1
=
new
CarInfoDecorator
(
case1
);
case1
=
new
CarDetectDecorator
(
case1
);
case1
=
new
CarDetectDecorator
(
case1
);
case1
=
new
CarStatusDecorator
(
case1
);
case1
.
check
();
case1
.
check
();
}
}
...
...
src/main/java/com/vandyo/sentry/core/cases/CarStatusDecorator.java
0 → 100644
View file @
30ac403a
package
com
.
vandyo
.
sentry
.
core
.
cases
;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
/**
* 车动态测试实例
*/
public
class
CarStatusDecorator
extends
CaseDecorator
{
private
final
static
String
carStatusUrl
=
"/carDynamic/api/status/car/state/get"
;
public
CarStatusDecorator
(
Case
aCase
)
{
super
(
aCase
);
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
Res
<
Map
<
String
,
String
>>
newRes
=
new
Res
<>();
newRes
.
setSId
(
oldRes
.
getSId
());
newRes
.
setUId
(
oldRes
.
getUId
());
if
(
Objects
.
isNull
(
carMap
)
||
!
carMap
.
containsKey
(
"cid"
)){
newRes
.
setStatus
(
ErrStatus
.
ErrUnexpected
);
newRes
.
setSuccess
(
false
);
}
else
{
String
cid
=
carMap
.
get
(
"cid"
);
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"cid"
,
cid
);
paramMap
.
put
(
"uid"
,
oldRes
.
getUId
());
paramMap
.
put
(
"start"
,
String
.
valueOf
(
System
.
currentTimeMillis
()/
1000
));
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
carStatusUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
paramMap
,
oldRes
.
getSId
()))
).
execute
();
if
(
response
.
isOk
()){
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
//todo 检测 返回值可用性
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
true
);
}
else
{
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
}
}
return
newRes
;
}
else
{
return
oldRes
;
}
}
}
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