fix(接口测试): 版本重构以及创建时间修改
--user=郭雨琦 --bug=1014707 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014707 --bug=1014732 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014732 --bug=1014708 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014708 --bug=1014793 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014793
This commit is contained in:
parent
0ab07b7da8
commit
bf6c1e4ed1
|
@ -1206,15 +1206,26 @@ public class ApiAutomationService {
|
||||||
ApiScenarioWithBLOBs scenarioWithBLOBs, ApiTestImportRequest apiTestImportRequest, ApiTestCaseMapper apiTestCaseMapper, ApiDefinitionMapper apiDefinitionMapper) {
|
ApiScenarioWithBLOBs scenarioWithBLOBs, ApiTestImportRequest apiTestImportRequest, ApiTestCaseMapper apiTestCaseMapper, ApiDefinitionMapper apiDefinitionMapper) {
|
||||||
if (CollectionUtils.isEmpty(sameRequest)) {
|
if (CollectionUtils.isEmpty(sameRequest)) {
|
||||||
scenarioWithBLOBs.setId(UUID.randomUUID().toString());
|
scenarioWithBLOBs.setId(UUID.randomUUID().toString());
|
||||||
scenarioWithBLOBs.setOrder(getImportNextOrder(apiTestImportRequest.getProjectId()));
|
scenarioWithBLOBs.setCreateTime(System.currentTimeMillis());
|
||||||
// 导入时设置版本
|
if (!scenarioWithBLOBs.getVersionId().equals("update")) {
|
||||||
scenarioWithBLOBs.setRefId(scenarioWithBLOBs.getId());
|
scenarioWithBLOBs.setOrder(getImportNextOrder(apiTestImportRequest.getProjectId()));
|
||||||
if (StringUtils.isNotEmpty(apiTestImportRequest.getVersionId())) {
|
// 导入时设置版本
|
||||||
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getVersionId());
|
scenarioWithBLOBs.setRefId(scenarioWithBLOBs.getId());
|
||||||
|
if (StringUtils.isNotEmpty(apiTestImportRequest.getVersionId())) {
|
||||||
|
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getVersionId());
|
||||||
|
} else {
|
||||||
|
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getDefaultVersion());
|
||||||
|
}
|
||||||
|
scenarioWithBLOBs.setLatest(true);
|
||||||
} else {
|
} else {
|
||||||
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getDefaultVersion());
|
if (StringUtils.isNotEmpty(apiTestImportRequest.getUpdateVersionId())) {
|
||||||
|
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getUpdateVersionId());
|
||||||
|
} else {
|
||||||
|
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getDefaultVersion());
|
||||||
|
}
|
||||||
|
scenarioWithBLOBs.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion()));
|
||||||
}
|
}
|
||||||
scenarioWithBLOBs.setLatest(true);
|
|
||||||
checkReferenceCase(scenarioWithBLOBs, apiTestCaseMapper, apiDefinitionMapper);
|
checkReferenceCase(scenarioWithBLOBs, apiTestCaseMapper, apiDefinitionMapper);
|
||||||
batchMapper.insert(scenarioWithBLOBs);
|
batchMapper.insert(scenarioWithBLOBs);
|
||||||
apiScenarioReferenceIdService.saveApiAndScenarioRelation(scenarioWithBLOBs);
|
apiScenarioReferenceIdService.saveApiAndScenarioRelation(scenarioWithBLOBs);
|
||||||
|
@ -1230,10 +1241,14 @@ public class ApiAutomationService {
|
||||||
// 新增对应的版本
|
// 新增对应的版本
|
||||||
if (!scenarioOp.isPresent()) {
|
if (!scenarioOp.isPresent()) {
|
||||||
scenarioWithBLOBs.setId(UUID.randomUUID().toString());
|
scenarioWithBLOBs.setId(UUID.randomUUID().toString());
|
||||||
scenarioWithBLOBs.setRefId(sameRequest.get(0).getRefId());
|
scenarioWithBLOBs.setCreateTime(System.currentTimeMillis());
|
||||||
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getUpdateVersionId());
|
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getUpdateVersionId());
|
||||||
scenarioWithBLOBs.setNum(sameRequest.get(0).getNum()); // 使用第一个num当作本次的num
|
scenarioWithBLOBs.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion()));
|
||||||
scenarioWithBLOBs.setOrder(sameRequest.get(0).getOrder());
|
if (!scenarioWithBLOBs.getVersionId().equals("update")) {
|
||||||
|
scenarioWithBLOBs.setRefId(sameRequest.get(0).getRefId());
|
||||||
|
scenarioWithBLOBs.setNum(sameRequest.get(0).getNum()); // 使用第一个num当作本次的num
|
||||||
|
scenarioWithBLOBs.setOrder(sameRequest.get(0).getOrder());
|
||||||
|
}
|
||||||
batchMapper.insert(scenarioWithBLOBs);
|
batchMapper.insert(scenarioWithBLOBs);
|
||||||
} else {
|
} else {
|
||||||
ApiScenarioWithBLOBs existScenario = scenarioOp.get();
|
ApiScenarioWithBLOBs existScenario = scenarioOp.get();
|
||||||
|
@ -1255,7 +1270,6 @@ public class ApiAutomationService {
|
||||||
ApiTestImportRequest apiTestImportRequest, List<ApiScenarioWithBLOBs> sameList, ApiTestCaseMapper apiTestCaseMapper, ApiDefinitionMapper apiDefinitionMapper) {
|
ApiTestImportRequest apiTestImportRequest, List<ApiScenarioWithBLOBs> sameList, ApiTestCaseMapper apiTestCaseMapper, ApiDefinitionMapper apiDefinitionMapper) {
|
||||||
final ApiScenarioWithBLOBs scenarioWithBLOBs = new ApiScenarioWithBLOBs();
|
final ApiScenarioWithBLOBs scenarioWithBLOBs = new ApiScenarioWithBLOBs();
|
||||||
BeanUtils.copyBean(scenarioWithBLOBs, request);
|
BeanUtils.copyBean(scenarioWithBLOBs, request);
|
||||||
scenarioWithBLOBs.setCreateTime(System.currentTimeMillis());
|
|
||||||
scenarioWithBLOBs.setUpdateTime(System.currentTimeMillis());
|
scenarioWithBLOBs.setUpdateTime(System.currentTimeMillis());
|
||||||
if (StringUtils.isEmpty(scenarioWithBLOBs.getStatus())) {
|
if (StringUtils.isEmpty(scenarioWithBLOBs.getStatus())) {
|
||||||
scenarioWithBLOBs.setStatus(APITestStatus.Underway.name());
|
scenarioWithBLOBs.setStatus(APITestStatus.Underway.name());
|
||||||
|
@ -1302,6 +1316,7 @@ public class ApiAutomationService {
|
||||||
_importCreate(sameList, batchMapper, extApiScenarioMapper, scenarioWithBLOBs, apiTestImportRequest, apiTestCaseMapper, apiDefinitionMapper);
|
_importCreate(sameList, batchMapper, extApiScenarioMapper, scenarioWithBLOBs, apiTestImportRequest, apiTestCaseMapper, apiDefinitionMapper);
|
||||||
} else if (StringUtils.equals("incrementalMerge", apiTestImportRequest.getModeId())) {
|
} else if (StringUtils.equals("incrementalMerge", apiTestImportRequest.getModeId())) {
|
||||||
scenarioWithBLOBs.setId(UUID.randomUUID().toString());
|
scenarioWithBLOBs.setId(UUID.randomUUID().toString());
|
||||||
|
scenarioWithBLOBs.setCreateTime(System.currentTimeMillis());
|
||||||
if (CollectionUtils.isEmpty(sameList)) {
|
if (CollectionUtils.isEmpty(sameList)) {
|
||||||
if (scenarioWithBLOBs.getVersionId() != null && scenarioWithBLOBs.getVersionId().equals("new")) {
|
if (scenarioWithBLOBs.getVersionId() != null && scenarioWithBLOBs.getVersionId().equals("new")) {
|
||||||
scenarioWithBLOBs.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion()));
|
scenarioWithBLOBs.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion()));
|
||||||
|
@ -1378,7 +1393,7 @@ public class ApiAutomationService {
|
||||||
if (item.getName().length() > 255) {
|
if (item.getName().length() > 255) {
|
||||||
item.setName(item.getName().substring(0, 255));
|
item.setName(item.getName().substring(0, 255));
|
||||||
}
|
}
|
||||||
if (item.getVersionId() == null || !item.getVersionId().equals("new")) {
|
if (item.getVersionId() == null || (!item.getVersionId().equals("new") && !item.getVersionId().equals("update"))) {
|
||||||
item.setNum(num);
|
item.setNum(num);
|
||||||
}
|
}
|
||||||
if (BooleanUtils.isFalse(request.getOpenCustomNum())) {
|
if (BooleanUtils.isFalse(request.getOpenCustomNum())) {
|
||||||
|
|
|
@ -790,8 +790,7 @@ public class ApiDefinitionService {
|
||||||
List<ApiDefinitionWithBLOBs> updateList, ApiTestCaseMapper apiTestCaseMapper, List<ApiTestCaseWithBLOBs> caseList) {
|
List<ApiDefinitionWithBLOBs> updateList, ApiTestCaseMapper apiTestCaseMapper, List<ApiTestCaseWithBLOBs> caseList) {
|
||||||
SaveApiDefinitionRequest saveReq = new SaveApiDefinitionRequest();
|
SaveApiDefinitionRequest saveReq = new SaveApiDefinitionRequest();
|
||||||
BeanUtils.copyBean(saveReq, apiDefinition);
|
BeanUtils.copyBean(saveReq, apiDefinition);
|
||||||
apiDefinition.setCreateTime(System.currentTimeMillis());
|
|
||||||
apiDefinition.setUpdateTime(System.currentTimeMillis());
|
|
||||||
if (StringUtils.isEmpty(apiDefinition.getStatus())) {
|
if (StringUtils.isEmpty(apiDefinition.getStatus())) {
|
||||||
apiDefinition.setStatus(APITestStatus.Underway.name());
|
apiDefinition.setStatus(APITestStatus.Underway.name());
|
||||||
}
|
}
|
||||||
|
@ -809,6 +808,8 @@ public class ApiDefinitionService {
|
||||||
if (CollectionUtils.isEmpty(collect)) {
|
if (CollectionUtils.isEmpty(collect)) {
|
||||||
String originId = apiDefinition.getId();
|
String originId = apiDefinition.getId();
|
||||||
apiDefinition.setId(UUID.randomUUID().toString());
|
apiDefinition.setId(UUID.randomUUID().toString());
|
||||||
|
apiDefinition.setCreateTime(System.currentTimeMillis());
|
||||||
|
apiDefinition.setUpdateTime(System.currentTimeMillis());
|
||||||
//postman 可能含有前置脚本,接口定义去掉脚本
|
//postman 可能含有前置脚本,接口定义去掉脚本
|
||||||
if (apiDefinition.getVersionId() != null && apiDefinition.getVersionId().equals("new")) {
|
if (apiDefinition.getVersionId() != null && apiDefinition.getVersionId().equals("new")) {
|
||||||
apiDefinition.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion()));
|
apiDefinition.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion()));
|
||||||
|
@ -850,9 +851,7 @@ public class ApiDefinitionService {
|
||||||
if (apiTestCaseWithBLOBs.getCreateTime() == null) {
|
if (apiTestCaseWithBLOBs.getCreateTime() == null) {
|
||||||
apiTestCaseWithBLOBs.setCreateTime(System.currentTimeMillis());
|
apiTestCaseWithBLOBs.setCreateTime(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
if (apiTestCaseWithBLOBs.getUpdateTime() == null) {
|
apiTestCaseWithBLOBs.setUpdateTime(System.currentTimeMillis());
|
||||||
apiTestCaseWithBLOBs.setUpdateTime(System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotBlank(apiTestCaseWithBLOBs.getId())) {
|
if (StringUtils.isNotBlank(apiTestCaseWithBLOBs.getId())) {
|
||||||
apiTestCaseMapper.updateByPrimaryKeyWithBLOBs(apiTestCaseWithBLOBs);
|
apiTestCaseMapper.updateByPrimaryKeyWithBLOBs(apiTestCaseWithBLOBs);
|
||||||
} else {
|
} else {
|
||||||
|
@ -895,14 +894,27 @@ public class ApiDefinitionService {
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(sameRequest)) { // 没有这个接口 新增
|
if (CollectionUtils.isEmpty(sameRequest)) { // 没有这个接口 新增
|
||||||
apiDefinition.setId(UUID.randomUUID().toString());
|
apiDefinition.setId(UUID.randomUUID().toString());
|
||||||
apiDefinition.setRefId(apiDefinition.getId());
|
|
||||||
if (StringUtils.isNotEmpty(apiTestImportRequest.getVersionId())) {
|
apiDefinition.setCreateTime(System.currentTimeMillis());
|
||||||
apiDefinition.setVersionId(apiTestImportRequest.getVersionId());
|
apiDefinition.setUpdateTime(System.currentTimeMillis());
|
||||||
|
if (apiDefinition.getVersionId().equals("update")) {
|
||||||
|
if (StringUtils.isNotEmpty(apiTestImportRequest.getUpdateVersionId())) {
|
||||||
|
apiDefinition.setVersionId(apiTestImportRequest.getUpdateVersionId());
|
||||||
|
} else {
|
||||||
|
apiDefinition.setVersionId(apiTestImportRequest.getDefaultVersion());
|
||||||
|
}
|
||||||
|
apiDefinition.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion()));
|
||||||
} else {
|
} else {
|
||||||
apiDefinition.setVersionId(apiTestImportRequest.getDefaultVersion());
|
apiDefinition.setRefId(apiDefinition.getId());
|
||||||
|
apiDefinition.setLatest(true); // 新增接口 latest = true
|
||||||
|
apiDefinition.setOrder(getImportNextOrder(apiTestImportRequest.getProjectId()));
|
||||||
|
if (StringUtils.isNotEmpty(apiTestImportRequest.getVersionId())) {
|
||||||
|
apiDefinition.setVersionId(apiTestImportRequest.getVersionId());
|
||||||
|
} else {
|
||||||
|
apiDefinition.setVersionId(apiTestImportRequest.getDefaultVersion());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
apiDefinition.setLatest(true); // 新增接口 latest = true
|
|
||||||
apiDefinition.setOrder(getImportNextOrder(apiTestImportRequest.getProjectId()));
|
|
||||||
reSetImportMocksApiId(mocks, originId, apiDefinition.getId(), apiDefinition.getNum());
|
reSetImportMocksApiId(mocks, originId, apiDefinition.getId(), apiDefinition.getNum());
|
||||||
if (StringUtils.equalsIgnoreCase(apiDefinition.getProtocol(), RequestType.HTTP)) {
|
if (StringUtils.equalsIgnoreCase(apiDefinition.getProtocol(), RequestType.HTTP)) {
|
||||||
batchMapper.insert(apiDefinition);
|
batchMapper.insert(apiDefinition);
|
||||||
|
@ -925,14 +937,20 @@ public class ApiDefinitionService {
|
||||||
|
|
||||||
if (!apiOp.isPresent()) {
|
if (!apiOp.isPresent()) {
|
||||||
apiDefinition.setId(UUID.randomUUID().toString());
|
apiDefinition.setId(UUID.randomUUID().toString());
|
||||||
if (sameRequest.get(0).getRefId() != null) {
|
apiDefinition.setCreateTime(System.currentTimeMillis());
|
||||||
apiDefinition.setRefId(sameRequest.get(0).getRefId());
|
apiDefinition.setUpdateTime(System.currentTimeMillis());
|
||||||
} else {
|
if (!apiDefinition.getVersionId().equals("update")) {
|
||||||
apiDefinition.setRefId(apiDefinition.getId());
|
if (sameRequest.get(0).getRefId() != null) {
|
||||||
|
apiDefinition.setRefId(sameRequest.get(0).getRefId());
|
||||||
|
} else {
|
||||||
|
apiDefinition.setRefId(apiDefinition.getId());
|
||||||
|
}
|
||||||
|
apiDefinition.setNum(sameRequest.get(0).getNum()); // 使用第一个num当作本次的num
|
||||||
|
apiDefinition.setOrder(sameRequest.get(0).getOrder());
|
||||||
}
|
}
|
||||||
|
apiDefinition.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion()));
|
||||||
apiDefinition.setVersionId(apiTestImportRequest.getUpdateVersionId());
|
apiDefinition.setVersionId(apiTestImportRequest.getUpdateVersionId());
|
||||||
apiDefinition.setNum(sameRequest.get(0).getNum()); // 使用第一个num当作本次的num
|
|
||||||
apiDefinition.setOrder(sameRequest.get(0).getOrder());
|
|
||||||
if (sameRequest.get(0).getUserId() != null) {
|
if (sameRequest.get(0).getUserId() != null) {
|
||||||
apiDefinition.setUserId(sameRequest.get(0).getUserId());
|
apiDefinition.setUserId(sameRequest.get(0).getUserId());
|
||||||
}
|
}
|
||||||
|
@ -956,9 +974,11 @@ public class ApiDefinitionService {
|
||||||
//Check whether the content has changed, if not, do not change the creation time
|
//Check whether the content has changed, if not, do not change the creation time
|
||||||
if (apiDefinition.getProtocol().equals("HTTP")) {
|
if (apiDefinition.getProtocol().equals("HTTP")) {
|
||||||
Boolean toChangeTime = checkIsSynchronize(existApi, apiDefinition);
|
Boolean toChangeTime = checkIsSynchronize(existApi, apiDefinition);
|
||||||
if (!toChangeTime) {
|
if (toChangeTime) {
|
||||||
apiDefinition.setUpdateTime(existApi.getUpdateTime());
|
apiDefinition.setUpdateTime(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
apiDefinition.setUpdateTime(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!StringUtils.equalsIgnoreCase(apiTestImportRequest.getPlatform(), ApiImportPlatform.Metersphere.name())) {
|
if (!StringUtils.equalsIgnoreCase(apiTestImportRequest.getPlatform(), ApiImportPlatform.Metersphere.name())) {
|
||||||
|
@ -1509,7 +1529,7 @@ public class ApiDefinitionService {
|
||||||
item.setName(item.getName().substring(0, 255));
|
item.setName(item.getName().substring(0, 255));
|
||||||
}
|
}
|
||||||
//如果是创建版本数据,则num和其他版本数据一致
|
//如果是创建版本数据,则num和其他版本数据一致
|
||||||
if (item.getVersionId() == null || !item.getVersionId().equals("new")) {
|
if (item.getVersionId() == null || (!item.getVersionId().equals("new") && !item.getVersionId().equals("update"))) {
|
||||||
item.setNum(num++);
|
item.setNum(num++);
|
||||||
}
|
}
|
||||||
//如果EsbData需要存储,则需要进行接口是否更新的判断
|
//如果EsbData需要存储,则需要进行接口是否更新的判断
|
||||||
|
|
|
@ -854,18 +854,20 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
//不覆盖选择版本,如果被选版本有同接口,不导入,否则创建新版本接口
|
//不覆盖选择版本,如果被选版本有同接口,不导入,否则创建新版本接口
|
||||||
if (v.getVersionId().equals(versionId)) {
|
if (v.getVersionId().equals(versionId)) {
|
||||||
optionData.remove(apiDefinitionWithBLOBs);
|
optionData.remove(apiDefinitionWithBLOBs);
|
||||||
distinctNameCases.forEach(optionDataCases::remove);
|
if (distinctNameCases != null && !distinctNameCases.isEmpty()) {
|
||||||
|
distinctNameCases.forEach(optionDataCases::remove);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//这里是为了标识当前数据是需要创建版本的,不是全新增的数据
|
//这里是为了标识当前数据是需要创建版本的,不是全新增的数据
|
||||||
addNewVersionApi(apiDefinitionWithBLOBs, v);
|
addNewVersionApi(apiDefinitionWithBLOBs, v, "new");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addNewVersionApi(ApiDefinitionWithBLOBs apiDefinitionWithBLOBs, ApiDefinitionWithBLOBs v) {
|
private void addNewVersionApi(ApiDefinitionWithBLOBs apiDefinitionWithBLOBs, ApiDefinitionWithBLOBs v, String version) {
|
||||||
apiDefinitionWithBLOBs.setVersionId("new");
|
apiDefinitionWithBLOBs.setVersionId(version);
|
||||||
apiDefinitionWithBLOBs.setNum(v.getNum());
|
apiDefinitionWithBLOBs.setNum(v.getNum());
|
||||||
apiDefinitionWithBLOBs.setStatus(v.getStatus());
|
apiDefinitionWithBLOBs.setStatus(v.getStatus());
|
||||||
apiDefinitionWithBLOBs.setOrder(v.getOrder());
|
apiDefinitionWithBLOBs.setOrder(v.getOrder());
|
||||||
|
@ -884,6 +886,11 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
repeatDataMap.forEach((k, v) -> {
|
repeatDataMap.forEach((k, v) -> {
|
||||||
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k);
|
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k);
|
||||||
if (apiDefinitionWithBLOBs != null) {
|
if (apiDefinitionWithBLOBs != null) {
|
||||||
|
//系统内重复的数据的版本如果不是选择的数据更新版本,则在数据更新版本新增,否则更新这个版本的数据
|
||||||
|
if (!v.getVersionId().equals(updateVersionId)) {
|
||||||
|
addNewVersionApi(apiDefinitionWithBLOBs, v, "update");
|
||||||
|
return;
|
||||||
|
}
|
||||||
//该接口的case
|
//该接口的case
|
||||||
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
|
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
|
||||||
apiDefinitionWithBLOBs.setId(v.getId());
|
apiDefinitionWithBLOBs.setId(v.getId());
|
||||||
|
@ -896,6 +903,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
apiDefinitionWithBLOBs.setRefId(v.getRefId());
|
apiDefinitionWithBLOBs.setRefId(v.getRefId());
|
||||||
apiDefinitionWithBLOBs.setLatest(v.getLatest());
|
apiDefinitionWithBLOBs.setLatest(v.getLatest());
|
||||||
apiDefinitionWithBLOBs.setCreateTime(v.getCreateTime());
|
apiDefinitionWithBLOBs.setCreateTime(v.getCreateTime());
|
||||||
|
apiDefinitionWithBLOBs.setUpdateTime(v.getUpdateTime());
|
||||||
//组合case
|
//组合case
|
||||||
if (caseNameMap != null) {
|
if (caseNameMap != null) {
|
||||||
buildCaseList(oldCaseMap, caseNameMap, v);
|
buildCaseList(oldCaseMap, caseNameMap, v);
|
||||||
|
@ -931,6 +939,11 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
repeatDataMap.forEach((k, v) -> {
|
repeatDataMap.forEach((k, v) -> {
|
||||||
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k);
|
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k);
|
||||||
if (apiDefinitionWithBLOBs != null) {
|
if (apiDefinitionWithBLOBs != null) {
|
||||||
|
//系统内重复的数据的版本如果不是选择的数据更新版本,则在数据更新版本新增,否则更新这个版本的数据
|
||||||
|
if (!v.getVersionId().equals(updateVersionId)) {
|
||||||
|
addNewVersionApi(apiDefinitionWithBLOBs, v, "update");
|
||||||
|
return;
|
||||||
|
}
|
||||||
//该接口的case
|
//该接口的case
|
||||||
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
|
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
|
||||||
apiDefinitionWithBLOBs.setId(v.getId());
|
apiDefinitionWithBLOBs.setId(v.getId());
|
||||||
|
@ -1024,10 +1037,12 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
List<ApiDefinitionWithBLOBs> sameVersionList = v.stream().filter(t -> t.getVersionId().equals(versionId)).collect(Collectors.toList());
|
List<ApiDefinitionWithBLOBs> sameVersionList = v.stream().filter(t -> t.getVersionId().equals(versionId)).collect(Collectors.toList());
|
||||||
if (!sameVersionList.isEmpty()) {
|
if (!sameVersionList.isEmpty()) {
|
||||||
optionData.remove(apiDefinitionWithBLOBs);
|
optionData.remove(apiDefinitionWithBLOBs);
|
||||||
distinctNameCases.forEach(optionDataCases::remove);
|
if (distinctNameCases != null && !distinctNameCases.isEmpty()) {
|
||||||
|
distinctNameCases.forEach(optionDataCases::remove);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (ApiDefinitionWithBLOBs definitionWithBLOBs : v) {
|
for (ApiDefinitionWithBLOBs definitionWithBLOBs : v) {
|
||||||
addNewVersionApi(apiDefinitionWithBLOBs, definitionWithBLOBs);
|
addNewVersionApi(apiDefinitionWithBLOBs, definitionWithBLOBs, "new");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1050,6 +1065,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
apiDefinitionWithBLOBs.setRefId(definitionWithBLOBs.getRefId());
|
apiDefinitionWithBLOBs.setRefId(definitionWithBLOBs.getRefId());
|
||||||
apiDefinitionWithBLOBs.setLatest(definitionWithBLOBs.getLatest());
|
apiDefinitionWithBLOBs.setLatest(definitionWithBLOBs.getLatest());
|
||||||
apiDefinitionWithBLOBs.setCreateTime(definitionWithBLOBs.getCreateTime());
|
apiDefinitionWithBLOBs.setCreateTime(definitionWithBLOBs.getCreateTime());
|
||||||
|
apiDefinitionWithBLOBs.setUpdateTime(definitionWithBLOBs.getUpdateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeModulePath(Map<String, ApiModule> moduleMap, Map<String, List<ApiDefinitionWithBLOBs>> moduleOptionData, String modulePath) {
|
private void removeModulePath(Map<String, ApiModule> moduleMap, Map<String, List<ApiDefinitionWithBLOBs>> moduleOptionData, String modulePath) {
|
||||||
|
@ -1078,7 +1094,12 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
//该接口的case
|
//该接口的case
|
||||||
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
|
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
|
||||||
//循环系统内重复接口
|
//循环系统内重复接口
|
||||||
|
int i = 0;
|
||||||
for (ApiDefinitionWithBLOBs definitionWithBLOBs : v) {
|
for (ApiDefinitionWithBLOBs definitionWithBLOBs : v) {
|
||||||
|
if (!definitionWithBLOBs.getVersionId().equals(updateVersionId)) {
|
||||||
|
i += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
//组合case
|
//组合case
|
||||||
if (caseNameMap != null) {
|
if (caseNameMap != null) {
|
||||||
buildCaseList(oldCaseMap, caseNameMap, definitionWithBLOBs);
|
buildCaseList(oldCaseMap, caseNameMap, definitionWithBLOBs);
|
||||||
|
@ -1094,9 +1115,16 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
api.setNum(definitionWithBLOBs.getNum());
|
api.setNum(definitionWithBLOBs.getNum());
|
||||||
api.setStatus(definitionWithBLOBs.getStatus());
|
api.setStatus(definitionWithBLOBs.getStatus());
|
||||||
api.setCreateTime(definitionWithBLOBs.getCreateTime());
|
api.setCreateTime(definitionWithBLOBs.getCreateTime());
|
||||||
|
api.setUpdateTime(definitionWithBLOBs.getUpdateTime());
|
||||||
coverApiList.add(api);
|
coverApiList.add(api);
|
||||||
}
|
}
|
||||||
optionData.remove(apiDefinitionWithBLOBs);
|
if (i == v.size()) {
|
||||||
|
//如果系统内的所有版本都不是当前选择的数据更新版本,则在数据更新版本这里新建数据
|
||||||
|
addNewVersionApi(apiDefinitionWithBLOBs, v.get(0), "update");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
optionData.remove(apiDefinitionWithBLOBs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buildOtherParam(toUpdateList, optionData, coverApiList);
|
buildOtherParam(toUpdateList, optionData, coverApiList);
|
||||||
|
@ -1110,7 +1138,6 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
Map<String, ApiTestCaseWithBLOBs> oldCaseNameMap;
|
Map<String, ApiTestCaseWithBLOBs> oldCaseNameMap;
|
||||||
if (apiTestCases != null && !apiTestCases.isEmpty()) {
|
if (apiTestCases != null && !apiTestCases.isEmpty()) {
|
||||||
oldCaseNameMap = apiTestCases.stream().collect(Collectors.toMap(ApiTestCase::getName, testCase -> testCase));
|
oldCaseNameMap = apiTestCases.stream().collect(Collectors.toMap(ApiTestCase::getName, testCase -> testCase));
|
||||||
|
|
||||||
caseNameMap.forEach((name, caseWithBLOBs1) -> {
|
caseNameMap.forEach((name, caseWithBLOBs1) -> {
|
||||||
//如果导入的有重名,覆盖,接口ID替换成系统内的
|
//如果导入的有重名,覆盖,接口ID替换成系统内的
|
||||||
caseWithBLOBs1.setApiDefinitionId(definitionWithBLOBs.getId());
|
caseWithBLOBs1.setApiDefinitionId(definitionWithBLOBs.getId());
|
||||||
|
@ -1147,7 +1174,12 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
if (apiDefinitionWithBLOBs != null) {
|
if (apiDefinitionWithBLOBs != null) {
|
||||||
//该接口的case
|
//该接口的case
|
||||||
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
|
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
|
||||||
|
int i = 0;
|
||||||
for (ApiDefinitionWithBLOBs definitionWithBLOBs : v) {
|
for (ApiDefinitionWithBLOBs definitionWithBLOBs : v) {
|
||||||
|
if (!definitionWithBLOBs.getVersionId().equals(updateVersionId)) {
|
||||||
|
i += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
//组合case
|
//组合case
|
||||||
if (caseNameMap != null) {
|
if (caseNameMap != null) {
|
||||||
buildCaseList(oldCaseMap, caseNameMap, definitionWithBLOBs);
|
buildCaseList(oldCaseMap, caseNameMap, definitionWithBLOBs);
|
||||||
|
@ -1165,9 +1197,16 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
api.setRefId(apiDefinitionWithBLOBs.getRefId());
|
api.setRefId(apiDefinitionWithBLOBs.getRefId());
|
||||||
api.setLatest(apiDefinitionWithBLOBs.getLatest());
|
api.setLatest(apiDefinitionWithBLOBs.getLatest());
|
||||||
api.setCreateTime(definitionWithBLOBs.getCreateTime());
|
api.setCreateTime(definitionWithBLOBs.getCreateTime());
|
||||||
|
api.setUpdateTime(definitionWithBLOBs.getUpdateTime());
|
||||||
coverApiList.add(api);
|
coverApiList.add(api);
|
||||||
}
|
}
|
||||||
optionData.remove(apiDefinitionWithBLOBs);
|
if (i == v.size()) {
|
||||||
|
//如果系统内的所有版本都不是当前选择的数据更新版本,则在数据更新版本这里新建数据
|
||||||
|
addNewVersionApi(apiDefinitionWithBLOBs, v.get(0), "update");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
optionData.remove(apiDefinitionWithBLOBs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buildOtherParam(toUpdateList, optionData, coverApiList);
|
buildOtherParam(toUpdateList, optionData, coverApiList);
|
||||||
|
|
|
@ -592,19 +592,23 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
||||||
if (v.getVersionId().equals(versionId)) {
|
if (v.getVersionId().equals(versionId)) {
|
||||||
optionData.remove(apiScenarioWithBLOBs);
|
optionData.remove(apiScenarioWithBLOBs);
|
||||||
} else {
|
} else {
|
||||||
apiScenarioWithBLOBs.setVersionId("new");
|
addNewVersionScenario(apiScenarioWithBLOBs, v, "new");
|
||||||
apiScenarioWithBLOBs.setNum(v.getNum());
|
|
||||||
apiScenarioWithBLOBs.setStatus(v.getStatus());
|
|
||||||
apiScenarioWithBLOBs.setCreateTime(v.getCreateTime());
|
|
||||||
apiScenarioWithBLOBs.setRefId(v.getRefId());
|
|
||||||
apiScenarioWithBLOBs.setOrder(v.getOrder());
|
|
||||||
apiScenarioWithBLOBs.setLatest(v.getLatest());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addNewVersionScenario(ApiScenarioWithBLOBs apiScenarioWithBLOBs, ApiScenarioWithBLOBs v, String version) {
|
||||||
|
apiScenarioWithBLOBs.setVersionId(version);
|
||||||
|
apiScenarioWithBLOBs.setNum(v.getNum());
|
||||||
|
apiScenarioWithBLOBs.setStatus(v.getStatus());
|
||||||
|
apiScenarioWithBLOBs.setCreateTime(v.getCreateTime());
|
||||||
|
apiScenarioWithBLOBs.setRefId(v.getRefId());
|
||||||
|
apiScenarioWithBLOBs.setOrder(v.getOrder());
|
||||||
|
apiScenarioWithBLOBs.setLatest(v.getLatest());
|
||||||
|
}
|
||||||
|
|
||||||
private void removeModulePath(Map<String, ApiScenarioModule> moduleMap, Map<String, List<ApiScenarioWithBLOBs>> moduleOptionData, String modulePath) {
|
private void removeModulePath(Map<String, ApiScenarioModule> moduleMap, Map<String, List<ApiScenarioWithBLOBs>> moduleOptionData, String modulePath) {
|
||||||
if (StringUtils.isBlank(modulePath)) {
|
if (StringUtils.isBlank(modulePath)) {
|
||||||
return;
|
return;
|
||||||
|
@ -623,6 +627,10 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
||||||
repeatDataMap.forEach((k, v) -> {
|
repeatDataMap.forEach((k, v) -> {
|
||||||
ApiScenarioWithBLOBs apiScenarioWithBLOBs = nameModuleMap.get(k);
|
ApiScenarioWithBLOBs apiScenarioWithBLOBs = nameModuleMap.get(k);
|
||||||
if (apiScenarioWithBLOBs != null) {
|
if (apiScenarioWithBLOBs != null) {
|
||||||
|
if (!v.getVersionId().equals(updateVersionId)) {
|
||||||
|
addNewVersionScenario(apiScenarioWithBLOBs, v, "update");
|
||||||
|
return;
|
||||||
|
}
|
||||||
apiScenarioWithBLOBs.setId(v.getId());
|
apiScenarioWithBLOBs.setId(v.getId());
|
||||||
apiScenarioWithBLOBs.setVersionId(updateVersionId);
|
apiScenarioWithBLOBs.setVersionId(updateVersionId);
|
||||||
apiScenarioWithBLOBs.setApiScenarioModuleId(v.getApiScenarioModuleId());
|
apiScenarioWithBLOBs.setApiScenarioModuleId(v.getApiScenarioModuleId());
|
||||||
|
@ -633,6 +641,7 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
||||||
apiScenarioWithBLOBs.setRefId(v.getRefId());
|
apiScenarioWithBLOBs.setRefId(v.getRefId());
|
||||||
apiScenarioWithBLOBs.setOrder(v.getOrder());
|
apiScenarioWithBLOBs.setOrder(v.getOrder());
|
||||||
apiScenarioWithBLOBs.setLatest(v.getLatest());
|
apiScenarioWithBLOBs.setLatest(v.getLatest());
|
||||||
|
apiScenarioWithBLOBs.setCreateTime(v.getCreateTime());
|
||||||
toUpdateList.add(apiScenarioWithBLOBs);
|
toUpdateList.add(apiScenarioWithBLOBs);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -661,6 +670,10 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
||||||
repeatDataMap.forEach((k, v) -> {
|
repeatDataMap.forEach((k, v) -> {
|
||||||
ApiScenarioWithBLOBs apiScenarioWithBLOBs = nameModuleMap.get(k);
|
ApiScenarioWithBLOBs apiScenarioWithBLOBs = nameModuleMap.get(k);
|
||||||
if (apiScenarioWithBLOBs != null) {
|
if (apiScenarioWithBLOBs != null) {
|
||||||
|
if (!v.getVersionId().equals(updateVersionId)) {
|
||||||
|
addNewVersionScenario(apiScenarioWithBLOBs, v, "update");
|
||||||
|
return;
|
||||||
|
}
|
||||||
apiScenarioWithBLOBs.setId(v.getId());
|
apiScenarioWithBLOBs.setId(v.getId());
|
||||||
apiScenarioWithBLOBs.setVersionId(updateVersionId);
|
apiScenarioWithBLOBs.setVersionId(updateVersionId);
|
||||||
apiScenarioWithBLOBs.setNum(v.getNum());
|
apiScenarioWithBLOBs.setNum(v.getNum());
|
||||||
|
@ -669,6 +682,7 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
||||||
apiScenarioWithBLOBs.setRefId(v.getRefId());
|
apiScenarioWithBLOBs.setRefId(v.getRefId());
|
||||||
apiScenarioWithBLOBs.setOrder(v.getOrder());
|
apiScenarioWithBLOBs.setOrder(v.getOrder());
|
||||||
apiScenarioWithBLOBs.setLatest(v.getLatest());
|
apiScenarioWithBLOBs.setLatest(v.getLatest());
|
||||||
|
apiScenarioWithBLOBs.setCreateTime(v.getCreateTime());
|
||||||
toUpdateList.add(apiScenarioWithBLOBs);
|
toUpdateList.add(apiScenarioWithBLOBs);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue