|
@@ -4,11 +4,14 @@ import cn.seecoder.common.util.SpringUtil;
|
|
|
import cn.seecoder.web.core.pipeline.Context;
|
|
import cn.seecoder.web.core.pipeline.Context;
|
|
|
import cn.seecoder.web.core.pipeline.PipelineException;
|
|
import cn.seecoder.web.core.pipeline.PipelineException;
|
|
|
import cn.seecoder.web.service.APITest.APITestService;
|
|
import cn.seecoder.web.service.APITest.APITestService;
|
|
|
|
|
+import cn.seecoder.web.service.InterfaceTest.InterfaceTestService;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
|
import lombok.EqualsAndHashCode;
|
|
import lombok.EqualsAndHashCode;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author PuHong Weng
|
|
* @author PuHong Weng
|
|
@@ -21,36 +24,55 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
public class ApiTestHandler extends AbstractHandler {
|
|
public class ApiTestHandler extends AbstractHandler {
|
|
|
|
|
|
|
|
- private final APITestService apiTestService;
|
|
|
|
|
|
|
+// private final APITestService apiTestService;
|
|
|
|
|
+//
|
|
|
|
|
+// public ApiTestHandler() {
|
|
|
|
|
+// this.apiTestService = SpringUtil.getBean(APITestService.class);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 要自动执行的apiTest的json
|
|
|
|
|
+// * 格式 [1,2,3]
|
|
|
|
|
+// */
|
|
|
|
|
+// private Integer[] apiTestIds = new Integer[]{};
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public void process(Context context) throws PipelineException {
|
|
|
|
|
+// ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
+//// List<Integer> ids;
|
|
|
|
|
+//// try {
|
|
|
|
|
+//// ids = objectMapper.readValue(apiTestIds, new TypeReference<List<Integer>>() {
|
|
|
|
|
+//// });
|
|
|
|
|
+//// } catch (JsonProcessingException e) {
|
|
|
|
|
+//// throw new PipelineException(HttpStatus.SC_SERVICE_UNAVAILABLE,API_TEST_ID_RESOLVE_ERROR,e);
|
|
|
|
|
+//// }
|
|
|
|
|
+// for (Integer testId : apiTestIds){
|
|
|
|
|
+// try {
|
|
|
|
|
+// apiTestService.executeAPITest(testId);
|
|
|
|
|
+// } catch (InterruptedException e) {
|
|
|
|
|
+// log.warn("api test 出现 InterruptedException, 目前暂无特殊处理。 Test id: {}",testId);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+ private final InterfaceTestService interfaceTestService;
|
|
|
|
|
|
|
|
public ApiTestHandler() {
|
|
public ApiTestHandler() {
|
|
|
- this.apiTestService = SpringUtil.getBean(APITestService.class);
|
|
|
|
|
|
|
+ this.interfaceTestService = SpringUtil.getBean(InterfaceTestService.class);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 要自动执行的apiTest的json
|
|
|
|
|
- * 格式 [1,2,3]
|
|
|
|
|
- */
|
|
|
|
|
- private Integer[] apiTestIds = new Integer[]{};
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ private Integer[] interfaceTestIds = new Integer[]{};
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void process(Context context) throws PipelineException {
|
|
|
|
|
|
|
+ public void process(Context context) throws PipelineException {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
-// List<Integer> ids;
|
|
|
|
|
-// try {
|
|
|
|
|
-// ids = objectMapper.readValue(apiTestIds, new TypeReference<List<Integer>>() {
|
|
|
|
|
-// });
|
|
|
|
|
-// } catch (JsonProcessingException e) {
|
|
|
|
|
-// throw new PipelineException(HttpStatus.SC_SERVICE_UNAVAILABLE,API_TEST_ID_RESOLVE_ERROR,e);
|
|
|
|
|
-// }
|
|
|
|
|
- for (Integer testId : apiTestIds){
|
|
|
|
|
|
|
+ for (Integer testId : interfaceTestIds) {
|
|
|
try {
|
|
try {
|
|
|
- apiTestService.executeAPITest(testId);
|
|
|
|
|
- } catch (InterruptedException e) {
|
|
|
|
|
- log.warn("api test 出现 InterruptedException, 目前暂无特殊处理。 Test id: {}",testId);
|
|
|
|
|
|
|
+ interfaceTestService.executeInterfaceTestById(testId, "devcloud", "computer");
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ log.warn("interface test 出现 IOException, 目前暂无特殊处理。 Test id: {}",testId);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|