fix: 解决冲突
This commit is contained in:
commit
30a1858ffa
|
@ -19,7 +19,7 @@
|
|||
<java.version>1.8</java.version>
|
||||
<jmeter.version>5.2.1</jmeter.version>
|
||||
<nacos.version>1.1.3</nacos.version>
|
||||
<dubbo.version>2.7.7</dubbo.version>
|
||||
<dubbo.version>2.7.8</dubbo.version>
|
||||
<graalvm.version>20.1.0</graalvm.version>
|
||||
</properties>
|
||||
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
package io.metersphere.api.controller;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.api.dto.APIReportResult;
|
||||
import io.metersphere.api.dto.ApiTestImportRequest;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionRequest;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionResult;
|
||||
import io.metersphere.api.dto.definition.RunDefinitionRequest;
|
||||
import io.metersphere.api.dto.definition.SaveApiDefinitionRequest;
|
||||
import io.metersphere.api.service.ApiDefinitionService;
|
||||
import io.metersphere.base.domain.ApiDefinition;
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.commons.utils.PageUtils;
|
||||
import io.metersphere.commons.utils.Pager;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/definition")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
|
||||
public class ApiDefinitionController {
|
||||
@Resource
|
||||
private ApiDefinitionService apiDefinitionService;
|
||||
|
||||
@PostMapping("/list/{goPage}/{pageSize}")
|
||||
public Pager<List<ApiDefinitionResult>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDefinitionRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||
return PageUtils.setPageInfo(page, apiDefinitionService.list(request));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/create", consumes = {"multipart/form-data"})
|
||||
public void create(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||
apiDefinitionService.create(request, bodyFiles);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/update", consumes = {"multipart/form-data"})
|
||||
public void update(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||
apiDefinitionService.update(request, bodyFiles);
|
||||
}
|
||||
|
||||
@GetMapping("/delete/{id}")
|
||||
public void delete(@PathVariable String id) {
|
||||
apiDefinitionService.delete(id);
|
||||
}
|
||||
|
||||
@PostMapping("/deleteBatch")
|
||||
public void deleteBatch(@RequestBody List<String> ids) {
|
||||
apiDefinitionService.deleteBatch(ids);
|
||||
}
|
||||
|
||||
@PostMapping("/removeToGc")
|
||||
public void removeToGc(@RequestBody List<String> ids) {
|
||||
apiDefinitionService.removeToGc(ids);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/get/{id}")
|
||||
public ApiDefinition get(@PathVariable String id) {
|
||||
return apiDefinitionService.get(id);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/run/debug", consumes = {"multipart/form-data"})
|
||||
public String runDebug(@RequestPart("request") RunDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||
return apiDefinitionService.run(request, bodyFiles);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/run", consumes = {"multipart/form-data"})
|
||||
public String run(@RequestPart("request") RunDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||
return apiDefinitionService.run(request, bodyFiles);
|
||||
}
|
||||
|
||||
@GetMapping("/report/get/{testId}/{test}")
|
||||
public APIReportResult get(@PathVariable String testId, @PathVariable String test) {
|
||||
return apiDefinitionService.getResult(testId, test);
|
||||
}
|
||||
|
||||
@GetMapping("/report/getReport/{testId}")
|
||||
public APIReportResult getReport(@PathVariable String testId) {
|
||||
return apiDefinitionService.getDbResult(testId);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/import", consumes = {"multipart/form-data"})
|
||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public String testCaseImport(@RequestPart(value = "file", required = false) MultipartFile file, @RequestPart("request") ApiTestImportRequest request) {
|
||||
return apiDefinitionService.apiTestImport(file, request);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package io.metersphere.api.controller;
|
||||
|
||||
import io.metersphere.api.dto.definition.ApiModuleDTO;
|
||||
import io.metersphere.api.dto.definition.DragModuleRequest;
|
||||
import io.metersphere.api.service.ApiModuleService;
|
||||
import io.metersphere.base.domain.ApiModule;
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.service.CheckOwnerService;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RequestMapping("/api/module")
|
||||
@RestController
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER, RoleConstants.ORG_ADMIN}, logical = Logical.OR)
|
||||
public class ApiModuleController {
|
||||
|
||||
@Resource
|
||||
ApiModuleService apiModuleService;
|
||||
@Resource
|
||||
private CheckOwnerService checkOwnerService;
|
||||
|
||||
@GetMapping("/list/{projectId}/{protocol}")
|
||||
public List<ApiModuleDTO> getNodeByProjectId(@PathVariable String projectId,@PathVariable String protocol) {
|
||||
checkOwnerService.checkProjectOwner(projectId);
|
||||
return apiModuleService.getNodeTreeByProjectId(projectId,protocol);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public String addNode(@RequestBody ApiModule node) {
|
||||
return apiModuleService.addNode(node);
|
||||
}
|
||||
|
||||
@PostMapping("/edit")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public int editNode(@RequestBody DragModuleRequest node) {
|
||||
return apiModuleService.editNode(node);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public int deleteNode(@RequestBody List<String> nodeIds) {
|
||||
//nodeIds 包含删除节点ID及其所有子节点ID
|
||||
return apiModuleService.deleteNode(nodeIds);
|
||||
}
|
||||
|
||||
@PostMapping("/drag")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public void dragNode(@RequestBody DragModuleRequest node) {
|
||||
apiModuleService.dragNode(node);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package io.metersphere.api.controller;
|
||||
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseResult;
|
||||
import io.metersphere.api.dto.definition.SaveApiTestCaseRequest;
|
||||
import io.metersphere.api.service.ApiTestCaseService;
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/testcase")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
|
||||
public class ApiTestCaseController {
|
||||
|
||||
@Resource
|
||||
private ApiTestCaseService apiTestCaseService;
|
||||
|
||||
@PostMapping("/list")
|
||||
public List<ApiTestCaseResult> list(@RequestBody ApiTestCaseRequest request) {
|
||||
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||
return apiTestCaseService.list(request);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/create", consumes = {"multipart/form-data"})
|
||||
public void create(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||
apiTestCaseService.create(request, bodyFiles);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/update", consumes = {"multipart/form-data"})
|
||||
public void update(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||
apiTestCaseService.update(request, bodyFiles);
|
||||
}
|
||||
|
||||
@GetMapping("/delete/{id}")
|
||||
public void delete(@PathVariable String id) {
|
||||
apiTestCaseService.delete(id);
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,8 @@ import lombok.Setter;
|
|||
@Getter
|
||||
public class ApiTestImportRequest {
|
||||
private String name;
|
||||
private String moduleId;
|
||||
private String modulePath;
|
||||
private String environmentId;
|
||||
private String projectId;
|
||||
private String platform;
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiComputeResult {
|
||||
private String apiDefinitionId;
|
||||
private String caseTotal;
|
||||
private String status;
|
||||
private String passRate;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiDTO extends TestCaseWithBLOBs {
|
||||
|
||||
private String maintainerName;
|
||||
private String apiName;
|
||||
private String performName;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.controller.request.OrderRequest;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiDefinitionRequest {
|
||||
|
||||
private String id;
|
||||
private String excludeId;
|
||||
private String projectId;
|
||||
private String moduleId;
|
||||
private List<String> moduleIds;
|
||||
private String protocol;
|
||||
private String name;
|
||||
private String workspaceId;
|
||||
private String userId;
|
||||
private boolean recent = false;
|
||||
private List<OrderRequest> orders;
|
||||
private List<String> filters;
|
||||
private Map<String, Object> combine;
|
||||
private List<String> ids;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.base.domain.ApiDefinition;
|
||||
import io.metersphere.base.domain.Schedule;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class ApiDefinitionResult extends ApiDefinition {
|
||||
|
||||
private String projectName;
|
||||
|
||||
private String userName;
|
||||
|
||||
private String caseTotal;
|
||||
|
||||
private String caseStatus;
|
||||
|
||||
private String casePassingRate;
|
||||
|
||||
private Schedule schedule;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.base.domain.ApiModule;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiModuleDTO extends ApiModule {
|
||||
|
||||
private String label;
|
||||
private List<ApiModuleDTO> children;
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.controller.request.OrderRequest;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiTestCaseRequest {
|
||||
|
||||
private String id;
|
||||
private String projectId;
|
||||
private String priority;
|
||||
private String name;
|
||||
private String environmentId;
|
||||
private String workspaceId;
|
||||
private String apiDefinitionId;
|
||||
private List<OrderRequest> orders;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.base.domain.ApiTestCase;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class ApiTestCaseResult extends ApiTestCase {
|
||||
private String projectName;
|
||||
private String createUser;
|
||||
private String updateUser;
|
||||
private String execResult;
|
||||
private boolean active = false;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.base.domain.ApiModule;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class DragModuleRequest extends ApiModule {
|
||||
|
||||
List<String> nodeIds;
|
||||
ApiModuleDTO nodeTree;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import io.metersphere.api.dto.definition.response.Response;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class RunDefinitionRequest {
|
||||
|
||||
private String id;
|
||||
|
||||
private String reportId;
|
||||
|
||||
private MsTestElement testElement;
|
||||
|
||||
private Response response;
|
||||
|
||||
private List<String> bodyUploadIds;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import io.metersphere.api.dto.definition.response.Response;
|
||||
import io.metersphere.base.domain.Schedule;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class SaveApiDefinitionRequest {
|
||||
|
||||
private String id;
|
||||
|
||||
private String reportId;
|
||||
|
||||
private String projectId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String path;
|
||||
|
||||
private String protocol;
|
||||
|
||||
private String moduleId;
|
||||
|
||||
private String status;
|
||||
|
||||
private String description;
|
||||
|
||||
private String modulePath;
|
||||
|
||||
private String method;
|
||||
|
||||
private MsTestElement request;
|
||||
|
||||
private Response response;
|
||||
|
||||
private String environmentId;
|
||||
|
||||
private String userId;
|
||||
|
||||
private Schedule schedule;
|
||||
|
||||
private String triggerMode;
|
||||
|
||||
private List<String> bodyUploadIds;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class SaveApiTestCaseRequest {
|
||||
|
||||
private String id;
|
||||
|
||||
private String projectId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String priority;
|
||||
|
||||
private String apiDefinitionId;
|
||||
|
||||
private String description;
|
||||
|
||||
private MsTestElement request;
|
||||
|
||||
private String response;
|
||||
|
||||
private String crateUserId;
|
||||
|
||||
private String updateUserId;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private Long updateTime;
|
||||
|
||||
private List<String> bodyUploadIds;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package io.metersphere.api.dto.definition.parse;
|
||||
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionResult;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ApiDefinitionImport {
|
||||
private String projectName;
|
||||
private String protocol;
|
||||
private List<ApiDefinitionResult> data;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package io.metersphere.api.dto.definition.parse.postman;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PostmanCollection {
|
||||
|
||||
private PostmanCollectionInfo info;
|
||||
private List<PostmanItem> item;
|
||||
private List<PostmanKeyValue> variable;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package io.metersphere.api.dto.definition.parse.postman;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PostmanCollectionInfo {
|
||||
|
||||
@JSONField(name = "_postman_id")
|
||||
private String postmanId;
|
||||
private String name;
|
||||
private String schema;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.api.dto.definition.parse.postman;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PostmanItem {
|
||||
private String name;
|
||||
private PostmanRequest request;
|
||||
private List<PostmanItem> item;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package io.metersphere.api.dto.definition.parse.postman;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PostmanKeyValue {
|
||||
private String key;
|
||||
private String value;
|
||||
private String type;
|
||||
|
||||
public PostmanKeyValue() {
|
||||
}
|
||||
|
||||
public PostmanKeyValue(String key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package io.metersphere.api.dto.definition.parse.postman;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PostmanRequest {
|
||||
|
||||
private String method;
|
||||
private String schema;
|
||||
private List<PostmanKeyValue> header;
|
||||
private JSONObject body;
|
||||
private JSONObject auth;
|
||||
private PostmanUrl url;
|
||||
private String description;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package io.metersphere.api.dto.definition.parse.postman;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PostmanUrl {
|
||||
|
||||
private String raw;
|
||||
private String protocol;
|
||||
private String port;
|
||||
private List<PostmanKeyValue> query;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package io.metersphere.api.dto.definition.parse.swagger;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SwaggerApi {
|
||||
private String swagger;
|
||||
private SwaggerInfo info;
|
||||
private String host;
|
||||
private String basePath;
|
||||
private List<String> schemes;
|
||||
private List<SwaggerTag> tags;
|
||||
private JSONObject paths;
|
||||
private JSONObject definitions;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package io.metersphere.api.dto.definition.parse.swagger;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SwaggerInfo {
|
||||
private String version;
|
||||
private String title;
|
||||
private String description;
|
||||
private String termsOfService;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package io.metersphere.api.dto.definition.parse.swagger;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SwaggerParameter {
|
||||
private String name;
|
||||
private String in;
|
||||
private String description;
|
||||
private Boolean required;
|
||||
private String type;
|
||||
private String format;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package io.metersphere.api.dto.definition.parse.swagger;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SwaggerRequest {
|
||||
private List<String> tags;
|
||||
private String summary;
|
||||
private String description;
|
||||
private String operationId;
|
||||
private List<String> consumes;
|
||||
private List<String> produces;
|
||||
private List<SwaggerParameter> parameters;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package io.metersphere.api.dto.definition.parse.swagger;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SwaggerTag {
|
||||
private String name;
|
||||
private String description;
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package io.metersphere.api.dto.definition.request;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import io.metersphere.api.dto.definition.request.assertions.MsAssertions;
|
||||
import io.metersphere.api.dto.definition.request.auth.MsAuthManager;
|
||||
import io.metersphere.api.dto.definition.request.configurations.MsHeaderManager;
|
||||
import io.metersphere.api.dto.definition.request.extract.MsExtract;
|
||||
import io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor;
|
||||
import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor;
|
||||
import io.metersphere.api.dto.definition.request.sampler.MsDubboSampler;
|
||||
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
|
||||
import io.metersphere.api.dto.definition.request.sampler.MsJDBCSampler;
|
||||
import io.metersphere.api.dto.definition.request.sampler.MsTCPSampler;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import lombok.Data;
|
||||
import org.apache.jmeter.protocol.http.control.AuthManager;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
import org.apache.jorphan.collections.ListedHashTree;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type")
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = MsHTTPSamplerProxy.class, name = "HTTPSamplerProxy"),
|
||||
@JsonSubTypes.Type(value = MsHeaderManager.class, name = "HeaderManager"),
|
||||
@JsonSubTypes.Type(value = MsJSR223PostProcessor.class, name = "JSR223PostProcessor"),
|
||||
@JsonSubTypes.Type(value = MsJSR223PreProcessor.class, name = "JSR223PreProcessor"),
|
||||
@JsonSubTypes.Type(value = MsTestPlan.class, name = "TestPlan"),
|
||||
@JsonSubTypes.Type(value = MsThreadGroup.class, name = "ThreadGroup"),
|
||||
@JsonSubTypes.Type(value = MsAuthManager.class, name = "AuthManager"),
|
||||
@JsonSubTypes.Type(value = MsAssertions.class, name = "Assertions"),
|
||||
@JsonSubTypes.Type(value = MsExtract.class, name = "Extract"),
|
||||
@JsonSubTypes.Type(value = MsTCPSampler.class, name = "TCPSampler"),
|
||||
@JsonSubTypes.Type(value = MsDubboSampler.class, name = "DubboSampler"),
|
||||
@JsonSubTypes.Type(value = MsJDBCSampler.class, name = "JDBCSampler"),
|
||||
|
||||
})
|
||||
@JSONType(seeAlso = {MsHTTPSamplerProxy.class, MsHeaderManager.class, MsJSR223PostProcessor.class,
|
||||
MsJSR223PreProcessor.class, MsTestPlan.class, MsThreadGroup.class, AuthManager.class, MsAssertions.class,
|
||||
MsExtract.class, MsTCPSampler.class, MsDubboSampler.class, MsJDBCSampler.class}, typeKey = "type")
|
||||
@Data
|
||||
public abstract class MsTestElement {
|
||||
private String type;
|
||||
@JSONField(ordinal = 1)
|
||||
private String id;
|
||||
@JSONField(ordinal = 2)
|
||||
private String name;
|
||||
@JSONField(ordinal = 3)
|
||||
private String label;
|
||||
@JSONField(ordinal = 4)
|
||||
private LinkedList<MsTestElement> hashTree;
|
||||
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree) {
|
||||
for (MsTestElement el : hashTree) {
|
||||
el.toHashTree(tree, el.hashTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换JMX
|
||||
*
|
||||
* @param hashTree
|
||||
* @return
|
||||
*/
|
||||
public String getJmx(HashTree hashTree) {
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||
SaveService.saveTree(hashTree, baos);
|
||||
System.out.print(baos.toString());
|
||||
return baos.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogUtil.warn("HashTree error, can't log jmx content");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public HashTree generateHashTree() {
|
||||
HashTree jmeterTestPlanHashTree = new ListedHashTree();
|
||||
this.toHashTree(jmeterTestPlanHashTree, this.hashTree);
|
||||
return jmeterTestPlanHashTree;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package io.metersphere.api.dto.definition.request;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.jmeter.config.Arguments;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jmeter.testelement.TestPlan;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@JSONType(typeName = "TestPlan")
|
||||
public class MsTestPlan extends MsTestElement {
|
||||
private String type = "TestPlan";
|
||||
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree) {
|
||||
final HashTree testPlanTree = tree.add(getPlan());
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
hashTree.forEach(el -> {
|
||||
el.toHashTree(testPlanTree, el.getHashTree());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public TestPlan getPlan() {
|
||||
TestPlan testPlan = new TestPlan(this.getName() + "TestPlan");
|
||||
testPlan.setProperty(TestElement.TEST_CLASS, TestPlan.class.getName());
|
||||
testPlan.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestPlanGui"));
|
||||
testPlan.setEnabled(true);
|
||||
testPlan.setFunctionalMode(false);
|
||||
testPlan.setSerialized(true);
|
||||
testPlan.setTearDownOnShutdown(true);
|
||||
testPlan.setUserDefinedVariables(new Arguments());
|
||||
return testPlan;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package io.metersphere.api.dto.definition.request;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.jmeter.control.LoopController;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jmeter.threads.ThreadGroup;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@JSONType(typeName = "ThreadGroup")
|
||||
public class MsThreadGroup extends MsTestElement {
|
||||
private String type = "ThreadGroup";
|
||||
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree) {
|
||||
final HashTree groupTree = tree.add(getThreadGroup());
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
hashTree.forEach(el -> {
|
||||
el.toHashTree(groupTree, el.getHashTree());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public ThreadGroup getThreadGroup() {
|
||||
LoopController loopController = new LoopController();
|
||||
loopController.setName("LoopController");
|
||||
loopController.setProperty(TestElement.TEST_CLASS, LoopController.class.getName());
|
||||
loopController.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("LoopControlPanel"));
|
||||
loopController.setEnabled(true);
|
||||
loopController.setLoops(1);
|
||||
|
||||
ThreadGroup threadGroup = new ThreadGroup();
|
||||
threadGroup.setEnabled(true);
|
||||
threadGroup.setName(this.getName() + "ThreadGroup");
|
||||
threadGroup.setProperty(TestElement.TEST_CLASS, ThreadGroup.class.getName());
|
||||
threadGroup.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("ThreadGroupGui"));
|
||||
threadGroup.setNumThreads(1);
|
||||
threadGroup.setRampUp(1);
|
||||
threadGroup.setDelay(0);
|
||||
threadGroup.setDuration(0);
|
||||
threadGroup.setProperty(ThreadGroup.ON_SAMPLE_ERROR, ThreadGroup.ON_SAMPLE_ERROR_CONTINUE);
|
||||
threadGroup.setScheduler(false);
|
||||
threadGroup.setSamplerController(loopController);
|
||||
return threadGroup;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package io.metersphere.api.dto.definition.request.assertions;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MsAssertionDuration extends MsAssertionType {
|
||||
private long value;
|
||||
|
||||
public MsAssertionDuration() {
|
||||
setType(MsAssertionType.DURATION);
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return value > 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package io.metersphere.api.dto.definition.request.assertions;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MsAssertionJSR223 extends MsAssertionType {
|
||||
private String variable;
|
||||
private String operator;
|
||||
private String value;
|
||||
private String desc;
|
||||
private String name;
|
||||
private String script;
|
||||
private String language;
|
||||
|
||||
public MsAssertionJSR223() {
|
||||
setType(MsAssertionType.JSR223);
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return StringUtils.isNotBlank(script) && StringUtils.isNotBlank(language);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package io.metersphere.api.dto.definition.request.assertions;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MsAssertionJsonPath extends MsAssertionType {
|
||||
private String expect;
|
||||
private String expression;
|
||||
private String description;
|
||||
|
||||
public MsAssertionJsonPath() {
|
||||
setType(MsAssertionType.JSON_PATH);
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return StringUtils.isNotBlank(expression);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package io.metersphere.api.dto.definition.request.assertions;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MsAssertionRegex extends MsAssertionType {
|
||||
private String subject;
|
||||
private String expression;
|
||||
private String description;
|
||||
private boolean assumeSuccess;
|
||||
|
||||
public MsAssertionRegex() {
|
||||
setType(MsAssertionType.REGEX);
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return StringUtils.isNotBlank(subject) && StringUtils.isNotBlank(expression);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package io.metersphere.api.dto.definition.request.assertions;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MsAssertionType {
|
||||
public final static String REGEX = "Regex";
|
||||
public final static String DURATION = "Duration";
|
||||
public final static String JSON_PATH = "JSONPath";
|
||||
public final static String JSR223 = "JSR223";
|
||||
public final static String TEXT = "Text";
|
||||
public final static String XPATH2 = "XPath2";
|
||||
|
||||
private String type;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package io.metersphere.api.dto.definition.request.assertions;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MsAssertionXPath2 extends MsAssertionType {
|
||||
private String expression;
|
||||
|
||||
public MsAssertionXPath2() {
|
||||
setType(MsAssertionType.XPATH2);
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return StringUtils.isNotBlank(expression);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package io.metersphere.api.dto.definition.request.assertions;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.jmeter.assertions.*;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@JSONType(typeName = "Assertions")
|
||||
public class MsAssertions extends MsTestElement {
|
||||
private List<MsAssertionRegex> regex;
|
||||
private List<MsAssertionJsonPath> jsonPath;
|
||||
private List<MsAssertionJSR223> jsr223;
|
||||
private List<MsAssertionXPath2> xpath2;
|
||||
private MsAssertionDuration duration;
|
||||
private String type = "Assertions";
|
||||
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree) {
|
||||
addAssertions(tree);
|
||||
|
||||
}
|
||||
private void addAssertions(HashTree hashTree) {
|
||||
if (CollectionUtils.isNotEmpty(this.getRegex())) {
|
||||
this.getRegex().stream().filter(MsAssertionRegex::isValid).forEach(assertion ->
|
||||
hashTree.add(responseAssertion(assertion))
|
||||
);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(this.getJsonPath())) {
|
||||
this.getJsonPath().stream().filter(MsAssertionJsonPath::isValid).forEach(assertion ->
|
||||
hashTree.add(jsonPathAssertion(assertion))
|
||||
);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(this.getXpath2())) {
|
||||
this.getXpath2().stream().filter(MsAssertionXPath2::isValid).forEach(assertion ->
|
||||
hashTree.add(xPath2Assertion(assertion))
|
||||
);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(this.getJsr223())) {
|
||||
this.getJsr223().stream().filter(MsAssertionJSR223::isValid).forEach(assertion ->
|
||||
hashTree.add(jsr223Assertion(assertion))
|
||||
);
|
||||
}
|
||||
|
||||
if (this.getDuration().isValid()) {
|
||||
hashTree.add(durationAssertion(this.getDuration()));
|
||||
}
|
||||
}
|
||||
|
||||
private ResponseAssertion responseAssertion(MsAssertionRegex assertionRegex) {
|
||||
ResponseAssertion assertion = new ResponseAssertion();
|
||||
assertion.setEnabled(true);
|
||||
assertion.setName(assertionRegex.getDescription());
|
||||
assertion.setProperty(TestElement.TEST_CLASS, ResponseAssertion.class.getName());
|
||||
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("AssertionGui"));
|
||||
assertion.setAssumeSuccess(assertionRegex.isAssumeSuccess());
|
||||
assertion.setToContainsType();
|
||||
switch (assertionRegex.getSubject()) {
|
||||
case "Response Code":
|
||||
assertion.setTestFieldResponseCode();
|
||||
break;
|
||||
case "Response Headers":
|
||||
assertion.setTestFieldResponseHeaders();
|
||||
break;
|
||||
case "Response Data":
|
||||
assertion.setTestFieldResponseData();
|
||||
break;
|
||||
}
|
||||
return assertion;
|
||||
}
|
||||
|
||||
private JSONPathAssertion jsonPathAssertion(MsAssertionJsonPath assertionJsonPath) {
|
||||
JSONPathAssertion assertion = new JSONPathAssertion();
|
||||
assertion.setEnabled(true);
|
||||
assertion.setName(assertionJsonPath.getDescription());
|
||||
assertion.setProperty(TestElement.TEST_CLASS, JSONPathAssertion.class.getName());
|
||||
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("JSONPathAssertionGui"));
|
||||
assertion.setJsonPath(assertionJsonPath.getExpression());
|
||||
assertion.setExpectedValue(assertionJsonPath.getExpect());
|
||||
assertion.setJsonValidationBool(true);
|
||||
assertion.setExpectNull(false);
|
||||
assertion.setInvert(false);
|
||||
assertion.setIsRegex(true);
|
||||
return assertion;
|
||||
}
|
||||
|
||||
private XPath2Assertion xPath2Assertion(MsAssertionXPath2 assertionXPath2) {
|
||||
XPath2Assertion assertion = new XPath2Assertion();
|
||||
assertion.setEnabled(true);
|
||||
assertion.setName(assertionXPath2.getExpression());
|
||||
assertion.setProperty(TestElement.TEST_CLASS, XPath2Assertion.class.getName());
|
||||
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("XPath2AssertionGui"));
|
||||
assertion.setXPathString(assertionXPath2.getExpression());
|
||||
assertion.setNegated(false);
|
||||
return assertion;
|
||||
}
|
||||
|
||||
private DurationAssertion durationAssertion(MsAssertionDuration assertionDuration) {
|
||||
DurationAssertion assertion = new DurationAssertion();
|
||||
assertion.setEnabled(true);
|
||||
assertion.setName("Response In Time: " + assertionDuration.getValue());
|
||||
assertion.setProperty(TestElement.TEST_CLASS, DurationAssertion.class.getName());
|
||||
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("DurationAssertionGui"));
|
||||
assertion.setAllowedDuration(assertionDuration.getValue());
|
||||
return assertion;
|
||||
}
|
||||
|
||||
private JSR223Assertion jsr223Assertion(MsAssertionJSR223 assertionJSR223) {
|
||||
JSR223Assertion assertion = new JSR223Assertion();
|
||||
assertion.setEnabled(true);
|
||||
assertion.setName(assertionJSR223.getDesc());
|
||||
assertion.setProperty(TestElement.TEST_CLASS, JSR223Assertion.class.getName());
|
||||
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
assertion.setProperty("cacheKey", "true");
|
||||
assertion.setProperty("scriptLanguage", assertionJSR223.getLanguage());
|
||||
assertion.setProperty("script", assertionJSR223.getScript());
|
||||
return assertion;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package io.metersphere.api.dto.definition.request.auth;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||
import io.metersphere.api.service.ApiTestEnvironmentService;
|
||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.jmeter.protocol.http.control.AuthManager;
|
||||
import org.apache.jmeter.protocol.http.control.Authorization;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@JSONType(typeName = "AuthManager")
|
||||
public class MsAuthManager extends MsTestElement {
|
||||
private String type = "AuthManager";
|
||||
@JSONField(ordinal = 10)
|
||||
private String username;
|
||||
|
||||
@JSONField(ordinal = 11)
|
||||
private String password;
|
||||
|
||||
@JSONField(ordinal = 12)
|
||||
private String url;
|
||||
|
||||
@JSONField(ordinal = 13)
|
||||
private String realm;
|
||||
|
||||
@JSONField(ordinal = 14)
|
||||
private String verification;
|
||||
|
||||
@JSONField(ordinal = 15)
|
||||
private String mechanism;
|
||||
|
||||
@JSONField(ordinal = 16)
|
||||
private String encrypt;
|
||||
|
||||
@JSONField(ordinal = 17)
|
||||
private String domain;
|
||||
|
||||
@JSONField(ordinal = 18)
|
||||
private String environment;
|
||||
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree) {
|
||||
AuthManager authManager = new AuthManager();
|
||||
authManager.setEnabled(true);
|
||||
authManager.setName(this.getUsername() + "AuthManager");
|
||||
authManager.setProperty(TestElement.TEST_CLASS, AuthManager.class.getName());
|
||||
authManager.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("AuthPanel"));
|
||||
Authorization auth = new Authorization();
|
||||
if (this.url != null) {
|
||||
auth.setURL(this.url);
|
||||
} else {
|
||||
if (environment != null) {
|
||||
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
|
||||
ApiTestEnvironmentWithBLOBs environmentWithBLOBs = environmentService.get(environment);
|
||||
EnvironmentConfig config = JSONObject.parseObject(environmentWithBLOBs.getConfig(), EnvironmentConfig.class);
|
||||
this.url = config.getHttpConfig().getProtocol() + "://" + config.getHttpConfig().getSocket();
|
||||
}
|
||||
}
|
||||
auth.setDomain(this.domain);
|
||||
auth.setUser(this.username);
|
||||
auth.setPass(this.password);
|
||||
auth.setMechanism(AuthManager.Mechanism.DIGEST);
|
||||
authManager.addAuth(auth);
|
||||
tree.add(authManager);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package io.metersphere.api.dto.definition.request.configurations;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.jmeter.protocol.http.control.Header;
|
||||
import org.apache.jmeter.protocol.http.control.HeaderManager;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@JSONType(typeName = "HeaderManager")
|
||||
public class MsHeaderManager extends MsTestElement {
|
||||
|
||||
private String type = "HeaderManager";
|
||||
@JSONField(ordinal = 10)
|
||||
private List<KeyValue> headers;
|
||||
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree) {
|
||||
HeaderManager headerManager = new HeaderManager();
|
||||
headerManager.setEnabled(true);
|
||||
headerManager.setName(this.getName() + "Headers");
|
||||
headerManager.setProperty(TestElement.TEST_CLASS, HeaderManager.class.getName());
|
||||
headerManager.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("HeaderPanel"));
|
||||
headers.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
|
||||
headerManager.add(new Header(keyValue.getName(), keyValue.getValue()))
|
||||
);
|
||||
final HashTree headersTree = tree.add(headerManager);
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
hashTree.forEach(el -> {
|
||||
el.toHashTree(headersTree, el.getHashTree());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package io.metersphere.api.dto.definition.request.dns;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||
import io.metersphere.api.dto.scenario.environment.Host;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.config.Arguments;
|
||||
import org.apache.jmeter.protocol.http.control.DNSCacheManager;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@JSONType(typeName = "DNSCacheManager")
|
||||
public class MsDNSCacheManager extends MsTestElement {
|
||||
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree) {
|
||||
for (MsTestElement el : hashTree) {
|
||||
el.toHashTree(tree, el.getHashTree());
|
||||
}
|
||||
}
|
||||
|
||||
public static void addEnvironmentVariables(HashTree samplerHashTree, String name, EnvironmentConfig config) {
|
||||
name += "Environment Variables";
|
||||
samplerHashTree.add(arguments(name, config.getCommonConfig().getVariables()));
|
||||
}
|
||||
|
||||
public static void addEnvironmentDNS(HashTree samplerHashTree, String name, EnvironmentConfig config) {
|
||||
if (config.getCommonConfig().isEnableHost() && CollectionUtils.isNotEmpty(config.getCommonConfig().getHosts())) {
|
||||
String domain = config.getHttpConfig().getDomain().trim();
|
||||
List<Host> hosts = new ArrayList<>();
|
||||
config.getCommonConfig().getHosts().forEach(host -> {
|
||||
if (StringUtils.isNotBlank(host.getDomain())) {
|
||||
String hostDomain = host.getDomain().trim().replace("http://", "").replace("https://", "");
|
||||
if (StringUtils.equals(hostDomain, domain)) {
|
||||
host.setDomain(hostDomain); // 域名去掉协议
|
||||
hosts.add(host);
|
||||
}
|
||||
}
|
||||
});
|
||||
samplerHashTree.add(dnsCacheManager(name + " DNSCacheManager", hosts));
|
||||
}
|
||||
}
|
||||
|
||||
private static Arguments arguments(String name, List<KeyValue> variables) {
|
||||
Arguments arguments = new Arguments();
|
||||
arguments.setEnabled(true);
|
||||
arguments.setName(name);
|
||||
arguments.setProperty(TestElement.TEST_CLASS, Arguments.class.getName());
|
||||
arguments.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("ArgumentsPanel"));
|
||||
variables.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
|
||||
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
|
||||
);
|
||||
return arguments;
|
||||
}
|
||||
|
||||
private static DNSCacheManager dnsCacheManager(String name, List<Host> hosts) {
|
||||
DNSCacheManager dnsCacheManager = new DNSCacheManager();
|
||||
dnsCacheManager.setEnabled(true);
|
||||
dnsCacheManager.setName(name);
|
||||
dnsCacheManager.setProperty(TestElement.TEST_CLASS, DNSCacheManager.class.getName());
|
||||
dnsCacheManager.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("DNSCachePanel"));
|
||||
dnsCacheManager.setCustomResolver(true);
|
||||
hosts.forEach(host -> dnsCacheManager.addHost(host.getDomain(), host.getIp()));
|
||||
|
||||
return dnsCacheManager;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package io.metersphere.api.dto.definition.request.extract;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.jmeter.extractor.RegexExtractor;
|
||||
import org.apache.jmeter.extractor.XPath2Extractor;
|
||||
import org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@JSONType(typeName = "Extract")
|
||||
public class MsExtract extends MsTestElement {
|
||||
private List<MsExtractRegex> regex;
|
||||
private List<MsExtractJSONPath> json;
|
||||
private List<MsExtractXPath> xpath;
|
||||
private String type = "Extract";
|
||||
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree) {
|
||||
addRequestExtractors(tree);
|
||||
}
|
||||
|
||||
private void addRequestExtractors(HashTree samplerHashTree) {
|
||||
if (CollectionUtils.isNotEmpty(this.getRegex())) {
|
||||
this.getRegex().stream().filter(MsExtractRegex::isValid).forEach(extractRegex ->
|
||||
samplerHashTree.add(regexExtractor(extractRegex))
|
||||
);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(this.getXpath())) {
|
||||
this.getXpath().stream().filter(MsExtractCommon::isValid).forEach(extractXPath ->
|
||||
samplerHashTree.add(xPath2Extractor(extractXPath))
|
||||
);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(this.getJson())) {
|
||||
this.getJson().stream().filter(MsExtractCommon::isValid).forEach(extractJSONPath ->
|
||||
samplerHashTree.add(jsonPostProcessor(extractJSONPath))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private RegexExtractor regexExtractor(MsExtractRegex extractRegex) {
|
||||
RegexExtractor extractor = new RegexExtractor();
|
||||
extractor.setEnabled(true);
|
||||
extractor.setName(extractRegex.getVariable() + " RegexExtractor");
|
||||
extractor.setProperty(TestElement.TEST_CLASS, RegexExtractor.class.getName());
|
||||
extractor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("RegexExtractorGui"));
|
||||
extractor.setRefName(extractRegex.getVariable());
|
||||
extractor.setRegex(extractRegex.getExpression());
|
||||
extractor.setUseField(extractRegex.getUseHeaders());
|
||||
if (extractRegex.isMultipleMatching()) {
|
||||
extractor.setMatchNumber(-1);
|
||||
}
|
||||
extractor.setTemplate("$1$");
|
||||
return extractor;
|
||||
}
|
||||
|
||||
private XPath2Extractor xPath2Extractor(MsExtractXPath extractXPath) {
|
||||
XPath2Extractor extractor = new XPath2Extractor();
|
||||
extractor.setEnabled(true);
|
||||
extractor.setName(extractXPath.getVariable() + " XPath2Extractor");
|
||||
extractor.setProperty(TestElement.TEST_CLASS, XPath2Extractor.class.getName());
|
||||
extractor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("XPath2ExtractorGui"));
|
||||
extractor.setRefName(extractXPath.getVariable());
|
||||
extractor.setXPathQuery(extractXPath.getExpression());
|
||||
if (extractXPath.isMultipleMatching()) {
|
||||
extractor.setMatchNumber(-1);
|
||||
}
|
||||
return extractor;
|
||||
}
|
||||
|
||||
private JSONPostProcessor jsonPostProcessor(MsExtractJSONPath extractJSONPath) {
|
||||
JSONPostProcessor extractor = new JSONPostProcessor();
|
||||
extractor.setEnabled(true);
|
||||
extractor.setName(extractJSONPath.getVariable() + " JSONExtractor");
|
||||
extractor.setProperty(TestElement.TEST_CLASS, JSONPostProcessor.class.getName());
|
||||
extractor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("JSONPostProcessorGui"));
|
||||
extractor.setRefNames(extractJSONPath.getVariable());
|
||||
extractor.setJsonPathExpressions(extractJSONPath.getExpression());
|
||||
if (extractJSONPath.isMultipleMatching()) {
|
||||
extractor.setMatchNumbers("-1");
|
||||
}
|
||||
return extractor;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package io.metersphere.api.dto.definition.request.extract;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MsExtractCommon extends MsExtractType{
|
||||
private String variable;
|
||||
private String value; // value: ${variable}
|
||||
private String expression;
|
||||
private String description;
|
||||
private boolean multipleMatching;
|
||||
|
||||
public boolean isValid() {
|
||||
return StringUtils.isNotBlank(variable) && StringUtils.isNotBlank(expression);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.api.dto.definition.request.extract;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MsExtractJSONPath extends MsExtractCommon {
|
||||
public MsExtractJSONPath() {
|
||||
setType(MsExtractType.JSON_PATH);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package io.metersphere.api.dto.definition.request.extract;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MsExtractRegex extends MsExtractCommon {
|
||||
private String useHeaders;
|
||||
|
||||
public MsExtractRegex() {
|
||||
setType(MsExtractType.REGEX);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.api.dto.definition.request.extract;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MsExtractType {
|
||||
public final static String REGEX = "Regex";
|
||||
public final static String JSON_PATH = "JSONPath";
|
||||
public final static String XPATH = "XPath";
|
||||
|
||||
private String type;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.api.dto.definition.request.extract;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MsExtractXPath extends MsExtractCommon {
|
||||
public MsExtractXPath() {
|
||||
setType(MsExtractType.XPATH);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package io.metersphere.api.dto.definition.request.processors.post;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.jmeter.extractor.JSR223PostProcessor;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@JSONType(typeName = "JSR223PostProcessor")
|
||||
public class MsJSR223PostProcessor extends MsTestElement {
|
||||
private String type = "JSR223PostProcessor";
|
||||
|
||||
@JSONField(ordinal = 10)
|
||||
private String script;
|
||||
|
||||
@JSONField(ordinal = 11)
|
||||
private String scriptLanguage;
|
||||
|
||||
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree) {
|
||||
JSR223PostProcessor processor = new JSR223PostProcessor();
|
||||
processor.setEnabled(true);
|
||||
processor.setName(this.getName() + "JSR223PostProcessor");
|
||||
processor.setProperty(TestElement.TEST_CLASS, JSR223PostProcessor.class.getName());
|
||||
processor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
processor.setProperty("cacheKey", "true");
|
||||
processor.setProperty("scriptLanguage", this.getScriptLanguage());
|
||||
processor.setProperty("script", this.getScript());
|
||||
|
||||
final HashTree jsr223PostTree = tree.add(processor);
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
hashTree.forEach(el -> {
|
||||
el.toHashTree(jsr223PostTree, el.getHashTree());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package io.metersphere.api.dto.definition.request.processors.pre;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.jmeter.modifiers.JSR223PreProcessor;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@JSONType(typeName = "JSR223PreProcessor")
|
||||
public class MsJSR223PreProcessor extends MsTestElement {
|
||||
private String type = "JSR223PreProcessor";
|
||||
|
||||
@JSONField(ordinal = 10)
|
||||
private String script;
|
||||
|
||||
@JSONField(ordinal = 11)
|
||||
private String scriptLanguage;
|
||||
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree) {
|
||||
JSR223PreProcessor processor = new JSR223PreProcessor();
|
||||
processor.setEnabled(true);
|
||||
processor.setName(this.getName() + "JSR223PreProcessor");
|
||||
processor.setProperty(TestElement.TEST_CLASS, JSR223PreProcessor.class.getName());
|
||||
processor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
processor.setProperty("cacheKey", "true");
|
||||
processor.setProperty("scriptLanguage", this.getScriptLanguage());
|
||||
processor.setProperty("script", this.getScript());
|
||||
|
||||
final HashTree jsr223PreTree = tree.add(processor);
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
hashTree.forEach(el -> {
|
||||
el.toHashTree(jsr223PreTree, el.getHashTree());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
package io.metersphere.api.dto.definition.request.sampler;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.github.ningyu.jmeter.plugin.dubbo.sample.DubboSample;
|
||||
import io.github.ningyu.jmeter.plugin.dubbo.sample.MethodArgument;
|
||||
import io.github.ningyu.jmeter.plugin.util.Constants;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import io.metersphere.api.dto.definition.request.sampler.dubbo.MsConfigCenter;
|
||||
import io.metersphere.api.dto.definition.request.sampler.dubbo.MsConsumerAndService;
|
||||
import io.metersphere.api.dto.definition.request.sampler.dubbo.MsRegistryCenter;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.jmeter.config.ConfigTestElement;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
import org.apache.jorphan.collections.ListedHashTree;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@JSONType(typeName = "DubboSampler")
|
||||
public class MsDubboSampler extends MsTestElement {
|
||||
// type 必须放最前面,以便能够转换正确的类
|
||||
private String type = "DubboSampler";
|
||||
|
||||
@JSONField(ordinal = 52)
|
||||
private String protocol;
|
||||
@JsonProperty(value = "interface")
|
||||
@JSONField(ordinal = 53, name = "interface")
|
||||
private String _interface;
|
||||
@JSONField(ordinal = 54)
|
||||
private String method;
|
||||
|
||||
@JSONField(ordinal = 55)
|
||||
private MsConfigCenter configCenter;
|
||||
@JSONField(ordinal = 56)
|
||||
private MsRegistryCenter registryCenter;
|
||||
@JSONField(ordinal = 57)
|
||||
private MsConsumerAndService consumerAndService;
|
||||
|
||||
@JSONField(ordinal = 58)
|
||||
private List<KeyValue> args;
|
||||
@JSONField(ordinal = 59)
|
||||
private List<KeyValue> attachmentArgs;
|
||||
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree) {
|
||||
final HashTree testPlanTree = new ListedHashTree();
|
||||
testPlanTree.add(dubboConfig());
|
||||
tree.set(dubboSample(), testPlanTree);
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
hashTree.forEach(el -> {
|
||||
el.toHashTree(testPlanTree, el.getHashTree());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private DubboSample dubboSample() {
|
||||
DubboSample sampler = new DubboSample();
|
||||
sampler.setName(this.getName());
|
||||
sampler.setProperty(TestElement.TEST_CLASS, DubboSample.class.getName());
|
||||
sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("DubboSampleGui"));
|
||||
|
||||
sampler.addTestElement(configCenter(this.getConfigCenter()));
|
||||
sampler.addTestElement(registryCenter(this.getRegistryCenter()));
|
||||
sampler.addTestElement(consumerAndService(this.getConsumerAndService()));
|
||||
|
||||
Constants.setRpcProtocol(this.getProtocol(), sampler);
|
||||
Constants.setInterfaceName(this.get_interface(), sampler);
|
||||
Constants.setMethod(this.getMethod(), sampler);
|
||||
|
||||
List<MethodArgument> methodArgs = this.getArgs().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable)
|
||||
.map(keyValue -> new MethodArgument(keyValue.getName(), keyValue.getValue())).collect(Collectors.toList());
|
||||
Constants.setMethodArgs(methodArgs, sampler);
|
||||
|
||||
List<MethodArgument> attachmentArgs = this.getAttachmentArgs().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable)
|
||||
.map(keyValue -> new MethodArgument(keyValue.getName(), keyValue.getValue())).collect(Collectors.toList());
|
||||
Constants.setAttachmentArgs(attachmentArgs, sampler);
|
||||
|
||||
return sampler;
|
||||
}
|
||||
|
||||
|
||||
private ConfigTestElement dubboConfig() {
|
||||
ConfigTestElement configTestElement = new ConfigTestElement();
|
||||
configTestElement.setEnabled(true);
|
||||
configTestElement.setName(this.getName());
|
||||
configTestElement.setProperty(TestElement.TEST_CLASS, ConfigTestElement.class.getName());
|
||||
configTestElement.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("DubboDefaultConfigGui"));
|
||||
configTestElement.addConfigElement(configCenter(this.getConfigCenter()));
|
||||
configTestElement.addConfigElement(registryCenter(this.getRegistryCenter()));
|
||||
configTestElement.addConfigElement(consumerAndService(this.getConsumerAndService()));
|
||||
return configTestElement;
|
||||
}
|
||||
|
||||
private ConfigTestElement configCenter(MsConfigCenter configCenter) {
|
||||
ConfigTestElement configTestElement = new ConfigTestElement();
|
||||
if (configCenter != null) {
|
||||
Constants.setConfigCenterProtocol(configCenter.getProtocol(), configTestElement);
|
||||
Constants.setConfigCenterGroup(configCenter.getGroup(), configTestElement);
|
||||
Constants.setConfigCenterNamespace(configCenter.getNamespace(), configTestElement);
|
||||
Constants.setConfigCenterUserName(configCenter.getUsername(), configTestElement);
|
||||
Constants.setConfigCenterPassword(configCenter.getPassword(), configTestElement);
|
||||
Constants.setConfigCenterAddress(configCenter.getAddress(), configTestElement);
|
||||
Constants.setConfigCenterTimeout(configCenter.getTimeout(), configTestElement);
|
||||
}
|
||||
return configTestElement;
|
||||
}
|
||||
|
||||
private ConfigTestElement registryCenter(MsRegistryCenter registryCenter) {
|
||||
ConfigTestElement configTestElement = new ConfigTestElement();
|
||||
if (registryCenter != null) {
|
||||
Constants.setRegistryProtocol(registryCenter.getProtocol(), configTestElement);
|
||||
Constants.setRegistryGroup(registryCenter.getGroup(), configTestElement);
|
||||
Constants.setRegistryUserName(registryCenter.getUsername(), configTestElement);
|
||||
Constants.setRegistryPassword(registryCenter.getPassword(), configTestElement);
|
||||
Constants.setRegistryTimeout(registryCenter.getTimeout(), configTestElement);
|
||||
Constants.setAddress(registryCenter.getAddress(), configTestElement);
|
||||
}
|
||||
return configTestElement;
|
||||
}
|
||||
|
||||
private ConfigTestElement consumerAndService(MsConsumerAndService consumerAndService) {
|
||||
ConfigTestElement configTestElement = new ConfigTestElement();
|
||||
if (consumerAndService != null) {
|
||||
Constants.setTimeout(consumerAndService.getTimeout(), configTestElement);
|
||||
Constants.setVersion(consumerAndService.getVersion(), configTestElement);
|
||||
Constants.setGroup(consumerAndService.getGroup(), configTestElement);
|
||||
Constants.setConnections(consumerAndService.getConnections(), configTestElement);
|
||||
Constants.setLoadbalance(consumerAndService.getLoadBalance(), configTestElement);
|
||||
Constants.setAsync(consumerAndService.getAsync(), configTestElement);
|
||||
Constants.setCluster(consumerAndService.getCluster(), configTestElement);
|
||||
}
|
||||
return configTestElement;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,250 @@
|
|||
package io.metersphere.api.dto.definition.request.sampler;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import io.metersphere.api.dto.definition.request.dns.MsDNSCacheManager;
|
||||
import io.metersphere.api.dto.scenario.Body;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||
import io.metersphere.api.dto.scenario.request.BodyFile;
|
||||
import io.metersphere.api.service.ApiTestEnvironmentService;
|
||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.config.Arguments;
|
||||
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy;
|
||||
import org.apache.jmeter.protocol.http.util.HTTPArgument;
|
||||
import org.apache.jmeter.protocol.http.util.HTTPFileArg;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@JSONType(typeName = "HTTPSamplerProxy")
|
||||
public class MsHTTPSamplerProxy extends MsTestElement {
|
||||
private String type = "HTTPSamplerProxy";
|
||||
|
||||
@JSONField(ordinal = 10)
|
||||
private String protocol;
|
||||
|
||||
@JSONField(ordinal = 11)
|
||||
private String domain;
|
||||
|
||||
@JSONField(ordinal = 12)
|
||||
private String port;
|
||||
|
||||
@JSONField(ordinal = 13)
|
||||
private String method;
|
||||
|
||||
@JSONField(ordinal = 14)
|
||||
private String path;
|
||||
|
||||
@JSONField(ordinal = 15)
|
||||
private String connectTimeout;
|
||||
@JSONField(ordinal = 16)
|
||||
|
||||
private String responseTimeout;
|
||||
@JSONField(ordinal = 17)
|
||||
|
||||
private List<KeyValue> arguments;
|
||||
|
||||
@JSONField(ordinal = 18)
|
||||
private Body body;
|
||||
|
||||
@JSONField(ordinal = 19)
|
||||
private List<KeyValue> rest;
|
||||
|
||||
@JSONField(ordinal = 20)
|
||||
private String url;
|
||||
|
||||
@JSONField(ordinal = 21)
|
||||
private boolean followRedirects;
|
||||
|
||||
@JSONField(ordinal = 22)
|
||||
private boolean doMultipartPost;
|
||||
|
||||
@JSONField(ordinal = 23)
|
||||
private String useEnvironment;
|
||||
|
||||
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree) {
|
||||
HTTPSamplerProxy sampler = new HTTPSamplerProxy();
|
||||
sampler.setEnabled(true);
|
||||
sampler.setName(this.getName());
|
||||
sampler.setProperty(TestElement.TEST_CLASS, HTTPSamplerProxy.class.getName());
|
||||
sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("HttpTestSampleGui"));
|
||||
sampler.setMethod(this.getMethod());
|
||||
sampler.setContentEncoding("UTF-8");
|
||||
sampler.setConnectTimeout(this.getConnectTimeout() == null ? "6000" : this.getConnectTimeout());
|
||||
sampler.setResponseTimeout(this.getResponseTimeout() == null ? "6000" : this.getResponseTimeout());
|
||||
sampler.setFollowRedirects(this.isFollowRedirects());
|
||||
sampler.setUseKeepAlive(true);
|
||||
sampler.setDoMultipart(this.isDoMultipartPost());
|
||||
EnvironmentConfig config = null;
|
||||
if (useEnvironment != null) {
|
||||
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
|
||||
ApiTestEnvironmentWithBLOBs environment = environmentService.get(useEnvironment);
|
||||
config = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
}
|
||||
try {
|
||||
if (config != null) {
|
||||
String url = "";
|
||||
sampler.setDomain(config.getHttpConfig().getDomain());
|
||||
sampler.setPort(config.getHttpConfig().getPort());
|
||||
sampler.setProtocol(config.getHttpConfig().getProtocol());
|
||||
url = config.getHttpConfig().getProtocol() + "://" + config.getHttpConfig().getSocket();
|
||||
URL urlObject = new URL(url);
|
||||
String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath();
|
||||
if (StringUtils.isNotBlank(this.getPath())) {
|
||||
envPath += this.getPath();
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(this.getRest()) && this.isRest()) {
|
||||
sampler.setPath(getRestParameters(URLDecoder.decode(envPath, "UTF-8")));
|
||||
} else {
|
||||
sampler.setPath(getPostQueryParameters(URLDecoder.decode(envPath, "UTF-8")));
|
||||
}
|
||||
} else {
|
||||
String url = this.getUrl();
|
||||
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
||||
url = "http://" + url;
|
||||
}
|
||||
URL urlObject = new URL(url);
|
||||
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), "UTF-8"));
|
||||
sampler.setPort(urlObject.getPort());
|
||||
sampler.setProtocol(urlObject.getProtocol());
|
||||
|
||||
sampler.setPath(getRestParameters(URLDecoder.decode(urlObject.getPath(), "UTF-8")));
|
||||
sampler.setPath(getPostQueryParameters(URLDecoder.decode(urlObject.getPath(), "UTF-8")));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
|
||||
// 请求参数
|
||||
if (CollectionUtils.isNotEmpty(this.getArguments())) {
|
||||
sampler.setArguments(httpArguments(this.getArguments()));
|
||||
}
|
||||
// 请求体
|
||||
if (!StringUtils.equals(this.getMethod(), "GET")) {
|
||||
List<KeyValue> body = new ArrayList<>();
|
||||
if (this.getBody().isKV() || this.getBody().isBinary()) {
|
||||
body = this.getBody().getKvs().stream().filter(KeyValue::isValid).collect(Collectors.toList());
|
||||
HTTPFileArg[] httpFileArgs = httpFileArgs();
|
||||
// 文件上传
|
||||
if (httpFileArgs.length > 0) {
|
||||
sampler.setHTTPFiles(httpFileArgs());
|
||||
sampler.setDoMultipart(true);
|
||||
}
|
||||
} else if (this.getBody().isJson()) {
|
||||
KeyValue keyValue = new KeyValue("", JSON.toJSONString(this.getBody().getJson()));
|
||||
keyValue.setEnable(true);
|
||||
keyValue.setEncode(false);
|
||||
body.add(keyValue);
|
||||
} else {
|
||||
if (StringUtils.isNotBlank(this.getBody().getRaw())) {
|
||||
sampler.setPostBodyRaw(true);
|
||||
KeyValue keyValue = new KeyValue("", this.getBody().getRaw());
|
||||
keyValue.setEnable(true);
|
||||
keyValue.setEncode(false);
|
||||
body.add(keyValue);
|
||||
}
|
||||
if (StringUtils.isNotBlank(this.getBody().getXml())) {
|
||||
sampler.setPostBodyRaw(true);
|
||||
KeyValue keyValue = new KeyValue("", this.getBody().getXml());
|
||||
keyValue.setEnable(true);
|
||||
keyValue.setEncode(false);
|
||||
body.add(keyValue);
|
||||
}
|
||||
}
|
||||
sampler.setArguments(httpArguments(body));
|
||||
}
|
||||
|
||||
final HashTree httpSamplerTree = tree.add(sampler);
|
||||
|
||||
//判断是否要开启DNS
|
||||
if (config != null && config.getCommonConfig() != null && config.getCommonConfig().isEnableHost()) {
|
||||
MsDNSCacheManager.addEnvironmentVariables(httpSamplerTree, this.getName(), config);
|
||||
MsDNSCacheManager.addEnvironmentDNS(httpSamplerTree, this.getName(), config);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
hashTree.forEach(el -> {
|
||||
el.toHashTree(httpSamplerTree, el.getHashTree());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private String getRestParameters(String path) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(path);
|
||||
stringBuffer.append("/");
|
||||
this.getRest().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).forEach(keyValue ->
|
||||
stringBuffer.append(keyValue.getValue()).append("/")
|
||||
);
|
||||
return stringBuffer.substring(0, stringBuffer.length() - 1);
|
||||
}
|
||||
|
||||
private String getPostQueryParameters(String path) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(path);
|
||||
stringBuffer.append("?");
|
||||
this.getArguments().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).forEach(keyValue ->
|
||||
stringBuffer.append(keyValue.getName()).append("=").append(keyValue.getValue()).append("&")
|
||||
);
|
||||
return stringBuffer.substring(0, stringBuffer.length() - 1);
|
||||
}
|
||||
|
||||
private Arguments httpArguments(List<KeyValue> list) {
|
||||
Arguments arguments = new Arguments();
|
||||
list.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue -> {
|
||||
HTTPArgument httpArgument = new HTTPArgument(keyValue.getName(), keyValue.getValue());
|
||||
httpArgument.setAlwaysEncoded(keyValue.isEncode());
|
||||
if (StringUtils.isNotBlank(keyValue.getContentType())) {
|
||||
httpArgument.setContentType(keyValue.getContentType());
|
||||
}
|
||||
arguments.addArgument(httpArgument);
|
||||
}
|
||||
);
|
||||
return arguments;
|
||||
}
|
||||
|
||||
private void setFileArg(List<HTTPFileArg> list, List<BodyFile> files, KeyValue keyValue) {
|
||||
final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
if (files != null) {
|
||||
files.forEach(file -> {
|
||||
String paramName = keyValue.getName() == null ? this.getId() : keyValue.getName();
|
||||
String path = BODY_FILE_DIR + '/' + file.getId() + '_' + file.getName();
|
||||
String mimetype = keyValue.getContentType();
|
||||
list.add(new HTTPFileArg(path, paramName, mimetype));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private HTTPFileArg[] httpFileArgs() {
|
||||
List<HTTPFileArg> list = new ArrayList<>();
|
||||
this.getBody().getKvs().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> {
|
||||
setFileArg(list, keyValue.getFiles(), keyValue);
|
||||
});
|
||||
this.getBody().getBinary().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> {
|
||||
setFileArg(list, keyValue.getFiles(), keyValue);
|
||||
});
|
||||
return list.toArray(new HTTPFileArg[0]);
|
||||
}
|
||||
|
||||
private boolean isRest() {
|
||||
return this.getRest().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).toArray().length > 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
package io.metersphere.api.dto.definition.request.sampler;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import io.metersphere.api.dto.scenario.DatabaseConfig;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.jmeter.config.Arguments;
|
||||
import org.apache.jmeter.protocol.jdbc.config.DataSourceElement;
|
||||
import org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@JSONType(typeName = "JDBCSampler")
|
||||
public class MsJDBCSampler extends MsTestElement {
|
||||
// type 必须放最前面,以便能够转换正确的类
|
||||
private String type = "JDBCSampler";
|
||||
@JSONField(ordinal = 10)
|
||||
private DatabaseConfig dataSource;
|
||||
@JSONField(ordinal = 11)
|
||||
private String query;
|
||||
@JSONField(ordinal = 12)
|
||||
private long queryTimeout;
|
||||
@JSONField(ordinal = 13)
|
||||
private String resultVariable;
|
||||
@JSONField(ordinal = 14)
|
||||
private String variableNames;
|
||||
@JSONField(ordinal = 15)
|
||||
private List<KeyValue> variables;
|
||||
@JSONField(ordinal = 16)
|
||||
private String environmentId;
|
||||
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree) {
|
||||
final HashTree samplerHashTree = tree.add(jdbcSampler());
|
||||
tree.add(jdbcDataSource());
|
||||
tree.add(arguments(this.getName() + " Variables", this.getVariables()));
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
hashTree.forEach(el -> {
|
||||
el.toHashTree(samplerHashTree, el.getHashTree());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private Arguments arguments(String name, List<KeyValue> variables) {
|
||||
Arguments arguments = new Arguments();
|
||||
if (!variables.isEmpty()) {
|
||||
arguments.setEnabled(true);
|
||||
arguments.setName(name);
|
||||
arguments.setProperty(TestElement.TEST_CLASS, Arguments.class.getName());
|
||||
arguments.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("ArgumentsPanel"));
|
||||
variables.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
|
||||
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
|
||||
);
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
private JDBCSampler jdbcSampler() {
|
||||
JDBCSampler sampler = new JDBCSampler();
|
||||
sampler.setName(this.getName());
|
||||
sampler.setProperty(TestElement.TEST_CLASS, JDBCSampler.class.getName());
|
||||
sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
// request.getDataSource() 是ID,需要转换为Name
|
||||
sampler.setProperty("dataSource", this.dataSource.getName());
|
||||
sampler.setProperty("query", this.getQuery());
|
||||
sampler.setProperty("queryTimeout", String.valueOf(this.getQueryTimeout()));
|
||||
sampler.setProperty("resultVariable", this.getResultVariable());
|
||||
sampler.setProperty("variableNames", this.getVariableNames());
|
||||
sampler.setProperty("resultSetHandler", "Store as String");
|
||||
sampler.setProperty("queryType", "Callable Statement");
|
||||
return sampler;
|
||||
}
|
||||
|
||||
private DataSourceElement jdbcDataSource() {
|
||||
DataSourceElement dataSourceElement = new DataSourceElement();
|
||||
dataSourceElement.setEnabled(true);
|
||||
dataSourceElement.setName(this.getName() + " JDBCDataSource");
|
||||
dataSourceElement.setProperty(TestElement.TEST_CLASS, DataSourceElement.class.getName());
|
||||
dataSourceElement.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
dataSourceElement.setProperty("autocommit", true);
|
||||
dataSourceElement.setProperty("keepAlive", true);
|
||||
dataSourceElement.setProperty("preinit", false);
|
||||
dataSourceElement.setProperty("dataSource", dataSource.getName());
|
||||
dataSourceElement.setProperty("dbUrl", dataSource.getDbUrl());
|
||||
dataSourceElement.setProperty("driver", dataSource.getDriver());
|
||||
dataSourceElement.setProperty("username", dataSource.getUsername());
|
||||
dataSourceElement.setProperty("password", dataSource.getPassword());
|
||||
dataSourceElement.setProperty("poolMax", dataSource.getPoolMax());
|
||||
dataSourceElement.setProperty("timeout", String.valueOf(dataSource.getTimeout()));
|
||||
dataSourceElement.setProperty("connectionAge", 5000);
|
||||
dataSourceElement.setProperty("trimInterval", 6000);
|
||||
dataSourceElement.setProperty("transactionIsolation", "DEFAULT");
|
||||
return dataSourceElement;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package io.metersphere.api.dto.definition.request.sampler;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.jmeter.config.ConfigTestElement;
|
||||
import org.apache.jmeter.protocol.tcp.sampler.TCPSampler;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
import org.apache.jorphan.collections.ListedHashTree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@JSONType(typeName = "TCPSampler")
|
||||
public class MsTCPSampler extends MsTestElement {
|
||||
@JSONField(ordinal = 10)
|
||||
private String type = "TCPSampler";
|
||||
@JSONField(ordinal = 11)
|
||||
private String classname = "";
|
||||
@JSONField(ordinal = 12)
|
||||
private String server = "";
|
||||
@JSONField(ordinal = 13)
|
||||
private String port = "";
|
||||
@JSONField(ordinal = 14)
|
||||
private String ctimeout = "";
|
||||
@JSONField(ordinal = 15)
|
||||
private String timeout = "";
|
||||
@JSONField(ordinal = 16)
|
||||
private boolean reUseConnection = true;
|
||||
@JSONField(ordinal = 17)
|
||||
private boolean nodelay;
|
||||
@JSONField(ordinal = 18)
|
||||
private boolean closeConnection;
|
||||
@JSONField(ordinal = 19)
|
||||
private String soLinger = "";
|
||||
@JSONField(ordinal = 20)
|
||||
private String eolByte = "";
|
||||
@JSONField(ordinal = 21)
|
||||
private String username = "";
|
||||
@JSONField(ordinal = 22)
|
||||
private String password = "";
|
||||
@JSONField(ordinal = 23)
|
||||
private String request;
|
||||
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree) {
|
||||
final HashTree samplerHashTree = new ListedHashTree();
|
||||
samplerHashTree.add(tcpConfig());
|
||||
tree.set(tcpSampler(), samplerHashTree);
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
hashTree.forEach(el -> {
|
||||
el.toHashTree(samplerHashTree, el.getHashTree());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private TCPSampler tcpSampler() {
|
||||
TCPSampler tcpSampler = new TCPSampler();
|
||||
tcpSampler.setName(this.getName());
|
||||
tcpSampler.setProperty(TestElement.TEST_CLASS, TCPSampler.class.getName());
|
||||
tcpSampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TCPSamplerGui"));
|
||||
tcpSampler.setClassname(this.getClassname());
|
||||
tcpSampler.setServer(this.getServer());
|
||||
tcpSampler.setPort(this.getPort());
|
||||
tcpSampler.setConnectTimeout(this.getCtimeout());
|
||||
tcpSampler.setProperty(TCPSampler.RE_USE_CONNECTION, this.isReUseConnection());
|
||||
tcpSampler.setProperty(TCPSampler.NODELAY, this.isNodelay());
|
||||
tcpSampler.setCloseConnection(String.valueOf(this.isCloseConnection()));
|
||||
tcpSampler.setSoLinger(this.getSoLinger());
|
||||
tcpSampler.setEolByte(this.getEolByte());
|
||||
tcpSampler.setRequestData(this.getRequest());
|
||||
tcpSampler.setProperty(ConfigTestElement.USERNAME, this.getUsername());
|
||||
tcpSampler.setProperty(ConfigTestElement.PASSWORD, this.getPassword());
|
||||
|
||||
return tcpSampler;
|
||||
}
|
||||
|
||||
private ConfigTestElement tcpConfig() {
|
||||
ConfigTestElement configTestElement = new ConfigTestElement();
|
||||
configTestElement.setEnabled(true);
|
||||
configTestElement.setName(this.getName());
|
||||
configTestElement.setProperty(TestElement.TEST_CLASS, ConfigTestElement.class.getName());
|
||||
configTestElement.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TCPConfigGui"));
|
||||
configTestElement.setProperty(TCPSampler.CLASSNAME, this.getClassname());
|
||||
configTestElement.setProperty(TCPSampler.SERVER, this.getServer());
|
||||
configTestElement.setProperty(TCPSampler.PORT, this.getPort());
|
||||
configTestElement.setProperty(TCPSampler.TIMEOUT_CONNECT, this.getCtimeout());
|
||||
configTestElement.setProperty(TCPSampler.RE_USE_CONNECTION, this.isReUseConnection());
|
||||
configTestElement.setProperty(TCPSampler.NODELAY, this.isNodelay());
|
||||
configTestElement.setProperty(TCPSampler.CLOSE_CONNECTION, this.isCloseConnection());
|
||||
configTestElement.setProperty(TCPSampler.SO_LINGER, this.getSoLinger());
|
||||
configTestElement.setProperty(TCPSampler.EOL_BYTE, this.getEolByte());
|
||||
configTestElement.setProperty(TCPSampler.SO_LINGER, this.getSoLinger());
|
||||
configTestElement.setProperty(ConfigTestElement.USERNAME, this.getUsername());
|
||||
configTestElement.setProperty(ConfigTestElement.PASSWORD, this.getPassword());
|
||||
return configTestElement;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package io.metersphere.api.dto.definition.request.sampler.dubbo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MsConfigCenter {
|
||||
private String protocol;
|
||||
private String group;
|
||||
private String namespace;
|
||||
private String username;
|
||||
private String address;
|
||||
private String password;
|
||||
private String timeout;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package io.metersphere.api.dto.definition.request.sampler.dubbo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MsConsumerAndService {
|
||||
private String timeout;
|
||||
private String version;
|
||||
private String retries;
|
||||
private String cluster;
|
||||
private String group;
|
||||
private String connections;
|
||||
private String async;
|
||||
private String loadBalance;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package io.metersphere.api.dto.definition.request.sampler.dubbo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MsRegistryCenter {
|
||||
private String protocol;
|
||||
private String group;
|
||||
private String username;
|
||||
private String address;
|
||||
private String password;
|
||||
private String timeout;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package io.metersphere.api.dto.definition.response;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.scenario.Body;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import io.metersphere.api.dto.scenario.request.RequestType;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@JSONType(typeName = RequestType.HTTP)
|
||||
public class HttpResponse extends Response {
|
||||
// type 必须放最前面,以便能够转换正确的类
|
||||
private String type = RequestType.HTTP;
|
||||
@JSONField(ordinal = 1)
|
||||
private List<KeyValue> headers;
|
||||
@JSONField(ordinal = 2)
|
||||
private List<KeyValue> statusCode;
|
||||
@JSONField(ordinal = 3)
|
||||
private Body body;
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package io.metersphere.api.dto.definition.response;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import io.metersphere.api.dto.scenario.request.RequestType;
|
||||
import lombok.Data;
|
||||
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type")
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = HttpResponse.class, name = RequestType.HTTP),
|
||||
})
|
||||
@JSONType(seeAlso = {HttpResponse.class}, typeKey = "type")
|
||||
@Data
|
||||
public abstract class Response {
|
||||
@JSONField(ordinal = 1)
|
||||
private String id;
|
||||
@JSONField(ordinal = 2)
|
||||
private String name;
|
||||
@JSONField(ordinal = 3)
|
||||
private Boolean enable;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package io.metersphere.api.dto.scenario;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AuthConfig {
|
||||
private String verification;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.api.dto.scenario;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -9,5 +10,41 @@ public class Body {
|
|||
private String type;
|
||||
private String raw;
|
||||
private String format;
|
||||
private List<KeyValue> fromUrlencoded;
|
||||
private List<KeyValue> kvs;
|
||||
private List<KeyValue> binary;
|
||||
private Object json;
|
||||
private String xml;
|
||||
|
||||
private final static String KV = "KeyValue";
|
||||
private final static String FORM_DATA = "Form Data";
|
||||
private final static String RAW = "Raw";
|
||||
private final static String BINARY = "BINARY";
|
||||
private final static String JSON = "JSON";
|
||||
private final static String XML = "XML";
|
||||
|
||||
public boolean isValid() {
|
||||
if (this.isKV()) {
|
||||
return kvs.stream().anyMatch(KeyValue::isValid);
|
||||
} else {
|
||||
return StringUtils.isNotBlank(raw);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isKV() {
|
||||
return StringUtils.equals(type, KV);
|
||||
}
|
||||
|
||||
public boolean isBinary() {
|
||||
return StringUtils.equals(type, BINARY);
|
||||
}
|
||||
|
||||
public boolean isJson() {
|
||||
return StringUtils.equals(type, JSON);
|
||||
}
|
||||
|
||||
public boolean isXml() {
|
||||
return StringUtils.equals(type, XML);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package io.metersphere.api.dto.scenario;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HttpConfig {
|
||||
private String socket;
|
||||
private String domain;
|
||||
private String protocol = "https";
|
||||
private int port;
|
||||
private List<KeyValue> headers;
|
||||
}
|
|
@ -2,6 +2,8 @@ package io.metersphere.api.dto.scenario;
|
|||
|
||||
import io.metersphere.api.dto.scenario.request.BodyFile;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -14,15 +16,19 @@ public class KeyValue {
|
|||
private String description;
|
||||
private String contentType;
|
||||
private boolean enable;
|
||||
private boolean encode = true;
|
||||
private boolean required;
|
||||
|
||||
public KeyValue() {
|
||||
this.enable = true;
|
||||
this.required = true;
|
||||
}
|
||||
|
||||
public KeyValue(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.enable = true;
|
||||
this.required = true;
|
||||
}
|
||||
|
||||
public KeyValue(String name, String value, String description) {
|
||||
|
@ -30,5 +36,14 @@ public class KeyValue {
|
|||
this.value = value;
|
||||
this.enable = true;
|
||||
this.description = description;
|
||||
this.required = true;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return (StringUtils.isNotBlank(name) || StringUtils.isNotBlank(value)) && !StringUtils.equalsIgnoreCase(type, "file");
|
||||
}
|
||||
|
||||
public boolean isFile() {
|
||||
return (CollectionUtils.isNotEmpty(files)) && StringUtils.equalsIgnoreCase(type, "file");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ public class Scenario {
|
|||
private String name;
|
||||
private String url;
|
||||
private String environmentId;
|
||||
private Boolean enableCookieShare;
|
||||
private boolean enableCookieShare;
|
||||
private List<KeyValue> variables;
|
||||
private List<KeyValue> headers;
|
||||
private List<Request> requests;
|
||||
|
@ -22,4 +22,6 @@ public class Scenario {
|
|||
private List<DatabaseConfig> databaseConfigs;
|
||||
private Boolean enable;
|
||||
private Boolean referenceEnable;
|
||||
private boolean enable = true;
|
||||
private Boolean referenceEnable;
|
||||
}
|
||||
|
|
|
@ -4,16 +4,16 @@ import lombok.Data;
|
|||
|
||||
@Data
|
||||
public class TCPConfig {
|
||||
private String classname;
|
||||
private String server;
|
||||
private Integer port;
|
||||
private Integer ctimeout;
|
||||
private Integer timeout;
|
||||
private Boolean reUseConnection;
|
||||
private Boolean nodelay;
|
||||
private Boolean closeConnection;
|
||||
private String soLinger;
|
||||
private String eolByte;
|
||||
private String username;
|
||||
private String password;
|
||||
private String classname = "";
|
||||
private String server = "";
|
||||
private String port = "";
|
||||
private String ctimeout = "";
|
||||
private String timeout = "";
|
||||
private boolean reUseConnection = true;
|
||||
private boolean nodelay;
|
||||
private boolean closeConnection;
|
||||
private String soLinger = "";
|
||||
private String eolByte = "";
|
||||
private String username = "";
|
||||
private String password = "";
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.api.dto.scenario.assertions;
|
|||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -11,4 +12,8 @@ public class AssertionDuration extends AssertionType {
|
|||
public AssertionDuration() {
|
||||
setType(AssertionType.DURATION);
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return value > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.api.dto.scenario.assertions;
|
|||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -17,4 +18,8 @@ public class AssertionJSR223 extends AssertionType {
|
|||
public AssertionJSR223() {
|
||||
setType(AssertionType.JSR223);
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return StringUtils.isNotBlank(script) && StringUtils.isNotBlank(language);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.api.dto.scenario.assertions;
|
|||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -13,4 +14,8 @@ public class AssertionJsonPath extends AssertionType {
|
|||
public AssertionJsonPath() {
|
||||
setType(AssertionType.JSON_PATH);
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return StringUtils.isNotBlank(expression);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.api.dto.scenario.assertions;
|
|||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -9,9 +10,13 @@ public class AssertionRegex extends AssertionType {
|
|||
private String subject;
|
||||
private String expression;
|
||||
private String description;
|
||||
private Boolean assumeSuccess;
|
||||
private boolean assumeSuccess;
|
||||
|
||||
public AssertionRegex() {
|
||||
setType(AssertionType.REGEX);
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return StringUtils.isNotBlank(subject) && StringUtils.isNotBlank(expression);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,18 @@ package io.metersphere.api.dto.scenario.assertions;
|
|||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class AssertionXPath2 extends AssertionType {
|
||||
private String expression;
|
||||
|
||||
public AssertionXPath2() {
|
||||
setType(AssertionType.XPATH2);
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return StringUtils.isNotBlank(expression);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,56 @@
|
|||
package io.metersphere.api.dto.scenario.controller;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Data
|
||||
public class IfController {
|
||||
private String type;
|
||||
private String id;
|
||||
private Boolean enable;
|
||||
private boolean enable = true;
|
||||
private String variable;
|
||||
private String operator;
|
||||
private String value;
|
||||
|
||||
public boolean isValid() {
|
||||
if (StringUtils.contains(operator, "empty")) {
|
||||
return StringUtils.isNotBlank(variable);
|
||||
}
|
||||
return StringUtils.isNotBlank(variable) && StringUtils.isNotBlank(operator) && StringUtils.isNotBlank(value);
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
if (isValid()) {
|
||||
String label = variable + " " + operator;
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
label += " " + this.value;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
String variable = "\"" + this.variable + "\"";
|
||||
String operator = this.operator;
|
||||
String value = "\"" + this.value + "\"";
|
||||
|
||||
if (StringUtils.contains(operator, "~")) {
|
||||
value = "\".*" + this.value + ".*\"";
|
||||
}
|
||||
|
||||
if (StringUtils.equals(operator, "is empty")) {
|
||||
variable = "empty(" + variable + ")";
|
||||
operator = "";
|
||||
value = "";
|
||||
}
|
||||
|
||||
if (StringUtils.equals(operator, "is not empty")) {
|
||||
variable = "!empty(" + variable + ")";
|
||||
operator = "";
|
||||
value = "";
|
||||
}
|
||||
|
||||
return "${__jexl3(" + variable + operator + value + ")}";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package io.metersphere.api.dto.scenario.environment;
|
||||
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CommonConfig {
|
||||
private List<KeyValue> variables;
|
||||
private boolean enableHost;
|
||||
private List<Host> hosts;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package io.metersphere.api.dto.scenario.environment;
|
||||
|
||||
import io.metersphere.api.dto.scenario.DatabaseConfig;
|
||||
import io.metersphere.api.dto.scenario.HttpConfig;
|
||||
import io.metersphere.api.dto.scenario.TCPConfig;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class EnvironmentConfig {
|
||||
private CommonConfig commonConfig;
|
||||
private HttpConfig httpConfig;
|
||||
private List<DatabaseConfig> databaseConfigs;
|
||||
private TCPConfig tcpConfig;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.api.dto.scenario.environment;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Host {
|
||||
private String ip;
|
||||
private String domain;
|
||||
private String status;
|
||||
private String annotation;
|
||||
private String uuid;
|
||||
}
|
|
@ -2,6 +2,7 @@ package io.metersphere.api.dto.scenario.extract;
|
|||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -10,5 +11,9 @@ public class ExtractCommon extends ExtractType {
|
|||
private String value; // value: ${variable}
|
||||
private String expression;
|
||||
private String description;
|
||||
private Boolean multipleMatching;
|
||||
private boolean multipleMatching;
|
||||
|
||||
public boolean isValid() {
|
||||
return StringUtils.isNotBlank(variable) && StringUtils.isNotBlank(expression);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,23 +18,23 @@ import java.util.List;
|
|||
public class DubboRequest extends Request {
|
||||
// type 必须放最前面,以便能够转换正确的类
|
||||
private String type = RequestType.DUBBO;
|
||||
@JSONField(ordinal = 2)
|
||||
@JSONField(ordinal = 52)
|
||||
private String protocol;
|
||||
@JsonProperty(value = "interface")
|
||||
@JSONField(ordinal = 3, name = "interface")
|
||||
@JSONField(ordinal = 53, name = "interface")
|
||||
private String _interface;
|
||||
@JSONField(ordinal = 4)
|
||||
@JSONField(ordinal = 54)
|
||||
private String method;
|
||||
|
||||
@JSONField(ordinal = 5)
|
||||
@JSONField(ordinal = 55)
|
||||
private ConfigCenter configCenter;
|
||||
@JSONField(ordinal = 6)
|
||||
@JSONField(ordinal = 56)
|
||||
private RegistryCenter registryCenter;
|
||||
@JSONField(ordinal = 7)
|
||||
@JSONField(ordinal = 57)
|
||||
private ConsumerAndService consumerAndService;
|
||||
|
||||
@JSONField(ordinal = 8)
|
||||
@JSONField(ordinal = 58)
|
||||
private List<KeyValue> args;
|
||||
@JSONField(ordinal = 9)
|
||||
@JSONField(ordinal = 59)
|
||||
private List<KeyValue> attachmentArgs;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.api.dto.scenario.request;
|
|||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.scenario.AuthConfig;
|
||||
import io.metersphere.api.dto.scenario.Body;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import lombok.Data;
|
||||
|
@ -15,26 +16,32 @@ import java.util.List;
|
|||
public class HttpRequest extends Request {
|
||||
// type 必须放最前面,以便能够转换正确的类
|
||||
private String type = RequestType.HTTP;
|
||||
@JSONField(ordinal = 2)
|
||||
@JSONField(ordinal = 50)
|
||||
private String url;
|
||||
@JSONField(ordinal = 3)
|
||||
@JSONField(ordinal = 51)
|
||||
private String method;
|
||||
@JSONField(ordinal = 4)
|
||||
@JSONField(ordinal = 52)
|
||||
private String path;
|
||||
@JSONField(ordinal = 5)
|
||||
private Boolean useEnvironment;
|
||||
@JSONField(ordinal = 6)
|
||||
@JSONField(ordinal = 53)
|
||||
private List<KeyValue> parameters;
|
||||
@JSONField(ordinal = 7)
|
||||
@JSONField(ordinal = 54)
|
||||
private List<KeyValue> headers;
|
||||
@JSONField(ordinal = 8)
|
||||
@JSONField(ordinal = 55)
|
||||
private Body body;
|
||||
@JSONField(ordinal = 14)
|
||||
private Long connectTimeout;
|
||||
@JSONField(ordinal = 15)
|
||||
private Long responseTimeout;
|
||||
@JSONField(ordinal = 16)
|
||||
private Boolean followRedirects;
|
||||
@JSONField(ordinal = 17)
|
||||
private Boolean doMultipartPost;
|
||||
@JSONField(ordinal = 56)
|
||||
private String connectTimeout;
|
||||
@JSONField(ordinal = 57)
|
||||
private String responseTimeout;
|
||||
@JSONField(ordinal = 58)
|
||||
private boolean followRedirects;
|
||||
@JSONField(ordinal = 59)
|
||||
private boolean doMultipartPost;
|
||||
@JSONField(ordinal = 60)
|
||||
private List<KeyValue> rest;
|
||||
@JSONField(ordinal = 61)
|
||||
private AuthConfig authConfig;
|
||||
// 和接口定义模块用途区分
|
||||
@JSONField(ordinal = 62)
|
||||
private boolean isDefinition;
|
||||
|
||||
}
|
||||
|
|
|
@ -22,22 +22,25 @@ import lombok.Data;
|
|||
@JSONType(seeAlso = {HttpRequest.class, DubboRequest.class, SqlRequest.class, TCPRequest.class}, typeKey = "type")
|
||||
@Data
|
||||
public abstract class Request {
|
||||
private String type;
|
||||
@JSONField(ordinal = 1)
|
||||
private String id;
|
||||
@JSONField(ordinal = 2)
|
||||
private String name;
|
||||
@JSONField(ordinal = 3)
|
||||
private Boolean enable;
|
||||
private boolean enable = true;
|
||||
@JSONField(ordinal = 4)
|
||||
private Assertions assertions;
|
||||
private boolean useEnvironment;
|
||||
@JSONField(ordinal = 5)
|
||||
private Extract extract;
|
||||
private Assertions assertions;
|
||||
@JSONField(ordinal = 6)
|
||||
private JSR223PreProcessor jsr223PreProcessor;
|
||||
private Extract extract;
|
||||
@JSONField(ordinal = 7)
|
||||
private JSR223PostProcessor jsr223PostProcessor;
|
||||
private JSR223PreProcessor jsr223PreProcessor;
|
||||
@JSONField(ordinal = 8)
|
||||
private IfController controller;
|
||||
private JSR223PostProcessor jsr223PostProcessor;
|
||||
@JSONField(ordinal = 9)
|
||||
private IfController controller;
|
||||
@JSONField(ordinal = 10)
|
||||
private ConstantTimer timer;
|
||||
}
|
||||
|
|
|
@ -14,20 +14,16 @@ import java.util.List;
|
|||
public class SqlRequest extends Request {
|
||||
// type 必须放最前面,以便能够转换正确的类
|
||||
private String type = RequestType.SQL;
|
||||
@JSONField(ordinal = 3)
|
||||
@JSONField(ordinal = 50)
|
||||
private String dataSource;
|
||||
@JSONField(ordinal = 4)
|
||||
@JSONField(ordinal = 51)
|
||||
private String query;
|
||||
@JSONField(ordinal = 5)
|
||||
@JSONField(ordinal = 52)
|
||||
private long queryTimeout;
|
||||
@JSONField(ordinal = 6)
|
||||
private Boolean useEnvironment;
|
||||
@JSONField(ordinal = 7)
|
||||
private Boolean followRedirects;
|
||||
@JSONField(ordinal = 13)
|
||||
@JSONField(ordinal = 53)
|
||||
private String resultVariable;
|
||||
@JSONField(ordinal = 14)
|
||||
@JSONField(ordinal = 54)
|
||||
private String variableNames;
|
||||
@JSONField(ordinal = 15)
|
||||
@JSONField(ordinal = 55)
|
||||
private List<KeyValue> variables;
|
||||
}
|
||||
|
|
|
@ -11,32 +11,30 @@ import lombok.EqualsAndHashCode;
|
|||
public class TCPRequest extends Request {
|
||||
// type 必须放最前面,以便能够转换正确的类
|
||||
private String type = RequestType.TCP;
|
||||
@JSONField(ordinal = 50)
|
||||
private Boolean useEnvironment;
|
||||
@JSONField(ordinal = 51)
|
||||
private String classname;
|
||||
private String classname = "";
|
||||
@JSONField(ordinal = 52)
|
||||
private String server;
|
||||
private String server = "";
|
||||
@JSONField(ordinal = 53)
|
||||
private Integer port;
|
||||
private String port = "";
|
||||
@JSONField(ordinal = 54)
|
||||
private Integer ctimeout;
|
||||
private String ctimeout = "";
|
||||
@JSONField(ordinal = 55)
|
||||
private Integer timeout;
|
||||
private String timeout = "";
|
||||
@JSONField(ordinal = 56)
|
||||
private Boolean reUseConnection;
|
||||
private boolean reUseConnection;
|
||||
@JSONField(ordinal = 57)
|
||||
private Boolean nodelay;
|
||||
private boolean nodelay;
|
||||
@JSONField(ordinal = 58)
|
||||
private Boolean closeConnection;
|
||||
private boolean closeConnection;
|
||||
@JSONField(ordinal = 59)
|
||||
private String soLinger;
|
||||
private String soLinger = "";
|
||||
@JSONField(ordinal = 60)
|
||||
private String eolByte;
|
||||
private String eolByte = "";
|
||||
@JSONField(ordinal = 61)
|
||||
private String request;
|
||||
private String request = "";
|
||||
@JSONField(ordinal = 62)
|
||||
private String username;
|
||||
private String username = "";
|
||||
@JSONField(ordinal = 63)
|
||||
private String password;
|
||||
private String password = "";
|
||||
}
|
||||
|
|
|
@ -6,6 +6,6 @@ import lombok.Data;
|
|||
public class ConstantTimer {
|
||||
private String type;
|
||||
private String id;
|
||||
private Boolean enable;
|
||||
private boolean enable = true;
|
||||
private String delay;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package io.metersphere.api.jmeter;
|
|||
|
||||
import io.metersphere.api.service.APIReportService;
|
||||
import io.metersphere.api.service.APITestService;
|
||||
import io.metersphere.api.service.ApiDefinitionExecResultService;
|
||||
import io.metersphere.api.service.ApiDefinitionService;
|
||||
import io.metersphere.base.domain.ApiTestReport;
|
||||
import io.metersphere.commons.constants.APITestStatus;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
|
@ -20,11 +22,14 @@ import io.metersphere.service.SystemParameterService;
|
|||
import io.metersphere.track.service.TestPlanTestCaseService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.assertions.AssertionResult;
|
||||
import org.apache.jmeter.protocol.http.sampler.HTTPSampleResult;
|
||||
import org.apache.jmeter.samplers.SampleResult;
|
||||
import org.apache.jmeter.visualizers.backend.AbstractBackendListenerClient;
|
||||
import org.apache.jmeter.visualizers.backend.BackendListenerContext;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
|
@ -51,6 +56,9 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
|
||||
private MailService mailService;
|
||||
|
||||
private ApiDefinitionService apiDefinitionService;
|
||||
private ApiDefinitionExecResultService apiDefinitionExecResultService;
|
||||
|
||||
public String runMode = ApiRunMode.RUN.name();
|
||||
|
||||
// 测试ID
|
||||
|
@ -58,8 +66,22 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
|
||||
private String debugReportId;
|
||||
|
||||
//获得控制台内容
|
||||
private PrintStream oldPrintStream = System.out;
|
||||
private ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
|
||||
private void setConsole() {
|
||||
System.setOut(new PrintStream(bos)); //设置新的out
|
||||
}
|
||||
|
||||
private String getConsole() {
|
||||
System.setOut(oldPrintStream);
|
||||
return bos.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupTest(BackendListenerContext context) throws Exception {
|
||||
setConsole();
|
||||
setParam(context);
|
||||
apiTestService = CommonBeanFactory.getBean(APITestService.class);
|
||||
if (apiTestService == null) {
|
||||
|
@ -82,6 +104,14 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
if (mailService == null) {
|
||||
LogUtil.error("mailService is required");
|
||||
}
|
||||
apiDefinitionService = CommonBeanFactory.getBean(ApiDefinitionService.class);
|
||||
if (apiDefinitionService == null) {
|
||||
LogUtil.error("apiDefinitionService is required");
|
||||
}
|
||||
apiDefinitionExecResultService = CommonBeanFactory.getBean(ApiDefinitionExecResultService.class);
|
||||
if (apiDefinitionExecResultService == null) {
|
||||
LogUtil.error("apiDefinitionExecResultService is required");
|
||||
}
|
||||
super.setupTest(context);
|
||||
}
|
||||
|
||||
|
@ -99,7 +129,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
|
||||
// 一个脚本里可能包含多个场景(ThreadGroup),所以要区分开,key: 场景Id
|
||||
final Map<String, ScenarioResult> scenarios = new LinkedHashMap<>();
|
||||
queue.forEach(result -> {
|
||||
queue.forEach(result -> {
|
||||
// 线程名称: <场景名> <场景Index>-<请求Index>, 例如:Scenario 2-1
|
||||
String scenarioName = StringUtils.substringBeforeLast(result.getThreadName(), THREAD_SPLIT);
|
||||
String index = StringUtils.substringAfterLast(result.getThreadName(), THREAD_SPLIT);
|
||||
|
@ -137,17 +167,25 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
scenarioResult.addPassAssertions(requestResult.getPassAssertions());
|
||||
scenarioResult.addTotalAssertions(requestResult.getTotalAssertions());
|
||||
});
|
||||
|
||||
testResult.getScenarios().addAll(scenarios.values());
|
||||
testResult.getScenarios().sort(Comparator.comparing(ScenarioResult::getId));
|
||||
ApiTestReport report;
|
||||
ApiTestReport report = null;
|
||||
if (StringUtils.equals(this.runMode, ApiRunMode.DEBUG.name())) {
|
||||
report = apiReportService.get(debugReportId);
|
||||
apiReportService.complete(testResult, report);
|
||||
} else if (StringUtils.equals(this.runMode, ApiRunMode.DELIMIT.name())) {
|
||||
// 调试操作,不需要存储结果
|
||||
if (StringUtils.isBlank(debugReportId)) {
|
||||
apiDefinitionService.addResult(testResult);
|
||||
} else {
|
||||
apiDefinitionService.addResult(testResult);
|
||||
apiDefinitionExecResultService.saveApiResult(testResult);
|
||||
}
|
||||
} else {
|
||||
apiTestService.changeStatus(testId, APITestStatus.Completed);
|
||||
report = apiReportService.getRunningReport(testResult.getTestId());
|
||||
apiReportService.complete(testResult, report);
|
||||
}
|
||||
apiReportService.complete(testResult, report);
|
||||
queue.clear();
|
||||
super.teardownTest(context);
|
||||
|
||||
|
@ -242,6 +280,14 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
requestResult.setTotalAssertions(result.getAssertionResults().length);
|
||||
requestResult.setSuccess(result.isSuccessful());
|
||||
requestResult.setError(result.getErrorCount());
|
||||
if (result instanceof HTTPSampleResult) {
|
||||
HTTPSampleResult res = (HTTPSampleResult) result;
|
||||
requestResult.setCookies(res.getCookies());
|
||||
}
|
||||
|
||||
for (SampleResult subResult : result.getSubResults()) {
|
||||
requestResult.getSubRequestResults().add(getRequestResult(subResult));
|
||||
}
|
||||
for (SampleResult subResult : result.getSubResults()) {
|
||||
requestResult.getSubRequestResults().add(getRequestResult(subResult));
|
||||
}
|
||||
|
@ -277,6 +323,8 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
}
|
||||
responseResult.getAssertions().add(responseAssertionResult);
|
||||
}
|
||||
responseResult.setConsole(getConsole());
|
||||
|
||||
return requestResult;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.apache.jorphan.collections.HashTree;
|
|||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
@ -25,19 +26,23 @@ public class JMeterService {
|
|||
@Resource
|
||||
private JmeterProperties jmeterProperties;
|
||||
|
||||
public void run(String testId, String debugReportId, InputStream is) {
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
String JMETER_HOME = getJmeterHome();
|
||||
|
||||
String JMETER_PROPERTIES = JMETER_HOME + "/bin/jmeter.properties";
|
||||
JMeterUtils.loadJMeterProperties(JMETER_PROPERTIES);
|
||||
JMeterUtils.setJMeterHome(JMETER_HOME);
|
||||
JMeterUtils.setLocale(LocaleContextHolder.getLocale());
|
||||
}
|
||||
|
||||
public void run(String testId, String debugReportId, InputStream is) {
|
||||
init();
|
||||
try {
|
||||
Object scriptWrapper = SaveService.loadElement(is);
|
||||
HashTree testPlan = getHashTree(scriptWrapper);
|
||||
JMeterVars.addJSR223PostProcessor(testPlan);
|
||||
addBackendListener(testId, debugReportId, testPlan);
|
||||
addBackendListener(testId, debugReportId, ApiRunMode.DEBUG.name(), testPlan);
|
||||
LocalRunner runner = new LocalRunner(testPlan);
|
||||
runner.run();
|
||||
} catch (Exception e) {
|
||||
|
@ -66,17 +71,32 @@ public class JMeterService {
|
|||
return (HashTree) field.get(scriptWrapper);
|
||||
}
|
||||
|
||||
private void addBackendListener(String testId, String debugReportId, HashTree testPlan) {
|
||||
private void addBackendListener(String testId, String debugReportId, String runMode, HashTree testPlan) {
|
||||
BackendListener backendListener = new BackendListener();
|
||||
backendListener.setName(testId);
|
||||
Arguments arguments = new Arguments();
|
||||
arguments.addArgument(APIBackendListenerClient.TEST_ID, testId);
|
||||
if (StringUtils.isNotBlank(runMode)) {
|
||||
arguments.addArgument("runMode", runMode);
|
||||
}
|
||||
if (StringUtils.isNotBlank(debugReportId)) {
|
||||
arguments.addArgument("runMode", ApiRunMode.DEBUG.name());
|
||||
arguments.addArgument("debugReportId", debugReportId);
|
||||
}
|
||||
backendListener.setArguments(arguments);
|
||||
backendListener.setClassname(APIBackendListenerClient.class.getCanonicalName());
|
||||
testPlan.add(testPlan.getArray()[0], backendListener);
|
||||
}
|
||||
|
||||
public void runDefinition(String testId, HashTree testPlan, String debugReportId, String runMode) {
|
||||
try {
|
||||
init();
|
||||
JMeterVars.addJSR223PostProcessor(testPlan);
|
||||
addBackendListener(testId, debugReportId, runMode, testPlan);
|
||||
LocalRunner runner = new LocalRunner(testPlan);
|
||||
runner.run();
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
MSException.throwException(Translator.get("api_load_script_error"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ public class ResponseResult {
|
|||
|
||||
private String vars;
|
||||
|
||||
private String console;
|
||||
|
||||
private final List<ResponseAssertionResult> assertions = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package io.metersphere.api.parse;
|
||||
|
||||
import io.metersphere.api.dto.ApiTestImportRequest;
|
||||
import io.metersphere.api.dto.definition.parse.ApiDefinitionImport;
|
||||
import io.metersphere.api.dto.parse.ApiImport;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public interface ApiImportParser {
|
||||
ApiImport parse(InputStream source, ApiTestImportRequest request);
|
||||
ApiDefinitionImport parseApi(InputStream source, ApiTestImportRequest request);
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class JmeterDocumentParser {
|
|||
private final static String STRING_PROP = "stringProp";
|
||||
private final static String ARGUMENTS = "Arguments";
|
||||
private final static String COLLECTION_PROP = "collectionProp";
|
||||
private final static String HTTP_SAMPLER_PROXY = "HTTPSamplerProxy";
|
||||
private final static String HTTP_SAMPLER_PROXY = "MsHTTPSamplerProxy";
|
||||
private final static String ELEMENT_PROP = "elementProp";
|
||||
|
||||
public static byte[] parse(byte[] source) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import io.metersphere.api.dto.ApiTestImportRequest;
|
||||
import io.metersphere.api.dto.definition.parse.ApiDefinitionImport;
|
||||
import io.metersphere.api.dto.parse.ApiImport;
|
||||
import io.metersphere.api.dto.scenario.request.RequestType;
|
||||
import io.metersphere.commons.constants.MsRequestBodyType;
|
||||
|
@ -22,6 +23,13 @@ public class MsParser extends ApiImportAbstractParser {
|
|||
return apiImport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiDefinitionImport parseApi(InputStream source, ApiTestImportRequest request) {
|
||||
String testStr = getApiTestStr(source);
|
||||
ApiDefinitionImport apiImport = JSON.parseObject(testStr, ApiDefinitionImport.class);
|
||||
return apiImport;
|
||||
}
|
||||
|
||||
private String parsePluginFormat(String testStr) {
|
||||
JSONObject testObject = JSONObject.parseObject(testStr, Feature.OrderedField);
|
||||
if (testObject.get("scenarios") != null) {
|
||||
|
|
|
@ -3,6 +3,11 @@ package io.metersphere.api.parse;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.metersphere.api.dto.ApiTestImportRequest;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionResult;
|
||||
import io.metersphere.api.dto.definition.parse.ApiDefinitionImport;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import io.metersphere.api.dto.definition.request.configurations.MsHeaderManager;
|
||||
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
|
||||
import io.metersphere.api.dto.parse.ApiImport;
|
||||
import io.metersphere.api.dto.parse.postman.*;
|
||||
import io.metersphere.api.dto.scenario.Body;
|
||||
|
@ -10,12 +15,17 @@ import io.metersphere.api.dto.scenario.KeyValue;
|
|||
import io.metersphere.api.dto.scenario.Scenario;
|
||||
import io.metersphere.api.dto.scenario.request.HttpRequest;
|
||||
import io.metersphere.api.dto.scenario.request.Request;
|
||||
import io.metersphere.api.dto.scenario.request.RequestType;
|
||||
import io.metersphere.commons.constants.MsRequestBodyType;
|
||||
import io.metersphere.commons.constants.PostmanRequestBodyMode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PostmanParser extends ApiImportAbstractParser {
|
||||
|
||||
|
@ -38,6 +48,67 @@ public class PostmanParser extends ApiImportAbstractParser {
|
|||
return apiImport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiDefinitionImport parseApi(InputStream source, ApiTestImportRequest request) {
|
||||
String testStr = getApiTestStr(source);
|
||||
PostmanCollection postmanCollection = JSON.parseObject(testStr, PostmanCollection.class);
|
||||
List<PostmanKeyValue> variables = postmanCollection.getVariable();
|
||||
ApiDefinitionImport apiImport = new ApiDefinitionImport();
|
||||
List<ApiDefinitionResult> requests = new ArrayList<>();
|
||||
|
||||
parseItem(postmanCollection.getItem(), variables, requests);
|
||||
apiImport.setData(requests);
|
||||
return apiImport;
|
||||
}
|
||||
|
||||
private void parseItem(List<PostmanItem> items, List<PostmanKeyValue> variables, List<ApiDefinitionResult> scenarios) {
|
||||
for (PostmanItem item : items) {
|
||||
List<PostmanItem> childItems = item.getItem();
|
||||
if (childItems != null) {
|
||||
parseItem(childItems, variables, scenarios);
|
||||
} else {
|
||||
ApiDefinitionResult request = parsePostman(item);
|
||||
if (request != null) {
|
||||
scenarios.add(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ApiDefinitionResult parsePostman(PostmanItem requestItem) {
|
||||
PostmanRequest requestDesc = requestItem.getRequest();
|
||||
if (requestDesc == null) {
|
||||
return null;
|
||||
}
|
||||
PostmanUrl url = requestDesc.getUrl();
|
||||
ApiDefinitionResult request = new ApiDefinitionResult();
|
||||
request.setName(requestItem.getName());
|
||||
request.setPath(url.getRaw());
|
||||
request.setMethod(requestDesc.getMethod());
|
||||
request.setProtocol(RequestType.HTTP);
|
||||
MsHTTPSamplerProxy requestElement = new MsHTTPSamplerProxy();
|
||||
requestElement.setName(requestItem.getName() + "Postman MHTTPSamplerProxy");
|
||||
requestElement.setBody(parseBody(requestDesc));
|
||||
requestElement.setArguments(parseKeyValue(url.getQuery()));
|
||||
requestElement.setProtocol(RequestType.HTTP);
|
||||
requestElement.setPath(url.getRaw());
|
||||
requestElement.setMethod(requestDesc.getMethod());
|
||||
requestElement.setId(UUID.randomUUID().toString());
|
||||
requestElement.setRest(new ArrayList<KeyValue>());
|
||||
MsHeaderManager headerManager = new MsHeaderManager();
|
||||
headerManager.setId(UUID.randomUUID().toString());
|
||||
headerManager.setName(requestItem.getName() + "Postman MsHeaderManager");
|
||||
headerManager.setHeaders(parseKeyValue(requestDesc.getHeader()));
|
||||
HashTree tree = new HashTree();
|
||||
tree.add(headerManager);
|
||||
LinkedList<MsTestElement> list = new LinkedList<>();
|
||||
list.add(headerManager);
|
||||
requestElement.setHashTree(list);
|
||||
request.setRequest(JSON.toJSONString(requestElement));
|
||||
return request;
|
||||
}
|
||||
|
||||
|
||||
private List<KeyValue> parseKeyValue(List<PostmanKeyValue> postmanKeyValues) {
|
||||
if (postmanKeyValues == null) {
|
||||
return null;
|
||||
|
|
|
@ -1,14 +1,21 @@
|
|||
package io.metersphere.api.parse;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.metersphere.api.dto.ApiTestImportRequest;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionResult;
|
||||
import io.metersphere.api.dto.definition.parse.ApiDefinitionImport;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import io.metersphere.api.dto.definition.request.configurations.MsHeaderManager;
|
||||
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
|
||||
import io.metersphere.api.dto.parse.ApiImport;
|
||||
import io.metersphere.api.dto.scenario.Body;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import io.metersphere.api.dto.scenario.Scenario;
|
||||
import io.metersphere.api.dto.scenario.request.HttpRequest;
|
||||
import io.metersphere.api.dto.scenario.request.Request;
|
||||
import io.metersphere.api.dto.scenario.request.RequestType;
|
||||
import io.metersphere.commons.constants.MsRequestBodyType;
|
||||
import io.metersphere.commons.constants.SwaggerParameterType;
|
||||
import io.swagger.models.*;
|
||||
|
@ -19,6 +26,7 @@ import io.swagger.models.properties.Property;
|
|||
import io.swagger.models.properties.RefProperty;
|
||||
import io.swagger.parser.SwaggerParser;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
@ -39,6 +47,52 @@ public class Swagger2Parser extends ApiImportAbstractParser {
|
|||
return apiImport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiDefinitionImport parseApi(InputStream source, ApiTestImportRequest request) {
|
||||
ApiImport apiImport = this.parse(source, request);
|
||||
ApiDefinitionImport definitionImport = new ApiDefinitionImport();
|
||||
definitionImport.setData(parseSwagger(apiImport));
|
||||
return definitionImport;
|
||||
}
|
||||
|
||||
private List<ApiDefinitionResult> parseSwagger(ApiImport apiImport) {
|
||||
List<ApiDefinitionResult> results = new LinkedList<>();
|
||||
apiImport.getScenarios().forEach(item -> {
|
||||
item.getRequests().forEach(childItem -> {
|
||||
if (childItem instanceof HttpRequest) {
|
||||
HttpRequest res = (HttpRequest) childItem;
|
||||
ApiDefinitionResult request = new ApiDefinitionResult();
|
||||
request.setName(res.getName());
|
||||
request.setPath(res.getPath());
|
||||
request.setMethod(res.getMethod());
|
||||
request.setProtocol(RequestType.HTTP);
|
||||
MsHTTPSamplerProxy requestElement = new MsHTTPSamplerProxy();
|
||||
requestElement.setName(res.getName() + "Postman MHTTPSamplerProxy");
|
||||
requestElement.setBody(res.getBody());
|
||||
requestElement.setArguments(res.getParameters());
|
||||
requestElement.setProtocol(RequestType.HTTP);
|
||||
requestElement.setPath(res.getPath());
|
||||
requestElement.setMethod(res.getMethod());
|
||||
requestElement.setId(UUID.randomUUID().toString());
|
||||
requestElement.setRest(new ArrayList<KeyValue>());
|
||||
MsHeaderManager headerManager = new MsHeaderManager();
|
||||
headerManager.setId(UUID.randomUUID().toString());
|
||||
headerManager.setName(res.getName() + "Postman MsHeaderManager");
|
||||
headerManager.setHeaders(res.getHeaders());
|
||||
HashTree tree = new HashTree();
|
||||
tree.add(headerManager);
|
||||
LinkedList<MsTestElement> list = new LinkedList<>();
|
||||
list.add(headerManager);
|
||||
requestElement.setHashTree(list);
|
||||
request.setRequest(JSON.toJSONString(requestElement));
|
||||
results.add(request);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
private List<Scenario> parseRequests(Swagger swagger) {
|
||||
Map<String, Path> paths = swagger.getPaths();
|
||||
Set<String> pathNames = paths.keySet();
|
||||
|
@ -141,7 +195,7 @@ public class Swagger2Parser extends ApiImportAbstractParser {
|
|||
Model model = definitions.get(simpleRef);
|
||||
HashSet<String> refSet = new HashSet<>();
|
||||
refSet.add(simpleRef);
|
||||
if (model != null ) {
|
||||
if (model != null) {
|
||||
JSONObject bodyParameters = getBodyJSONObjectParameters(model.getProperties(), definitions, refSet);
|
||||
body.setRaw(bodyParameters.toJSONString());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package io.metersphere.api.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.metersphere.api.jmeter.TestResult;
|
||||
import io.metersphere.base.domain.ApiDefinitionExecResult;
|
||||
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class ApiDefinitionExecResultService {
|
||||
@Resource
|
||||
private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper;
|
||||
|
||||
|
||||
public void saveApiResult(TestResult result) {
|
||||
result.getScenarios().get(0).getRequestResults().forEach(item -> {
|
||||
// 清理原始资源,每个执行 保留一条结果
|
||||
apiDefinitionExecResultMapper.deleteByResourceId(item.getName());
|
||||
ApiDefinitionExecResult saveResult = new ApiDefinitionExecResult();
|
||||
saveResult.setId(UUID.randomUUID().toString());
|
||||
saveResult.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
|
||||
saveResult.setName(item.getName());
|
||||
saveResult.setResourceId(item.getName());
|
||||
saveResult.setContent(JSON.toJSONString(item));
|
||||
saveResult.setStartTime(item.getStartTime());
|
||||
saveResult.setEndTime(item.getResponseResult().getResponseTime());
|
||||
saveResult.setStatus(item.getResponseResult().getResponseCode().equals("200") ? "success" : "error");
|
||||
apiDefinitionExecResultMapper.insert(saveResult);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,344 @@
|
|||
package io.metersphere.api.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.metersphere.api.dto.APIReportResult;
|
||||
import io.metersphere.api.dto.ApiTestImportRequest;
|
||||
import io.metersphere.api.dto.definition.*;
|
||||
import io.metersphere.api.dto.definition.parse.ApiDefinitionImport;
|
||||
import io.metersphere.api.dto.scenario.request.RequestType;
|
||||
import io.metersphere.api.jmeter.JMeterService;
|
||||
import io.metersphere.api.jmeter.TestResult;
|
||||
import io.metersphere.api.parse.ApiImportParser;
|
||||
import io.metersphere.api.parse.ApiImportParserFactory;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
|
||||
import io.metersphere.base.mapper.ApiDefinitionMapper;
|
||||
import io.metersphere.base.mapper.ApiTestFileMapper;
|
||||
import io.metersphere.commons.constants.APITestStatus;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.commons.utils.ServiceUtils;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.service.FileService;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
import org.aspectj.util.FileUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import sun.security.util.Cache;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class ApiDefinitionService {
|
||||
@Resource
|
||||
private ApiDefinitionMapper apiDefinitionMapper;
|
||||
@Resource
|
||||
private ApiTestFileMapper apiTestFileMapper;
|
||||
@Resource
|
||||
private FileService fileService;
|
||||
@Resource
|
||||
private ApiTestCaseService apiTestCaseService;
|
||||
@Resource
|
||||
private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper;
|
||||
@Resource
|
||||
private JMeterService jMeterService;
|
||||
|
||||
private static Cache cache = Cache.newHardMemoryCache(0, 3600 * 24);
|
||||
|
||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
|
||||
public List<ApiDefinitionResult> list(ApiDefinitionRequest request) {
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
List<ApiDefinitionResult> resList = apiDefinitionMapper.list(request);
|
||||
if (!resList.isEmpty()) {
|
||||
List<String> ids = resList.stream().map(ApiDefinitionResult::getId).collect(Collectors.toList());
|
||||
List<ApiComputeResult> results = apiDefinitionMapper.selectByIds(ids);
|
||||
Map<String, ApiComputeResult> resultMap = results.stream().collect(Collectors.toMap(ApiComputeResult::getApiDefinitionId, Function.identity()));
|
||||
for (ApiDefinitionResult res : resList) {
|
||||
ApiComputeResult compRes = resultMap.get(res.getId());
|
||||
if (compRes != null) {
|
||||
res.setCaseTotal(compRes.getCaseTotal());
|
||||
res.setCasePassingRate(compRes.getPassRate());
|
||||
res.setCaseStatus(compRes.getStatus());
|
||||
} else {
|
||||
res.setCaseTotal("-");
|
||||
res.setCasePassingRate("-");
|
||||
res.setCaseStatus("-");
|
||||
}
|
||||
}
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
public ApiDefinition get(String id) {
|
||||
return apiDefinitionMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public void create(SaveApiDefinitionRequest request, List<MultipartFile> bodyFiles) {
|
||||
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
|
||||
createTest(request);
|
||||
createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
}
|
||||
|
||||
public void update(SaveApiDefinitionRequest request, List<MultipartFile> bodyFiles) {
|
||||
deleteFileByTestId(request.getRequest().getId());
|
||||
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
|
||||
request.setBodyUploadIds(null);
|
||||
updateTest(request);
|
||||
createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
}
|
||||
|
||||
private void createBodyFiles(List<String> bodyUploadIds, List<MultipartFile> bodyFiles) {
|
||||
if (bodyUploadIds.size() > 0) {
|
||||
File testDir = new File(BODY_FILE_DIR);
|
||||
if (!testDir.exists()) {
|
||||
testDir.mkdirs();
|
||||
}
|
||||
for (int i = 0; i < bodyUploadIds.size(); i++) {
|
||||
MultipartFile item = bodyFiles.get(i);
|
||||
File file = new File(BODY_FILE_DIR + "/" + bodyUploadIds.get(i) + "_" + item.getOriginalFilename());
|
||||
try (InputStream in = item.getInputStream(); OutputStream out = new FileOutputStream(file)) {
|
||||
file.createNewFile();
|
||||
FileUtil.copyStream(in, out);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e);
|
||||
MSException.throwException(Translator.get("upload_fail"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(String apiId) {
|
||||
apiTestCaseService.deleteTestCase(apiId);
|
||||
deleteFileByTestId(apiId);
|
||||
apiDefinitionExecResultMapper.deleteByResourceId(apiId);
|
||||
apiDefinitionMapper.deleteByPrimaryKey(apiId);
|
||||
deleteBodyFiles(apiId);
|
||||
}
|
||||
|
||||
public void deleteBatch(List<String> apiIds) {
|
||||
// 简单处理后续优化
|
||||
apiIds.forEach(item -> {
|
||||
delete(item);
|
||||
});
|
||||
}
|
||||
|
||||
public void removeToGc(List<String> apiIds) {
|
||||
apiDefinitionMapper.removeToGc(apiIds);
|
||||
}
|
||||
|
||||
public void deleteBodyFiles(String apiId) {
|
||||
File file = new File(BODY_FILE_DIR + "/" + apiId);
|
||||
FileUtil.deleteContents(file);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkNameExist(SaveApiDefinitionRequest request) {
|
||||
ApiDefinitionExample example = new ApiDefinitionExample();
|
||||
if (request.getProtocol().equals(RequestType.HTTP)) {
|
||||
example.createCriteria().andProtocolEqualTo(request.getProtocol()).andPathEqualTo(request.getPath()).andProjectIdEqualTo(request.getProjectId()).andIdNotEqualTo(request.getId());
|
||||
if (apiDefinitionMapper.countByExample(example) > 0) {
|
||||
MSException.throwException(Translator.get("api_definition_url_not_repeating"));
|
||||
}
|
||||
} else {
|
||||
example.createCriteria().andProtocolEqualTo(request.getProtocol()).andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId()).andIdNotEqualTo(request.getId());
|
||||
if (apiDefinitionMapper.countByExample(example) > 0) {
|
||||
MSException.throwException(Translator.get("load_test_already_exists"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ApiDefinition updateTest(SaveApiDefinitionRequest request) {
|
||||
checkNameExist(request);
|
||||
final ApiDefinition test = new ApiDefinition();
|
||||
test.setId(request.getId());
|
||||
test.setName(request.getName());
|
||||
test.setPath(request.getPath());
|
||||
test.setProjectId(request.getProjectId());
|
||||
test.setRequest(JSONObject.toJSONString(request.getRequest()));
|
||||
test.setUpdateTime(System.currentTimeMillis());
|
||||
test.setStatus(request.getStatus());
|
||||
test.setModulePath(request.getModulePath());
|
||||
test.setModuleId(request.getModuleId());
|
||||
test.setMethod(request.getMethod());
|
||||
test.setProtocol(request.getProtocol());
|
||||
test.setDescription(request.getDescription());
|
||||
test.setResponse(JSONObject.toJSONString(request.getResponse()));
|
||||
test.setEnvironmentId(request.getEnvironmentId());
|
||||
test.setUserId(request.getUserId());
|
||||
|
||||
apiDefinitionMapper.updateByPrimaryKeySelective(test);
|
||||
return test;
|
||||
}
|
||||
|
||||
private ApiDefinition createTest(SaveApiDefinitionRequest request) {
|
||||
checkNameExist(request);
|
||||
final ApiDefinition test = new ApiDefinition();
|
||||
test.setId(request.getId());
|
||||
test.setName(request.getName());
|
||||
test.setProtocol(request.getProtocol());
|
||||
test.setMethod(request.getMethod());
|
||||
test.setPath(request.getPath());
|
||||
test.setModuleId(request.getModuleId());
|
||||
test.setProjectId(request.getProjectId());
|
||||
test.setRequest(JSONObject.toJSONString(request.getRequest()));
|
||||
test.setCreateTime(System.currentTimeMillis());
|
||||
test.setUpdateTime(System.currentTimeMillis());
|
||||
test.setStatus(APITestStatus.Underway.name());
|
||||
test.setModulePath(request.getModulePath());
|
||||
test.setResponse(JSONObject.toJSONString(request.getResponse()));
|
||||
test.setEnvironmentId(request.getEnvironmentId());
|
||||
if (request.getUserId() == null) {
|
||||
test.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
|
||||
} else {
|
||||
test.setUserId(request.getUserId());
|
||||
}
|
||||
test.setDescription(request.getDescription());
|
||||
apiDefinitionMapper.insert(test);
|
||||
return test;
|
||||
}
|
||||
|
||||
private ApiDefinition createTest(ApiDefinitionResult request) {
|
||||
SaveApiDefinitionRequest saveReq = new SaveApiDefinitionRequest();
|
||||
saveReq.setId(UUID.randomUUID().toString());
|
||||
saveReq.setName(request.getName());
|
||||
saveReq.setProtocol(request.getProtocol());
|
||||
saveReq.setProjectId(request.getProjectId());
|
||||
saveReq.setPath(request.getPath());
|
||||
checkNameExist(saveReq);
|
||||
final ApiDefinition test = new ApiDefinition();
|
||||
test.setId(request.getId());
|
||||
test.setName(request.getName());
|
||||
test.setProtocol(request.getProtocol());
|
||||
test.setMethod(request.getMethod());
|
||||
test.setPath(request.getPath());
|
||||
test.setModuleId(request.getModuleId());
|
||||
test.setProjectId(request.getProjectId());
|
||||
test.setRequest(request.getRequest());
|
||||
test.setCreateTime(System.currentTimeMillis());
|
||||
test.setUpdateTime(System.currentTimeMillis());
|
||||
test.setStatus(APITestStatus.Underway.name());
|
||||
test.setModulePath(request.getModulePath());
|
||||
test.setResponse(request.getResponse());
|
||||
test.setEnvironmentId(request.getEnvironmentId());
|
||||
if (request.getUserId() == null) {
|
||||
test.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
|
||||
} else {
|
||||
test.setUserId(request.getUserId());
|
||||
}
|
||||
test.setDescription(request.getDescription());
|
||||
apiDefinitionMapper.insert(test);
|
||||
return test;
|
||||
}
|
||||
|
||||
private void deleteFileByTestId(String apiId) {
|
||||
ApiTestFileExample apiTestFileExample = new ApiTestFileExample();
|
||||
apiTestFileExample.createCriteria().andTestIdEqualTo(apiId);
|
||||
final List<ApiTestFile> ApiTestFiles = apiTestFileMapper.selectByExample(apiTestFileExample);
|
||||
apiTestFileMapper.deleteByExample(apiTestFileExample);
|
||||
|
||||
if (!CollectionUtils.isEmpty(ApiTestFiles)) {
|
||||
final List<String> fileIds = ApiTestFiles.stream().map(ApiTestFile::getFileId).collect(Collectors.toList());
|
||||
fileService.deleteFileByIds(fileIds);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试执行
|
||||
*
|
||||
* @param request
|
||||
* @param bodyFiles
|
||||
* @return
|
||||
*/
|
||||
public String run(RunDefinitionRequest request, List<MultipartFile> bodyFiles) {
|
||||
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
|
||||
createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
|
||||
HashTree hashTree = request.getTestElement().generateHashTree();
|
||||
// 调用执行方法
|
||||
jMeterService.runDefinition(request.getId(), hashTree, request.getReportId(), ApiRunMode.DELIMIT.name());
|
||||
return request.getId();
|
||||
}
|
||||
|
||||
public void addResult(TestResult res) {
|
||||
if (!res.getScenarios().isEmpty() && !res.getScenarios().get(0).getRequestResults().isEmpty()) {
|
||||
cache.put(res.getTestId(), res.getScenarios().get(0).getRequestResults().get(0));
|
||||
} else {
|
||||
MSException.throwException(Translator.get("test_not_found"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取零时执行结果报告
|
||||
*
|
||||
* @param testId
|
||||
* @param test
|
||||
* @return
|
||||
*/
|
||||
public APIReportResult getResult(String testId, String test) {
|
||||
Object res = cache.get(testId);
|
||||
if (res != null) {
|
||||
cache.remove(testId);
|
||||
APIReportResult reportResult = new APIReportResult();
|
||||
reportResult.setContent(JSON.toJSONString(res));
|
||||
return reportResult;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取存储执行结果报告
|
||||
*
|
||||
* @param testId
|
||||
* @return
|
||||
*/
|
||||
public APIReportResult getDbResult(String testId) {
|
||||
ApiDefinitionExecResult result = apiDefinitionExecResultMapper.selectByResourceId(testId);
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
APIReportResult reportResult = new APIReportResult();
|
||||
reportResult.setContent(result.getContent());
|
||||
return reportResult;
|
||||
}
|
||||
|
||||
|
||||
public String apiTestImport(MultipartFile file, ApiTestImportRequest request) {
|
||||
ApiImportParser apiImportParser = ApiImportParserFactory.getApiImportParser(request.getPlatform());
|
||||
ApiDefinitionImport apiImport = null;
|
||||
try {
|
||||
apiImport = Objects.requireNonNull(apiImportParser).parseApi(file == null ? null : file.getInputStream(), request);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
MSException.throwException(Translator.get("parse_data_error"));
|
||||
}
|
||||
importApiTest(request, apiImport);
|
||||
return "SUCCESS";
|
||||
}
|
||||
|
||||
private void importApiTest(ApiTestImportRequest importRequest, ApiDefinitionImport apiImport) {
|
||||
apiImport.getData().forEach(item -> {
|
||||
item.setProjectId(importRequest.getProjectId());
|
||||
item.setModuleId(importRequest.getModuleId());
|
||||
item.setModulePath(importRequest.getModulePath());
|
||||
item.setEnvironmentId(importRequest.getEnvironmentId());
|
||||
item.setId(UUID.randomUUID().toString());
|
||||
item.setUserId(null);
|
||||
createTest(item);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,242 @@
|
|||
package io.metersphere.api.service;
|
||||
|
||||
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionRequest;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionResult;
|
||||
import io.metersphere.api.dto.definition.ApiModuleDTO;
|
||||
import io.metersphere.api.dto.definition.DragModuleRequest;
|
||||
import io.metersphere.base.domain.ApiDefinitionExample;
|
||||
import io.metersphere.base.domain.ApiModule;
|
||||
import io.metersphere.base.domain.ApiModuleExample;
|
||||
import io.metersphere.base.mapper.ApiDefinitionMapper;
|
||||
import io.metersphere.base.mapper.ApiModuleMapper;
|
||||
import io.metersphere.commons.constants.TestCaseConstants;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.BeanUtils;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class ApiModuleService {
|
||||
|
||||
@Resource
|
||||
ApiModuleMapper apiModuleMapper;
|
||||
@Resource
|
||||
private ApiDefinitionMapper apiDefinitionMapper;
|
||||
@Resource
|
||||
SqlSessionFactory sqlSessionFactory;
|
||||
|
||||
public List<ApiModuleDTO> getNodeTreeByProjectId(String projectId, String protocol) {
|
||||
ApiModuleExample apiDefinitionNodeExample = new ApiModuleExample();
|
||||
apiDefinitionNodeExample.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol);
|
||||
apiDefinitionNodeExample.setOrderByClause("create_time asc");
|
||||
List<ApiModule> nodes = apiModuleMapper.selectByExample(apiDefinitionNodeExample);
|
||||
return getNodeTrees(nodes);
|
||||
}
|
||||
|
||||
public List<ApiModuleDTO> getNodeTrees(List<ApiModule> nodes) {
|
||||
|
||||
List<ApiModuleDTO> nodeTreeList = new ArrayList<>();
|
||||
Map<Integer, List<ApiModule>> nodeLevelMap = new HashMap<>();
|
||||
nodes.forEach(node -> {
|
||||
Integer level = node.getLevel();
|
||||
if (nodeLevelMap.containsKey(level)) {
|
||||
nodeLevelMap.get(level).add(node);
|
||||
} else {
|
||||
List<ApiModule> apiModules = new ArrayList<>();
|
||||
apiModules.add(node);
|
||||
nodeLevelMap.put(node.getLevel(), apiModules);
|
||||
}
|
||||
});
|
||||
List<ApiModule> rootNodes = Optional.ofNullable(nodeLevelMap.get(1)).orElse(new ArrayList<>());
|
||||
rootNodes.forEach(rootNode -> nodeTreeList.add(buildNodeTree(nodeLevelMap, rootNode)));
|
||||
return nodeTreeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归构建节点树
|
||||
*
|
||||
* @param nodeLevelMap
|
||||
* @param rootNode
|
||||
* @return
|
||||
*/
|
||||
private ApiModuleDTO buildNodeTree(Map<Integer, List<ApiModule>> nodeLevelMap, ApiModule rootNode) {
|
||||
|
||||
ApiModuleDTO nodeTree = new ApiModuleDTO();
|
||||
BeanUtils.copyBean(nodeTree, rootNode);
|
||||
nodeTree.setLabel(rootNode.getName());
|
||||
|
||||
List<ApiModule> lowerNodes = nodeLevelMap.get(rootNode.getLevel() + 1);
|
||||
if (lowerNodes == null) {
|
||||
return nodeTree;
|
||||
}
|
||||
List<ApiModuleDTO> children = Optional.ofNullable(nodeTree.getChildren()).orElse(new ArrayList<>());
|
||||
lowerNodes.forEach(node -> {
|
||||
if (node.getParentId() != null && node.getParentId().equals(rootNode.getId())) {
|
||||
children.add(buildNodeTree(nodeLevelMap, node));
|
||||
nodeTree.setChildren(children);
|
||||
}
|
||||
});
|
||||
|
||||
return nodeTree;
|
||||
}
|
||||
|
||||
|
||||
public String addNode(ApiModule node) {
|
||||
validateNode(node);
|
||||
node.setCreateTime(System.currentTimeMillis());
|
||||
node.setUpdateTime(System.currentTimeMillis());
|
||||
node.setId(UUID.randomUUID().toString());
|
||||
apiModuleMapper.insertSelective(node);
|
||||
return node.getId();
|
||||
}
|
||||
|
||||
private void validateNode(ApiModule node) {
|
||||
if (node.getLevel() > TestCaseConstants.MAX_NODE_DEPTH) {
|
||||
throw new RuntimeException(Translator.get("test_case_node_level_tip")
|
||||
+ TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level"));
|
||||
}
|
||||
checkApiModuleExist(node);
|
||||
}
|
||||
|
||||
private void checkApiModuleExist(ApiModule node) {
|
||||
if (node.getName() != null) {
|
||||
ApiModuleExample example = new ApiModuleExample();
|
||||
ApiModuleExample.Criteria criteria = example.createCriteria();
|
||||
criteria.andNameEqualTo(node.getName())
|
||||
.andProjectIdEqualTo(node.getProjectId());
|
||||
if (StringUtils.isNotBlank(node.getParentId())) {
|
||||
criteria.andParentIdEqualTo(node.getParentId());
|
||||
} else {
|
||||
criteria.andParentIdIsNull();
|
||||
}
|
||||
if (StringUtils.isNotBlank(node.getId())) {
|
||||
criteria.andIdNotEqualTo(node.getId());
|
||||
}
|
||||
if (apiModuleMapper.selectByExample(example).size() > 0) {
|
||||
MSException.throwException(Translator.get("test_case_module_already_exists"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<ApiDefinitionResult> queryByModuleIds(List<String> nodeIds) {
|
||||
ApiDefinitionRequest apiDefinitionRequest = new ApiDefinitionRequest();
|
||||
apiDefinitionRequest.setModuleIds(nodeIds);
|
||||
return apiDefinitionMapper.list(apiDefinitionRequest);
|
||||
}
|
||||
|
||||
public int editNode(DragModuleRequest request) {
|
||||
request.setUpdateTime(System.currentTimeMillis());
|
||||
checkApiModuleExist(request);
|
||||
List<ApiDefinitionResult> apiModule = queryByModuleIds(request.getNodeIds());
|
||||
|
||||
apiModule.forEach(apiDefinition -> {
|
||||
StringBuilder path = new StringBuilder(apiDefinition.getModulePath());
|
||||
List<String> pathLists = Arrays.asList(path.toString().split("/"));
|
||||
pathLists.set(request.getLevel(), request.getName());
|
||||
path.delete(0, path.length());
|
||||
for (int i = 1; i < pathLists.size(); i++) {
|
||||
path = path.append("/").append(pathLists.get(i));
|
||||
}
|
||||
apiDefinition.setModulePath(path.toString());
|
||||
});
|
||||
|
||||
batchUpdateApiDefinition(apiModule);
|
||||
|
||||
return apiModuleMapper.updateByPrimaryKeySelective(request);
|
||||
}
|
||||
|
||||
public int deleteNode(List<String> nodeIds) {
|
||||
ApiDefinitionExample apiDefinitionExample = new ApiDefinitionExample();
|
||||
apiDefinitionExample.createCriteria().andModuleIdIn(nodeIds);
|
||||
apiDefinitionMapper.deleteByExample(apiDefinitionExample);
|
||||
|
||||
ApiModuleExample apiDefinitionNodeExample = new ApiModuleExample();
|
||||
apiDefinitionNodeExample.createCriteria().andIdIn(nodeIds);
|
||||
return apiModuleMapper.deleteByExample(apiDefinitionNodeExample);
|
||||
}
|
||||
|
||||
private void batchUpdateApiDefinition(List<ApiDefinitionResult> apiModule) {
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
ApiDefinitionMapper apiDefinitionMapper = sqlSession.getMapper(ApiDefinitionMapper.class);
|
||||
apiModule.forEach((value) -> {
|
||||
apiDefinitionMapper.updateByPrimaryKey(value);
|
||||
});
|
||||
sqlSession.flushStatements();
|
||||
}
|
||||
|
||||
public void dragNode(DragModuleRequest request) {
|
||||
|
||||
checkApiModuleExist(request);
|
||||
|
||||
List<String> nodeIds = request.getNodeIds();
|
||||
|
||||
List<ApiDefinitionResult> apiModule = queryByModuleIds(nodeIds);
|
||||
|
||||
ApiModuleDTO nodeTree = request.getNodeTree();
|
||||
|
||||
List<ApiModule> updateNodes = new ArrayList<>();
|
||||
|
||||
buildUpdateDefinition(nodeTree, apiModule, updateNodes, "/", "0", nodeTree.getLevel());
|
||||
|
||||
updateNodes = updateNodes.stream()
|
||||
.filter(item -> nodeIds.contains(item.getId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
batchUpdateModule(updateNodes);
|
||||
|
||||
batchUpdateApiDefinition(apiModule);
|
||||
}
|
||||
|
||||
private void buildUpdateDefinition(ApiModuleDTO rootNode, List<ApiDefinitionResult> apiDefinitions,
|
||||
List<ApiModule> updateNodes, String rootPath, String pId, int level) {
|
||||
|
||||
rootPath = rootPath + rootNode.getName();
|
||||
|
||||
if (level > 8) {
|
||||
MSException.throwException(Translator.get("node_deep_limit"));
|
||||
}
|
||||
if (rootNode.getId().equals("root")) {
|
||||
rootPath = "";
|
||||
}
|
||||
ApiModule apiDefinitionNode = new ApiModule();
|
||||
apiDefinitionNode.setId(rootNode.getId());
|
||||
apiDefinitionNode.setLevel(level);
|
||||
apiDefinitionNode.setParentId(pId);
|
||||
updateNodes.add(apiDefinitionNode);
|
||||
|
||||
for (ApiDefinitionResult item : apiDefinitions) {
|
||||
if (StringUtils.equals(item.getModuleId(), rootNode.getId())) {
|
||||
item.setModulePath(rootPath);
|
||||
}
|
||||
}
|
||||
|
||||
List<ApiModuleDTO> children = rootNode.getChildren();
|
||||
if (children != null && children.size() > 0) {
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
buildUpdateDefinition(children.get(i), apiDefinitions, updateNodes, rootPath + '/', rootNode.getId(), level + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void batchUpdateModule(List<ApiModule> updateNodes) {
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
ApiModuleMapper apiModuleMapper = sqlSession.getMapper(ApiModuleMapper.class);
|
||||
updateNodes.forEach((value) -> {
|
||||
apiModuleMapper.updateByPrimaryKeySelective(value);
|
||||
});
|
||||
sqlSession.flushStatements();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,208 @@
|
|||
package io.metersphere.api.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseResult;
|
||||
import io.metersphere.api.dto.definition.SaveApiTestCaseRequest;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
|
||||
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
||||
import io.metersphere.base.mapper.ApiTestFileMapper;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.commons.utils.ServiceUtils;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.service.FileService;
|
||||
import io.metersphere.service.QuotaService;
|
||||
import org.aspectj.util.FileUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class ApiTestCaseService {
|
||||
@Resource
|
||||
private ApiTestCaseMapper apiTestCaseMapper;
|
||||
@Resource
|
||||
private ApiTestFileMapper apiTestFileMapper;
|
||||
@Resource
|
||||
private FileService fileService;
|
||||
@Resource
|
||||
private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper;
|
||||
|
||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
|
||||
public List<ApiTestCaseResult> list(ApiTestCaseRequest request) {
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
return apiTestCaseMapper.list(request);
|
||||
}
|
||||
|
||||
public ApiTestCase get(String id) {
|
||||
return apiTestCaseMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public void create(SaveApiTestCaseRequest request, List<MultipartFile> bodyFiles) {
|
||||
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
|
||||
ApiTestCase test = createTest(request);
|
||||
createBodyFiles(test, bodyUploadIds, bodyFiles);
|
||||
}
|
||||
|
||||
private void checkQuota() {
|
||||
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
|
||||
if (quotaService != null) {
|
||||
quotaService.checkAPITestQuota();
|
||||
}
|
||||
}
|
||||
|
||||
public void update(SaveApiTestCaseRequest request, List<MultipartFile> bodyFiles) {
|
||||
|
||||
deleteFileByTestId(request.getId());
|
||||
|
||||
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
|
||||
request.setBodyUploadIds(null);
|
||||
ApiTestCase test = updateTest(request);
|
||||
createBodyFiles(test, bodyUploadIds, bodyFiles);
|
||||
}
|
||||
|
||||
private void createBodyFiles(ApiTestCase test, List<String> bodyUploadIds, List<MultipartFile> bodyFiles) {
|
||||
if (bodyUploadIds.size() > 0) {
|
||||
String dir = BODY_FILE_DIR + "/" + test.getId();
|
||||
File testDir = new File(dir);
|
||||
if (!testDir.exists()) {
|
||||
testDir.mkdirs();
|
||||
}
|
||||
for (int i = 0; i < bodyUploadIds.size(); i++) {
|
||||
MultipartFile item = bodyFiles.get(i);
|
||||
File file = new File(testDir + "/" + bodyUploadIds.get(i) + "_" + item.getOriginalFilename());
|
||||
try (InputStream in = item.getInputStream(); OutputStream out = new FileOutputStream(file)) {
|
||||
file.createNewFile();
|
||||
FileUtil.copyStream(in, out);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e);
|
||||
MSException.throwException(Translator.get("upload_fail"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(String testId) {
|
||||
deleteFileByTestId(testId);
|
||||
apiDefinitionExecResultMapper.deleteByResourceId(testId);
|
||||
apiTestCaseMapper.deleteByPrimaryKey(testId);
|
||||
deleteBodyFiles(testId);
|
||||
}
|
||||
|
||||
public void deleteTestCase(String apiId) {
|
||||
ApiTestCaseExample testCaseExample = new ApiTestCaseExample();
|
||||
testCaseExample.createCriteria().andApiDefinitionIdEqualTo(apiId);
|
||||
List<ApiTestCase> testCases = apiTestCaseMapper.selectByExample(testCaseExample);
|
||||
if (testCases.size() > 0) {
|
||||
for (ApiTestCase testCase : testCases) {
|
||||
this.delete(testCase.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否已经创建了测试用例
|
||||
*/
|
||||
public void checkIsRelateTest(String apiId) {
|
||||
ApiTestCaseExample testCaseExample = new ApiTestCaseExample();
|
||||
testCaseExample.createCriteria().andApiDefinitionIdEqualTo(apiId);
|
||||
List<ApiTestCase> testCases = apiTestCaseMapper.selectByExample(testCaseExample);
|
||||
StringBuilder caseName = new StringBuilder();
|
||||
if (testCases.size() > 0) {
|
||||
for (ApiTestCase testCase : testCases) {
|
||||
caseName = caseName.append(testCase.getName()).append(",");
|
||||
}
|
||||
String str = caseName.toString().substring(0, caseName.length() - 1);
|
||||
MSException.throwException(Translator.get("related_case_del_fail_prefix") + " " + str + " " + Translator.get("related_case_del_fail_suffix"));
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteBodyFiles(String testId) {
|
||||
File file = new File(BODY_FILE_DIR + "/" + testId);
|
||||
FileUtil.deleteContents(file);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkNameExist(SaveApiTestCaseRequest request) {
|
||||
ApiTestCaseExample example = new ApiTestCaseExample();
|
||||
example.createCriteria().andNameEqualTo(request.getName()).andApiDefinitionIdEqualTo(request.getApiDefinitionId()).andIdNotEqualTo(request.getId());
|
||||
if (apiTestCaseMapper.countByExample(example) > 0) {
|
||||
MSException.throwException(Translator.get("load_test_already_exists"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ApiTestCase updateTest(SaveApiTestCaseRequest request) {
|
||||
checkNameExist(request);
|
||||
final ApiTestCase test = new ApiTestCase();
|
||||
test.setId(request.getId());
|
||||
test.setName(request.getName());
|
||||
test.setApiDefinitionId(request.getApiDefinitionId());
|
||||
test.setUpdateUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
|
||||
test.setProjectId(request.getProjectId());
|
||||
test.setRequest(JSONObject.toJSONString(request.getRequest()));
|
||||
test.setResponse(JSONObject.toJSONString(request.getResponse()));
|
||||
test.setPriority(request.getPriority());
|
||||
test.setUpdateTime(System.currentTimeMillis());
|
||||
test.setDescription(request.getDescription());
|
||||
apiTestCaseMapper.updateByPrimaryKeySelective(test);
|
||||
return test;
|
||||
}
|
||||
|
||||
private ApiTestCase createTest(SaveApiTestCaseRequest request) {
|
||||
request.setId(UUID.randomUUID().toString());
|
||||
checkNameExist(request);
|
||||
final ApiTestCase test = new ApiTestCase();
|
||||
test.setId(request.getId());
|
||||
test.setName(request.getName());
|
||||
test.setApiDefinitionId(request.getApiDefinitionId());
|
||||
test.setCreateUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
|
||||
test.setUpdateUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
|
||||
test.setProjectId(request.getProjectId());
|
||||
test.setRequest(JSONObject.toJSONString(request.getRequest()));
|
||||
test.setResponse(JSONObject.toJSONString(request.getResponse()));
|
||||
test.setCreateTime(System.currentTimeMillis());
|
||||
test.setPriority(request.getPriority());
|
||||
test.setUpdateTime(System.currentTimeMillis());
|
||||
test.setDescription(request.getDescription());
|
||||
apiTestCaseMapper.insert(test);
|
||||
return test;
|
||||
}
|
||||
|
||||
private void saveFile(String testId, MultipartFile file) {
|
||||
final FileMetadata fileMetadata = fileService.saveFile(file);
|
||||
ApiTestFile apiTestFile = new ApiTestFile();
|
||||
apiTestFile.setTestId(testId);
|
||||
apiTestFile.setFileId(fileMetadata.getId());
|
||||
apiTestFileMapper.insert(apiTestFile);
|
||||
}
|
||||
|
||||
private void deleteFileByTestId(String testId) {
|
||||
ApiTestFileExample ApiTestFileExample = new ApiTestFileExample();
|
||||
ApiTestFileExample.createCriteria().andTestIdEqualTo(testId);
|
||||
final List<ApiTestFile> ApiTestFiles = apiTestFileMapper.selectByExample(ApiTestFileExample);
|
||||
apiTestFileMapper.deleteByExample(ApiTestFileExample);
|
||||
|
||||
if (!CollectionUtils.isEmpty(ApiTestFiles)) {
|
||||
final List<String> fileIds = ApiTestFiles.stream().map(ApiTestFile::getFileId).collect(Collectors.toList());
|
||||
fileService.deleteFileByIds(fileIds);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ApiDefinition implements Serializable {
|
||||
private String id;
|
||||
|
||||
private String projectId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String method;
|
||||
|
||||
private String path;
|
||||
|
||||
private String protocol;
|
||||
|
||||
private String environmentId;
|
||||
|
||||
private String status;
|
||||
|
||||
private String description;
|
||||
|
||||
private String userId;
|
||||
|
||||
private String moduleId;
|
||||
|
||||
private String modulePath;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private Long updateTime;
|
||||
|
||||
private String request;
|
||||
|
||||
private String response;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,756 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ApiDefinitionExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public ApiDefinitionExample() {
|
||||
oredCriteria = new ArrayList<Criteria>();
|
||||
}
|
||||
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<Criterion>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(String value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(String value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(String value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(String value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLike(String value) {
|
||||
addCriterion("id like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotLike(String value) {
|
||||
addCriterion("id not like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<String> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdIn(List<String> values) {
|
||||
addCriterion("module_id in", values, "module_id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<String> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(String value1, String value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(String value1, String value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIsNull() {
|
||||
addCriterion("project_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIsNotNull() {
|
||||
addCriterion("project_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdEqualTo(String value) {
|
||||
addCriterion("project_id =", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotEqualTo(String value) {
|
||||
addCriterion("project_id <>", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdGreaterThan(String value) {
|
||||
addCriterion("project_id >", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("project_id >=", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdLessThan(String value) {
|
||||
addCriterion("project_id <", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("project_id <=", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdLike(String value) {
|
||||
addCriterion("project_id like", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotLike(String value) {
|
||||
addCriterion("project_id not like", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIn(List<String> values) {
|
||||
addCriterion("project_id in", values, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotIn(List<String> values) {
|
||||
addCriterion("project_id not in", values, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdBetween(String value1, String value2) {
|
||||
addCriterion("project_id between", value1, value2, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotBetween(String value1, String value2) {
|
||||
addCriterion("project_id not between", value1, value2, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIsNull() {
|
||||
addCriterion("name is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIsNotNull() {
|
||||
addCriterion("name is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameEqualTo(String value) {
|
||||
addCriterion("name =", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPathEqualTo(String value) {
|
||||
addCriterion("path =", value, "path");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
|
||||
public Criteria andProtocolEqualTo(String value) {
|
||||
addCriterion("protocol =", value, "protocol");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotEqualTo(String value) {
|
||||
addCriterion("name <>", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameGreaterThan(String value) {
|
||||
addCriterion("name >", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("name >=", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLessThan(String value) {
|
||||
addCriterion("name <", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLessThanOrEqualTo(String value) {
|
||||
addCriterion("name <=", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLike(String value) {
|
||||
addCriterion("name like", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotLike(String value) {
|
||||
addCriterion("name not like", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIn(List<String> values) {
|
||||
addCriterion("name in", values, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotIn(List<String> values) {
|
||||
addCriterion("name not in", values, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameBetween(String value1, String value2) {
|
||||
addCriterion("name between", value1, value2, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotBetween(String value1, String value2) {
|
||||
addCriterion("name not between", value1, value2, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionIsNull() {
|
||||
addCriterion("description is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionIsNotNull() {
|
||||
addCriterion("description is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionEqualTo(String value) {
|
||||
addCriterion("description =", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionNotEqualTo(String value) {
|
||||
addCriterion("description <>", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionGreaterThan(String value) {
|
||||
addCriterion("description >", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("description >=", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionLessThan(String value) {
|
||||
addCriterion("description <", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionLessThanOrEqualTo(String value) {
|
||||
addCriterion("description <=", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionLike(String value) {
|
||||
addCriterion("description like", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionNotLike(String value) {
|
||||
addCriterion("description not like", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionIn(List<String> values) {
|
||||
addCriterion("description in", values, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionNotIn(List<String> values) {
|
||||
addCriterion("description not in", values, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionBetween(String value1, String value2) {
|
||||
addCriterion("description between", value1, value2, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionNotBetween(String value1, String value2) {
|
||||
addCriterion("description not between", value1, value2, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusIsNull() {
|
||||
addCriterion("status is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusIsNotNull() {
|
||||
addCriterion("status is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusEqualTo(String value) {
|
||||
addCriterion("status =", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusNotEqualTo(String value) {
|
||||
addCriterion("status <>", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusGreaterThan(String value) {
|
||||
addCriterion("status >", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("status >=", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusLessThan(String value) {
|
||||
addCriterion("status <", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusLessThanOrEqualTo(String value) {
|
||||
addCriterion("status <=", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusLike(String value) {
|
||||
addCriterion("status like", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusNotLike(String value) {
|
||||
addCriterion("status not like", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusIn(List<String> values) {
|
||||
addCriterion("status in", values, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusNotIn(List<String> values) {
|
||||
addCriterion("status not in", values, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusBetween(String value1, String value2) {
|
||||
addCriterion("status between", value1, value2, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusNotBetween(String value1, String value2) {
|
||||
addCriterion("status not between", value1, value2, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdIsNull() {
|
||||
addCriterion("user_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdIsNotNull() {
|
||||
addCriterion("user_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdEqualTo(String value) {
|
||||
addCriterion("user_id =", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdNotEqualTo(String value) {
|
||||
addCriterion("user_id <>", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdGreaterThan(String value) {
|
||||
addCriterion("user_id >", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("user_id >=", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdLessThan(String value) {
|
||||
addCriterion("user_id <", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("user_id <=", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdLike(String value) {
|
||||
addCriterion("user_id like", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdNotLike(String value) {
|
||||
addCriterion("user_id not like", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdIn(List<String> values) {
|
||||
addCriterion("user_id in", values, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdNotIn(List<String> values) {
|
||||
addCriterion("user_id not in", values, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdBetween(String value1, String value2) {
|
||||
addCriterion("user_id between", value1, value2, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdNotBetween(String value1, String value2) {
|
||||
addCriterion("user_id not between", value1, value2, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNull() {
|
||||
addCriterion("create_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNotNull() {
|
||||
addCriterion("create_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeEqualTo(Long value) {
|
||||
addCriterion("create_time =", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotEqualTo(Long value) {
|
||||
addCriterion("create_time <>", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThan(Long value) {
|
||||
addCriterion("create_time >", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("create_time >=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThan(Long value) {
|
||||
addCriterion("create_time <", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
|
||||
addCriterion("create_time <=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIn(List<Long> values) {
|
||||
addCriterion("create_time in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotIn(List<Long> values) {
|
||||
addCriterion("create_time not in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeBetween(Long value1, Long value2) {
|
||||
addCriterion("create_time between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
|
||||
addCriterion("create_time not between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeIsNull() {
|
||||
addCriterion("update_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeIsNotNull() {
|
||||
addCriterion("update_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeEqualTo(Long value) {
|
||||
addCriterion("update_time =", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeNotEqualTo(Long value) {
|
||||
addCriterion("update_time <>", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeGreaterThan(Long value) {
|
||||
addCriterion("update_time >", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("update_time >=", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeLessThan(Long value) {
|
||||
addCriterion("update_time <", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeLessThanOrEqualTo(Long value) {
|
||||
addCriterion("update_time <=", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeIn(List<Long> values) {
|
||||
addCriterion("update_time in", values, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeNotIn(List<Long> values) {
|
||||
addCriterion("update_time not in", values, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeBetween(Long value1, Long value2) {
|
||||
addCriterion("update_time between", value1, value2, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeNotBetween(Long value1, Long value2) {
|
||||
addCriterion("update_time not between", value1, value2, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ApiDefinitionExecResult implements Serializable {
|
||||
private String id;
|
||||
private String resourceId;
|
||||
private String name;
|
||||
private String content;
|
||||
private String status;
|
||||
private String userId;
|
||||
private Long startTime;
|
||||
private Long endTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ApiModule implements Serializable {
|
||||
private String id;
|
||||
|
||||
private String projectId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String parentId;
|
||||
|
||||
private Integer level;
|
||||
|
||||
private String protocol;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private Long updateTime;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,666 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ApiModuleExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public ApiModuleExample() {
|
||||
oredCriteria = new ArrayList<Criteria>();
|
||||
}
|
||||
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<Criterion>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(String value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(String value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(String value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(String value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLike(String value) {
|
||||
addCriterion("id like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotLike(String value) {
|
||||
addCriterion("id not like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<String> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<String> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(String value1, String value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(String value1, String value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIsNull() {
|
||||
addCriterion("project_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIsNotNull() {
|
||||
addCriterion("project_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdEqualTo(String value) {
|
||||
addCriterion("project_id =", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
|
||||
public Criteria andProtocolEqualTo(String value) {
|
||||
addCriterion("protocol =", value, "protocol");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotEqualTo(String value) {
|
||||
addCriterion("project_id <>", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdGreaterThan(String value) {
|
||||
addCriterion("project_id >", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("project_id >=", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdLessThan(String value) {
|
||||
addCriterion("project_id <", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("project_id <=", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdLike(String value) {
|
||||
addCriterion("project_id like", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotLike(String value) {
|
||||
addCriterion("project_id not like", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIn(List<String> values) {
|
||||
addCriterion("project_id in", values, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotIn(List<String> values) {
|
||||
addCriterion("project_id not in", values, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdBetween(String value1, String value2) {
|
||||
addCriterion("project_id between", value1, value2, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotBetween(String value1, String value2) {
|
||||
addCriterion("project_id not between", value1, value2, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIsNull() {
|
||||
addCriterion("name is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIsNotNull() {
|
||||
addCriterion("name is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameEqualTo(String value) {
|
||||
addCriterion("name =", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotEqualTo(String value) {
|
||||
addCriterion("name <>", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameGreaterThan(String value) {
|
||||
addCriterion("name >", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("name >=", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLessThan(String value) {
|
||||
addCriterion("name <", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLessThanOrEqualTo(String value) {
|
||||
addCriterion("name <=", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLike(String value) {
|
||||
addCriterion("name like", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotLike(String value) {
|
||||
addCriterion("name not like", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIn(List<String> values) {
|
||||
addCriterion("name in", values, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotIn(List<String> values) {
|
||||
addCriterion("name not in", values, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameBetween(String value1, String value2) {
|
||||
addCriterion("name between", value1, value2, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotBetween(String value1, String value2) {
|
||||
addCriterion("name not between", value1, value2, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdIsNull() {
|
||||
addCriterion("parent_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdIsNotNull() {
|
||||
addCriterion("parent_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdEqualTo(String value) {
|
||||
addCriterion("parent_id =", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdNotEqualTo(String value) {
|
||||
addCriterion("parent_id <>", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdGreaterThan(String value) {
|
||||
addCriterion("parent_id >", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("parent_id >=", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdLessThan(String value) {
|
||||
addCriterion("parent_id <", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("parent_id <=", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdLike(String value) {
|
||||
addCriterion("parent_id like", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdNotLike(String value) {
|
||||
addCriterion("parent_id not like", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdIn(List<String> values) {
|
||||
addCriterion("parent_id in", values, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdNotIn(List<String> values) {
|
||||
addCriterion("parent_id not in", values, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdBetween(String value1, String value2) {
|
||||
addCriterion("parent_id between", value1, value2, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdNotBetween(String value1, String value2) {
|
||||
addCriterion("parent_id not between", value1, value2, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelIsNull() {
|
||||
addCriterion("level is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelIsNotNull() {
|
||||
addCriterion("level is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelEqualTo(Integer value) {
|
||||
addCriterion("level =", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelNotEqualTo(Integer value) {
|
||||
addCriterion("level <>", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelGreaterThan(Integer value) {
|
||||
addCriterion("level >", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("level >=", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelLessThan(Integer value) {
|
||||
addCriterion("level <", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("level <=", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelIn(List<Integer> values) {
|
||||
addCriterion("level in", values, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelNotIn(List<Integer> values) {
|
||||
addCriterion("level not in", values, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelBetween(Integer value1, Integer value2) {
|
||||
addCriterion("level between", value1, value2, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("level not between", value1, value2, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNull() {
|
||||
addCriterion("create_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNotNull() {
|
||||
addCriterion("create_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeEqualTo(Long value) {
|
||||
addCriterion("create_time =", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotEqualTo(Long value) {
|
||||
addCriterion("create_time <>", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThan(Long value) {
|
||||
addCriterion("create_time >", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("create_time >=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThan(Long value) {
|
||||
addCriterion("create_time <", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
|
||||
addCriterion("create_time <=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIn(List<Long> values) {
|
||||
addCriterion("create_time in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotIn(List<Long> values) {
|
||||
addCriterion("create_time not in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeBetween(Long value1, Long value2) {
|
||||
addCriterion("create_time between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
|
||||
addCriterion("create_time not between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeIsNull() {
|
||||
addCriterion("update_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeIsNotNull() {
|
||||
addCriterion("update_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeEqualTo(Long value) {
|
||||
addCriterion("update_time =", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeNotEqualTo(Long value) {
|
||||
addCriterion("update_time <>", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeGreaterThan(Long value) {
|
||||
addCriterion("update_time >", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("update_time >=", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeLessThan(Long value) {
|
||||
addCriterion("update_time <", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeLessThanOrEqualTo(Long value) {
|
||||
addCriterion("update_time <=", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeIn(List<Long> values) {
|
||||
addCriterion("update_time in", values, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeNotIn(List<Long> values) {
|
||||
addCriterion("update_time not in", values, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeBetween(Long value1, Long value2) {
|
||||
addCriterion("update_time between", value1, value2, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeNotBetween(Long value1, Long value2) {
|
||||
addCriterion("update_time not between", value1, value2, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ApiTestCase implements Serializable {
|
||||
private String id;
|
||||
|
||||
private String projectId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String priority;
|
||||
|
||||
private String apiDefinitionId;
|
||||
|
||||
private String description;
|
||||
|
||||
private String request;
|
||||
|
||||
private String response;
|
||||
|
||||
private String createUserId;
|
||||
|
||||
private String updateUserId;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private Long updateTime;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,751 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ApiTestCaseExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public ApiTestCaseExample() {
|
||||
oredCriteria = new ArrayList<Criteria>();
|
||||
}
|
||||
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<Criterion>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(String value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(String value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(String value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(String value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLike(String value) {
|
||||
addCriterion("id like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotLike(String value) {
|
||||
addCriterion("id not like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<String> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdIn(List<String> values) {
|
||||
addCriterion("module_id in", values, "module_id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<String> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(String value1, String value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(String value1, String value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIsNull() {
|
||||
addCriterion("project_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIsNotNull() {
|
||||
addCriterion("project_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdEqualTo(String value) {
|
||||
addCriterion("project_id =", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andApiDefinitionIdEqualTo(String value) {
|
||||
addCriterion("api_definition_id =", value, "api_definition_id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
|
||||
public Criteria andProjectIdNotEqualTo(String value) {
|
||||
addCriterion("project_id <>", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdGreaterThan(String value) {
|
||||
addCriterion("project_id >", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("project_id >=", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdLessThan(String value) {
|
||||
addCriterion("project_id <", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("project_id <=", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdLike(String value) {
|
||||
addCriterion("project_id like", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotLike(String value) {
|
||||
addCriterion("project_id not like", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIn(List<String> values) {
|
||||
addCriterion("project_id in", values, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotIn(List<String> values) {
|
||||
addCriterion("project_id not in", values, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdBetween(String value1, String value2) {
|
||||
addCriterion("project_id between", value1, value2, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotBetween(String value1, String value2) {
|
||||
addCriterion("project_id not between", value1, value2, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIsNull() {
|
||||
addCriterion("name is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIsNotNull() {
|
||||
addCriterion("name is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameEqualTo(String value) {
|
||||
addCriterion("name =", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotEqualTo(String value) {
|
||||
addCriterion("name <>", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameGreaterThan(String value) {
|
||||
addCriterion("name >", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("name >=", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLessThan(String value) {
|
||||
addCriterion("name <", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLessThanOrEqualTo(String value) {
|
||||
addCriterion("name <=", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLike(String value) {
|
||||
addCriterion("name like", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotLike(String value) {
|
||||
addCriterion("name not like", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIn(List<String> values) {
|
||||
addCriterion("name in", values, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotIn(List<String> values) {
|
||||
addCriterion("name not in", values, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameBetween(String value1, String value2) {
|
||||
addCriterion("name between", value1, value2, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotBetween(String value1, String value2) {
|
||||
addCriterion("name not between", value1, value2, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionIsNull() {
|
||||
addCriterion("description is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionIsNotNull() {
|
||||
addCriterion("description is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionEqualTo(String value) {
|
||||
addCriterion("description =", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionNotEqualTo(String value) {
|
||||
addCriterion("description <>", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionGreaterThan(String value) {
|
||||
addCriterion("description >", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("description >=", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionLessThan(String value) {
|
||||
addCriterion("description <", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionLessThanOrEqualTo(String value) {
|
||||
addCriterion("description <=", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionLike(String value) {
|
||||
addCriterion("description like", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionNotLike(String value) {
|
||||
addCriterion("description not like", value, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionIn(List<String> values) {
|
||||
addCriterion("description in", values, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionNotIn(List<String> values) {
|
||||
addCriterion("description not in", values, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionBetween(String value1, String value2) {
|
||||
addCriterion("description between", value1, value2, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDescriptionNotBetween(String value1, String value2) {
|
||||
addCriterion("description not between", value1, value2, "description");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusIsNull() {
|
||||
addCriterion("status is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusIsNotNull() {
|
||||
addCriterion("status is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusEqualTo(String value) {
|
||||
addCriterion("status =", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusNotEqualTo(String value) {
|
||||
addCriterion("status <>", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusGreaterThan(String value) {
|
||||
addCriterion("status >", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("status >=", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusLessThan(String value) {
|
||||
addCriterion("status <", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusLessThanOrEqualTo(String value) {
|
||||
addCriterion("status <=", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusLike(String value) {
|
||||
addCriterion("status like", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusNotLike(String value) {
|
||||
addCriterion("status not like", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusIn(List<String> values) {
|
||||
addCriterion("status in", values, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusNotIn(List<String> values) {
|
||||
addCriterion("status not in", values, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusBetween(String value1, String value2) {
|
||||
addCriterion("status between", value1, value2, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusNotBetween(String value1, String value2) {
|
||||
addCriterion("status not between", value1, value2, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdIsNull() {
|
||||
addCriterion("user_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdIsNotNull() {
|
||||
addCriterion("user_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdEqualTo(String value) {
|
||||
addCriterion("user_id =", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdNotEqualTo(String value) {
|
||||
addCriterion("user_id <>", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdGreaterThan(String value) {
|
||||
addCriterion("user_id >", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("user_id >=", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdLessThan(String value) {
|
||||
addCriterion("user_id <", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("user_id <=", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdLike(String value) {
|
||||
addCriterion("user_id like", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdNotLike(String value) {
|
||||
addCriterion("user_id not like", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdIn(List<String> values) {
|
||||
addCriterion("user_id in", values, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdNotIn(List<String> values) {
|
||||
addCriterion("user_id not in", values, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdBetween(String value1, String value2) {
|
||||
addCriterion("user_id between", value1, value2, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdNotBetween(String value1, String value2) {
|
||||
addCriterion("user_id not between", value1, value2, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNull() {
|
||||
addCriterion("create_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNotNull() {
|
||||
addCriterion("create_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeEqualTo(Long value) {
|
||||
addCriterion("create_time =", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotEqualTo(Long value) {
|
||||
addCriterion("create_time <>", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThan(Long value) {
|
||||
addCriterion("create_time >", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("create_time >=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThan(Long value) {
|
||||
addCriterion("create_time <", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
|
||||
addCriterion("create_time <=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIn(List<Long> values) {
|
||||
addCriterion("create_time in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotIn(List<Long> values) {
|
||||
addCriterion("create_time not in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeBetween(Long value1, Long value2) {
|
||||
addCriterion("create_time between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
|
||||
addCriterion("create_time not between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeIsNull() {
|
||||
addCriterion("update_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeIsNotNull() {
|
||||
addCriterion("update_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeEqualTo(Long value) {
|
||||
addCriterion("update_time =", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeNotEqualTo(Long value) {
|
||||
addCriterion("update_time <>", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeGreaterThan(Long value) {
|
||||
addCriterion("update_time >", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("update_time >=", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeLessThan(Long value) {
|
||||
addCriterion("update_time <", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeLessThanOrEqualTo(Long value) {
|
||||
addCriterion("update_time <=", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeIn(List<Long> values) {
|
||||
addCriterion("update_time in", values, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeNotIn(List<Long> values) {
|
||||
addCriterion("update_time not in", values, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeBetween(Long value1, Long value2) {
|
||||
addCriterion("update_time between", value1, value2, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeNotBetween(Long value1, Long value2) {
|
||||
addCriterion("update_time not between", value1, value2, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package io.metersphere.base.mapper;
|
||||
|
||||
import io.metersphere.base.domain.ApiDefinitionExecResult;
|
||||
|
||||
public interface ApiDefinitionExecResultMapper {
|
||||
|
||||
int deleteByResourceId(String id);
|
||||
|
||||
int insert(ApiDefinitionExecResult record);
|
||||
|
||||
ApiDefinitionExecResult selectByResourceId(String resourceId);
|
||||
|
||||
ApiDefinitionExecResult selectByPrimaryKey(String id);
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue