Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
szpt
Project overview
Project overview
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
以墨为白
szpt
Commits
698d67ae
Commit
698d67ae
authored
Jan 09, 2025
by
夏敏伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
编写测试
parent
e0869171
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
2 deletions
+81
-2
src/main/java/com/zksy/szpt/domain/dto/SzptFwxxDTO.java
src/main/java/com/zksy/szpt/domain/dto/SzptFwxxDTO.java
+1
-0
src/test/java/com/zksy/szpt/MainTestX.java
src/test/java/com/zksy/szpt/MainTestX.java
+80
-2
No files found.
src/main/java/com/zksy/szpt/domain/dto/SzptFwxxDTO.java
View file @
698d67ae
...
@@ -181,6 +181,7 @@ public class SzptFwxxDTO {
...
@@ -181,6 +181,7 @@ public class SzptFwxxDTO {
/**
/**
* 健康码核验时间
* 健康码核验时间
*/
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
jkmhysj
;
private
Date
jkmhysj
;
/**
/**
...
...
src/test/java/com/zksy/szpt/MainTestX.java
View file @
698d67ae
...
@@ -4,6 +4,7 @@ import cn.hutool.crypto.digest.DigestUtil;
...
@@ -4,6 +4,7 @@ import cn.hutool.crypto.digest.DigestUtil;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.zksy.szpt.domain.dto.SzptClockInDTO
;
import
com.zksy.szpt.domain.dto.SzptClockInDTO
;
import
com.zksy.szpt.domain.dto.SzptFwxxDTO
;
import
com.zksy.szpt.service.AppStoreService
;
import
com.zksy.szpt.service.AppStoreService
;
import
com.zksy.szpt.util.EncryptUtil
;
import
com.zksy.szpt.util.EncryptUtil
;
import
com.zksy.szpt.util.SignatureUtil
;
import
com.zksy.szpt.util.SignatureUtil
;
...
@@ -15,6 +16,7 @@ import org.springframework.web.reactive.function.client.WebClient;
...
@@ -15,6 +16,7 @@ import org.springframework.web.reactive.function.client.WebClient;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.Date
;
@SpringBootTest
()
@SpringBootTest
()
public
class
MainTestX
{
public
class
MainTestX
{
...
@@ -42,7 +44,7 @@ public class MainTestX {
...
@@ -42,7 +44,7 @@ public class MainTestX {
//请求参数
//请求参数
SzptClockInDTO
szptClockInDTO
=
new
SzptClockInDTO
();
SzptClockInDTO
szptClockInDTO
=
new
SzptClockInDTO
();
szptClockInDTO
.
setId
(
100
);
szptClockInDTO
.
setId
(
100
);
szptClockInDTO
.
setCsid
(
"123456"
);
szptClockInDTO
.
setCsid
(
"123456
111111111111111
"
);
szptClockInDTO
.
setSbqd
(
"123456"
);
szptClockInDTO
.
setSbqd
(
"123456"
);
szptClockInDTO
.
setXbqt
(
"123456"
);
szptClockInDTO
.
setXbqt
(
"123456"
);
szptClockInDTO
.
setXcqk
(
"1"
);
szptClockInDTO
.
setXcqk
(
"1"
);
...
@@ -73,7 +75,7 @@ public class MainTestX {
...
@@ -73,7 +75,7 @@ public class MainTestX {
.
baseUrl
(
"http://localhost:8086"
)
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/index/
add
SzptClockIn"
)
String
response
=
webClient
.
post
().
uri
(
"/rest/index/
update
SzptClockIn"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
...
@@ -84,4 +86,80 @@ public class MainTestX {
...
@@ -84,4 +86,80 @@ public class MainTestX {
.
block
();
.
block
();
System
.
out
.
println
(
response
);
System
.
out
.
println
(
response
);
}
}
@Test
@DisplayName
(
"房屋信息"
)
public
void
szptFwxxTest
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
SzptFwxxDTO
szptFwxxDTO
=
new
SzptFwxxDTO
();
szptFwxxDTO
.
setQyid
(
"2"
);
szptFwxxDTO
.
setCsid
(
"123456"
);
szptFwxxDTO
.
setFwjc
(
"123456"
);
szptFwxxDTO
.
setJzqk
(
"1"
);
szptFwxxDTO
.
setCzyt
(
"1"
);
szptFwxxDTO
.
setHxjg
(
"1"
);
szptFwxxDTO
.
setFxid
(
"123456"
);
szptFwxxDTO
.
setCzba
(
"2"
);
szptFwxxDTO
.
setCzbah
(
"123456"
);
szptFwxxDTO
.
setCzbaqs
(
"1"
);
szptFwxxDTO
.
setCzbajz
(
"1"
);
szptFwxxDTO
.
setFzxm
(
"1"
);
szptFwxxDTO
.
setFzsfzh
(
"1"
);
szptFwxxDTO
.
setFzryid
(
"1"
);
szptFwxxDTO
.
setFzlxdh
(
"1"
);
szptFwxxDTO
.
setFwlc
(
"1"
);
szptFwxxDTO
.
setFwfjh
(
"1"
);
szptFwxxDTO
.
setFwzt
(
"1"
);
szptFwxxDTO
.
setQjms
(
"1"
);
szptFwxxDTO
.
setQjzt
(
"1"
);
szptFwxxDTO
.
setZjqjsj
(
new
Date
());
szptFwxxDTO
.
setZdrq
(
"1"
);
szptFwxxDTO
.
setZdzq
(
"1"
);
szptFwxxDTO
.
setFwcs
(
"1"
);
szptFwxxDTO
.
setGlrlx
(
"1"
);
szptFwxxDTO
.
setGlrxm
(
"1"
);
szptFwxxDTO
.
setGlrsfzh
(
"1"
);
szptFwxxDTO
.
setGlrryid
(
"1"
);
szptFwxxDTO
.
setGlrlxdh
(
"1"
);
szptFwxxDTO
.
setGlrgsmc
(
"1"
);
szptFwxxDTO
.
setZcsid
(
"1"
);
szptFwxxDTO
.
setBz
(
"1"
);
szptFwxxDTO
.
setFkdjzdsh
(
"1"
);
szptFwxxDTO
.
setQtfwyt
(
"1"
);
szptFwxxDTO
.
setJkmhysj
(
new
Date
());
szptFwxxDTO
.
setSjgsdwdm
(
"340102"
);
szptFwxxDTO
.
setSjgsdwmc
(
"1"
);
szptFwxxDTO
.
setFzzjzp
(
"1"
);
String
json
=
null
;
try
{
json
=
objectMapper
.
writeValueAsString
(
szptFwxxDTO
);
}
catch
(
JsonProcessingException
e
)
{
Assertions
.
fail
(
"json序列化失败"
);
}
//请求体加密
json
=
EncryptUtil
.
getInstance
().
AESEncode
(
json
,
secretKey
);
//签名appId+nonce+timestampStr+aes(body)
String
data
=
String
.
format
(
"%s%s%s%s"
,
appId
,
nonce
,
timestampStr
,
json
);
String
generatedSignature
=
DigestUtil
.
md5Hex
(
data
);
//请求
WebClient
webClient
=
WebClient
.
builder
()
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/index/addSzptFwxx"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
.
header
(
SignatureUtil
.
SIGNATURE
,
generatedSignature
)
.
body
(
Mono
.
just
(
szptFwxxDTO
),
SzptFwxxDTO
.
class
)
.
retrieve
()
.
bodyToMono
(
String
.
class
)
.
block
();
System
.
out
.
println
(
response
);
}
}
}
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