Commit e52b7286 authored by wdy's avatar wdy

测试用例二维矩阵

parent d74fddfa
package com.ruoyi.domain.vo;
import lombok.Data;
@Data
public class MethodVo {
private String name;
}
package com.ruoyi.domain.vo;
import lombok.Data;
@Data
public class ScenarioKEVO {
private String name;
}
......@@ -14,16 +14,20 @@ public class UseCaseVO {
private String name;
// 测试场景
private String scenario;
// private String scenario;
private ScenarioKEVO scenario;
// 测试方法
private String test_type;
// private String test_type;
private MethodVo method;
/**
* 返回用例在矩阵中的坐标
* @return
*/
public String getCoordinates() {
return scenario + test_type;
return scenario.getClass().getName() + method.getClass().getName();
}
}
......@@ -2,10 +2,12 @@ package com.ruoyi.service;
import com.ruoyi.web.response.MatrixResponse;
import java.io.IOException;
public interface MatrixService {
MatrixResponse getMatrix();
MatrixResponse getMatrixForUrl();
MatrixResponse getMatrixForUrl() throws IOException;
}
......@@ -11,9 +11,13 @@ import com.ruoyi.service.ITestTypeService;
import com.ruoyi.service.MatrixService;
import com.ruoyi.service.TestUseCaseService;
import com.ruoyi.web.response.MatrixResponse;
import lombok.Data;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -47,7 +51,7 @@ public class MatrixServiceImpl implements MatrixService {
}
@Override
public MatrixResponse getMatrixForUrl() {
public MatrixResponse getMatrixForUrl() throws IOException {
//以post形式请求接口
String result= HttpUtil.post("https://10.12.48.78:8090/DescribeScenarioTestTypeList","");
......@@ -71,10 +75,48 @@ public class MatrixServiceImpl implements MatrixService {
String caseResult= HttpUtil.post("https://10.12.48.78:8090/DescribeCaseList","");
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
// 创建请求体
String request = "{\"offset\": {\n" +
" \"offset\": 0,\n" +
" \"limit\": 9999\n" +
" },\n" +
" \"searchFields\":{\n" +
" \"name\": \"\",\n" +
" \"scenario\":\"\",\n" +
" \"method\":\"\"\n" +
" }}";
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query useCases($offset:OffsetConnectionInput$orderBy:OrderByInput$filter:Map$search:String$searchFields:Map){useCases(offset:$offset orderBy:$orderBy filterFields:$filter search:$search searchFields:$searchFields){nodes{id displayID class name description remediation requirements riskLevel method{name}scenario{name}}totalCount}}\",\"variables\":"+ request +"}");
Request requestKE = new Request.Builder()
.url("http://10.12.48.80:8089/api/query")
.method("POST", body)
.addHeader("Content-Type", "application/json")
// TODO 连接
// .addHeader("Host", "10.12.48.80:8089")
// .addHeader("Origin", "http://10.12.48.80:8089")
// .addHeader("Referer", "http://10.12.48.80:8089/api/graphql/playground")
// .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36")
.build();
Response responseR = client.newCall(requestKE).execute();
String string = responseR.body().string();
JSONObject jsonO = JSONObject.parseObject(string);
// System.out.println("jsonO = " + jsonO);
JSONObject object = JSONObject.parseObject(caseResult);
// 获取测试用例列表
List<UseCaseVO> caseList = object.getList("case_list", UseCaseVO.class);
List<UseCaseVO> caseList = jsonO.getJSONObject("data").getJSONObject("useCases").getList("nodes", UseCaseVO.class);
// List<UseCaseVO> caseList = object.getList("case_list", UseCaseVO.class);
MatrixResponse response = new MatrixResponse();
setHeaderName(response, testTypeList);
setRowsName(response, scenarioList, testTypeList, caseList);
......@@ -173,4 +215,21 @@ public class MatrixServiceImpl implements MatrixService {
}
return null;
}
@Data
public static class CaseVO {
private String id;
private String name;
private ScenarioKEVO scenario;
private MethodVo method;
public String getCoordinates() {
return scenario.getClass().getName() + method.getClass().getName();
}
}
}
......@@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
@Api(tags = "审查细则的审查结果")
@RestController
@RequestMapping("/usecase/matrix")
......@@ -24,7 +26,7 @@ public class MatrixController {
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/getInfo")
public R<MatrixResponse> getInfo() {
public R<MatrixResponse> getInfo() throws IOException {
return R.ok(matrixService.getMatrixForUrl());
}
......
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