refactor(接口测试): 优化场景字段,优化保存接口的逻辑
This commit is contained in:
parent
6c6edd4e44
commit
cbe6c19c45
|
@ -15,6 +15,9 @@ public class ApiDefinitionSwagger implements Serializable {
|
||||||
@Size(min = 1, max = 50, message = "{api_definition_swagger.id.length_range}", groups = {Created.class, Updated.class})
|
@Size(min = 1, max = 50, message = "{api_definition_swagger.id.length_range}", groups = {Created.class, Updated.class})
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@Schema(description = "业务id")
|
||||||
|
private Long num;
|
||||||
|
|
||||||
@Schema(description = "定时任务名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "定时任务名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotBlank(message = "{api_definition_swagger.name.not_blank}", groups = {Created.class})
|
@NotBlank(message = "{api_definition_swagger.name.not_blank}", groups = {Created.class})
|
||||||
@Size(min = 1, max = 255, message = "{api_definition_swagger.name.length_range}", groups = {Created.class, Updated.class})
|
@Size(min = 1, max = 255, message = "{api_definition_swagger.name.length_range}", groups = {Created.class, Updated.class})
|
||||||
|
@ -49,6 +52,7 @@ public class ApiDefinitionSwagger implements Serializable {
|
||||||
|
|
||||||
public enum Column {
|
public enum Column {
|
||||||
id("id", "id", "VARCHAR", false),
|
id("id", "id", "VARCHAR", false),
|
||||||
|
num("num", "num", "BIGINT", false),
|
||||||
name("name", "name", "VARCHAR", true),
|
name("name", "name", "VARCHAR", true),
|
||||||
swaggerUrl("swagger_url", "swaggerUrl", "VARCHAR", false),
|
swaggerUrl("swagger_url", "swaggerUrl", "VARCHAR", false),
|
||||||
moduleId("module_id", "moduleId", "VARCHAR", false),
|
moduleId("module_id", "moduleId", "VARCHAR", false),
|
||||||
|
|
|
@ -174,6 +174,66 @@ public class ApiDefinitionSwaggerExample {
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Criteria andNumIsNull() {
|
||||||
|
addCriterion("num is null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumIsNotNull() {
|
||||||
|
addCriterion("num is not null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumEqualTo(Long value) {
|
||||||
|
addCriterion("num =", value, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumNotEqualTo(Long value) {
|
||||||
|
addCriterion("num <>", value, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumGreaterThan(Long value) {
|
||||||
|
addCriterion("num >", value, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumGreaterThanOrEqualTo(Long value) {
|
||||||
|
addCriterion("num >=", value, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumLessThan(Long value) {
|
||||||
|
addCriterion("num <", value, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumLessThanOrEqualTo(Long value) {
|
||||||
|
addCriterion("num <=", value, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumIn(List<Long> values) {
|
||||||
|
addCriterion("num in", values, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumNotIn(List<Long> values) {
|
||||||
|
addCriterion("num not in", values, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumBetween(Long value1, Long value2) {
|
||||||
|
addCriterion("num between", value1, value2, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumNotBetween(Long value1, Long value2) {
|
||||||
|
addCriterion("num not between", value1, value2, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
public Criteria andNameIsNull() {
|
public Criteria andNameIsNull() {
|
||||||
addCriterion("`name` is null");
|
addCriterion("`name` is null");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
package io.metersphere.api.domain;
|
package io.metersphere.api.domain;
|
||||||
|
|
||||||
import io.metersphere.validation.groups.Created;
|
import io.metersphere.validation.groups.*;
|
||||||
import io.metersphere.validation.groups.Updated;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.*;
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import jakarta.validation.constraints.Size;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ApiScenario implements Serializable {
|
public class ApiScenario implements Serializable {
|
||||||
|
@ -38,14 +35,13 @@ public class ApiScenario implements Serializable {
|
||||||
@NotNull(message = "{api_scenario.step_total.not_blank}", groups = {Created.class})
|
@NotNull(message = "{api_scenario.step_total.not_blank}", groups = {Created.class})
|
||||||
private Integer stepTotal;
|
private Integer stepTotal;
|
||||||
|
|
||||||
@Schema(description = "请求执行率", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "请求执行率")
|
||||||
@NotBlank(message = "{api_scenario.request_execution_rate.not_blank}", groups = {Created.class})
|
|
||||||
@Size(min = 1, max = 255, message = "{api_scenario.request_execution_rate.length_range}", groups = {Created.class, Updated.class})
|
|
||||||
private String requestExecutionRate;
|
private String requestExecutionRate;
|
||||||
|
|
||||||
@Schema(description = "通过率", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "请求通过率", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "{api_scenario.request_pass_rate.not_blank}", groups = {Created.class})
|
@NotBlank(message = "{api_scenario.request_pass_rate.not_blank}", groups = {Created.class})
|
||||||
private Long requestPassRate;
|
@Size(min = 1, max = 20, message = "{api_scenario.request_pass_rate.length_range}", groups = {Created.class, Updated.class})
|
||||||
|
private String requestPassRate;
|
||||||
|
|
||||||
@Schema(description = "最后一次执行的结果状态")
|
@Schema(description = "最后一次执行的结果状态")
|
||||||
private String lastReportStatus;
|
private String lastReportStatus;
|
||||||
|
@ -125,7 +121,7 @@ public class ApiScenario implements Serializable {
|
||||||
status("status", "status", "VARCHAR", true),
|
status("status", "status", "VARCHAR", true),
|
||||||
stepTotal("step_total", "stepTotal", "INTEGER", false),
|
stepTotal("step_total", "stepTotal", "INTEGER", false),
|
||||||
requestExecutionRate("request_execution_rate", "requestExecutionRate", "VARCHAR", false),
|
requestExecutionRate("request_execution_rate", "requestExecutionRate", "VARCHAR", false),
|
||||||
requestPassRate("request_pass_rate", "requestPassRate", "BIGINT", false),
|
requestPassRate("request_pass_rate", "requestPassRate", "VARCHAR", false),
|
||||||
lastReportStatus("last_report_status", "lastReportStatus", "VARCHAR", false),
|
lastReportStatus("last_report_status", "lastReportStatus", "VARCHAR", false),
|
||||||
lastReportId("last_report_id", "lastReportId", "VARCHAR", false),
|
lastReportId("last_report_id", "lastReportId", "VARCHAR", false),
|
||||||
num("num", "num", "BIGINT", false),
|
num("num", "num", "BIGINT", false),
|
||||||
|
|
|
@ -558,52 +558,62 @@ public class ApiScenarioExample {
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andRequestPassRateEqualTo(Long value) {
|
public Criteria andRequestPassRateEqualTo(String value) {
|
||||||
addCriterion("request_pass_rate =", value, "requestPassRate");
|
addCriterion("request_pass_rate =", value, "requestPassRate");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andRequestPassRateNotEqualTo(Long value) {
|
public Criteria andRequestPassRateNotEqualTo(String value) {
|
||||||
addCriterion("request_pass_rate <>", value, "requestPassRate");
|
addCriterion("request_pass_rate <>", value, "requestPassRate");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andRequestPassRateGreaterThan(Long value) {
|
public Criteria andRequestPassRateGreaterThan(String value) {
|
||||||
addCriterion("request_pass_rate >", value, "requestPassRate");
|
addCriterion("request_pass_rate >", value, "requestPassRate");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andRequestPassRateGreaterThanOrEqualTo(Long value) {
|
public Criteria andRequestPassRateGreaterThanOrEqualTo(String value) {
|
||||||
addCriterion("request_pass_rate >=", value, "requestPassRate");
|
addCriterion("request_pass_rate >=", value, "requestPassRate");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andRequestPassRateLessThan(Long value) {
|
public Criteria andRequestPassRateLessThan(String value) {
|
||||||
addCriterion("request_pass_rate <", value, "requestPassRate");
|
addCriterion("request_pass_rate <", value, "requestPassRate");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andRequestPassRateLessThanOrEqualTo(Long value) {
|
public Criteria andRequestPassRateLessThanOrEqualTo(String value) {
|
||||||
addCriterion("request_pass_rate <=", value, "requestPassRate");
|
addCriterion("request_pass_rate <=", value, "requestPassRate");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andRequestPassRateIn(List<Long> values) {
|
public Criteria andRequestPassRateLike(String value) {
|
||||||
|
addCriterion("request_pass_rate like", value, "requestPassRate");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andRequestPassRateNotLike(String value) {
|
||||||
|
addCriterion("request_pass_rate not like", value, "requestPassRate");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andRequestPassRateIn(List<String> values) {
|
||||||
addCriterion("request_pass_rate in", values, "requestPassRate");
|
addCriterion("request_pass_rate in", values, "requestPassRate");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andRequestPassRateNotIn(List<Long> values) {
|
public Criteria andRequestPassRateNotIn(List<String> values) {
|
||||||
addCriterion("request_pass_rate not in", values, "requestPassRate");
|
addCriterion("request_pass_rate not in", values, "requestPassRate");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andRequestPassRateBetween(Long value1, Long value2) {
|
public Criteria andRequestPassRateBetween(String value1, String value2) {
|
||||||
addCriterion("request_pass_rate between", value1, value2, "requestPassRate");
|
addCriterion("request_pass_rate between", value1, value2, "requestPassRate");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andRequestPassRateNotBetween(Long value1, Long value2) {
|
public Criteria andRequestPassRateNotBetween(String value1, String value2) {
|
||||||
addCriterion("request_pass_rate not between", value1, value2, "requestPassRate");
|
addCriterion("request_pass_rate not between", value1, value2, "requestPassRate");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<mapper namespace="io.metersphere.api.mapper.ApiDefinitionSwaggerMapper">
|
<mapper namespace="io.metersphere.api.mapper.ApiDefinitionSwaggerMapper">
|
||||||
<resultMap id="BaseResultMap" type="io.metersphere.api.domain.ApiDefinitionSwagger">
|
<resultMap id="BaseResultMap" type="io.metersphere.api.domain.ApiDefinitionSwagger">
|
||||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||||
|
<result column="num" jdbcType="BIGINT" property="num" />
|
||||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||||
<result column="swagger_url" jdbcType="VARCHAR" property="swaggerUrl" />
|
<result column="swagger_url" jdbcType="VARCHAR" property="swaggerUrl" />
|
||||||
<result column="module_id" jdbcType="VARCHAR" property="moduleId" />
|
<result column="module_id" jdbcType="VARCHAR" property="moduleId" />
|
||||||
|
@ -71,7 +72,7 @@
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, `name`, swagger_url, module_id, config, cover_data, cover_module, project_id,
|
id, num, `name`, swagger_url, module_id, config, cover_data, cover_module, project_id,
|
||||||
version_id
|
version_id
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectByExample" parameterType="io.metersphere.api.domain.ApiDefinitionSwaggerExample" resultMap="BaseResultMap">
|
<select id="selectByExample" parameterType="io.metersphere.api.domain.ApiDefinitionSwaggerExample" resultMap="BaseResultMap">
|
||||||
|
@ -105,14 +106,14 @@
|
||||||
</if>
|
</if>
|
||||||
</delete>
|
</delete>
|
||||||
<insert id="insert" parameterType="io.metersphere.api.domain.ApiDefinitionSwagger">
|
<insert id="insert" parameterType="io.metersphere.api.domain.ApiDefinitionSwagger">
|
||||||
insert into api_definition_swagger (id, `name`, swagger_url,
|
insert into api_definition_swagger (id, num, `name`,
|
||||||
module_id, config, cover_data,
|
swagger_url, module_id, config,
|
||||||
cover_module, project_id, version_id
|
cover_data, cover_module, project_id,
|
||||||
)
|
version_id)
|
||||||
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{swaggerUrl,jdbcType=VARCHAR},
|
values (#{id,jdbcType=VARCHAR}, #{num,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR},
|
||||||
#{moduleId,jdbcType=VARCHAR}, #{config,jdbcType=VARCHAR}, #{coverData,jdbcType=BIT},
|
#{swaggerUrl,jdbcType=VARCHAR}, #{moduleId,jdbcType=VARCHAR}, #{config,jdbcType=VARCHAR},
|
||||||
#{coverModule,jdbcType=BIT}, #{projectId,jdbcType=VARCHAR}, #{versionId,jdbcType=VARCHAR}
|
#{coverData,jdbcType=BIT}, #{coverModule,jdbcType=BIT}, #{projectId,jdbcType=VARCHAR},
|
||||||
)
|
#{versionId,jdbcType=VARCHAR})
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelective" parameterType="io.metersphere.api.domain.ApiDefinitionSwagger">
|
<insert id="insertSelective" parameterType="io.metersphere.api.domain.ApiDefinitionSwagger">
|
||||||
insert into api_definition_swagger
|
insert into api_definition_swagger
|
||||||
|
@ -120,6 +121,9 @@
|
||||||
<if test="id != null">
|
<if test="id != null">
|
||||||
id,
|
id,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="num != null">
|
||||||
|
num,
|
||||||
|
</if>
|
||||||
<if test="name != null">
|
<if test="name != null">
|
||||||
`name`,
|
`name`,
|
||||||
</if>
|
</if>
|
||||||
|
@ -149,6 +153,9 @@
|
||||||
<if test="id != null">
|
<if test="id != null">
|
||||||
#{id,jdbcType=VARCHAR},
|
#{id,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="num != null">
|
||||||
|
#{num,jdbcType=BIGINT},
|
||||||
|
</if>
|
||||||
<if test="name != null">
|
<if test="name != null">
|
||||||
#{name,jdbcType=VARCHAR},
|
#{name,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
@ -187,6 +194,9 @@
|
||||||
<if test="record.id != null">
|
<if test="record.id != null">
|
||||||
id = #{record.id,jdbcType=VARCHAR},
|
id = #{record.id,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="record.num != null">
|
||||||
|
num = #{record.num,jdbcType=BIGINT},
|
||||||
|
</if>
|
||||||
<if test="record.name != null">
|
<if test="record.name != null">
|
||||||
`name` = #{record.name,jdbcType=VARCHAR},
|
`name` = #{record.name,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
@ -219,6 +229,7 @@
|
||||||
<update id="updateByExample" parameterType="map">
|
<update id="updateByExample" parameterType="map">
|
||||||
update api_definition_swagger
|
update api_definition_swagger
|
||||||
set id = #{record.id,jdbcType=VARCHAR},
|
set id = #{record.id,jdbcType=VARCHAR},
|
||||||
|
num = #{record.num,jdbcType=BIGINT},
|
||||||
`name` = #{record.name,jdbcType=VARCHAR},
|
`name` = #{record.name,jdbcType=VARCHAR},
|
||||||
swagger_url = #{record.swaggerUrl,jdbcType=VARCHAR},
|
swagger_url = #{record.swaggerUrl,jdbcType=VARCHAR},
|
||||||
module_id = #{record.moduleId,jdbcType=VARCHAR},
|
module_id = #{record.moduleId,jdbcType=VARCHAR},
|
||||||
|
@ -234,6 +245,9 @@
|
||||||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.api.domain.ApiDefinitionSwagger">
|
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.api.domain.ApiDefinitionSwagger">
|
||||||
update api_definition_swagger
|
update api_definition_swagger
|
||||||
<set>
|
<set>
|
||||||
|
<if test="num != null">
|
||||||
|
num = #{num,jdbcType=BIGINT},
|
||||||
|
</if>
|
||||||
<if test="name != null">
|
<if test="name != null">
|
||||||
`name` = #{name,jdbcType=VARCHAR},
|
`name` = #{name,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
@ -263,7 +277,8 @@
|
||||||
</update>
|
</update>
|
||||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.api.domain.ApiDefinitionSwagger">
|
<update id="updateByPrimaryKey" parameterType="io.metersphere.api.domain.ApiDefinitionSwagger">
|
||||||
update api_definition_swagger
|
update api_definition_swagger
|
||||||
set `name` = #{name,jdbcType=VARCHAR},
|
set num = #{num,jdbcType=BIGINT},
|
||||||
|
`name` = #{name,jdbcType=VARCHAR},
|
||||||
swagger_url = #{swaggerUrl,jdbcType=VARCHAR},
|
swagger_url = #{swaggerUrl,jdbcType=VARCHAR},
|
||||||
module_id = #{moduleId,jdbcType=VARCHAR},
|
module_id = #{moduleId,jdbcType=VARCHAR},
|
||||||
config = #{config,jdbcType=VARCHAR},
|
config = #{config,jdbcType=VARCHAR},
|
||||||
|
@ -275,14 +290,14 @@
|
||||||
</update>
|
</update>
|
||||||
<insert id="batchInsert" parameterType="map">
|
<insert id="batchInsert" parameterType="map">
|
||||||
insert into api_definition_swagger
|
insert into api_definition_swagger
|
||||||
(id, `name`, swagger_url, module_id, config, cover_data, cover_module, project_id,
|
(id, num, `name`, swagger_url, module_id, config, cover_data, cover_module, project_id,
|
||||||
version_id)
|
version_id)
|
||||||
values
|
values
|
||||||
<foreach collection="list" item="item" separator=",">
|
<foreach collection="list" item="item" separator=",">
|
||||||
(#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.swaggerUrl,jdbcType=VARCHAR},
|
(#{item.id,jdbcType=VARCHAR}, #{item.num,jdbcType=BIGINT}, #{item.name,jdbcType=VARCHAR},
|
||||||
#{item.moduleId,jdbcType=VARCHAR}, #{item.config,jdbcType=VARCHAR}, #{item.coverData,jdbcType=BIT},
|
#{item.swaggerUrl,jdbcType=VARCHAR}, #{item.moduleId,jdbcType=VARCHAR}, #{item.config,jdbcType=VARCHAR},
|
||||||
#{item.coverModule,jdbcType=BIT}, #{item.projectId,jdbcType=VARCHAR}, #{item.versionId,jdbcType=VARCHAR}
|
#{item.coverData,jdbcType=BIT}, #{item.coverModule,jdbcType=BIT}, #{item.projectId,jdbcType=VARCHAR},
|
||||||
)
|
#{item.versionId,jdbcType=VARCHAR})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="batchInsertSelective" parameterType="map">
|
<insert id="batchInsertSelective" parameterType="map">
|
||||||
|
@ -298,6 +313,9 @@
|
||||||
<if test="'id'.toString() == column.value">
|
<if test="'id'.toString() == column.value">
|
||||||
#{item.id,jdbcType=VARCHAR}
|
#{item.id,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="'num'.toString() == column.value">
|
||||||
|
#{item.num,jdbcType=BIGINT}
|
||||||
|
</if>
|
||||||
<if test="'name'.toString() == column.value">
|
<if test="'name'.toString() == column.value">
|
||||||
#{item.name,jdbcType=VARCHAR}
|
#{item.name,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<result column="status" jdbcType="VARCHAR" property="status" />
|
<result column="status" jdbcType="VARCHAR" property="status" />
|
||||||
<result column="step_total" jdbcType="INTEGER" property="stepTotal" />
|
<result column="step_total" jdbcType="INTEGER" property="stepTotal" />
|
||||||
<result column="request_execution_rate" jdbcType="VARCHAR" property="requestExecutionRate" />
|
<result column="request_execution_rate" jdbcType="VARCHAR" property="requestExecutionRate" />
|
||||||
<result column="request_pass_rate" jdbcType="BIGINT" property="requestPassRate" />
|
<result column="request_pass_rate" jdbcType="VARCHAR" property="requestPassRate" />
|
||||||
<result column="last_report_status" jdbcType="VARCHAR" property="lastReportStatus" />
|
<result column="last_report_status" jdbcType="VARCHAR" property="lastReportStatus" />
|
||||||
<result column="last_report_id" jdbcType="VARCHAR" property="lastReportId" />
|
<result column="last_report_id" jdbcType="VARCHAR" property="lastReportId" />
|
||||||
<result column="num" jdbcType="BIGINT" property="num" />
|
<result column="num" jdbcType="BIGINT" property="num" />
|
||||||
|
@ -173,7 +173,7 @@
|
||||||
update_time)
|
update_time)
|
||||||
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{priority,jdbcType=VARCHAR},
|
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{priority,jdbcType=VARCHAR},
|
||||||
#{status,jdbcType=VARCHAR}, #{stepTotal,jdbcType=INTEGER}, #{requestExecutionRate,jdbcType=VARCHAR},
|
#{status,jdbcType=VARCHAR}, #{stepTotal,jdbcType=INTEGER}, #{requestExecutionRate,jdbcType=VARCHAR},
|
||||||
#{requestPassRate,jdbcType=BIGINT}, #{lastReportStatus,jdbcType=VARCHAR}, #{lastReportId,jdbcType=VARCHAR},
|
#{requestPassRate,jdbcType=VARCHAR}, #{lastReportStatus,jdbcType=VARCHAR}, #{lastReportId,jdbcType=VARCHAR},
|
||||||
#{num,jdbcType=BIGINT}, #{deleted,jdbcType=BIT}, #{pos,jdbcType=BIGINT}, #{versionId,jdbcType=VARCHAR},
|
#{num,jdbcType=BIGINT}, #{deleted,jdbcType=BIT}, #{pos,jdbcType=BIGINT}, #{versionId,jdbcType=VARCHAR},
|
||||||
#{refId,jdbcType=VARCHAR}, #{latest,jdbcType=BIT}, #{projectId,jdbcType=VARCHAR},
|
#{refId,jdbcType=VARCHAR}, #{latest,jdbcType=BIT}, #{projectId,jdbcType=VARCHAR},
|
||||||
#{moduleId,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler},
|
#{moduleId,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler},
|
||||||
|
@ -283,7 +283,7 @@
|
||||||
#{requestExecutionRate,jdbcType=VARCHAR},
|
#{requestExecutionRate,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="requestPassRate != null">
|
<if test="requestPassRate != null">
|
||||||
#{requestPassRate,jdbcType=BIGINT},
|
#{requestPassRate,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="lastReportStatus != null">
|
<if test="lastReportStatus != null">
|
||||||
#{lastReportStatus,jdbcType=VARCHAR},
|
#{lastReportStatus,jdbcType=VARCHAR},
|
||||||
|
@ -372,7 +372,7 @@
|
||||||
request_execution_rate = #{record.requestExecutionRate,jdbcType=VARCHAR},
|
request_execution_rate = #{record.requestExecutionRate,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="record.requestPassRate != null">
|
<if test="record.requestPassRate != null">
|
||||||
request_pass_rate = #{record.requestPassRate,jdbcType=BIGINT},
|
request_pass_rate = #{record.requestPassRate,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="record.lastReportStatus != null">
|
<if test="record.lastReportStatus != null">
|
||||||
last_report_status = #{record.lastReportStatus,jdbcType=VARCHAR},
|
last_report_status = #{record.lastReportStatus,jdbcType=VARCHAR},
|
||||||
|
@ -444,7 +444,7 @@
|
||||||
`status` = #{record.status,jdbcType=VARCHAR},
|
`status` = #{record.status,jdbcType=VARCHAR},
|
||||||
step_total = #{record.stepTotal,jdbcType=INTEGER},
|
step_total = #{record.stepTotal,jdbcType=INTEGER},
|
||||||
request_execution_rate = #{record.requestExecutionRate,jdbcType=VARCHAR},
|
request_execution_rate = #{record.requestExecutionRate,jdbcType=VARCHAR},
|
||||||
request_pass_rate = #{record.requestPassRate,jdbcType=BIGINT},
|
request_pass_rate = #{record.requestPassRate,jdbcType=VARCHAR},
|
||||||
last_report_status = #{record.lastReportStatus,jdbcType=VARCHAR},
|
last_report_status = #{record.lastReportStatus,jdbcType=VARCHAR},
|
||||||
last_report_id = #{record.lastReportId,jdbcType=VARCHAR},
|
last_report_id = #{record.lastReportId,jdbcType=VARCHAR},
|
||||||
num = #{record.num,jdbcType=BIGINT},
|
num = #{record.num,jdbcType=BIGINT},
|
||||||
|
@ -487,7 +487,7 @@
|
||||||
request_execution_rate = #{requestExecutionRate,jdbcType=VARCHAR},
|
request_execution_rate = #{requestExecutionRate,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="requestPassRate != null">
|
<if test="requestPassRate != null">
|
||||||
request_pass_rate = #{requestPassRate,jdbcType=BIGINT},
|
request_pass_rate = #{requestPassRate,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="lastReportStatus != null">
|
<if test="lastReportStatus != null">
|
||||||
last_report_status = #{lastReportStatus,jdbcType=VARCHAR},
|
last_report_status = #{lastReportStatus,jdbcType=VARCHAR},
|
||||||
|
@ -556,7 +556,7 @@
|
||||||
`status` = #{status,jdbcType=VARCHAR},
|
`status` = #{status,jdbcType=VARCHAR},
|
||||||
step_total = #{stepTotal,jdbcType=INTEGER},
|
step_total = #{stepTotal,jdbcType=INTEGER},
|
||||||
request_execution_rate = #{requestExecutionRate,jdbcType=VARCHAR},
|
request_execution_rate = #{requestExecutionRate,jdbcType=VARCHAR},
|
||||||
request_pass_rate = #{requestPassRate,jdbcType=BIGINT},
|
request_pass_rate = #{requestPassRate,jdbcType=VARCHAR},
|
||||||
last_report_status = #{lastReportStatus,jdbcType=VARCHAR},
|
last_report_status = #{lastReportStatus,jdbcType=VARCHAR},
|
||||||
last_report_id = #{lastReportId,jdbcType=VARCHAR},
|
last_report_id = #{lastReportId,jdbcType=VARCHAR},
|
||||||
num = #{num,jdbcType=BIGINT},
|
num = #{num,jdbcType=BIGINT},
|
||||||
|
@ -588,7 +588,7 @@
|
||||||
<foreach collection="list" item="item" separator=",">
|
<foreach collection="list" item="item" separator=",">
|
||||||
(#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.priority,jdbcType=VARCHAR},
|
(#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.priority,jdbcType=VARCHAR},
|
||||||
#{item.status,jdbcType=VARCHAR}, #{item.stepTotal,jdbcType=INTEGER}, #{item.requestExecutionRate,jdbcType=VARCHAR},
|
#{item.status,jdbcType=VARCHAR}, #{item.stepTotal,jdbcType=INTEGER}, #{item.requestExecutionRate,jdbcType=VARCHAR},
|
||||||
#{item.requestPassRate,jdbcType=BIGINT}, #{item.lastReportStatus,jdbcType=VARCHAR},
|
#{item.requestPassRate,jdbcType=VARCHAR}, #{item.lastReportStatus,jdbcType=VARCHAR},
|
||||||
#{item.lastReportId,jdbcType=VARCHAR}, #{item.num,jdbcType=BIGINT}, #{item.deleted,jdbcType=BIT},
|
#{item.lastReportId,jdbcType=VARCHAR}, #{item.num,jdbcType=BIGINT}, #{item.deleted,jdbcType=BIT},
|
||||||
#{item.pos,jdbcType=BIGINT}, #{item.versionId,jdbcType=VARCHAR}, #{item.refId,jdbcType=VARCHAR},
|
#{item.pos,jdbcType=BIGINT}, #{item.versionId,jdbcType=VARCHAR}, #{item.refId,jdbcType=VARCHAR},
|
||||||
#{item.latest,jdbcType=BIT}, #{item.projectId,jdbcType=VARCHAR}, #{item.moduleId,jdbcType=VARCHAR},
|
#{item.latest,jdbcType=BIT}, #{item.projectId,jdbcType=VARCHAR}, #{item.moduleId,jdbcType=VARCHAR},
|
||||||
|
@ -627,7 +627,7 @@
|
||||||
#{item.requestExecutionRate,jdbcType=VARCHAR}
|
#{item.requestExecutionRate,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
<if test="'request_pass_rate'.toString() == column.value">
|
<if test="'request_pass_rate'.toString() == column.value">
|
||||||
#{item.requestPassRate,jdbcType=BIGINT}
|
#{item.requestPassRate,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
<if test="'last_report_status'.toString() == column.value">
|
<if test="'last_report_status'.toString() == column.value">
|
||||||
#{item.lastReportStatus,jdbcType=VARCHAR}
|
#{item.lastReportStatus,jdbcType=VARCHAR}
|
||||||
|
|
|
@ -209,8 +209,8 @@ CREATE TABLE IF NOT EXISTS api_scenario(
|
||||||
`priority` VARCHAR(10) NOT NULL COMMENT '场景级别/P0/P1等' ,
|
`priority` VARCHAR(10) NOT NULL COMMENT '场景级别/P0/P1等' ,
|
||||||
`status` VARCHAR(20) NOT NULL COMMENT '场景状态/未规划/已完成 等' ,
|
`status` VARCHAR(20) NOT NULL COMMENT '场景状态/未规划/已完成 等' ,
|
||||||
`step_total` INT NOT NULL DEFAULT 0 COMMENT '场景步骤总数' ,
|
`step_total` INT NOT NULL DEFAULT 0 COMMENT '场景步骤总数' ,
|
||||||
`request_execution_rate` VARCHAR(255) NOT NULL DEFAULT '0.00' COMMENT '请求执行率' ,
|
`request_execution_rate` VARCHAR(20) NOT NULL DEFAULT '0.00' COMMENT '请求执行率' ,
|
||||||
`request_pass_rate` BIGINT NOT NULL DEFAULT '0.00' COMMENT '通过率' ,
|
`request_pass_rate` VARCHAR(20) NOT NULL DEFAULT '0.00' COMMENT '通过率' ,
|
||||||
`last_report_status` VARCHAR(50) COMMENT '最后一次执行的结果状态' ,
|
`last_report_status` VARCHAR(50) COMMENT '最后一次执行的结果状态' ,
|
||||||
`last_report_id` VARCHAR(50) COMMENT '最后一次执行的报告fk' ,
|
`last_report_id` VARCHAR(50) COMMENT '最后一次执行的报告fk' ,
|
||||||
`num` BIGINT NOT NULL COMMENT '编号' ,
|
`num` BIGINT NOT NULL COMMENT '编号' ,
|
||||||
|
@ -507,6 +507,7 @@ CREATE TABLE IF NOT EXISTS api_definition_mock_config(
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS api_definition_swagger(
|
CREATE TABLE IF NOT EXISTS api_definition_swagger(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '主键' ,
|
`id` VARCHAR(50) NOT NULL COMMENT '主键' ,
|
||||||
|
`num` BIGINT NOT NULL COMMENT '业务id' ,
|
||||||
`name` VARCHAR(255) NOT NULL COMMENT '定时任务名称' ,
|
`name` VARCHAR(255) NOT NULL COMMENT '定时任务名称' ,
|
||||||
`swagger_url` VARCHAR(500) NOT NULL COMMENT 'url地址' ,
|
`swagger_url` VARCHAR(500) NOT NULL COMMENT 'url地址' ,
|
||||||
`module_id` VARCHAR(50) COMMENT '模块fk' ,
|
`module_id` VARCHAR(50) COMMENT '模块fk' ,
|
||||||
|
|
|
@ -5,6 +5,7 @@ public enum ApplicationNumScope {
|
||||||
API_TEST_CASE,
|
API_TEST_CASE,
|
||||||
API_MOCK,
|
API_MOCK,
|
||||||
API_SCENARIO,
|
API_SCENARIO,
|
||||||
|
API_IMPORT,
|
||||||
|
|
||||||
UI_SCENARIO,
|
UI_SCENARIO,
|
||||||
UI_ELEMENT,
|
UI_ELEMENT,
|
||||||
|
|
|
@ -9,6 +9,7 @@ import io.metersphere.api.mapper.ApiDefinitionSwaggerMapper;
|
||||||
import io.metersphere.api.service.schedule.SwaggerUrlImportJob;
|
import io.metersphere.api.service.schedule.SwaggerUrlImportJob;
|
||||||
import io.metersphere.api.utils.ApiDataUtils;
|
import io.metersphere.api.utils.ApiDataUtils;
|
||||||
import io.metersphere.project.mapper.ProjectMapper;
|
import io.metersphere.project.mapper.ProjectMapper;
|
||||||
|
import io.metersphere.sdk.constants.ApplicationNumScope;
|
||||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||||
import io.metersphere.sdk.constants.ScheduleType;
|
import io.metersphere.sdk.constants.ScheduleType;
|
||||||
import io.metersphere.sdk.exception.MSException;
|
import io.metersphere.sdk.exception.MSException;
|
||||||
|
@ -23,6 +24,7 @@ import io.metersphere.system.log.service.OperationLogService;
|
||||||
import io.metersphere.system.mapper.ScheduleMapper;
|
import io.metersphere.system.mapper.ScheduleMapper;
|
||||||
import io.metersphere.system.sechedule.ScheduleService;
|
import io.metersphere.system.sechedule.ScheduleService;
|
||||||
import io.metersphere.system.uid.IDGenerator;
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
|
import io.metersphere.system.uid.NumGenerator;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -51,6 +53,7 @@ public class ApiDefinitionScheduleService {
|
||||||
ApiDefinitionSwagger apiSwagger = new ApiDefinitionSwagger();
|
ApiDefinitionSwagger apiSwagger = new ApiDefinitionSwagger();
|
||||||
BeanUtils.copyBean(apiSwagger, request);
|
BeanUtils.copyBean(apiSwagger, request);
|
||||||
apiSwagger.setId(IDGenerator.nextStr());
|
apiSwagger.setId(IDGenerator.nextStr());
|
||||||
|
apiSwagger.setNum(NumGenerator.nextNum(request.getProjectId(), ApplicationNumScope.API_IMPORT));
|
||||||
// 设置鉴权信息
|
// 设置鉴权信息
|
||||||
SwaggerBasicAuth basicAuth = new SwaggerBasicAuth();
|
SwaggerBasicAuth basicAuth = new SwaggerBasicAuth();
|
||||||
basicAuth.setUserName(request.getAuthUsername());
|
basicAuth.setUserName(request.getAuthUsername());
|
||||||
|
|
|
@ -227,6 +227,12 @@ public class ApiDefinitionService {
|
||||||
BeanUtils.copyBean(apiDefinition, request);
|
BeanUtils.copyBean(apiDefinition, request);
|
||||||
if (request.getProtocol().equals(ModuleConstants.NODE_PROTOCOL_HTTP)) {
|
if (request.getProtocol().equals(ModuleConstants.NODE_PROTOCOL_HTTP)) {
|
||||||
checkUpdateExist(apiDefinition);
|
checkUpdateExist(apiDefinition);
|
||||||
|
//http协议的接口,如果修改了path和method,需要同步把case的path和method修改
|
||||||
|
if (!originApiDefinition.getPath().equals(apiDefinition.getPath()) || !originApiDefinition.getMethod().equals(apiDefinition.getMethod())) {
|
||||||
|
List<String> ids = new ArrayList<>();
|
||||||
|
ids.add(request.getId());
|
||||||
|
apiTestCaseService.updateByApiDefinitionId(ids, apiDefinition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
apiDefinition.setStatus(request.getStatus());
|
apiDefinition.setStatus(request.getStatus());
|
||||||
apiDefinition.setUpdateUser(userId);
|
apiDefinition.setUpdateUser(userId);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import io.metersphere.api.constants.ApiResourceType;
|
||||||
import io.metersphere.api.domain.*;
|
import io.metersphere.api.domain.*;
|
||||||
import io.metersphere.api.dto.debug.ApiFileResourceUpdateRequest;
|
import io.metersphere.api.dto.debug.ApiFileResourceUpdateRequest;
|
||||||
import io.metersphere.api.dto.definition.*;
|
import io.metersphere.api.dto.definition.*;
|
||||||
|
import io.metersphere.api.dto.request.http.MsHTTPElement;
|
||||||
import io.metersphere.api.mapper.*;
|
import io.metersphere.api.mapper.*;
|
||||||
import io.metersphere.api.service.ApiFileResourceService;
|
import io.metersphere.api.service.ApiFileResourceService;
|
||||||
import io.metersphere.api.utils.ApiDataUtils;
|
import io.metersphere.api.utils.ApiDataUtils;
|
||||||
|
@ -351,7 +352,7 @@ public class ApiTestCaseService {
|
||||||
//记录删除日志
|
//记录删除日志
|
||||||
apiTestCaseLogService.deleteBatchLog(caseLists, userId, projectId);
|
apiTestCaseLogService.deleteBatchLog(caseLists, userId, projectId);
|
||||||
//TODO 需要删除测试计划与用例的中间表 功能用例的关联表等
|
//TODO 需要删除测试计划与用例的中间表 功能用例的关联表等
|
||||||
//TODO 删除附件关系
|
//TODO 删除附件关系 不需要删除报告
|
||||||
//extFileAssociationService.deleteByResourceIds(ids);
|
//extFileAssociationService.deleteByResourceIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,4 +498,34 @@ public class ApiTestCaseService {
|
||||||
return apiFileResourceService.uploadTempFile(file);
|
return apiFileResourceService.uploadTempFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateByApiDefinitionId(List<String> ids, ApiDefinition apiDefinition) {
|
||||||
|
String method = apiDefinition.getMethod();
|
||||||
|
String path = apiDefinition.getPath();
|
||||||
|
if (StringUtils.isNotEmpty(method) || StringUtils.isNotEmpty(path)) {
|
||||||
|
ApiTestCaseExample apiTestCaseExample = new ApiTestCaseExample();
|
||||||
|
apiTestCaseExample.createCriteria().andApiDefinitionIdIn(ids);
|
||||||
|
List<ApiTestCase> caseLists = apiTestCaseMapper.selectByExample(apiTestCaseExample);
|
||||||
|
List<String> caseIds = caseLists.stream().map(ApiTestCase::getId).toList();
|
||||||
|
if (CollectionUtils.isEmpty(caseIds)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ApiTestCaseBlobExample blobExample = new ApiTestCaseBlobExample();
|
||||||
|
blobExample.createCriteria().andIdIn(caseIds);
|
||||||
|
List<ApiTestCaseBlob> bloBs = apiTestCaseBlobMapper.selectByExampleWithBLOBs(blobExample);
|
||||||
|
|
||||||
|
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||||
|
ApiTestCaseBlobMapper batchMapper = sqlSession.getMapper(ApiTestCaseBlobMapper.class);
|
||||||
|
bloBs.forEach(apiTestCase -> {
|
||||||
|
MsHTTPElement msHttpElement = ApiDataUtils.parseObject(new String(apiTestCase.getRequest()), MsHTTPElement.class);
|
||||||
|
msHttpElement.setMethod(method);
|
||||||
|
msHttpElement.setPath(path);
|
||||||
|
apiTestCase.setRequest(ApiDataUtils.toJSONString(msHttpElement).getBytes());
|
||||||
|
batchMapper.updateByPrimaryKeySelective(apiTestCase);
|
||||||
|
});
|
||||||
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,6 +131,10 @@ public class ApiDefinitionControllerTests extends BaseTest {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private OperationHistoryMapper operationHistoryMapper;
|
private OperationHistoryMapper operationHistoryMapper;
|
||||||
|
@Resource
|
||||||
|
private ApiTestCaseMapper apiTestCaseMapper;
|
||||||
|
@Resource
|
||||||
|
private ApiTestCaseBlobMapper apiTestCaseBlobMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private OperationLogMapper operationLogMapper;
|
private OperationLogMapper operationLogMapper;
|
||||||
|
@ -392,6 +396,61 @@ public class ApiDefinitionControllerTests extends BaseTest {
|
||||||
|
|
||||||
// @@校验日志
|
// @@校验日志
|
||||||
checkLogModelList.add(new CheckLogModel(apiDefinition.getId(), OperationLogType.UPDATE, UPDATE));
|
checkLogModelList.add(new CheckLogModel(apiDefinition.getId(), OperationLogType.UPDATE, UPDATE));
|
||||||
|
|
||||||
|
//校验修改path和method时,是否会影响用例
|
||||||
|
ApiDefinitionAddRequest addRequest = new ApiDefinitionAddRequest();
|
||||||
|
addRequest.setName("测试修改path和method");
|
||||||
|
addRequest.setProtocol("HTTP");
|
||||||
|
addRequest.setProjectId(DEFAULT_PROJECT_ID);
|
||||||
|
addRequest.setMethod("POST");
|
||||||
|
addRequest.setPath("/api/admin/posts");
|
||||||
|
addRequest.setStatus(ApiDefinitionStatus.PREPARE.getValue());
|
||||||
|
addRequest.setModuleId("default");
|
||||||
|
addRequest.setVersionId(DEFAULT_PROJECT_ID);
|
||||||
|
addRequest.setDescription("描述内容");
|
||||||
|
addRequest.setTags(new LinkedHashSet<>(List.of("tag1", "tag2")));
|
||||||
|
addRequest.setCustomFields(new HashMap<>());
|
||||||
|
addRequest.setRequest(ApiDataUtils.toJSONString(msHttpElement));
|
||||||
|
addRequest.setResponse(ApiDataUtils.toJSONString(msHttpResponse));
|
||||||
|
MvcResult mvcResult = this.requestPostWithOkAndReturn(ADD, addRequest);
|
||||||
|
ApiDefinition apiDefinition = getResultData(mvcResult, ApiDefinition.class);
|
||||||
|
ApiDefinition apiPathAndMethod = apiDefinitionMapper.selectByPrimaryKey(apiDefinition.getId());
|
||||||
|
Assertions.assertEquals(addRequest.getPath(), apiPathAndMethod.getPath());
|
||||||
|
Assertions.assertEquals(addRequest.getMethod(), apiPathAndMethod.getMethod());
|
||||||
|
ApiDefinitionUpdateRequest updateRequest = new ApiDefinitionUpdateRequest();
|
||||||
|
BeanUtils.copyBean(updateRequest, apiPathAndMethod);
|
||||||
|
updateRequest.setPath("/api/test/path/method");
|
||||||
|
updateRequest.setRequest(ApiDataUtils.toJSONString(msHttpElement));
|
||||||
|
updateRequest.setResponse(ApiDataUtils.toJSONString(msHttpResponse));
|
||||||
|
updateRequest.setMethod("GET");
|
||||||
|
this.requestPostWithOk(UPDATE, updateRequest);
|
||||||
|
//增加用例
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
ApiTestCaseAddRequest testCaseAddRequest = new ApiTestCaseAddRequest();
|
||||||
|
testCaseAddRequest.setApiDefinitionId(apiPathAndMethod.getId());
|
||||||
|
testCaseAddRequest.setName("test-path" + i);
|
||||||
|
testCaseAddRequest.setProjectId(DEFAULT_PROJECT_ID);
|
||||||
|
testCaseAddRequest.setPriority("P0");
|
||||||
|
testCaseAddRequest.setStatus(ApiDefinitionStatus.PREPARE.getValue());
|
||||||
|
testCaseAddRequest.setTags(new LinkedHashSet<>(List.of("tag1", "tag2")));
|
||||||
|
testCaseAddRequest.setRequest(ApiDataUtils.toJSONString(msHttpElement));
|
||||||
|
this.requestPostWithOkAndReturn("/api/case/add", testCaseAddRequest);
|
||||||
|
}
|
||||||
|
updateRequest.setPath("/api/test/path/method/case");
|
||||||
|
this.requestPostWithOk(UPDATE, updateRequest);
|
||||||
|
//校验用例是否被修改
|
||||||
|
ApiTestCaseExample apiTestCaseExample = new ApiTestCaseExample();
|
||||||
|
apiTestCaseExample.createCriteria().andApiDefinitionIdEqualTo(apiPathAndMethod.getId());
|
||||||
|
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(apiTestCaseExample);
|
||||||
|
List<String> caseIds = apiTestCases.stream().map(ApiTestCase::getId).toList();
|
||||||
|
ApiTestCaseBlobExample apiTestCaseBlobExample = new ApiTestCaseBlobExample();
|
||||||
|
apiTestCaseBlobExample.createCriteria().andIdIn(caseIds);
|
||||||
|
List<ApiTestCaseBlob> apiTestCaseBlobs = apiTestCaseBlobMapper.selectByExampleWithBLOBs(apiTestCaseBlobExample);
|
||||||
|
apiTestCaseBlobs.forEach(apiTestCaseBlob -> {
|
||||||
|
MsHTTPElement caseElement = ApiDataUtils.parseObject(new String(apiTestCaseBlob.getRequest()), MsHTTPElement.class);
|
||||||
|
Assertions.assertEquals(updateRequest.getPath(), caseElement.getPath());
|
||||||
|
Assertions.assertEquals(updateRequest.getMethod(), caseElement.getMethod());
|
||||||
|
});
|
||||||
// @@异常参数校验
|
// @@异常参数校验
|
||||||
createdGroupParamValidateTest(ApiDefinitionUpdateRequest.class, UPDATE);
|
createdGroupParamValidateTest(ApiDefinitionUpdateRequest.class, UPDATE);
|
||||||
// @@校验权限
|
// @@校验权限
|
||||||
|
|
Loading…
Reference in New Issue