Commit e746da10 authored by wdy's avatar wdy

科恩获取树状测试用例、获取标准要求

parent 5a7f5891
package com.ruoyi.domain.vo;
import lombok.Data;
import java.util.List;
/**
* 标准要求VO
*/
@Data
public class StandardNewVO {
// 标准要求id
private String id;
// 标准要求章节号
private String serialNumber;
// 标准要求
private String requirements;
// 用例VO
List<UseCaseNewVO> useCases;
}
package com.ruoyi.domain.vo;
import lombok.Data;
/**
* 测试用例VO
*/
@Data
public class UseCaseNewVO {
// 用例id
private String id;
// 用例编号
private String customizedID;
// 用例描述
private String description;
}
...@@ -7,6 +7,8 @@ import com.ruoyi.domain.vo.UseCaseUrlVO; ...@@ -7,6 +7,8 @@ import com.ruoyi.domain.vo.UseCaseUrlVO;
import com.ruoyi.web.request.TestUseCaseByScenarioRequest; import com.ruoyi.web.request.TestUseCaseByScenarioRequest;
import com.ruoyi.web.request.TestUseCaseIdListRequest; import com.ruoyi.web.request.TestUseCaseIdListRequest;
import com.ruoyi.web.request.TestUserCaseRequest; import com.ruoyi.web.request.TestUserCaseRequest;
import com.ruoyi.web.response.TestStandardListResponse;
import com.ruoyi.web.response.TestUserCaseListNewResponse;
import com.ruoyi.web.response.TestUserCaseListResponse; import com.ruoyi.web.response.TestUserCaseListResponse;
import com.ruoyi.web.response.UseCaseResponse; import com.ruoyi.web.response.UseCaseResponse;
...@@ -81,4 +83,20 @@ public interface TestUseCaseService extends IService<TestUseCase> { ...@@ -81,4 +83,20 @@ public interface TestUseCaseService extends IService<TestUseCase> {
* @throws IOException * @throws IOException
*/ */
List<String> selectCaseListByScenario(String request) throws IOException; List<String> selectCaseListByScenario(String request) throws IOException;
/**
* 科恩获取测试用例新
* @param request
* @return
* @throws IOException
*/
TestUserCaseListNewResponse getUseCaseListNew(String request) throws IOException;
/**
* 科恩获取测试标准要求
* @param request
* @return
* @throws IOException
*/
TestStandardListResponse getStandardList(String request) throws IOException;
} }
...@@ -10,6 +10,8 @@ import com.ruoyi.mapper.TestUseCaseMapper; ...@@ -10,6 +10,8 @@ import com.ruoyi.mapper.TestUseCaseMapper;
import com.ruoyi.web.request.TestUseCaseByScenarioRequest; import com.ruoyi.web.request.TestUseCaseByScenarioRequest;
import com.ruoyi.web.request.TestUseCaseIdListRequest; import com.ruoyi.web.request.TestUseCaseIdListRequest;
import com.ruoyi.web.request.TestUserCaseRequest; import com.ruoyi.web.request.TestUserCaseRequest;
import com.ruoyi.web.response.TestStandardListResponse;
import com.ruoyi.web.response.TestUserCaseListNewResponse;
import com.ruoyi.web.response.TestUserCaseListResponse; import com.ruoyi.web.response.TestUserCaseListResponse;
import com.ruoyi.web.response.UseCaseResponse; import com.ruoyi.web.response.UseCaseResponse;
import lombok.Data; import lombok.Data;
...@@ -270,6 +272,87 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU ...@@ -270,6 +272,87 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
/**
* 科恩获取测试用例新
* @param request
* @return
* @throws IOException
*/
@Override
public TestUserCaseListNewResponse getUseCaseListNew(String request) throws IOException {
TestUserCaseListNewResponse userCaseResponse = new TestUserCaseListNewResponse();
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
// 创建请求体
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query regulationAllUseCases($offset:OffsetConnectionInput$name: String!){regulationByName(name:$name){items(offset:$offset){ nodes{id serialNumber requirements useCases{id customizedID description}}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("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjAsInRva2VuaWQiOjYxLCJ0eXBlIjoiYXBpIiwidXNlcm5hbWUiOiJhZG1pbiJ9.48Ggjx-FtOcecf73vAHn0XglwgLXZlfXxhXiLDHWWQE")
// .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 response = client.newCall(requestKE).execute();
String string = response.body().string();
JSONObject jsonObject = JSONObject.parseObject(string);
// 获取测试用例
List<StandardNewVO> list = jsonObject.getJSONObject("data").getJSONObject("regulationByName").getJSONObject("items").getList("nodes", StandardNewVO.class);
userCaseResponse.setUseCases(list);
// 获取总条数
Integer totalCount = (Integer) jsonObject.getJSONObject("data").getJSONObject("regulationByName").getJSONObject("items").get("totalCount");
userCaseResponse.setTotalCount(totalCount);
return userCaseResponse;
}
@Override
public TestStandardListResponse getStandardList(String request) throws IOException {
TestStandardListResponse standardListResponse = new TestStandardListResponse();
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
// 创建请求体
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query regulationItems($name:String!$offset:OffsetConnectionInput$orderBy:OrderByInput$searchFields:Map){regulationByName(name:$name){items(offset:$offset orderBy:$orderBy searchFields:$searchFields){totalCount nodes{id serialNumber requirements}}}}\",\"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("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjAsInRva2VuaWQiOjYxLCJ0eXBlIjoiYXBpIiwidXNlcm5hbWUiOiJhZG1pbiJ9.48Ggjx-FtOcecf73vAHn0XglwgLXZlfXxhXiLDHWWQE")
// .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 response = client.newCall(requestKE).execute();
String string = response.body().string();
JSONObject jsonObject = JSONObject.parseObject(string);
// 获取测试用例
List<StandardNewVO> list = jsonObject.getJSONObject("data").getJSONObject("regulationByName").getJSONObject("items").getList("nodes", StandardNewVO.class);
standardListResponse.setStandards(list);
// 获取总条数
Integer totalCount = (Integer) jsonObject.getJSONObject("data").getJSONObject("regulationByName").getJSONObject("items").get("totalCount");
standardListResponse.setTotalCount(totalCount);
return standardListResponse;
}
} }
......
...@@ -8,6 +8,8 @@ import com.ruoyi.service.TestUseCaseService; ...@@ -8,6 +8,8 @@ import com.ruoyi.service.TestUseCaseService;
import com.ruoyi.web.request.TestUseCaseByScenarioRequest; import com.ruoyi.web.request.TestUseCaseByScenarioRequest;
import com.ruoyi.web.request.TestUseCaseIdListRequest; import com.ruoyi.web.request.TestUseCaseIdListRequest;
import com.ruoyi.web.request.TestUserCaseRequest; import com.ruoyi.web.request.TestUserCaseRequest;
import com.ruoyi.web.response.TestStandardListResponse;
import com.ruoyi.web.response.TestUserCaseListNewResponse;
import com.ruoyi.web.response.TestUserCaseListResponse; import com.ruoyi.web.response.TestUserCaseListResponse;
import com.ruoyi.web.response.UseCaseResponse; import com.ruoyi.web.response.UseCaseResponse;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -83,13 +85,33 @@ public class TestUserCaseController extends BaseController{ ...@@ -83,13 +85,33 @@ public class TestUserCaseController extends BaseController{
@ApiOperation("查询测试用例分页查询(科恩)") @ApiOperation("查询测试用例分页查询(科恩)")
@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 = "/getUseCaseList", produces="application/json;charset=UTF-8") @RequestMapping(method = RequestMethod.POST, value = "/getUseCaseListOld", produces="application/json;charset=UTF-8")
public R<TestUserCaseListResponse> getUseCaseList(@Validated @RequestBody String request) throws IOException { public R<TestUserCaseListResponse> getUseCaseListOld(@Validated @RequestBody String request) throws IOException {
return R.ok(testUseCaseService.getUseCaseList(request)); return R.ok(testUseCaseService.getUseCaseList(request));
} }
@ApiOperation("查询测试用例(科恩)新")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/getUseCaseList", produces="application/json;charset=UTF-8")
public R<TestUserCaseListNewResponse> getUseCaseList(@Validated @RequestBody String request) throws IOException {
return R.ok(testUseCaseService.getUseCaseListNew(request));
}
@ApiOperation("查询测试标准要求(科恩)")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/getStandardList", produces="application/json;charset=UTF-8")
public R<TestStandardListResponse> getStandardList(@Validated @RequestBody String request) throws IOException {
return R.ok(testUseCaseService.getStandardList(request));
}
/** /**
* 科恩获取首页信息 * 科恩获取首页信息
......
package com.ruoyi.web.response;
import com.ruoyi.domain.vo.StandardNewVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel(value = "TestUserCaseListResponse", description = "查询测试用例")
@Data
public class TestStandardListResponse {
@ApiModelProperty("测试标准要求")
List<StandardNewVO> standards;
@ApiModelProperty("总条数")
Integer totalCount;
}
package com.ruoyi.web.response;
import com.ruoyi.domain.vo.StandardNewVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel(value = "TestUserCaseListResponse", description = "查询测试用例")
@Data
public class TestUserCaseListNewResponse {
@ApiModelProperty("测试用例")
List<StandardNewVO> useCases;
@ApiModelProperty("总条数")
Integer totalCount;
}
package com.ruoyi;
import com.alibaba.fastjson2.JSONObject;
import okhttp3.*;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.io.IOException;
@SpringBootTest
public class TestUrlUseCase {
@Test
public void test() throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
// 定义查询变量
String variables = "{\n" +
" \"offset\": {\n" +
" \"offset\": 0,\n" +
" \"limit\": 10\n" +
" },\n" +
" \"name\": \"汽车整车信息安全技术要求\"\n" +
"}";
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query regulationAllUseCases($offset:OffsetConnectionInput$name: String!){regulationByName(name:$name){items(offset:$offset){ nodes{id serialNumber requirements useCases{id customizedID description}}totalCount}}}\",\"variables\":"+ variables +"}");
Request requestKs = new Request.Builder()
.url("http://10.12.48.80:8089/api/query")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjAsInRva2VuaWQiOjYxLCJ0eXBlIjoiYXBpIiwidXNlcm5hbWUiOiJhZG1pbiJ9.48Ggjx-FtOcecf73vAHn0XglwgLXZlfXxhXiLDHWWQE")
.build();
Response response = client.newCall(requestKs).execute();
String string = response.body().string();
JSONObject jsonObject = JSONObject.parseObject(string);
System.out.println("jsonObject = " + jsonObject);
// List<UseCaseUrlVO> list = jsonObject.getJSONObject("data").getJSONObject("useCases").getList("nodes", UseCaseUrlVO.class);
// list.forEach(item -> {
// System.out.println("item = " + item);
// });
}
}
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