Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
car-database-api
Project
Project
Details
Activity
Releases
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
中汽研标准应用数据库
car-database-api
Commits
f54d9f5f
Commit
f54d9f5f
authored
Sep 02, 2024
by
wdy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
连接科恩接口
parent
6b689fcf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
TestUrlK.java
ruoyi-admin/src/test/java/com/ruoyi/TestUrlK.java
+44
-0
No files found.
ruoyi-admin/src/test/java/com/ruoyi/TestUrlK.java
0 → 100644
View file @
f54d9f5f
package
com
.
ruoyi
;
import
com.alibaba.fastjson2.JSONObject
;
import
com.ruoyi.domain.vo.UseCaseUrlVO
;
import
okhttp3.*
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
java.io.IOException
;
import
java.util.List
;
@SpringBootTest
public
class
TestUrlK
{
@Test
public
void
test
()
throws
IOException
{
OkHttpClient
client
=
new
OkHttpClient
().
newBuilder
().
build
();
MediaType
mediaType
=
MediaType
.
parse
(
"application/json"
);
// 定义查询变量
String
variables
=
"{\n"
+
" \"regulationName\":\"汽车整车信息安全技术要求\",\n"
+
" \"matchUseCases\": [\"7.1.1.1-1\", \"7.2.11-3\"]\n"
+
"}"
;
RequestBody
body
=
RequestBody
.
create
(
mediaType
,
"{\"query\":\"query regulationItemsByUseCase($regulationName:String!$matchUseCases:[String!]!){regulationByName(name:$regulationName){itemsByUseCase(match:$matchUseCases){id serialNumber requirements useCases{id displayID customizedID class name description remediation requirements riskLevel method{name}scenario{name}}}}}\",\"variables\":"
+
variables
+
"}"
);
Request
requestKs
=
new
Request
.
Builder
()
.
url
(
"http://10.12.48.80:8089/api/query"
)
.
method
(
"POST"
,
body
)
.
addHeader
(
"Content-Type"
,
"application/json"
)
.
addHeader
(
"Authorization"
,
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjAsInRva2VuaWQiOjYxLCJ0eXBlIjoiYXBpIiwidXNlcm5hbWUiOiJhZG1pbiJ9.48Ggjx-FtOcecf73vAHn0XglwgLXZlfXxhXiLDHWWQE"
)
.
build
();
Response
response
=
client
.
newCall
(
requestKs
).
execute
();
String
string
=
response
.
body
().
string
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
string
);
System
.
out
.
println
(
"jsonObject = "
+
jsonObject
);
// List<UseCaseUrlVO> list = jsonObject.getJSONObject("data").getJSONObject("useCases").getList("nodes", UseCaseUrlVO.class);
// list.forEach(item -> {
// System.out.println("item = " + item);
// });
}
}
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