fix(接口测试): 修复因为解决别的缺陷导致的mock服务不能使用的问题
修复因为解决别的缺陷导致的mock服务不能使用的问题
This commit is contained in:
parent
39ef018d71
commit
739b4d2145
|
@ -32,8 +32,7 @@ public class MockApiController {
|
|||
public String postRequest(@PathVariable String projectSystemId, HttpServletRequest request, HttpServletResponse response) {
|
||||
Project project = baseProjectService.findBySystemId(projectSystemId);
|
||||
Map<String, String> requestHeaderMap = MockApiUtils.getHttpRequestHeader(request);
|
||||
String returnStr = mockConfigService.checkReturnWithMockExpectByBodyParam("POST", requestHeaderMap, project, request, response);
|
||||
return returnStr;
|
||||
return mockConfigService.checkReturnWithMockExpectByBodyParam("POST", requestHeaderMap, project, request, response);
|
||||
}
|
||||
|
||||
@GetMapping("/{projectSystemId}/**")
|
||||
|
@ -41,8 +40,7 @@ public class MockApiController {
|
|||
public String getRequest(@PathVariable String projectSystemId, HttpServletRequest request, HttpServletResponse response) {
|
||||
Project project = baseProjectService.findBySystemId(projectSystemId);
|
||||
Map<String, String> requestHeaderMap = MockApiUtils.getHttpRequestHeader(request);
|
||||
String returnStr = mockConfigService.checkReturnWithMockExpectByUrlParam("GET", requestHeaderMap, project, request, response);
|
||||
return returnStr;
|
||||
return mockConfigService.checkReturnWithMockExpectByUrlParam("GET", requestHeaderMap, project, request, response);
|
||||
}
|
||||
|
||||
@PutMapping("/{projectSystemId}/**")
|
||||
|
@ -50,8 +48,7 @@ public class MockApiController {
|
|||
public String putRequest(@PathVariable String projectSystemId, HttpServletRequest request, HttpServletResponse response) {
|
||||
Project project = baseProjectService.findBySystemId(projectSystemId);
|
||||
Map<String, String> requestHeaderMap = MockApiUtils.getHttpRequestHeader(request);
|
||||
String returnStr = mockConfigService.checkReturnWithMockExpectByBodyParam("PUT", requestHeaderMap, project, request, response);
|
||||
return returnStr;
|
||||
return mockConfigService.checkReturnWithMockExpectByBodyParam("PUT", requestHeaderMap, project, request, response);
|
||||
}
|
||||
|
||||
@PatchMapping("/{projectSystemId}/**")
|
||||
|
@ -59,8 +56,7 @@ public class MockApiController {
|
|||
public String patchRequest(@PathVariable String projectSystemId, HttpServletRequest request, HttpServletResponse response) {
|
||||
Project project = baseProjectService.findBySystemId(projectSystemId);
|
||||
Map<String, String> requestHeaderMap = MockApiUtils.getHttpRequestHeader(request);
|
||||
String returnStr = mockConfigService.checkReturnWithMockExpectByBodyParam("PATCH", requestHeaderMap, project, request, response);
|
||||
return returnStr;
|
||||
return mockConfigService.checkReturnWithMockExpectByBodyParam("PATCH", requestHeaderMap, project, request, response);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{projectSystemId}/**")
|
||||
|
@ -68,8 +64,7 @@ public class MockApiController {
|
|||
public String deleteRequest(@PathVariable String projectSystemId, HttpServletRequest request, HttpServletResponse response) {
|
||||
Project project = baseProjectService.findBySystemId(projectSystemId);
|
||||
Map<String, String> requestHeaderMap = MockApiUtils.getHttpRequestHeader(request);
|
||||
String returnStr = mockConfigService.checkReturnWithMockExpectByUrlParam("DELETE", requestHeaderMap, project, request, response);
|
||||
return returnStr;
|
||||
return mockConfigService.checkReturnWithMockExpectByUrlParam("DELETE", requestHeaderMap, project, request, response);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{projectSystemId}/**", method = RequestMethod.OPTIONS)
|
||||
|
@ -77,8 +72,7 @@ public class MockApiController {
|
|||
public String optionsRequest(@PathVariable String projectSystemId, HttpServletRequest request, HttpServletResponse response) {
|
||||
Project project = baseProjectService.findBySystemId(projectSystemId);
|
||||
Map<String, String> requestHeaderMap = MockApiUtils.getHttpRequestHeader(request);
|
||||
String returnStr = mockConfigService.checkReturnWithMockExpectByUrlParam("OPTIONS", requestHeaderMap, project, request, response);
|
||||
return returnStr;
|
||||
return mockConfigService.checkReturnWithMockExpectByUrlParam("OPTIONS", requestHeaderMap, project, request, response);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{projectSystemId}/**", method = RequestMethod.HEAD)
|
||||
|
|
|
@ -127,11 +127,17 @@ public class MockConfigService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 这个接口是生成用的!
|
||||
* 如果没数据就生成,有数据就返回一套数据结构!
|
||||
* 所有入参都没有必填项!
|
||||
* 如果为了查询,请写一个新的接口!
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public MockConfigResponse genMockConfig(MockConfigRequest request) {
|
||||
MockConfigResponse returnRsp;
|
||||
if (StringUtils.isEmpty(request.getId())) {
|
||||
return new MockConfigResponse(null, new ArrayList<>());
|
||||
}
|
||||
MockConfigExample example = new MockConfigExample();
|
||||
MockConfigExample.Criteria criteria = example.createCriteria();
|
||||
if (request.getId() != null) {
|
||||
|
@ -139,6 +145,8 @@ public class MockConfigService {
|
|||
}
|
||||
if (request.getApiId() != null) {
|
||||
criteria.andApiIdEqualTo(request.getApiId());
|
||||
} else if (StringUtils.isEmpty(request.getId())) {
|
||||
return new MockConfigResponse(null, new ArrayList<>());
|
||||
}
|
||||
if (request.getProjectId() != null) {
|
||||
criteria.andProjectIdEqualTo(request.getProjectId());
|
||||
|
|
|
@ -323,6 +323,7 @@ export default {
|
|||
},
|
||||
mockSetting() {
|
||||
let mockParam = {};
|
||||
|
||||
mockParam.projectId = this.projectId;
|
||||
if (this.currentApi.id) {
|
||||
mockParam.apiId = this.currentApi.id;
|
||||
|
|
Loading…
Reference in New Issue