Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
kt-keystone
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
kt-keystone
Commits
8e396d71
提交
8e396d71
authored
8月 15, 2022
作者:
mry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(web): 测试用例集的基本操作
上级
24b2d914
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
59 行增加
和
16 行删除
+59
-16
TestCaseCollection.java
...e/src/main/java/org/matrix/entity/TestCaseCollection.java
+2
-1
ITestCaseCollectionGroupingService.java
...rg/matrix/service/ITestCaseCollectionGroupingService.java
+2
-6
TestCaseCollectionGroupingServiceImpl.java
...x/service/impl/TestCaseCollectionGroupingServiceImpl.java
+4
-4
TestCaseCollectionController.java
...rix/autotest/controller/TestCaseCollectionController.java
+50
-4
TestCaseCollectionGroupingController.java
...test/controller/TestCaseCollectionGroupingController.java
+1
-1
没有找到文件。
kt-database/src/main/java/org/matrix/entity/TestCaseCollection.java
浏览文件 @
8e396d71
...
@@ -32,5 +32,6 @@ public class TestCaseCollection extends BaseEntity {
...
@@ -32,5 +32,6 @@ public class TestCaseCollection extends BaseEntity {
private
Long
projectId
;
private
Long
projectId
;
@ApiModelProperty
(
"测试用例集合(所有测试用例的主键id)"
)
@ApiModelProperty
(
"测试用例集合(所有测试用例的主键id)"
)
private
List
<
Long
>
testCaseIds
;
private
List
<
Long
>
testCaseCollection
;
}
}
kt-database/src/main/java/org/matrix/service/ITestCaseCollectionGroupingService.java
浏览文件 @
8e396d71
...
@@ -10,11 +10,7 @@ import org.matrix.vo.TestCaseCollectionGroupingVo;
...
@@ -10,11 +10,7 @@ import org.matrix.vo.TestCaseCollectionGroupingVo;
*/
*/
public
interface
ITestCaseCollectionGroupingService
extends
IService
<
TestCaseCollectionGrouping
>
{
public
interface
ITestCaseCollectionGroupingService
extends
IService
<
TestCaseCollectionGrouping
>
{
/**
* 查询测试用例集分组与分组下的分组
*
* @return 测试用例集分组与分组下的分组
*/
/**
/**
* 查询测试用例集分组与分组下的分组
* 查询测试用例集分组与分组下的分组
*
*
...
@@ -28,6 +24,6 @@ public interface ITestCaseCollectionGroupingService extends IService<TestCaseCol
...
@@ -28,6 +24,6 @@ public interface ITestCaseCollectionGroupingService extends IService<TestCaseCol
*
*
* @param id 主键id
* @param id 主键id
*/
*/
void
delete
(
Long
id
);
void
delete
ById
(
Long
id
);
}
}
kt-database/src/main/java/org/matrix/service/impl/TestCaseCollectionGroupingServiceImpl.java
浏览文件 @
8e396d71
...
@@ -62,20 +62,20 @@ public class TestCaseCollectionGroupingServiceImpl extends ServiceImpl<TestCaseC
...
@@ -62,20 +62,20 @@ public class TestCaseCollectionGroupingServiceImpl extends ServiceImpl<TestCaseC
}
}
@Override
@Override
public
void
delete
(
Long
id
)
{
public
void
delete
ById
(
Long
id
)
{
List
<
Long
>
list
=
new
ArrayList
<>();
List
<
Long
>
list
=
new
ArrayList
<>();
List
<
Long
>
groupIds
=
getGroupIds
(
id
,
list
);
List
<
Long
>
groupIds
=
getGroupIds
(
id
,
list
);
mapper
.
deleteBatchIds
(
groupIds
);
mapper
.
deleteBatchIds
(
groupIds
);
mapper
.
deleteById
(
id
);
mapper
.
deleteById
(
id
);
}
}
public
List
<
Long
>
getGroupIds
(
Long
id
,
List
<
Long
>
list
)
{
public
List
<
Long
>
getGroupIds
(
Long
id
,
List
<
Long
>
list
)
{
List
<
TestCaseCollectionGrouping
>
testCaseCollectionGroupings
=
Optional
.
ofNullable
(
mapper
.
selectList
(
Wrappers
.
lambdaQuery
(
TestCaseCollectionGrouping
.
class
)
List
<
TestCaseCollectionGrouping
>
testCaseCollectionGroupings
=
Optional
.
ofNullable
(
mapper
.
selectList
(
Wrappers
.
lambdaQuery
(
TestCaseCollectionGrouping
.
class
)
.
eq
(
TestCaseCollectionGrouping:
:
getGroupId
,
id
))).
orElse
(
new
ArrayList
<>());
.
eq
(
TestCaseCollectionGrouping:
:
getGroupId
,
id
))).
orElse
(
new
ArrayList
<>());
if
(!
CollectionUtils
.
isEmpty
(
testCaseCollectionGroupings
))
{
if
(!
CollectionUtils
.
isEmpty
(
testCaseCollectionGroupings
))
{
for
(
TestCaseCollectionGrouping
testCaseCollectionGrouping
:
testCaseCollectionGroupings
)
{
for
(
TestCaseCollectionGrouping
testCaseCollectionGrouping
:
testCaseCollectionGroupings
)
{
list
.
add
(
testCaseCollectionGrouping
.
getId
());
list
.
add
(
testCaseCollectionGrouping
.
getId
());
getGroupIds
(
testCaseCollectionGrouping
.
getId
(),
list
);
getGroupIds
(
testCaseCollectionGrouping
.
getId
(),
list
);
}
}
}
}
return
list
;
return
list
;
...
...
kt-web/src/main/java/org/matrix/autotest/controller/TestCaseCollectionController.java
浏览文件 @
8e396d71
package
org
.
matrix
.
autotest
.
controller
;
package
org
.
matrix
.
autotest
.
controller
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.matrix.entity.Case
;
import
org.matrix.entity.TestCaseCollection
;
import
org.matrix.entity.TestCaseCollection
;
import
org.matrix.exception.GlobalException
;
import
org.matrix.exception.GlobalException
;
import
org.matrix.service.ICaseService
;
import
org.matrix.service.ITestCaseCollectionService
;
import
org.matrix.service.ITestCaseCollectionService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
/**
/**
...
@@ -23,12 +28,15 @@ import java.util.Optional;
...
@@ -23,12 +28,15 @@ import java.util.Optional;
public
class
TestCaseCollectionController
{
public
class
TestCaseCollectionController
{
@Autowired
@Autowired
private
ITestCaseCollectionService
testCaseGroupingService
;
private
ITestCaseCollectionService
testCaseCollectionService
;
@Autowired
private
ICaseService
caseService
;
@ApiOperation
(
"添加测试用例集"
)
@ApiOperation
(
"添加测试用例集"
)
@PostMapping
@PostMapping
public
ResponseEntity
<
TestCaseCollection
>
insertTestCaseGrouping
(
@RequestBody
TestCaseCollection
testCaseCollection
)
{
public
ResponseEntity
<
TestCaseCollection
>
insertTestCaseGrouping
(
@RequestBody
TestCaseCollection
testCaseCollection
)
{
return
Optional
.
of
(
testCase
Grouping
Service
.
save
(
testCaseCollection
)).
orElseThrow
(()
->
new
GlobalException
(
"添加失败"
))
return
Optional
.
of
(
testCase
Collection
Service
.
save
(
testCaseCollection
)).
orElseThrow
(()
->
new
GlobalException
(
"添加失败"
))
?
ResponseEntity
.
ok
(
testCaseCollection
)
?
ResponseEntity
.
ok
(
testCaseCollection
)
:
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
testCaseCollection
);
:
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
testCaseCollection
);
}
}
...
@@ -36,7 +44,7 @@ public class TestCaseCollectionController {
...
@@ -36,7 +44,7 @@ public class TestCaseCollectionController {
@ApiOperation
(
"修改测试用例集"
)
@ApiOperation
(
"修改测试用例集"
)
@PutMapping
@PutMapping
public
ResponseEntity
<
TestCaseCollection
>
updateTestCaseGrouping
(
@RequestBody
TestCaseCollection
testCaseCollection
)
{
public
ResponseEntity
<
TestCaseCollection
>
updateTestCaseGrouping
(
@RequestBody
TestCaseCollection
testCaseCollection
)
{
return
Optional
.
of
(
testCase
Grouping
Service
.
updateById
(
testCaseCollection
)).
orElseThrow
(()
->
new
GlobalException
(
"修改失败"
))
return
Optional
.
of
(
testCase
Collection
Service
.
updateById
(
testCaseCollection
)).
orElseThrow
(()
->
new
GlobalException
(
"修改失败"
))
?
ResponseEntity
.
ok
(
testCaseCollection
)
?
ResponseEntity
.
ok
(
testCaseCollection
)
:
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
testCaseCollection
);
:
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
testCaseCollection
);
}
}
...
@@ -44,8 +52,46 @@ public class TestCaseCollectionController {
...
@@ -44,8 +52,46 @@ public class TestCaseCollectionController {
@ApiOperation
(
"删除测试用例集"
)
@ApiOperation
(
"删除测试用例集"
)
@DeleteMapping
(
"/{id}"
)
@DeleteMapping
(
"/{id}"
)
public
ResponseEntity
<
String
>
removeTestCaseGrouping
(
@PathVariable
Long
id
)
{
public
ResponseEntity
<
String
>
removeTestCaseGrouping
(
@PathVariable
Long
id
)
{
testCase
Grouping
Service
.
removeById
(
id
);
testCase
Collection
Service
.
removeById
(
id
);
return
ResponseEntity
.
ok
(
String
.
format
(
"删除的用例分组id为,%s"
,
id
));
return
ResponseEntity
.
ok
(
String
.
format
(
"删除的用例分组id为,%s"
,
id
));
}
}
@GetMapping
@ApiOperation
(
"查询所有测试用例集"
)
public
ResponseEntity
<
List
<
TestCaseCollection
>>
findTestCaseGrouping
(
@RequestParam
Long
projectId
)
{
List
<
TestCaseCollection
>
testCaseCollections
=
Optional
.
ofNullable
(
testCaseCollectionService
.
list
(
Wrappers
.
lambdaQuery
(
TestCaseCollection
.
class
)
.
eq
(
TestCaseCollection:
:
getProjectId
,
projectId
))).
orElse
(
new
ArrayList
<>());
return
ResponseEntity
.
ok
(
testCaseCollections
);
}
@GetMapping
(
"/id"
)
@ApiOperation
(
"根据id查询测试用例集"
)
public
ResponseEntity
<
TestCaseCollection
>
findById
(
@RequestParam
Long
id
)
{
TestCaseCollection
testCaseCollection
=
Optional
.
ofNullable
(
testCaseCollectionService
.
getById
(
id
)).
orElse
(
new
TestCaseCollection
());
return
ResponseEntity
.
ok
(
testCaseCollection
);
}
@GetMapping
(
"/groupId"
)
@ApiOperation
(
"根据分组id查询测试用例集"
)
public
ResponseEntity
<
List
<
TestCaseCollection
>>
findByGroupId
(
@RequestParam
Long
projectId
,
@RequestParam
Long
groupId
)
{
List
<
TestCaseCollection
>
testCaseCollections
=
Optional
.
ofNullable
(
testCaseCollectionService
.
list
(
Wrappers
.
lambdaQuery
(
TestCaseCollection
.
class
)
.
eq
(
TestCaseCollection:
:
getProjectId
,
projectId
)
.
eq
(
TestCaseCollection:
:
getGroupId
,
groupId
))).
orElse
(
new
ArrayList
<>());
return
ResponseEntity
.
ok
(
testCaseCollections
);
}
@GetMapping
(
"/testCase"
)
@ApiOperation
(
"查询当前测试用例集中的所有测试用例"
)
public
ResponseEntity
<
List
<
Case
>>
findTestCase
(
@RequestParam
Long
id
)
{
//存放测试用例的集合
List
<
Case
>
list
=
new
ArrayList
<>();
TestCaseCollection
testCaseCollection
=
Optional
.
ofNullable
(
testCaseCollectionService
.
getById
(
id
)).
orElse
(
new
TestCaseCollection
());
List
<
Long
>
idList
=
testCaseCollection
.
getTestCaseCollection
();
for
(
Long
caseId
:
idList
)
{
Case
testCase
=
caseService
.
getById
(
caseId
);
list
.
add
(
testCase
);
}
return
ResponseEntity
.
ok
(
list
);
}
}
}
kt-web/src/main/java/org/matrix/autotest/controller/TestCaseCollectionGroupingController.java
浏览文件 @
8e396d71
...
@@ -54,7 +54,7 @@ public class TestCaseCollectionGroupingController {
...
@@ -54,7 +54,7 @@ public class TestCaseCollectionGroupingController {
@DeleteMapping
(
"/{id}"
)
@DeleteMapping
(
"/{id}"
)
@ApiOperation
(
"根据分组主键id删除分组,以及分组下的所有分组"
)
@ApiOperation
(
"根据分组主键id删除分组,以及分组下的所有分组"
)
public
ResponseEntity
<
String
>
remove
(
@PathVariable
Long
id
)
{
public
ResponseEntity
<
String
>
remove
(
@PathVariable
Long
id
)
{
service
.
delete
(
id
);
service
.
delete
ById
(
id
);
return
ResponseEntity
.
ok
(
String
.
format
(
"删除的测试用例集分组id为%s"
,
id
));
return
ResponseEntity
.
ok
(
String
.
format
(
"删除的测试用例集分组id为%s"
,
id
));
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论