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
3b0b39c9
Commit
3b0b39c9
authored
Mar 23, 2020
by
zhouzihao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix-对报错微弱的优化
parent
595f1867
Pipeline
#97
failed with stages
in 25 seconds
Changes
20
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
381 additions
and
219 deletions
+381
-219
src/main/java/com/vandyo/sentry/core/Tmp.java
src/main/java/com/vandyo/sentry/core/Tmp.java
+42
-33
src/main/java/com/vandyo/sentry/core/cases/BannerListDecorator.java
...ava/com/vandyo/sentry/core/cases/BannerListDecorator.java
+24
-14
src/main/java/com/vandyo/sentry/core/cases/CarDetectDecorator.java
...java/com/vandyo/sentry/core/cases/CarDetectDecorator.java
+23
-15
src/main/java/com/vandyo/sentry/core/cases/CarInfoDecorator.java
...n/java/com/vandyo/sentry/core/cases/CarInfoDecorator.java
+23
-15
src/main/java/com/vandyo/sentry/core/cases/CarListDecorator.java
...n/java/com/vandyo/sentry/core/cases/CarListDecorator.java
+34
-24
src/main/java/com/vandyo/sentry/core/cases/CarLocausPointListDecorator.java
...vandyo/sentry/core/cases/CarLocausPointListDecorator.java
+2
-1
src/main/java/com/vandyo/sentry/core/cases/CarLocusEventDecorator.java
.../com/vandyo/sentry/core/cases/CarLocusEventDecorator.java
+2
-1
src/main/java/com/vandyo/sentry/core/cases/CarLocusPageDecorator.java
...a/com/vandyo/sentry/core/cases/CarLocusPageDecorator.java
+2
-1
src/main/java/com/vandyo/sentry/core/cases/CarLocusStatisticsDecorator.java
...vandyo/sentry/core/cases/CarLocusStatisticsDecorator.java
+2
-1
src/main/java/com/vandyo/sentry/core/cases/CarStatusDecorator.java
...java/com/vandyo/sentry/core/cases/CarStatusDecorator.java
+23
-15
src/main/java/com/vandyo/sentry/core/cases/Case.java
src/main/java/com/vandyo/sentry/core/cases/Case.java
+2
-1
src/main/java/com/vandyo/sentry/core/cases/CaseDecorator.java
...main/java/com/vandyo/sentry/core/cases/CaseDecorator.java
+2
-1
src/main/java/com/vandyo/sentry/core/cases/DayReportDecorator.java
...java/com/vandyo/sentry/core/cases/DayReportDecorator.java
+22
-15
src/main/java/com/vandyo/sentry/core/cases/LoginCase.java
src/main/java/com/vandyo/sentry/core/cases/LoginCase.java
+28
-18
src/main/java/com/vandyo/sentry/core/cases/LogoutDecorator.java
...in/java/com/vandyo/sentry/core/cases/LogoutDecorator.java
+24
-14
src/main/java/com/vandyo/sentry/core/cases/MallGoodsDecorator.java
...java/com/vandyo/sentry/core/cases/MallGoodsDecorator.java
+24
-14
src/main/java/com/vandyo/sentry/core/cases/MsgGetDecorator.java
...in/java/com/vandyo/sentry/core/cases/MsgGetDecorator.java
+28
-17
src/main/java/com/vandyo/sentry/core/cases/UserInfoDecorator.java
.../java/com/vandyo/sentry/core/cases/UserInfoDecorator.java
+27
-17
src/main/java/com/vandyo/sentry/core/exceptions/CaseException.java
...java/com/vandyo/sentry/core/exceptions/CaseException.java
+45
-0
src/main/java/com/vandyo/sentry/core/tools/Signature.java
src/main/java/com/vandyo/sentry/core/tools/Signature.java
+2
-2
No files found.
src/main/java/com/vandyo/sentry/core/Tmp.java
View file @
3b0b39c9
...
...
@@ -7,6 +7,8 @@ import com.vandyo.sentry.core.collectionMachine.CollectionMachine;
import
com.vandyo.sentry.core.collectionMachine.EmailDealer
;
import
com.vandyo.sentry.core.config.CheckMetaConfig
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -39,7 +41,7 @@ public class Tmp {
@Scheduled
(
fixedRate
=
1000
*
30
)
public
void
test
()
{
// log.info("we run it {} times", ++times);
try
{
Case
case1
=
null
;
// 上线前使用这段代码
// 登录
...
...
@@ -71,11 +73,18 @@ public class Tmp {
// banner接口
Case
case2
=
null
;
case2
=
new
EmptyCase
(
sId
,
uid
);
case2
=
new
EmptyCase
(
sId
,
uid
);
case2
=
new
BannerListDecorator
(
case2
);
// 获取商品列表
case2
=
new
MallGoodsDecorator
(
case2
);
case2
.
check
();
}
catch
(
CaseException
e
){
Res
res
=
new
Res
();
res
.
setKey
(
e
.
getKey
());
res
.
setStatus
(
e
.
getStatus
());
res
.
setSuccess
(
false
);
CollectionMachine
.
post
(
res
);
}
log
.
info
(
"over!"
);
}
...
...
src/main/java/com/vandyo/sentry/core/cases/BannerListDecorator.java
View file @
3b0b39c9
...
...
@@ -4,7 +4,9 @@ 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.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
...
...
@@ -22,7 +24,7 @@ public class BannerListDecorator extends CaseDecorator {
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
...
@@ -32,6 +34,7 @@ public class BannerListDecorator extends CaseDecorator {
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"uid"
,
oldRes
.
getUId
());
paramMap
.
put
(
"type"
,
"1"
);
try
{
HttpResponse
response
=
HttpRequest
.
post
(
Signature
.
host
+
bannerListUrl
)
.
body
(
JSONUtil
.
parseFromMap
(
paramMap
).
toString
())
.
execute
();
...
...
@@ -46,6 +49,13 @@ public class BannerListDecorator extends CaseDecorator {
newRes
.
setSuccess
(
false
);
}
return
newRes
;
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
bannerListUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
bannerListUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
else
{
oldRes
.
setIgnore
(
true
);
return
oldRes
;
...
...
src/main/java/com/vandyo/sentry/core/cases/CarDetectDecorator.java
View file @
3b0b39c9
...
...
@@ -6,6 +6,7 @@ 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.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
...
...
@@ -28,7 +29,7 @@ public class CarDetectDecorator extends CaseDecorator {
* @return
*/
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
...
@@ -44,22 +45,29 @@ public class CarDetectDecorator extends CaseDecorator {
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"cid"
,
cid
);
paramMap
.
put
(
"uid"
,
oldRes
.
getUId
());
try
{
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
carDetectUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
paramMap
,
oldRes
.
getSId
()))
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
paramMap
,
oldRes
.
getSId
()))
).
execute
();
if
(
response
.
isOk
())
{
if
(
response
.
isOk
())
{
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
//todo 检测 返回值可用性
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
true
);
}
else
{
}
else
{
newRes
.
setKey
(
carDetectUrl
);
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
}
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
carDetectUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
carDetectUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
return
newRes
;
}
else
{
...
...
src/main/java/com/vandyo/sentry/core/cases/CarInfoDecorator.java
View file @
3b0b39c9
...
...
@@ -7,6 +7,7 @@ import cn.hutool.json.JSONUtil;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
...
...
@@ -25,7 +26,7 @@ public class CarInfoDecorator extends CaseDecorator {
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
...
@@ -41,22 +42,29 @@ public class CarInfoDecorator extends CaseDecorator {
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"cid"
,
cid
);
paramMap
.
put
(
"uid"
,
oldRes
.
getUId
());
try
{
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
carInfoUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
paramMap
,
oldRes
.
getSId
()))
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
paramMap
,
oldRes
.
getSId
()))
).
execute
();
if
(
response
.
isOk
())
{
if
(
response
.
isOk
())
{
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
//todo 检测 返回值可用性
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
true
);
}
else
{
}
else
{
newRes
.
setKey
(
carInfoUrl
);
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
}
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
carInfoUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
carInfoUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
...
...
src/main/java/com/vandyo/sentry/core/cases/CarListDecorator.java
View file @
3b0b39c9
...
...
@@ -8,6 +8,7 @@ import cn.hutool.json.JSONUtil;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
...
...
@@ -23,38 +24,47 @@ public class CarListDecorator extends CaseDecorator {
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
data
=
new
HashMap
<>();
data
.
put
(
"uid"
,
oldRes
.
getUId
());
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
carListUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
data
,
oldRes
.
getSId
())))
try
{
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
carListUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
data
,
oldRes
.
getSId
())))
.
execute
();
Res
<
Map
<
String
,
String
>>
newRes
=
new
Res
<>();
newRes
.
setSId
(
oldRes
.
getSId
());
newRes
.
setUId
(
oldRes
.
getUId
());
if
(
response
.
isOk
())
{
if
(
response
.
isOk
())
{
JSONObject
json
=
JSONUtil
.
parseObj
(
response
.
body
());
JSONArray
list
=
json
.
getJSONArray
(
"result"
);
if
(
Objects
.
isNull
(
list
)
||
list
.
size
()
<
1
)
{
if
(
Objects
.
isNull
(
list
)
||
list
.
size
()
<
1
)
{
newRes
.
setSuccess
(
false
);
newRes
.
setStatus
(
ErrStatus
.
ErrUnexpected
);
}
else
{
Map
<
String
,
String
>
carMap
=
new
HashMap
<>();
}
else
{
Map
<
String
,
String
>
carMap
=
new
HashMap
<>();
JSONObject
car
=
(
JSONObject
)
list
.
get
(
0
);
carMap
.
put
(
"cid"
,
car
.
getStr
(
"cid"
));
carMap
.
put
(
"cid"
,
car
.
getStr
(
"cid"
));
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
true
);
}
}
else
{
}
else
{
newRes
.
setKey
(
carListUrl
);
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
carListUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
carListUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
else
{
oldRes
.
setIgnore
(
true
);
return
oldRes
;
...
...
src/main/java/com/vandyo/sentry/core/cases/CarLocausPointListDecorator.java
View file @
3b0b39c9
...
...
@@ -6,6 +6,7 @@ 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.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
...
...
@@ -24,7 +25,7 @@ public class CarLocausPointListDecorator extends CaseDecorator{
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
...
src/main/java/com/vandyo/sentry/core/cases/CarLocusEventDecorator.java
View file @
3b0b39c9
...
...
@@ -6,6 +6,7 @@ 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.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
...
...
@@ -24,7 +25,7 @@ public class CarLocusEventDecorator extends CaseDecorator {
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
...
src/main/java/com/vandyo/sentry/core/cases/CarLocusPageDecorator.java
View file @
3b0b39c9
...
...
@@ -7,6 +7,7 @@ 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.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
...
...
@@ -25,7 +26,7 @@ public class CarLocusPageDecorator extends CaseDecorator {
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
...
src/main/java/com/vandyo/sentry/core/cases/CarLocusStatisticsDecorator.java
View file @
3b0b39c9
...
...
@@ -6,6 +6,7 @@ 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.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
...
...
@@ -24,7 +25,7 @@ public class CarLocusStatisticsDecorator extends CaseDecorator {
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
...
src/main/java/com/vandyo/sentry/core/cases/CarStatusDecorator.java
View file @
3b0b39c9
...
...
@@ -7,6 +7,7 @@ import cn.hutool.json.JSONUtil;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
...
...
@@ -25,7 +26,7 @@ public class CarStatusDecorator extends CaseDecorator{
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
...
@@ -42,22 +43,29 @@ public class CarStatusDecorator extends CaseDecorator{
paramMap
.
put
(
"cid"
,
cid
);
paramMap
.
put
(
"uid"
,
oldRes
.
getUId
());
paramMap
.
put
(
"start"
,
String
.
valueOf
(
System
.
currentTimeMillis
()/
1000
));
try
{
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
carStatusUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
paramMap
,
oldRes
.
getSId
()))
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
paramMap
,
oldRes
.
getSId
()))
).
execute
();
if
(
response
.
isOk
())
{
if
(
response
.
isOk
())
{
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
//todo 检测 返回值可用性
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
true
);
}
else
{
}
else
{
newRes
.
setKey
(
carStatusUrl
);
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
}
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
carStatusUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
carStatusUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
...
...
src/main/java/com/vandyo/sentry/core/cases/Case.java
View file @
3b0b39c9
package
com
.
vandyo
.
sentry
.
core
.
cases
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
java.util.Map
;
public
abstract
class
Case
{
public
abstract
Res
<
Map
<
String
,
String
>>
check
();
public
abstract
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
;
}
src/main/java/com/vandyo/sentry/core/cases/CaseDecorator.java
View file @
3b0b39c9
package
com
.
vandyo
.
sentry
.
core
.
cases
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
java.util.Map
;
...
...
@@ -12,7 +13,7 @@ public abstract class CaseDecorator extends Case {
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
// fixme: 依赖上一个请求的数据都要对上一个是否成功进行不同的处理
// ?? 如果没有需要的值怎么处理业务逻辑呢??比如车列表内没有车?(这样要保证测试数据都有)
return
this
.
aCase
.
check
();
...
...
src/main/java/com/vandyo/sentry/core/cases/DayReportDecorator.java
View file @
3b0b39c9
...
...
@@ -6,6 +6,7 @@ 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.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
...
...
@@ -24,7 +25,7 @@ public class DayReportDecorator extends CaseDecorator {
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
...
@@ -46,21 +47,27 @@ public class DayReportDecorator extends CaseDecorator {
signMap
.
put
(
"Data"
,
JSONUtil
.
parseFromMap
(
paramMap
).
toString
());
Map
<
String
,
String
>
signedMap
=
Signature
.
sign
(
signMap
,
oldRes
.
getSId
());
signedMap
.
remove
(
"Data"
);
HttpResponse
response
=
HttpRequest
.
post
(
Signature
.
host
+
dayReportUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
signedMap
))
try
{
HttpResponse
response
=
HttpRequest
.
post
(
Signature
.
host
+
dayReportUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
signedMap
))
.
body
(
JSONUtil
.
parseFromMap
(
paramMap
).
toString
())
.
execute
();
if
(
response
.
isOk
()){
if
(
response
.
isOk
())
{
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
//todo 检测 返回值可用性
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
true
);
}
else
{
}
else
{
newRes
.
setKey
(
dayReportUrl
);
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
}
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
dayReportUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
dayReportUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
return
newRes
;
}
else
{
...
...
src/main/java/com/vandyo/sentry/core/cases/LoginCase.java
View file @
3b0b39c9
...
...
@@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
...
...
@@ -24,12 +26,13 @@ public class LoginCase extends Case {
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Map
<
String
,
String
>
data
=
new
HashMap
<>();
// data.put("mobile", "18623414467");
data
.
put
(
"mobile"
,
mobile
);
// data.put("password", "5f83f54fb34e2eed0439d37d80f5b1a3");
data
.
put
(
"password"
,
pwd
);
try
{
HttpResponse
response
=
HttpRequest
.
post
(
Signature
.
host
+
loginUrl
)
.
body
(
JSONUtil
.
parseFromMap
(
data
).
toString
()).
execute
();
Res
<
Map
<
String
,
String
>>
res
=
new
Res
<>();
...
...
@@ -48,5 +51,12 @@ public class LoginCase extends Case {
}
CollectionMachine
.
post
(
res
);
return
res
;
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
loginUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
loginUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
}
src/main/java/com/vandyo/sentry/core/cases/LogoutDecorator.java
View file @
3b0b39c9
...
...
@@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
...
...
@@ -23,11 +25,12 @@ public class LogoutDecorator extends CaseDecorator {
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
data
=
new
HashMap
<>();
data
.
put
(
"uid"
,
oldRes
.
getUId
());
try
{
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
logoutUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
data
,
oldRes
.
getSId
())))
.
execute
();
...
...
@@ -42,6 +45,13 @@ public class LogoutDecorator extends CaseDecorator {
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
logoutUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
logoutUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
else
{
oldRes
.
setIgnore
(
true
);
return
oldRes
;
...
...
src/main/java/com/vandyo/sentry/core/cases/MallGoodsDecorator.java
View file @
3b0b39c9
...
...
@@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
...
...
@@ -23,9 +25,10 @@ public class MallGoodsDecorator extends CaseDecorator {
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
super
.
check
();
Map
<
String
,
String
>
data
=
new
HashMap
<>();
try
{
HttpResponse
response
=
HttpRequest
.
post
(
Signature
.
host
+
mallGoodsUrl
)
.
body
(
"{}"
)
.
execute
();
...
...
@@ -40,5 +43,12 @@ public class MallGoodsDecorator extends CaseDecorator {
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
mallGoodsUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
mallGoodsUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
}
src/main/java/com/vandyo/sentry/core/cases/MsgGetDecorator.java
View file @
3b0b39c9
...
...
@@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
...
...
@@ -23,12 +25,14 @@ public class MsgGetDecorator extends CaseDecorator {
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
data
=
new
HashMap
<>();
data
.
put
(
"uid"
,
oldRes
.
getUId
());
data
.
put
(
"size"
,
String
.
valueOf
(
1
));
try
{
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
msgHost
+
msgGetUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
data
,
oldRes
.
getSId
())))
.
execute
();
...
...
@@ -46,6 +50,13 @@ public class MsgGetDecorator extends CaseDecorator {
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
msgGetUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
msgGetUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
else
{
oldRes
.
setIgnore
(
true
);
return
oldRes
;
...
...
src/main/java/com/vandyo/sentry/core/cases/UserInfoDecorator.java
View file @
3b0b39c9
...
...
@@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
...
...
@@ -24,11 +26,12 @@ public class UserInfoDecorator extends CaseDecorator {
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
data
=
new
HashMap
<>();
data
.
put
(
"uid"
,
oldRes
.
getUId
());
try
{
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
UserInfoUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
data
,
oldRes
.
getSId
())))
.
execute
();
...
...
@@ -46,6 +49,13 @@ public class UserInfoDecorator extends CaseDecorator {
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
catch
(
Exception
e
)
{
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
))
{
throw
new
CaseException
(
UserInfoUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
UserInfoUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
else
{
oldRes
.
setIgnore
(
true
);
return
oldRes
;
...
...
src/main/java/com/vandyo/sentry/core/exceptions/CaseException.java
0 → 100644
View file @
3b0b39c9
package
com
.
vandyo
.
sentry
.
core
.
exceptions
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
public
class
CaseException
extends
Exception
{
private
String
key
;
private
ErrStatus
status
;
public
CaseException
(
String
key
,
ErrStatus
status
)
{
this
.
key
=
key
;
this
.
status
=
status
;
}
public
CaseException
(
String
message
,
String
key
,
ErrStatus
status
)
{
super
(
message
);
this
.
key
=
key
;
this
.
status
=
status
;
}
public
CaseException
(
String
message
,
Throwable
cause
,
String
key
,
ErrStatus
status
)
{
super
(
message
,
cause
);
this
.
key
=
key
;
this
.
status
=
status
;
}
public
CaseException
(
Throwable
cause
,
String
key
,
ErrStatus
status
)
{
super
(
cause
);
this
.
key
=
key
;
this
.
status
=
status
;
}
public
CaseException
(
String
message
,
Throwable
cause
,
boolean
enableSuppression
,
boolean
writableStackTrace
,
String
key
,
ErrStatus
status
)
{
super
(
message
,
cause
,
enableSuppression
,
writableStackTrace
);
this
.
key
=
key
;
this
.
status
=
status
;
}
public
String
getKey
()
{
return
key
;
}
public
ErrStatus
getStatus
()
{
return
status
;
}
}
src/main/java/com/vandyo/sentry/core/tools/Signature.java
View file @
3b0b39c9
...
...
@@ -13,9 +13,9 @@ public class Signature {
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
Tmp
.
class
);
// need be change to product env
// public static final String host = "http://10.100.12.42:8080";
public
static
final
String
host
=
"http://api.vandyo.com:80"
;
public
static
final
String
host
=
"http://api.vandyo.com:80
111
"
;
// public static final String msgHost = "http://10.100.12.42:8089";
public
static
final
String
msgHost
=
"http://msg.vandyo.com:80"
;
public
static
final
String
msgHost
=
"http://msg.vandyo.com:80
11
"
;
/**
* 生成签名
...
...
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