Commit 57e17d94 authored by wdy's avatar wdy

Merge branch 'wangdingyi' into 'dev'

测试用例二维矩阵

See merge request !358
parents 399c73d2 4ab16587
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 { ...@@ -14,16 +14,20 @@ public class UseCaseVO {
private String name; private String name;
// 测试场景 // 测试场景
private String scenario; // private String scenario;
private ScenarioKEVO scenario;
// 测试方法 // 测试方法
private String test_type; // private String test_type;
private MethodVo method;
/** /**
* 返回用例在矩阵中的坐标 * 返回用例在矩阵中的坐标
* @return * @return
*/ */
public String getCoordinates() { public String getCoordinates() {
return scenario + test_type; return scenario.getClass().getName() + method.getClass().getName();
} }
} }
...@@ -2,10 +2,12 @@ package com.ruoyi.service; ...@@ -2,10 +2,12 @@ package com.ruoyi.service;
import com.ruoyi.web.response.MatrixResponse; import com.ruoyi.web.response.MatrixResponse;
import java.io.IOException;
public interface MatrixService { public interface MatrixService {
MatrixResponse getMatrix(); MatrixResponse getMatrix();
MatrixResponse getMatrixForUrl(); MatrixResponse getMatrixForUrl() throws IOException;
} }
...@@ -11,9 +11,13 @@ import com.ruoyi.service.ITestTypeService; ...@@ -11,9 +11,13 @@ import com.ruoyi.service.ITestTypeService;
import com.ruoyi.service.MatrixService; import com.ruoyi.service.MatrixService;
import com.ruoyi.service.TestUseCaseService; import com.ruoyi.service.TestUseCaseService;
import com.ruoyi.web.response.MatrixResponse; import com.ruoyi.web.response.MatrixResponse;
import lombok.Data;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -47,7 +51,7 @@ public class MatrixServiceImpl implements MatrixService { ...@@ -47,7 +51,7 @@ public class MatrixServiceImpl implements MatrixService {
} }
@Override @Override
public MatrixResponse getMatrixForUrl() { public MatrixResponse getMatrixForUrl() throws IOException {
//以post形式请求接口 //以post形式请求接口
String result= HttpUtil.post("https://10.12.48.78:8090/DescribeScenarioTestTypeList",""); String result= HttpUtil.post("https://10.12.48.78:8090/DescribeScenarioTestTypeList","");
...@@ -69,12 +73,48 @@ public class MatrixServiceImpl implements MatrixService { ...@@ -69,12 +73,48 @@ public class MatrixServiceImpl implements MatrixService {
} }
} }
String caseResult= HttpUtil.post("https://10.12.48.78:8090/DescribeCaseList",""); // 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();
JSONObject object = JSONObject.parseObject(caseResult); Response responseR = client.newCall(requestKE).execute();
String string = responseR.body().string();
JSONObject jsonO = JSONObject.parseObject(string);
// 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(); MatrixResponse response = new MatrixResponse();
setHeaderName(response, testTypeList); setHeaderName(response, testTypeList);
setRowsName(response, scenarioList, testTypeList, caseList); setRowsName(response, scenarioList, testTypeList, caseList);
...@@ -173,4 +213,21 @@ public class MatrixServiceImpl implements MatrixService { ...@@ -173,4 +213,21 @@ public class MatrixServiceImpl implements MatrixService {
} }
return null; 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; ...@@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
@Api(tags = "审查细则的审查结果") @Api(tags = "审查细则的审查结果")
@RestController @RestController
@RequestMapping("/usecase/matrix") @RequestMapping("/usecase/matrix")
...@@ -24,7 +26,7 @@ public class MatrixController { ...@@ -24,7 +26,7 @@ public class MatrixController {
@Trace @Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")}) @Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/getInfo") @RequestMapping(method = RequestMethod.POST, value = "/getInfo")
public R<MatrixResponse> getInfo() { public R<MatrixResponse> getInfo() throws IOException {
return R.ok(matrixService.getMatrixForUrl()); return R.ok(matrixService.getMatrixForUrl());
} }
......
...@@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModel; ...@@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ApiModel(value = "CarReviewTaskViewRequest", description = "查车辆审查任务") @ApiModel(value = "CarReviewTaskViewRequest", description = "查车辆审查任务")
@Data @Data
public class CarReviewTaskViewRequest { public class CarReviewTaskViewRequest {
......
...@@ -147,8 +147,8 @@ xss: ...@@ -147,8 +147,8 @@ xss:
minio: minio:
url: http://106.3.99.64:22013 url: http://106.3.99.64:22013
accessKey: lB7WhZYiQwLzhHPutRGn accessKey: FNGqDZnHJhrugLlZBh77
secretKey: 7XMWpLm6p4d20OFe9uXKifEyhF3cp4sTCowI2fhJ secretKey: TvnWeQxAQ1OYiAN68qlzEDJl5RqZ7tQYTMJ8XM0M
bucketName: vehicle-quality-review-oss bucketName: vehicle-quality-review-oss
......
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