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
e746da10
Commit
e746da10
authored
Sep 05, 2024
by
wdy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
科恩获取树状测试用例、获取标准要求
parent
5a7f5891
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
256 additions
and
2 deletions
+256
-2
StandardNewVO.java
...view/src/main/java/com/ruoyi/domain/vo/StandardNewVO.java
+25
-0
UseCaseNewVO.java
...eview/src/main/java/com/ruoyi/domain/vo/UseCaseNewVO.java
+20
-0
TestUseCaseService.java
...w/src/main/java/com/ruoyi/service/TestUseCaseService.java
+18
-0
TestUseCaseServiceImpl.java
...n/java/com/ruoyi/service/impl/TestUseCaseServiceImpl.java
+83
-0
TestUserCaseController.java
...w/src/main/java/com/ruoyi/web/TestUserCaseController.java
+24
-2
TestStandardListResponse.java
...java/com/ruoyi/web/response/TestStandardListResponse.java
+20
-0
TestUserCaseListNewResponse.java
...a/com/ruoyi/web/response/TestUserCaseListNewResponse.java
+20
-0
TestUrlUseCase.java
ruoyi-admin/src/test/java/com/ruoyi/TestUrlUseCase.java
+46
-0
No files found.
quality-review/src/main/java/com/ruoyi/domain/vo/StandardNewVO.java
0 → 100644
View file @
e746da10
package
com
.
ruoyi
.
domain
.
vo
;
import
lombok.Data
;
import
java.util.List
;
/**
* 标准要求VO
*/
@Data
public
class
StandardNewVO
{
// 标准要求id
private
String
id
;
// 标准要求章节号
private
String
serialNumber
;
// 标准要求
private
String
requirements
;
// 用例VO
List
<
UseCaseNewVO
>
useCases
;
}
quality-review/src/main/java/com/ruoyi/domain/vo/UseCaseNewVO.java
0 → 100644
View file @
e746da10
package
com
.
ruoyi
.
domain
.
vo
;
import
lombok.Data
;
/**
* 测试用例VO
*/
@Data
public
class
UseCaseNewVO
{
// 用例id
private
String
id
;
// 用例编号
private
String
customizedID
;
// 用例描述
private
String
description
;
}
quality-review/src/main/java/com/ruoyi/service/TestUseCaseService.java
View file @
e746da10
...
...
@@ -7,6 +7,8 @@ import com.ruoyi.domain.vo.UseCaseUrlVO;
import
com.ruoyi.web.request.TestUseCaseByScenarioRequest
;
import
com.ruoyi.web.request.TestUseCaseIdListRequest
;
import
com.ruoyi.web.request.TestUserCaseRequest
;
import
com.ruoyi.web.response.TestStandardListResponse
;
import
com.ruoyi.web.response.TestUserCaseListNewResponse
;
import
com.ruoyi.web.response.TestUserCaseListResponse
;
import
com.ruoyi.web.response.UseCaseResponse
;
...
...
@@ -81,4 +83,20 @@ public interface TestUseCaseService extends IService<TestUseCase> {
* @throws IOException
*/
List
<
String
>
selectCaseListByScenario
(
String
request
)
throws
IOException
;
/**
* 科恩获取测试用例新
* @param request
* @return
* @throws IOException
*/
TestUserCaseListNewResponse
getUseCaseListNew
(
String
request
)
throws
IOException
;
/**
* 科恩获取测试标准要求
* @param request
* @return
* @throws IOException
*/
TestStandardListResponse
getStandardList
(
String
request
)
throws
IOException
;
}
quality-review/src/main/java/com/ruoyi/service/impl/TestUseCaseServiceImpl.java
View file @
e746da10
...
...
@@ -10,6 +10,8 @@ import com.ruoyi.mapper.TestUseCaseMapper;
import
com.ruoyi.web.request.TestUseCaseByScenarioRequest
;
import
com.ruoyi.web.request.TestUseCaseIdListRequest
;
import
com.ruoyi.web.request.TestUserCaseRequest
;
import
com.ruoyi.web.response.TestStandardListResponse
;
import
com.ruoyi.web.response.TestUserCaseListNewResponse
;
import
com.ruoyi.web.response.TestUserCaseListResponse
;
import
com.ruoyi.web.response.UseCaseResponse
;
import
lombok.Data
;
...
...
@@ -270,6 +272,87 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU
.
collect
(
Collectors
.
toList
());
}
/**
* 科恩获取测试用例新
* @param request
* @return
* @throws IOException
*/
@Override
public
TestUserCaseListNewResponse
getUseCaseListNew
(
String
request
)
throws
IOException
{
TestUserCaseListNewResponse
userCaseResponse
=
new
TestUserCaseListNewResponse
();
OkHttpClient
client
=
new
OkHttpClient
().
newBuilder
().
build
();
MediaType
mediaType
=
MediaType
.
parse
(
"application/json"
);
// 创建请求体
RequestBody
body
=
RequestBody
.
create
(
mediaType
,
"{\"query\":\"query regulationAllUseCases($offset:OffsetConnectionInput$name: String!){regulationByName(name:$name){items(offset:$offset){ nodes{id serialNumber requirements useCases{id customizedID description}}totalCount}}}\",\"variables\":"
+
request
+
"}"
);
Request
requestKE
=
new
Request
.
Builder
()
.
url
(
"http://10.12.48.80:8089/api/query"
)
.
method
(
"POST"
,
body
)
.
addHeader
(
"Content-Type"
,
"application/json"
)
// TODO 连接
.
addHeader
(
"Authorization"
,
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjAsInRva2VuaWQiOjYxLCJ0eXBlIjoiYXBpIiwidXNlcm5hbWUiOiJhZG1pbiJ9.48Ggjx-FtOcecf73vAHn0XglwgLXZlfXxhXiLDHWWQE"
)
// .addHeader("Host", "10.12.48.80:8089")
// .addHeader("Origin", "http://10.12.48.80:8089")
// .addHeader("Referer", "http://10.12.48.80:8089/api/graphql/playground")
// .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36")
.
build
();
Response
response
=
client
.
newCall
(
requestKE
).
execute
();
String
string
=
response
.
body
().
string
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
string
);
// 获取测试用例
List
<
StandardNewVO
>
list
=
jsonObject
.
getJSONObject
(
"data"
).
getJSONObject
(
"regulationByName"
).
getJSONObject
(
"items"
).
getList
(
"nodes"
,
StandardNewVO
.
class
);
userCaseResponse
.
setUseCases
(
list
);
// 获取总条数
Integer
totalCount
=
(
Integer
)
jsonObject
.
getJSONObject
(
"data"
).
getJSONObject
(
"regulationByName"
).
getJSONObject
(
"items"
).
get
(
"totalCount"
);
userCaseResponse
.
setTotalCount
(
totalCount
);
return
userCaseResponse
;
}
@Override
public
TestStandardListResponse
getStandardList
(
String
request
)
throws
IOException
{
TestStandardListResponse
standardListResponse
=
new
TestStandardListResponse
();
OkHttpClient
client
=
new
OkHttpClient
().
newBuilder
().
build
();
MediaType
mediaType
=
MediaType
.
parse
(
"application/json"
);
// 创建请求体
RequestBody
body
=
RequestBody
.
create
(
mediaType
,
"{\"query\":\"query regulationItems($name:String!$offset:OffsetConnectionInput$orderBy:OrderByInput$searchFields:Map){regulationByName(name:$name){items(offset:$offset orderBy:$orderBy searchFields:$searchFields){totalCount nodes{id serialNumber requirements}}}}\",\"variables\":"
+
request
+
"}"
);
Request
requestKE
=
new
Request
.
Builder
()
.
url
(
"http://10.12.48.80:8089/api/query"
)
.
method
(
"POST"
,
body
)
.
addHeader
(
"Content-Type"
,
"application/json"
)
// TODO 连接
.
addHeader
(
"Authorization"
,
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjAsInRva2VuaWQiOjYxLCJ0eXBlIjoiYXBpIiwidXNlcm5hbWUiOiJhZG1pbiJ9.48Ggjx-FtOcecf73vAHn0XglwgLXZlfXxhXiLDHWWQE"
)
// .addHeader("Host", "10.12.48.80:8089")
// .addHeader("Origin", "http://10.12.48.80:8089")
// .addHeader("Referer", "http://10.12.48.80:8089/api/graphql/playground")
// .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36")
.
build
();
Response
response
=
client
.
newCall
(
requestKE
).
execute
();
String
string
=
response
.
body
().
string
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
string
);
// 获取测试用例
List
<
StandardNewVO
>
list
=
jsonObject
.
getJSONObject
(
"data"
).
getJSONObject
(
"regulationByName"
).
getJSONObject
(
"items"
).
getList
(
"nodes"
,
StandardNewVO
.
class
);
standardListResponse
.
setStandards
(
list
);
// 获取总条数
Integer
totalCount
=
(
Integer
)
jsonObject
.
getJSONObject
(
"data"
).
getJSONObject
(
"regulationByName"
).
getJSONObject
(
"items"
).
get
(
"totalCount"
);
standardListResponse
.
setTotalCount
(
totalCount
);
return
standardListResponse
;
}
}
...
...
quality-review/src/main/java/com/ruoyi/web/TestUserCaseController.java
View file @
e746da10
...
...
@@ -8,6 +8,8 @@ import com.ruoyi.service.TestUseCaseService;
import
com.ruoyi.web.request.TestUseCaseByScenarioRequest
;
import
com.ruoyi.web.request.TestUseCaseIdListRequest
;
import
com.ruoyi.web.request.TestUserCaseRequest
;
import
com.ruoyi.web.response.TestStandardListResponse
;
import
com.ruoyi.web.response.TestUserCaseListNewResponse
;
import
com.ruoyi.web.response.TestUserCaseListResponse
;
import
com.ruoyi.web.response.UseCaseResponse
;
import
io.swagger.annotations.Api
;
...
...
@@ -83,13 +85,33 @@ public class TestUserCaseController extends BaseController{
@ApiOperation
(
"查询测试用例分页查询(科恩)"
)
@Trace
@Tags
({
@Tag
(
key
=
"param"
,
value
=
"arg[0]"
),
@Tag
(
key
=
"result"
,
value
=
"returnedObj"
)})
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/getUseCaseList"
,
produces
=
"application/json;charset=UTF-8"
)
public
R
<
TestUserCaseListResponse
>
getUseCaseList
(
@Validated
@RequestBody
String
request
)
throws
IOException
{
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/getUseCaseList
Old
"
,
produces
=
"application/json;charset=UTF-8"
)
public
R
<
TestUserCaseListResponse
>
getUseCaseList
Old
(
@Validated
@RequestBody
String
request
)
throws
IOException
{
return
R
.
ok
(
testUseCaseService
.
getUseCaseList
(
request
));
}
@ApiOperation
(
"查询测试用例(科恩)新"
)
@Trace
@Tags
({
@Tag
(
key
=
"param"
,
value
=
"arg[0]"
),
@Tag
(
key
=
"result"
,
value
=
"returnedObj"
)})
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/getUseCaseList"
,
produces
=
"application/json;charset=UTF-8"
)
public
R
<
TestUserCaseListNewResponse
>
getUseCaseList
(
@Validated
@RequestBody
String
request
)
throws
IOException
{
return
R
.
ok
(
testUseCaseService
.
getUseCaseListNew
(
request
));
}
@ApiOperation
(
"查询测试标准要求(科恩)"
)
@Trace
@Tags
({
@Tag
(
key
=
"param"
,
value
=
"arg[0]"
),
@Tag
(
key
=
"result"
,
value
=
"returnedObj"
)})
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/getStandardList"
,
produces
=
"application/json;charset=UTF-8"
)
public
R
<
TestStandardListResponse
>
getStandardList
(
@Validated
@RequestBody
String
request
)
throws
IOException
{
return
R
.
ok
(
testUseCaseService
.
getStandardList
(
request
));
}
/**
* 科恩获取首页信息
...
...
quality-review/src/main/java/com/ruoyi/web/response/TestStandardListResponse.java
0 → 100644
View file @
e746da10
package
com
.
ruoyi
.
web
.
response
;
import
com.ruoyi.domain.vo.StandardNewVO
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
@ApiModel
(
value
=
"TestUserCaseListResponse"
,
description
=
"查询测试用例"
)
@Data
public
class
TestStandardListResponse
{
@ApiModelProperty
(
"测试标准要求"
)
List
<
StandardNewVO
>
standards
;
@ApiModelProperty
(
"总条数"
)
Integer
totalCount
;
}
quality-review/src/main/java/com/ruoyi/web/response/TestUserCaseListNewResponse.java
0 → 100644
View file @
e746da10
package
com
.
ruoyi
.
web
.
response
;
import
com.ruoyi.domain.vo.StandardNewVO
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
@ApiModel
(
value
=
"TestUserCaseListResponse"
,
description
=
"查询测试用例"
)
@Data
public
class
TestUserCaseListNewResponse
{
@ApiModelProperty
(
"测试用例"
)
List
<
StandardNewVO
>
useCases
;
@ApiModelProperty
(
"总条数"
)
Integer
totalCount
;
}
ruoyi-admin/src/test/java/com/ruoyi/TestUrlUseCase.java
0 → 100644
View file @
e746da10
package
com
.
ruoyi
;
import
com.alibaba.fastjson2.JSONObject
;
import
okhttp3.*
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
java.io.IOException
;
@SpringBootTest
public
class
TestUrlUseCase
{
@Test
public
void
test
()
throws
IOException
{
OkHttpClient
client
=
new
OkHttpClient
().
newBuilder
().
build
();
MediaType
mediaType
=
MediaType
.
parse
(
"application/json"
);
// 定义查询变量
String
variables
=
"{\n"
+
" \"offset\": {\n"
+
" \"offset\": 0,\n"
+
" \"limit\": 10\n"
+
" },\n"
+
" \"name\": \"汽车整车信息安全技术要求\"\n"
+
"}"
;
RequestBody
body
=
RequestBody
.
create
(
mediaType
,
"{\"query\":\"query regulationAllUseCases($offset:OffsetConnectionInput$name: String!){regulationByName(name:$name){items(offset:$offset){ nodes{id serialNumber requirements useCases{id customizedID description}}totalCount}}}\",\"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