Commit c441b357 authored by 盖献康's avatar 盖献康

车型试验开始子任务时所需 测试场景以及场景-用例

parent 2fc4cbcb
......@@ -2,7 +2,6 @@ package com.ruoyi.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.domain.TestScenario;
import com.ruoyi.domain.TestType;
import com.ruoyi.web.request.TestScenarioRequest;
import java.util.List;
......@@ -16,4 +15,10 @@ public interface ITestScenarioService extends IService<TestScenario> {
* @return 测试场景库集合
*/
public List<TestScenario> selectTestScenarioList(TestScenarioRequest testScenarioRequest);
/**
* 获取测试场景列表(科恩)
* @return
*/
public List<String> selectScenarioList();
}
package com.ruoyi.service;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.domain.TestUseCase;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.web.request.TestUseCaseByScenarioRequest;
import com.ruoyi.web.request.TestUseCaseIdListRequest;
import com.ruoyi.web.request.TestUserCaseRequest;
import java.util.List;
import java.util.Map;
/**
* @author wangfei
......@@ -27,4 +30,19 @@ public interface TestUseCaseService extends IService<TestUseCase> {
* @return
*/
List<String> selectCaseIdList(TestUseCaseIdListRequest request);
/**
* 通过测试场景获取所绑定的测试用例
* @param request
* @return
*/
List<String> selectCaseByScenario(TestUseCaseByScenarioRequest request);
/**
* 调用第三方接口
* @param url
* @param map
* @return
*/
JSONObject callThirdPartyInterface(String url, Map<String, Object> map);
}
package com.ruoyi.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.domain.TestScenario;
import com.ruoyi.mapper.TestScenarioMapper;
import com.ruoyi.service.ITestScenarioService;
import com.ruoyi.service.TestUseCaseService;
import com.ruoyi.web.request.TestScenarioRequest;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
@Service
@Transactional
......@@ -18,6 +22,11 @@ public class TestScenarioServiceImpl extends ServiceImpl<TestScenarioMapper, Tes
@Autowired
private TestScenarioMapper testScenarioMapper;
@Autowired
private TestUseCaseService testUseCaseService;
private static String url = "https://10.12.48.78:8090/DescribeScenarioTestTypeList";
@Override
public List<TestScenario> selectTestScenarioList(TestScenarioRequest testScenarioRequest){
if(testScenarioRequest.getTestScenario() != null && (testScenarioRequest.getTestScenario().contains("%") ||testScenarioRequest.getTestScenario().contains("_") )){
......@@ -25,4 +34,25 @@ public class TestScenarioServiceImpl extends ServiceImpl<TestScenarioMapper, Tes
}
return testScenarioMapper.selectTestScenarioList(testScenarioRequest);
}
/**
* 获取测试场景列表(科恩)
* @return
*/
@Override
public List<String> selectScenarioList() {
JSONObject jsonObject = testUseCaseService.callThirdPartyInterface(url, null);
List<String> scenarioList = jsonObject.getList("scenario_list", Scenario.class)
.stream()
.map(Scenario::getName)
.collect(Collectors.toList());
return scenarioList;
}
@Data
public class Scenario {
private String name;
}
}
package com.ruoyi.service.impl;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.domain.TestUseCase;
import com.ruoyi.domain.vo.CaseResultVO;
import com.ruoyi.domain.vo.TestUsecaseVO;
import com.ruoyi.service.TestUseCaseService;
import com.ruoyi.mapper.TestUseCaseMapper;
import com.ruoyi.web.request.TestUseCaseByScenarioRequest;
import com.ruoyi.web.request.TestUseCaseIdListRequest;
import com.ruoyi.web.request.TestUserCaseRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
......@@ -23,6 +30,8 @@ import java.util.stream.Collectors;
@Transactional
public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestUseCase> implements TestUseCaseService{
private String describeCaseList = "https://10.12.48.78:8090/DescribeCaseList";
@Autowired
private TestUseCaseMapper testUseCaseMapper;
......@@ -46,6 +55,39 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU
return list.stream().map(TestUsecaseVO::getCaseId).collect(Collectors.toList());
}
/**
* 通过测试场景获取所绑定的测试用例
* @param request
* @return
*/
@Override
public List<String> selectCaseByScenario(TestUseCaseByScenarioRequest request) {
// 根据场景名遍历查询所绑定用例
List<String> resultList = new ArrayList<>();
request.getScenarioNameList()
.forEach(scenarioName -> {
Map<String, Object> map = new HashMap<>();
map.put("scenario", scenarioName);
JSONObject jsonObject = callThirdPartyInterface(describeCaseList, map);
List<String> list = jsonObject.getList("case_list", CaseResultVO.class)
.stream().map(CaseResultVO::getId).collect(Collectors.toList());
resultList.addAll(list);
});
return resultList;
}
/**
* 调用第三方接口
* @param url
* @param map
* @return
*/
@Override
public JSONObject callThirdPartyInterface(String url, Map<String, Object> map) {
String result = HttpUtil.post(url, JSONObject.toJSONString(map));
return JSONObject.parseObject(result);
}
}
......
......@@ -3,7 +3,6 @@ package com.ruoyi.web;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.domain.Sample;
import com.ruoyi.domain.TestScenario;
import com.ruoyi.service.ITestScenarioService;
import com.ruoyi.web.request.TestScenarioRequest;
......@@ -14,10 +13,7 @@ import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -54,4 +50,13 @@ public class TestScenarioController extends BaseController {
return R.ok(testScenarioService.selectTestScenarioList(testScenarioRequest));
}
/**
* 获取测试场景列表(科恩)
*/
@ApiOperation("查询测试场景(科恩)")
@PostMapping("/getScenarioList")
public R<List<String>> getScenarioList(){
return R.ok(testScenarioService.selectScenarioList());
}
}
package com.ruoyi.web;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.domain.TestUseCase;
import com.ruoyi.service.TestUseCaseService;
import com.ruoyi.web.request.TestUseCaseByScenarioRequest;
import com.ruoyi.web.request.TestUseCaseIdListRequest;
import com.ruoyi.web.request.TestUserCaseRequest;
import io.swagger.annotations.Api;
......@@ -41,10 +41,20 @@ public class TestUserCaseController extends BaseController{
* @param request
* @return
*/
@Anonymous
@ApiOperation("根据场景查询用例ID集合")
@PostMapping("/getCaseIdList")
public R<List<String>> getCaseIdList(@Validated @RequestBody TestUseCaseIdListRequest request) {
return R.ok(testUseCaseService.selectCaseIdList(request));
}
/**
* 通过测试场景获取所绑定的测试用例
* @param request
* @return
*/
@ApiOperation("根据场景查询用例ID集合(科恩)")
@PostMapping("/getCaseByScenario")
public R<List<String>> getCaseByScenario(@Validated @RequestBody TestUseCaseByScenarioRequest request) {
return R.ok(testUseCaseService.selectCaseByScenario(request));
}
}
package com.ruoyi.web.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 通过测试场景获取测试用例ID集合 DTO
* @author gxk
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("通过测试场景获取测试用例ID集合 DTO")
public class TestUseCaseByScenarioRequest {
@ApiModelProperty("测试场景名称集合")
private List<String> scenarioNameList;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment