fix: 解决冲突

This commit is contained in:
chenjianxing 2021-01-26 15:12:33 +08:00
commit 824a5a9f0e
7 changed files with 58 additions and 30 deletions

View File

@ -55,6 +55,9 @@ public class ApiDefinitionExecResultService {
saveResult.setCreateTime(System.currentTimeMillis());
saveResult.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
saveResult.setName(item.getName());
if (item.getName().indexOf("<->") != -1) {
saveResult.setName(item.getName().substring(0, item.getName().indexOf("<->")));
}
saveResult.setResourceId(item.getName());
saveResult.setContent(JSON.toJSONString(item));
saveResult.setStartTime(item.getStartTime());

View File

@ -14,6 +14,7 @@ import io.metersphere.api.dto.scenario.request.RequestType;
import io.metersphere.api.dto.swaggerurl.SwaggerTaskResult;
import io.metersphere.api.dto.swaggerurl.SwaggerUrlRequest;
import io.metersphere.api.jmeter.JMeterService;
import io.metersphere.api.jmeter.RequestResult;
import io.metersphere.api.jmeter.TestResult;
import io.metersphere.api.parse.ApiImportParser;
import io.metersphere.api.parse.ApiImportParserFactory;
@ -297,7 +298,7 @@ public class ApiDefinitionService {
}
}
private ApiDefinition importCreate(ApiDefinitionResult request, ApiDefinitionMapper batchMapper,ApiTestImportRequest apiTestImportRequest) {
private ApiDefinition importCreate(ApiDefinitionResult request, ApiDefinitionMapper batchMapper, ApiTestImportRequest apiTestImportRequest) {
SaveApiDefinitionRequest saveReq = new SaveApiDefinitionRequest();
BeanUtils.copyBean(saveReq, request);
final ApiDefinitionWithBLOBs apiDefinition = new ApiDefinitionWithBLOBs();
@ -313,7 +314,7 @@ public class ApiDefinitionService {
apiDefinition.setDescription(request.getDescription());
List<ApiDefinition> sameRequest = getSameRequest(saveReq);
if(StringUtils.equals("fullCoverage",apiTestImportRequest.getModeId())){
if (StringUtils.equals("fullCoverage", apiTestImportRequest.getModeId())) {
if (CollectionUtils.isEmpty(sameRequest)) {
batchMapper.insert(apiDefinition);
} else {
@ -321,9 +322,9 @@ public class ApiDefinitionService {
apiDefinition.setId(sameRequest.get(0).getId());
apiDefinitionMapper.updateByPrimaryKeyWithBLOBs(apiDefinition);
}
}else if(StringUtils.equals("incrementalMerge",apiTestImportRequest.getModeId())){
} else if (StringUtils.equals("incrementalMerge", apiTestImportRequest.getModeId())) {
batchMapper.insert(apiDefinition);
}else{
} else {
if (CollectionUtils.isEmpty(sameRequest)) {
batchMapper.insert(apiDefinition);
} else {
@ -372,7 +373,11 @@ public class ApiDefinitionService {
public void addResult(TestResult res) {
if (!res.getScenarios().isEmpty() && !res.getScenarios().get(0).getRequestResults().isEmpty()) {
cache.put(res.getTestId(), res.getScenarios().get(0).getRequestResults().get(0));
RequestResult result = res.getScenarios().get(0).getRequestResults().get(0);
if (result.getName().indexOf("<->") != -1) {
result.setName(result.getName().substring(0, result.getName().indexOf("<->")));
}
cache.put(res.getTestId(), result);
} else {
MSException.throwException(Translator.get("test_not_found"));
}
@ -451,7 +456,7 @@ public class ApiDefinitionService {
item.setName(item.getName().substring(0, 255));
}
item.setNum(num++);
importCreate(item, batchMapper,request);
importCreate(item, batchMapper, request);
if (i % 300 == 0) {
sqlSession.flushStatements();
}
@ -614,7 +619,7 @@ public class ApiDefinitionService {
/*swagger定时导入*/
public void createSchedule(Schedule request) {
/*保存swaggerUrl*/
SwaggerUrlProject swaggerUrlProject=new SwaggerUrlProject();
SwaggerUrlProject swaggerUrlProject = new SwaggerUrlProject();
swaggerUrlProject.setId(UUID.randomUUID().toString());
swaggerUrlProject.setProjectId(request.getProjectId());
swaggerUrlProject.setSwaggerUrl(request.getResourceId());
@ -631,33 +636,38 @@ public class ApiDefinitionService {
this.addOrUpdateSwaggerImportCronJob(request);
}
//关闭
public void updateSchedule(Schedule request){
public void updateSchedule(Schedule request) {
scheduleService.editSchedule(request);
this.addOrUpdateSwaggerImportCronJob(request);
}
//删除
public void deleteSchedule(ScheduleInfoSwaggerUrlRequest request){
public void deleteSchedule(ScheduleInfoSwaggerUrlRequest request) {
swaggerUrlProjectMapper.deleteByPrimaryKey(request.getId());
scheduleMapper.deleteByPrimaryKey(request.getTaskId());
}
//查询swaggerUrl详情
public SwaggerUrlProject getSwaggerInfo(String resourceId){
public SwaggerUrlProject getSwaggerInfo(String resourceId) {
return swaggerUrlProjectMapper.selectByPrimaryKey(resourceId);
}
public String getResourceId(SwaggerUrlRequest swaggerUrlRequest){
SwaggerUrlProjectExample swaggerUrlProjectExample=new SwaggerUrlProjectExample();
SwaggerUrlProjectExample.Criteria criteria=swaggerUrlProjectExample.createCriteria();
public String getResourceId(SwaggerUrlRequest swaggerUrlRequest) {
SwaggerUrlProjectExample swaggerUrlProjectExample = new SwaggerUrlProjectExample();
SwaggerUrlProjectExample.Criteria criteria = swaggerUrlProjectExample.createCriteria();
criteria.andProjectIdEqualTo(swaggerUrlRequest.getProjectId()).andSwaggerUrlEqualTo(swaggerUrlRequest.getSwaggerUrl()).andModuleIdEqualTo(swaggerUrlRequest.getModuleId());
List<SwaggerUrlProject> list=swaggerUrlProjectMapper.selectByExample(swaggerUrlProjectExample);
String resourceId="";
if(list.size()==1){
resourceId=list.get(0).getId();
List<SwaggerUrlProject> list = swaggerUrlProjectMapper.selectByExample(swaggerUrlProjectExample);
String resourceId = "";
if (list.size() == 1) {
resourceId = list.get(0).getId();
}
return resourceId;
}
public List<SwaggerTaskResult> getSwaggerScheduleList(String projectId){
public List<SwaggerTaskResult> getSwaggerScheduleList(String projectId) {
return extSwaggerUrlScheduleMapper.getSwaggerTaskList(projectId);
}

View File

@ -412,6 +412,7 @@ public class HistoricalDataUpgradeService {
MsScenario step = new MsScenario();
step.setId(scenario1.getId());
step.setName(scenario1.getName());
step.setEnable(scenario.isEnable());
step.setType("scenario");
step.setResourceId(UUID.randomUUID().toString());
step.setReferenced("REF");

View File

@ -14,7 +14,7 @@
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
<ms-run :debug="false" :reportId="reportId" :run-data="runData"
<ms-run :debug="true" :reportId="reportId" :run-data="runData"
@runRefresh="runRefresh" ref="runTest"/>
</template>

View File

@ -42,6 +42,12 @@
this.isActive = true;
}
},
watch: {
result() {
this.response = this.result;
this.isActive = true;
}
},
methods: {
getExecResult() {
//

View File

@ -25,15 +25,15 @@
</span>
<span class="node-title">{{node.label}}</span>
</span>
</template>
</el-tree>
</div>
<template v-slot:footer>
<ms-dialog-footer
@cancel="close"
@confirm="save"/>
</template>
</el-dialog>
</template>
</el-tree>
</div>
<template v-slot:footer>
<ms-dialog-footer
@cancel="close"
@confirm="save"/>
</template>
</el-dialog>
</div>
</template>

View File

@ -257,9 +257,10 @@
<el-table-column prop="description" :label="$t('test_track.issue.description')">
<template v-slot:default="scope">
<el-popover
placement="left"
width="400"
placement="right"
width="500"
trigger="hover"
popper-class="issues-popover"
>
<ckeditor :editor="editor" disabled :config="readConfig"
v-model="scope.row.description"/>
@ -748,3 +749,10 @@ p {
z-index: 999;
}
</style>
<style>
.issues-popover {
height: 550px;
overflow: auto;
}
</style>