Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vehicle-quality-review
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
王飞
vehicle-quality-review
Commits
cac06825
Commit
cac06825
authored
Jun 17, 2024
by
wdy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试用例二维矩阵(pad)
parent
77c29c41
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
0 deletions
+109
-0
UseCaseVO.java
...y-review/src/main/java/com/ruoyi/domain/vo/UseCaseVO.java
+2
-0
MatrixService.java
...review/src/main/java/com/ruoyi/service/MatrixService.java
+1
-0
MatrixServiceImpl.java
...c/main/java/com/ruoyi/service/impl/MatrixServiceImpl.java
+98
-0
MatrixController.java
...-review/src/main/java/com/ruoyi/web/MatrixController.java
+8
-0
No files found.
quality-review/src/main/java/com/ruoyi/domain/vo/UseCaseVO.java
View file @
cac06825
...
@@ -13,6 +13,8 @@ public class UseCaseVO {
...
@@ -13,6 +13,8 @@ public class UseCaseVO {
private
String
name
;
private
String
name
;
private
String
displayID
;
// 测试场景
// 测试场景
private
String
scenarioName
;
private
String
scenarioName
;
private
ScenarioKEVO
scenario
;
private
ScenarioKEVO
scenario
;
...
...
quality-review/src/main/java/com/ruoyi/service/MatrixService.java
View file @
cac06825
...
@@ -10,4 +10,5 @@ public interface MatrixService {
...
@@ -10,4 +10,5 @@ public interface MatrixService {
MatrixResponse
getMatrixForUrl
()
throws
IOException
;
MatrixResponse
getMatrixForUrl
()
throws
IOException
;
MatrixResponse
getMatrixForUrlPad
()
throws
IOException
;
}
}
quality-review/src/main/java/com/ruoyi/service/impl/MatrixServiceImpl.java
View file @
cac06825
...
@@ -115,6 +115,70 @@ public class MatrixServiceImpl implements MatrixService {
...
@@ -115,6 +115,70 @@ public class MatrixServiceImpl implements MatrixService {
return
response
;
return
response
;
}
}
@Override
public
MatrixResponse
getMatrixForUrlPad
()
throws
IOException
{
//以post形式请求接口
String
result
=
HttpUtil
.
post
(
"https://10.12.48.78:8090/DescribeScenarioTestTypeList"
,
""
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
result
);
// 获取测试场景列表
List
<
ScenarioVO
>
scenarioList
=
jsonObject
.
getList
(
"scenario_list"
,
ScenarioVO
.
class
);
if
(
scenarioList
!=
null
&&
scenarioList
.
size
()
!=
0
)
{
for
(
int
i
=
0
;
i
<
scenarioList
.
size
();
i
++)
{
scenarioList
.
get
(
i
).
setId
((
long
)
i
);
}
}
// 获取测试方法列表
List
<
TestTypeVO
>
testTypeList
=
jsonObject
.
getList
(
"test_type_list"
,
TestTypeVO
.
class
);
if
(
testTypeList
!=
null
&&
testTypeList
.
size
()
!=
0
)
{
for
(
int
i
=
0
;
i
<
testTypeList
.
size
();
i
++)
{
testTypeList
.
get
(
i
).
setId
((
long
)
i
);
}
}
// 获取测试用例
OkHttpClient
client
=
new
OkHttpClient
().
newBuilder
().
build
();
MediaType
mediaType
=
MediaType
.
parse
(
"application/json"
);
// 创建请求体
String
request
=
"{\"offset\": {\n"
+
" \"offset\": 0,\n"
+
" \"limit\": 9999\n"
+
" },\n"
+
" \"searchFields\":{\n"
+
" \"name\": \"\",\n"
+
" \"scenario\":\"\",\n"
+
" \"method\":\"\"\n"
+
" }}"
;
RequestBody
body
=
RequestBody
.
create
(
mediaType
,
"{\"query\":\"query useCases($offset:OffsetConnectionInput$orderBy:OrderByInput$filter:Map$search:String$searchFields:Map){useCases(offset:$offset orderBy:$orderBy filterFields:$filter search:$search searchFields:$searchFields){nodes{id displayID class name description remediation requirements riskLevel method{name}scenario{name}}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("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
responseR
=
client
.
newCall
(
requestKE
).
execute
();
String
string
=
responseR
.
body
().
string
();
JSONObject
jsonO
=
JSONObject
.
parseObject
(
string
);
// 获取测试用例列表
List
<
UseCaseVO
>
caseList
=
jsonO
.
getJSONObject
(
"data"
).
getJSONObject
(
"useCases"
).
getList
(
"nodes"
,
UseCaseVO
.
class
);
MatrixResponse
response
=
new
MatrixResponse
();
setHeaderName
(
response
,
testTypeList
);
setRowsNamePad
(
response
,
scenarioList
,
testTypeList
,
caseList
);
return
response
;
}
private
void
setRowsName
(
MatrixResponse
response
,
List
<
ScenarioVO
>
scenarioList
,
List
<
TestTypeVO
>
testTypeList
,
List
<
UseCaseVO
>
caseList
)
{
private
void
setRowsName
(
MatrixResponse
response
,
List
<
ScenarioVO
>
scenarioList
,
List
<
TestTypeVO
>
testTypeList
,
List
<
UseCaseVO
>
caseList
)
{
List
<
Map
<
String
,
Object
>>
rows
=
new
ArrayList
();
List
<
Map
<
String
,
Object
>>
rows
=
new
ArrayList
();
...
@@ -139,6 +203,40 @@ public class MatrixServiceImpl implements MatrixService {
...
@@ -139,6 +203,40 @@ public class MatrixServiceImpl implements MatrixService {
response
.
setRows
(
rows
);
response
.
setRows
(
rows
);
}
}
private
void
setRowsNamePad
(
MatrixResponse
response
,
List
<
ScenarioVO
>
scenarioList
,
List
<
TestTypeVO
>
testTypeList
,
List
<
UseCaseVO
>
caseList
)
{
List
<
Map
<
String
,
Object
>>
rows
=
new
ArrayList
();
for
(
ScenarioVO
scenario
:
scenarioList
)
{
Map
<
String
,
Object
>
row
=
new
HashMap
();
row
.
put
(
"name"
,
scenario
.
getName
());
for
(
TestTypeVO
type
:
testTypeList
)
{
String
column
=
type
.
getName
();
String
columnId
=
String
.
valueOf
(
type
.
getId
());
String
coordinates
=
scenario
.
getName
()
+
column
;
String
useCase
=
getUseCaseIdByCoordinatesNamePad
(
caseList
,
coordinates
);
row
.
put
(
columnId
,
useCase
==
null
?
""
:
useCase
);
}
rows
.
add
(
row
);
}
response
.
setRows
(
rows
);
}
public
String
getUseCaseIdByCoordinatesNamePad
(
List
<
UseCaseVO
>
caseList
,
String
coordinates
)
{
for
(
UseCaseVO
useCase
:
caseList
)
{
if
(
useCase
.
getCoordinates
().
equals
(
coordinates
))
{
return
useCase
.
getDisplayID
();
}
}
return
null
;
}
public
String
getUseCaseIdByCoordinatesName
(
List
<
UseCaseVO
>
caseList
,
String
coordinates
)
{
public
String
getUseCaseIdByCoordinatesName
(
List
<
UseCaseVO
>
caseList
,
String
coordinates
)
{
for
(
UseCaseVO
useCase
:
caseList
)
{
for
(
UseCaseVO
useCase
:
caseList
)
{
...
...
quality-review/src/main/java/com/ruoyi/web/MatrixController.java
View file @
cac06825
...
@@ -30,4 +30,12 @@ public class MatrixController {
...
@@ -30,4 +30,12 @@ public class MatrixController {
return
R
.
ok
(
matrixService
.
getMatrixForUrl
());
return
R
.
ok
(
matrixService
.
getMatrixForUrl
());
}
}
@ApiOperation
(
"查看任务详情pad"
)
@Trace
@Tags
({
@Tag
(
key
=
"param"
,
value
=
"arg[0]"
),
@Tag
(
key
=
"result"
,
value
=
"returnedObj"
)})
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/getInfoPad"
)
public
R
<
MatrixResponse
>
getInfoPad
()
throws
IOException
{
return
R
.
ok
(
matrixService
.
getMatrixForUrlPad
());
}
}
}
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