diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/controller/ApiTestController.java b/backend/services/api-test/src/main/java/io/metersphere/api/controller/ApiTestController.java index 99ea236386..f45be2bdff 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/controller/ApiTestController.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/controller/ApiTestController.java @@ -1,6 +1,7 @@ package io.metersphere.api.controller; import io.metersphere.api.service.ApiTestService; +import io.metersphere.jmeter.mock.Mock; import io.metersphere.system.dto.ProtocolDTO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -29,4 +30,11 @@ public class ApiTestController { public List getProtocols(@PathVariable String organizationId) { return apiTestService.getProtocols(organizationId); } + + + @GetMapping("/mock/{key}") + @Operation(summary = "获取mock数据") + public String mock(@PathVariable String key) { + return Mock.calculate(key).toString(); + } } diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestControllerTests.java index c1dfd3c4ff..ebcb5dfc72 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestControllerTests.java @@ -18,6 +18,7 @@ public class ApiTestControllerTests extends BaseTest { private static final String BASE_PATH = "/api/test/"; protected static final String PROTOCOL_LIST = "protocol/{0}"; + protected static final String MOCK = "mock/{0}"; @Override protected String getBasePath() { @@ -29,4 +30,10 @@ public class ApiTestControllerTests extends BaseTest { // @@请求成功 this.requestGetWithOk(PROTOCOL_LIST, this.DEFAULT_ORGANIZATION_ID).andReturn(); } + + @Test + public void getMock() throws Exception { + // @@请求成功 + this.requestGetWithOk(MOCK, "@integer").andReturn(); + } } diff --git a/pom.xml b/pom.xml index f07bd0c583..de162285ae 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ 2.1.4 32.0.1-jre 6.0.0 - 1.5 + 3.0 1.0.7 3.23.5 5.1.0