feat(用例管理): 新增功能用例列表批量新增或关联需求接口

This commit is contained in:
guoyuqi 2024-02-06 16:28:30 +08:00 committed by 刘瑞斌
parent 3264666aac
commit 1a5d69840c
5 changed files with 156 additions and 38 deletions

View File

@ -3,6 +3,7 @@ package io.metersphere.functional.controller;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.functional.dto.FunctionalDemandDTO; import io.metersphere.functional.dto.FunctionalDemandDTO;
import io.metersphere.functional.request.FunctionalCaseDemandBatchRequest;
import io.metersphere.functional.request.FunctionalCaseDemandRequest; import io.metersphere.functional.request.FunctionalCaseDemandRequest;
import io.metersphere.functional.request.FunctionalThirdDemandPageRequest; import io.metersphere.functional.request.FunctionalThirdDemandPageRequest;
import io.metersphere.functional.request.QueryDemandListRequest; import io.metersphere.functional.request.QueryDemandListRequest;
@ -45,7 +46,7 @@ public class FunctionalCaseDemandController {
} }
@PostMapping("/add") @PostMapping("/add")
@Operation(summary = "用例管理-功能用例-关联需求-新增需求") @Operation(summary = "用例管理-功能用例详情-关联需求-新增/关联需求")
@RequiresPermissions(value = {PermissionConstants.FUNCTIONAL_CASE_READ_ADD, PermissionConstants.FUNCTIONAL_CASE_READ_UPDATE, PermissionConstants.FUNCTIONAL_CASE_READ_DELETE}, logical = Logical.OR) @RequiresPermissions(value = {PermissionConstants.FUNCTIONAL_CASE_READ_ADD, PermissionConstants.FUNCTIONAL_CASE_READ_UPDATE, PermissionConstants.FUNCTIONAL_CASE_READ_DELETE}, logical = Logical.OR)
public void addDemand(@RequestBody @Validated FunctionalCaseDemandRequest request) { public void addDemand(@RequestBody @Validated FunctionalCaseDemandRequest request) {
functionalCaseDemandService.addDemand(request, SessionUtils.getUserId()); functionalCaseDemandService.addDemand(request, SessionUtils.getUserId());
@ -67,9 +68,9 @@ public class FunctionalCaseDemandController {
} }
@PostMapping("/batch/relevance") @PostMapping("/batch/relevance")
@Operation(summary = "用例管理-功能用例-关联需求-批量关联需求") @Operation(summary = "用例管理-功能用例列表-关联需求-批量关联新增需求")
@RequiresPermissions(value = {PermissionConstants.FUNCTIONAL_CASE_READ_ADD, PermissionConstants.FUNCTIONAL_CASE_READ_UPDATE, PermissionConstants.FUNCTIONAL_CASE_READ_DELETE}, logical = Logical.OR) @RequiresPermissions(value = {PermissionConstants.FUNCTIONAL_CASE_READ_ADD, PermissionConstants.FUNCTIONAL_CASE_READ_UPDATE, PermissionConstants.FUNCTIONAL_CASE_READ_DELETE}, logical = Logical.OR)
public void batchRelevance(@RequestBody @Validated FunctionalCaseDemandRequest request) { public void batchRelevance(@RequestBody @Validated FunctionalCaseDemandBatchRequest request) {
functionalCaseDemandService.batchRelevance(request, SessionUtils.getUserId()); functionalCaseDemandService.batchRelevance(request, SessionUtils.getUserId());
} }

View File

@ -0,0 +1,27 @@
package io.metersphere.functional.request;
import io.metersphere.functional.dto.BaseFunctionalCaseBatchDTO;
import io.metersphere.functional.dto.DemandDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import java.util.List;
/**
* @author guoyuqi
*/
@Data
public class FunctionalCaseDemandBatchRequest extends BaseFunctionalCaseBatchDTO {
@Schema(description = "项目ID")
@NotBlank(message = "{functional_case_demand.projectId.not_blank}")
private String projectId;
@Schema(description = "需求所属平台(本地创建为系统平台名称)")
@NotBlank(message = "{functional_case_demand.demand_platform.not_blank}")
private String demandPlatform;
@Schema(description = "需求集合")
private List<DemandDTO> demandList;
}

View File

@ -5,7 +5,9 @@ import io.metersphere.functional.domain.FunctionalCaseDemandExample;
import io.metersphere.functional.dto.DemandDTO; import io.metersphere.functional.dto.DemandDTO;
import io.metersphere.functional.dto.FunctionalDemandDTO; import io.metersphere.functional.dto.FunctionalDemandDTO;
import io.metersphere.functional.mapper.ExtFunctionalCaseDemandMapper; import io.metersphere.functional.mapper.ExtFunctionalCaseDemandMapper;
import io.metersphere.functional.mapper.ExtFunctionalCaseMapper;
import io.metersphere.functional.mapper.FunctionalCaseDemandMapper; import io.metersphere.functional.mapper.FunctionalCaseDemandMapper;
import io.metersphere.functional.request.FunctionalCaseDemandBatchRequest;
import io.metersphere.functional.request.FunctionalCaseDemandRequest; import io.metersphere.functional.request.FunctionalCaseDemandRequest;
import io.metersphere.functional.request.FunctionalThirdDemandPageRequest; import io.metersphere.functional.request.FunctionalThirdDemandPageRequest;
import io.metersphere.functional.request.QueryDemandListRequest; import io.metersphere.functional.request.QueryDemandListRequest;
@ -52,6 +54,8 @@ public class FunctionalCaseDemandService {
private SystemParameterMapper systemParameterMapper; private SystemParameterMapper systemParameterMapper;
@Resource @Resource
private ProjectApplicationService projectApplicationService; private ProjectApplicationService projectApplicationService;
@Resource
private ExtFunctionalCaseMapper extFunctionalCaseMapper;
/** /**
* 获取需求列表 * 获取需求列表
@ -95,31 +99,40 @@ public class FunctionalCaseDemandService {
* @param userId 当前操作人 * @param userId 当前操作人
*/ */
public void addDemand(FunctionalCaseDemandRequest request, String userId) { public void addDemand(FunctionalCaseDemandRequest request, String userId) {
if (checkDemandList(request)) return; if (checkDemandList(request.getDemandList())) return;
FunctionalCaseDemand functionalCaseDemand = buildFunctionalCaseDemand(request, userId, request.getDemandList().get(0), new ArrayList<>()); SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
if (functionalCaseDemand != null) { FunctionalCaseDemandMapper functionalCaseDemandMapper = sqlSession.getMapper(FunctionalCaseDemandMapper.class);
functionalCaseDemandMapper.insertSelective(functionalCaseDemand); List<String> demandIds = request.getDemandList().stream().map(DemandDTO::getDemandId).toList();
FunctionalCaseDemandExample functionalCaseDemandExample = new FunctionalCaseDemandExample();
functionalCaseDemandExample.createCriteria().andCaseIdEqualTo(request.getCaseId()).andDemandPlatformEqualTo(request.getDemandPlatform());
List<FunctionalCaseDemand> existDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample);
List<String> existDemandIds = existDemands.stream().map(FunctionalCaseDemand::getDemandId).toList();
List<String> notRepeatDemandIds = demandIds.stream().filter(t -> !existDemandIds.contains(t)).toList();
Map<String, DemandDTO> demandDTOMap = request.getDemandList().stream().collect(Collectors.toMap(DemandDTO::getDemandId, t -> t));
for (String notRepeatDemandId : notRepeatDemandIds) {
DemandDTO demandDTO = demandDTOMap.get(notRepeatDemandId);
FunctionalCaseDemand functionalCaseDemand = buildFunctionalCaseDemand(request.getCaseId(), request.getDemandPlatform(), userId, demandDTO);
functionalCaseDemandMapper.insert(functionalCaseDemand);
} }
sqlSession.flushStatements();
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
} }
private FunctionalCaseDemand buildFunctionalCaseDemand(FunctionalCaseDemandRequest request, String userId, DemandDTO demandDTO, List<String> existDemandIds) { private FunctionalCaseDemand buildFunctionalCaseDemand(String caseId, String demandPlatform, String userId, DemandDTO demandDTO) {
FunctionalCaseDemand functionalCaseDemand = new FunctionalCaseDemand(); FunctionalCaseDemand functionalCaseDemand = new FunctionalCaseDemand();
functionalCaseDemand.setId(IDGenerator.nextStr()); functionalCaseDemand.setId(IDGenerator.nextStr());
functionalCaseDemand.setCaseId(request.getCaseId()); functionalCaseDemand.setCaseId(caseId);
functionalCaseDemand.setDemandPlatform(request.getDemandPlatform()); functionalCaseDemand.setDemandPlatform(demandPlatform);
functionalCaseDemand.setCreateTime(System.currentTimeMillis()); functionalCaseDemand.setCreateTime(System.currentTimeMillis());
functionalCaseDemand.setCreateUser(userId); functionalCaseDemand.setCreateUser(userId);
functionalCaseDemand.setUpdateTime(System.currentTimeMillis()); functionalCaseDemand.setUpdateTime(System.currentTimeMillis());
functionalCaseDemand.setUpdateUser(userId); functionalCaseDemand.setUpdateUser(userId);
if (existDemandIds.contains(demandDTO.getDemandId())) {
return null;
}
dealWithDemand(demandDTO, functionalCaseDemand); dealWithDemand(demandDTO, functionalCaseDemand);
return functionalCaseDemand; return functionalCaseDemand;
} }
private static boolean checkDemandList(FunctionalCaseDemandRequest request) { private static boolean checkDemandList(List<DemandDTO> demandList) {
return CollectionUtils.isEmpty(request.getDemandList()); return CollectionUtils.isEmpty(demandList);
} }
/** /**
@ -168,7 +181,7 @@ public class FunctionalCaseDemandService {
* @param userId 当前操作人 * @param userId 当前操作人
*/ */
public void updateDemand(FunctionalCaseDemandRequest request, String userId) { public void updateDemand(FunctionalCaseDemandRequest request, String userId) {
if (checkDemandList(request)) return; if (checkDemandList(request.getDemandList())) return;
FunctionalCaseDemand functionalCaseDemand = functionalCaseDemandMapper.selectByPrimaryKey(request.getId()); FunctionalCaseDemand functionalCaseDemand = functionalCaseDemandMapper.selectByPrimaryKey(request.getId());
if (functionalCaseDemand == null) { if (functionalCaseDemand == null) {
throw new MSException(Translator.get("case.demand.not.exist")); throw new MSException(Translator.get("case.demand.not.exist"));
@ -196,25 +209,51 @@ public class FunctionalCaseDemandService {
* @param request 页面参数 * @param request 页面参数
* @param userId 当前操作人 * @param userId 当前操作人
*/ */
public void batchRelevance(FunctionalCaseDemandRequest request, String userId) { public void batchRelevance(FunctionalCaseDemandBatchRequest request, String userId) {
if (checkDemandList(request)) return; if (checkDemandList(request.getDemandList())) return;
List<String> caseIds = doSelectIds(request, request.getProjectId());
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
FunctionalCaseDemandMapper functionalCaseDemandMapper = sqlSession.getMapper(FunctionalCaseDemandMapper.class); FunctionalCaseDemandMapper functionalCaseDemandMapper = sqlSession.getMapper(FunctionalCaseDemandMapper.class);
List<String> demandIds = request.getDemandList().stream().map(DemandDTO::getDemandId).toList(); List<String> demandIds = request.getDemandList().stream().map(DemandDTO::getDemandId).toList();
String demandPlatform = request.getDemandPlatform();
//查询当前平台所有已关联的需求
FunctionalCaseDemandExample functionalCaseDemandExample = new FunctionalCaseDemandExample(); FunctionalCaseDemandExample functionalCaseDemandExample = new FunctionalCaseDemandExample();
functionalCaseDemandExample.createCriteria().andCaseIdEqualTo(request.getCaseId()).andDemandPlatformEqualTo(request.getDemandPlatform()).andDemandIdIn(demandIds); functionalCaseDemandExample.createCriteria().andDemandPlatformEqualTo(demandPlatform);
List<FunctionalCaseDemand> existDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample); List<FunctionalCaseDemand> existPlatformDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample);
List<String> existDemandIds = existDemands.stream().map(FunctionalCaseDemand::getDemandId).toList(); Map<String, List<FunctionalCaseDemand>> caseDemandMap = existPlatformDemands.stream().collect(Collectors.groupingBy(FunctionalCaseDemand::getCaseId));
for (DemandDTO demandDTO : request.getDemandList()) { Map<String, DemandDTO> demandDTOMap = request.getDemandList().stream().collect(Collectors.toMap(DemandDTO::getDemandId, t -> t));
FunctionalCaseDemand functionalCaseDemand = buildFunctionalCaseDemand(request, userId, demandDTO, existDemandIds); caseIds.forEach(t -> {
if (functionalCaseDemand != null) { List<String> existDemandIds = new ArrayList<>();
List<FunctionalCaseDemand> functionalCaseDemands = caseDemandMap.get(t);
if (CollectionUtils.isNotEmpty(functionalCaseDemands)) {
existDemandIds = functionalCaseDemands.stream().map(FunctionalCaseDemand::getDemandId).toList();
}
//过滤已存在的
List<String> finalExistDemandIds = existDemandIds;
List<String> notRepeatDemandIds = demandIds.stream().filter(demand -> !finalExistDemandIds.contains(demand)).toList();
for (String notRepeatDemandId : notRepeatDemandIds) {
DemandDTO demandDTO = demandDTOMap.get(notRepeatDemandId);
FunctionalCaseDemand functionalCaseDemand = buildFunctionalCaseDemand(t, demandPlatform, userId, demandDTO);
functionalCaseDemandMapper.insert(functionalCaseDemand); functionalCaseDemandMapper.insert(functionalCaseDemand);
} }
} });
sqlSession.flushStatements(); sqlSession.flushStatements();
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
} }
public <T> List<String> doSelectIds(T dto, String projectId) {
FunctionalCaseDemandBatchRequest request = (FunctionalCaseDemandBatchRequest) dto;
if (request.isSelectAll()) {
List<String> ids = extFunctionalCaseMapper.getIds(request, projectId, false);
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
ids.removeAll(request.getExcludeIds());
}
return ids;
} else {
return request.getSelectIds();
}
}
public PluginPager<PlatformDemandDTO> pageDemand(FunctionalThirdDemandPageRequest request) { public PluginPager<PlatformDemandDTO> pageDemand(FunctionalThirdDemandPageRequest request) {
DemandPageRequest demandPageRequest = new DemandPageRequest(); DemandPageRequest demandPageRequest = new DemandPageRequest();
demandPageRequest.setQuery(request.getKeyword()); demandPageRequest.setQuery(request.getKeyword());

View File

@ -5,6 +5,7 @@ import io.metersphere.functional.domain.FunctionalCaseDemandExample;
import io.metersphere.functional.dto.DemandDTO; import io.metersphere.functional.dto.DemandDTO;
import io.metersphere.functional.dto.FunctionalDemandDTO; import io.metersphere.functional.dto.FunctionalDemandDTO;
import io.metersphere.functional.mapper.FunctionalCaseDemandMapper; import io.metersphere.functional.mapper.FunctionalCaseDemandMapper;
import io.metersphere.functional.request.FunctionalCaseDemandBatchRequest;
import io.metersphere.functional.request.FunctionalCaseDemandRequest; import io.metersphere.functional.request.FunctionalCaseDemandRequest;
import io.metersphere.functional.request.FunctionalThirdDemandPageRequest; import io.metersphere.functional.request.FunctionalThirdDemandPageRequest;
import io.metersphere.functional.request.QueryDemandListRequest; import io.metersphere.functional.request.QueryDemandListRequest;
@ -67,7 +68,6 @@ public class FunctionalCaseDemandControllerTests extends BaseTest {
private int mockServerHostPort; private int mockServerHostPort;
private static final String URL_DEMAND_PAGE = "/functional/case/demand/page"; private static final String URL_DEMAND_PAGE = "/functional/case/demand/page";
private static final String URL_DEMAND_ADD = "/functional/case/demand/add"; private static final String URL_DEMAND_ADD = "/functional/case/demand/add";
private static final String URL_DEMAND_UPDATE = "/functional/case/demand/update"; private static final String URL_DEMAND_UPDATE = "/functional/case/demand/update";
@ -348,7 +348,7 @@ public class FunctionalCaseDemandControllerTests extends BaseTest {
demandDTO3.setDemandName("手动加入Tapd2"); demandDTO3.setDemandName("手动加入Tapd2");
demandList.add(demandDTO3); demandList.add(demandDTO3);
functionalCaseDemandRequest.setDemandList(demandList); functionalCaseDemandRequest.setDemandList(demandList);
this.requestPostWithOkAndReturn(URL_DEMAND_BATCH_RELEVANCE, functionalCaseDemandRequest); this.requestPostWithOkAndReturn(URL_DEMAND_ADD, functionalCaseDemandRequest);
FunctionalCaseDemandExample functionalCaseDemandExample = new FunctionalCaseDemandExample(); FunctionalCaseDemandExample functionalCaseDemandExample = new FunctionalCaseDemandExample();
functionalCaseDemandExample.createCriteria().andCaseIdEqualTo("DEMAND_TEST_FUNCTIONAL_CASE_ID2"); functionalCaseDemandExample.createCriteria().andCaseIdEqualTo("DEMAND_TEST_FUNCTIONAL_CASE_ID2");
List<FunctionalCaseDemand> functionalCaseDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample); List<FunctionalCaseDemand> functionalCaseDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample);
@ -373,7 +373,7 @@ public class FunctionalCaseDemandControllerTests extends BaseTest {
functionalCaseDemandRequest.setDemandPlatform("ZanDao"); functionalCaseDemandRequest.setDemandPlatform("ZanDao");
List<DemandDTO> demandList = new ArrayList<>(); List<DemandDTO> demandList = new ArrayList<>();
functionalCaseDemandRequest.setDemandList(demandList); functionalCaseDemandRequest.setDemandList(demandList);
this.requestPostWithOkAndReturn(URL_DEMAND_BATCH_RELEVANCE, functionalCaseDemandRequest); this.requestPostWithOkAndReturn(URL_DEMAND_ADD, functionalCaseDemandRequest);
FunctionalCaseDemandExample functionalCaseDemandExample = new FunctionalCaseDemandExample(); FunctionalCaseDemandExample functionalCaseDemandExample = new FunctionalCaseDemandExample();
functionalCaseDemandExample.createCriteria().andCaseIdEqualTo("DEMAND_TEST_FUNCTIONAL_CASE_ID2").andDemandPlatformEqualTo("ZanDao"); functionalCaseDemandExample.createCriteria().andCaseIdEqualTo("DEMAND_TEST_FUNCTIONAL_CASE_ID2").andDemandPlatformEqualTo("ZanDao");
List<FunctionalCaseDemand> functionalCaseDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample); List<FunctionalCaseDemand> functionalCaseDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample);
@ -394,7 +394,7 @@ public class FunctionalCaseDemandControllerTests extends BaseTest {
demandDTO3.setDemandName("手动加入Tapd2"); demandDTO3.setDemandName("手动加入Tapd2");
demandList.add(demandDTO3); demandList.add(demandDTO3);
functionalCaseDemandRequest.setDemandList(demandList); functionalCaseDemandRequest.setDemandList(demandList);
this.requestPostWithOkAndReturn(URL_DEMAND_BATCH_RELEVANCE, functionalCaseDemandRequest); this.requestPostWithOkAndReturn(URL_DEMAND_ADD, functionalCaseDemandRequest);
functionalCaseDemandExample = new FunctionalCaseDemandExample(); functionalCaseDemandExample = new FunctionalCaseDemandExample();
functionalCaseDemandExample.createCriteria().andCaseIdEqualTo("DEMAND_TEST_FUNCTIONAL_CASE_ID2").andDemandPlatformEqualTo("TAPD"); functionalCaseDemandExample.createCriteria().andCaseIdEqualTo("DEMAND_TEST_FUNCTIONAL_CASE_ID2").andDemandPlatformEqualTo("TAPD");
@ -418,7 +418,7 @@ public class FunctionalCaseDemandControllerTests extends BaseTest {
demandDTO2.setDemandId("100006"); demandDTO2.setDemandId("100006");
demandList.add(demandDTO2); demandList.add(demandDTO2);
functionalCaseDemandRequest.setDemandList(demandList); functionalCaseDemandRequest.setDemandList(demandList);
this.requestPost(URL_DEMAND_BATCH_RELEVANCE, functionalCaseDemandRequest).andExpect(status().is5xxServerError()); this.requestPost(URL_DEMAND_ADD, functionalCaseDemandRequest).andExpect(status().is5xxServerError());
FunctionalCaseDemandExample functionalCaseDemandExample = new FunctionalCaseDemandExample(); FunctionalCaseDemandExample functionalCaseDemandExample = new FunctionalCaseDemandExample();
functionalCaseDemandExample.createCriteria().andCaseIdEqualTo("DEMAND_TEST_FUNCTIONAL_CASE_ID2").andDemandPlatformEqualTo("jira"); functionalCaseDemandExample.createCriteria().andCaseIdEqualTo("DEMAND_TEST_FUNCTIONAL_CASE_ID2").andDemandPlatformEqualTo("jira");
List<FunctionalCaseDemand> functionalCaseDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample); List<FunctionalCaseDemand> functionalCaseDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample);
@ -436,11 +436,65 @@ public class FunctionalCaseDemandControllerTests extends BaseTest {
demandDTO2.setDemandName("手动加入jira2"); demandDTO2.setDemandName("手动加入jira2");
demandList.add(demandDTO2); demandList.add(demandDTO2);
functionalCaseDemandRequest.setDemandList(demandList); functionalCaseDemandRequest.setDemandList(demandList);
this.requestPost(URL_DEMAND_BATCH_RELEVANCE, functionalCaseDemandRequest).andExpect(status().is5xxServerError()); this.requestPost(URL_DEMAND_ADD, functionalCaseDemandRequest).andExpect(status().is5xxServerError());
} }
@Test @Test
@Order(12) @Order(12)
public void batchCaseRelevance() throws Exception {
FunctionalCaseDemandBatchRequest functionalCaseDemandBatchRequest = new FunctionalCaseDemandBatchRequest();
functionalCaseDemandBatchRequest.setSelectAll(true);
functionalCaseDemandBatchRequest.setProjectId("project-case-demand-test");
functionalCaseDemandBatchRequest.setDemandPlatform("jira");
List<DemandDTO> demandList = new ArrayList<>();
DemandDTO demandDTO = new DemandDTO();
demandDTO.setDemandId("100008");
demandDTO.setDemandName("批量手动加入jira");
demandDTO.setParent("100007");
demandDTO.setDemandUrl("http://www.baidu.com");
demandList.add(demandDTO);
DemandDTO demandDTO2 = new DemandDTO();
demandDTO2.setDemandId("100007");
demandDTO2.setDemandName("批量手动加入jira爸爸");
demandDTO2.setDemandUrl("http://www.baidu.com");
demandList.add(demandDTO2);
functionalCaseDemandBatchRequest.setDemandList(demandList);
this.requestPostWithOkAndReturn(URL_DEMAND_BATCH_RELEVANCE, functionalCaseDemandBatchRequest);
FunctionalCaseDemandExample functionalCaseDemandExample = new FunctionalCaseDemandExample();
functionalCaseDemandExample.createCriteria().andDemandPlatformEqualTo("jira");
List<FunctionalCaseDemand> functionalCaseDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample);
Assertions.assertEquals(6,functionalCaseDemands.size());
String jsonString = JSON.toJSONString(functionalCaseDemands);
System.out.println(jsonString);
functionalCaseDemandBatchRequest.setExcludeIds(List.of("DEMAND_TEST_FUNCTIONAL_CASE_ID3"));
demandList = new ArrayList<>();
demandDTO = new DemandDTO();
demandDTO.setDemandId("100009");
demandDTO.setDemandName("批量手动加入jira2");
demandDTO.setParent("100007");
demandDTO.setDemandUrl("http://www.baidu.com");
demandList.add(demandDTO);
functionalCaseDemandBatchRequest.setDemandList(demandList);
this.requestPostWithOkAndReturn(URL_DEMAND_BATCH_RELEVANCE, functionalCaseDemandBatchRequest);
functionalCaseDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample);
jsonString = JSON.toJSONString(functionalCaseDemands);
System.out.println(jsonString);
functionalCaseDemandBatchRequest.setSelectAll(false);
functionalCaseDemandBatchRequest.setSelectIds(List.of("DEMAND_TEST_FUNCTIONAL_CASE_ID3"));
this.requestPostWithOkAndReturn(URL_DEMAND_BATCH_RELEVANCE, functionalCaseDemandBatchRequest);
functionalCaseDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample);
jsonString = JSON.toJSONString(functionalCaseDemands);
System.out.println(jsonString);
functionalCaseDemandBatchRequest.setDemandList(new ArrayList<>());
this.requestPostWithOkAndReturn(URL_DEMAND_BATCH_RELEVANCE, functionalCaseDemandBatchRequest);
}
@Test
@Order(13)
public void cancelDemandNoLog() throws Exception { public void cancelDemandNoLog() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get(URL_DEMAND_CANCEL+"DEMAND_TEST_FUNCTIONAL_CASE_X").header(SessionConstants.HEADER_TOKEN, sessionId) mockMvc.perform(MockMvcRequestBuilders.get(URL_DEMAND_CANCEL+"DEMAND_TEST_FUNCTIONAL_CASE_X").header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken) .header(SessionConstants.CSRF_TOKEN, csrfToken)
@ -458,7 +512,7 @@ public class FunctionalCaseDemandControllerTests extends BaseTest {
} }
@Test @Test
@Order(13) @Order(14)
public void pageDemandSuccess() throws Exception { public void pageDemandSuccess() throws Exception {
basePluginTestService.addJiraPlugin(); basePluginTestService.addJiraPlugin();
basePluginTestService.addServiceIntegration(DEFAULT_ORGANIZATION_ID); basePluginTestService.addServiceIntegration(DEFAULT_ORGANIZATION_ID);

View File

@ -11,13 +11,13 @@ INSERT INTO template (id, name, remark, internal, update_time, create_time, crea
VALUES ('test_template_case_demand_id', 'functional_case_demand_default', '', b'0', 1696992836000, 1696992836000, 'admin', 'PROJECT', 'project-case-demand-test', b'0', NULL, 'FUNCTIONAL'); VALUES ('test_template_case_demand_id', 'functional_case_demand_default', '', b'0', 1696992836000, 1696992836000, 'admin', 'PROJECT', 'project-case-demand-test', b'0', NULL, 'FUNCTIONAL');
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time) INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
VALUES ('DEMAND_TEST_FUNCTIONAL_CASE_ID', 1, 'DEMAND_TEST_MODULE_ID', 'project-case-demand-test', '100001', '关联需求测试', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'DEMAND_TEST_FUNCTIONAL_CASE_ID', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); VALUES ('DEMAND_TEST_FUNCTIONAL_CASE_ID', 1, 'DEMAND_TEST_MODULE_ID', 'project-case-demand-test', '100001', '关联需求测试', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'DEMAND_TEST_FUNCTIONAL_CASE_ID', 'UN_EXECUTED', false, b'0', b'1', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL);
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time) INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
VALUES ('DEMAND_TEST_FUNCTIONAL_CASE_ID2', 1, 'DEMAND_TEST_MODULE_ID', 'project-case-demand-test', '100001', '关联需求测试', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'DEMAND_TEST_FUNCTIONAL_CASE_ID2', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); VALUES ('DEMAND_TEST_FUNCTIONAL_CASE_ID2', 1, 'DEMAND_TEST_MODULE_ID', 'project-case-demand-test', '100001', '关联需求测试', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'DEMAND_TEST_FUNCTIONAL_CASE_ID2', 'UN_EXECUTED', false, b'0', b'1', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL);
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time) INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
VALUES ('DEMAND_TEST_FUNCTIONAL_CASE_ID3', 1, 'DEMAND_TEST_MODULE_ID', 'project-case-demand-test', '100001', '关联需求测试', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'DEMAND_TEST_FUNCTIONAL_CASE_ID3', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); VALUES ('DEMAND_TEST_FUNCTIONAL_CASE_ID3', 1, 'DEMAND_TEST_MODULE_ID', 'project-case-demand-test', '100001', '关联需求测试', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'DEMAND_TEST_FUNCTIONAL_CASE_ID3', 'UN_EXECUTED', false, b'0', b'1', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL);
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('DEMAND_TEST_FUNCTIONAL_CASE_ID', 'gyq_custom_id_demand1', '22'); INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('DEMAND_TEST_FUNCTIONAL_CASE_ID', 'gyq_custom_id_demand1', '22');
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('DEMAND_TEST_FUNCTIONAL_CASE_ID', 'gyq_custom_id_demand2', '33'); INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('DEMAND_TEST_FUNCTIONAL_CASE_ID', 'gyq_custom_id_demand2', '33');
@ -32,9 +32,6 @@ VALUES('gyq_custom_id_demand2', 'level', 'FUNCTIONAL', 'SELECT', '', 1, 'ORGANIZ
INSERT INTO functional_case_module(id, project_id, name, parent_id, pos, create_time, update_time, create_user, update_user) VALUES ('DEMAND_TEST_MODULE_ID', 'project-case-demand-test', '测试需求所属模块', 'NONE', 0, 1669174143999, 1669174143999, 'admin', 'admin'); INSERT INTO functional_case_module(id, project_id, name, parent_id, pos, create_time, update_time, create_user, update_user) VALUES ('DEMAND_TEST_MODULE_ID', 'project-case-demand-test', '测试需求所属模块', 'NONE', 0, 1669174143999, 1669174143999, 'admin', 'admin');
/*INSERT INTO service_integration(`id`, `plugin_id`, `enable`, `configuration`, `organization_id`) VALUES
('gyq_service_integration_id', 'jira', true, 0x504B0304140008080800BC517657000000000000000000000000030000007A6970258DC10EC2201044FF65CF06D2C498D89347B5574FBD6D8158222CD85D6268E3BF4BE3F5CDBC990DD0DAC531430FB348E65EEBE06B41AAA9289480CC1E4991130D07C022F3A366D7DA13B2373B32261592469AF1572FCF883E289362CB735BF8A4C5EE073474C3CB8E59A6F85EEFF12AE676EC4E67F8FE00504B0708384DA4307800000087000000504B01021400140008080800BC517657384DA43078000000870000000300000000000000000000000000000000007A6970504B0506000000000100010031000000A90000000000, '100001');*/
INSERT INTO project_application (project_id, type, type_value) VALUES INSERT INTO project_application (project_id, type, type_value) VALUES
('gyq_project-case-demand-test', 'CASE_RELATED_CASE_ENABLE', 'true'), ('gyq_project-case-demand-test', 'CASE_RELATED_CASE_ENABLE', 'true'),
('gyq_project-case-demand-test', 'CASE_RELATED_DEMAND_PLATFORM_CONFIG', '{"jiraKey":"TES","jiraDemandTypeId":"10007"}'), ('gyq_project-case-demand-test', 'CASE_RELATED_DEMAND_PLATFORM_CONFIG', '{"jiraKey":"TES","jiraDemandTypeId":"10007"}'),