feat(用例管理): 新增功能用例执行历史表以及功能用例执行历史接口

This commit is contained in:
guoyuqi 2024-05-11 19:58:03 +08:00 committed by 刘瑞斌
parent 65f04379dc
commit 1b00d8cd32
12 changed files with 1473 additions and 0 deletions

View File

@ -0,0 +1,133 @@
package io.metersphere.plan.domain;
import io.metersphere.validation.groups.*;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import lombok.Data;
@Data
public class TestPlanCaseExecuteHistory implements Serializable {
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{test_plan_case_execute_history.id.not_blank}", groups = {Updated.class})
@Size(min = 1, max = 50, message = "{test_plan_case_execute_history.id.length_range}", groups = {Created.class, Updated.class})
private String id;
@Schema(description = "测试计划ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{test_plan_case_execute_history.test_plan_id.not_blank}", groups = {Created.class})
@Size(min = 1, max = 50, message = "{test_plan_case_execute_history.test_plan_id.length_range}", groups = {Created.class, Updated.class})
private String testPlanId;
@Schema(description = "用例ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{test_plan_case_execute_history.case_id.not_blank}", groups = {Created.class})
@Size(min = 1, max = 50, message = "{test_plan_case_execute_history.case_id.length_range}", groups = {Created.class, Updated.class})
private String caseId;
@Schema(description = "执行结果:成功/失败/阻塞", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{test_plan_case_execute_history.status.not_blank}", groups = {Created.class})
@Size(min = 1, max = 64, message = "{test_plan_case_execute_history.status.length_range}", groups = {Created.class, Updated.class})
private String status;
@Schema(description = "是否是取消关联或执行被删除的0-否1-是", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "{test_plan_case_execute_history.deleted.not_blank}", groups = {Created.class})
private Boolean deleted;
@Schema(description = "通知人")
private String notifier;
@Schema(description = "操作人")
private String createUser;
@Schema(description = "操作时间")
private Long createTime;
@Schema(description = "执行评论意见")
private byte[] content;
@Schema(description = "用例步骤执行记录JSON)step_model 为 Step 时启用")
private byte[] steps;
private static final long serialVersionUID = 1L;
public enum Column {
id("id", "id", "VARCHAR", false),
testPlanId("test_plan_id", "testPlanId", "VARCHAR", false),
caseId("case_id", "caseId", "VARCHAR", false),
status("status", "status", "VARCHAR", true),
deleted("deleted", "deleted", "BIT", false),
notifier("notifier", "notifier", "VARCHAR", false),
createUser("create_user", "createUser", "VARCHAR", false),
createTime("create_time", "createTime", "BIGINT", false),
content("content", "content", "LONGVARBINARY", false),
steps("steps", "steps", "LONGVARBINARY", false);
private static final String BEGINNING_DELIMITER = "`";
private static final String ENDING_DELIMITER = "`";
private final String column;
private final boolean isColumnNameDelimited;
private final String javaProperty;
private final String jdbcType;
public String value() {
return this.column;
}
public String getValue() {
return this.column;
}
public String getJavaProperty() {
return this.javaProperty;
}
public String getJdbcType() {
return this.jdbcType;
}
Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
this.column = column;
this.javaProperty = javaProperty;
this.jdbcType = jdbcType;
this.isColumnNameDelimited = isColumnNameDelimited;
}
public String desc() {
return this.getEscapedColumnName() + " DESC";
}
public String asc() {
return this.getEscapedColumnName() + " ASC";
}
public static Column[] excludes(Column ... excludes) {
ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
if (excludes != null && excludes.length > 0) {
columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
}
return columns.toArray(new Column[]{});
}
public static Column[] all() {
return Column.values();
}
public String getEscapedColumnName() {
if (this.isColumnNameDelimited) {
return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
} else {
return this.column;
}
}
public String getAliasedEscapedColumnName() {
return this.getEscapedColumnName();
}
}
}

View File

@ -0,0 +1,740 @@
package io.metersphere.plan.domain;
import java.util.ArrayList;
import java.util.List;
public class TestPlanCaseExecuteHistoryExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public TestPlanCaseExecuteHistoryExample() {
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 andTestPlanIdIsNull() {
addCriterion("test_plan_id is null");
return (Criteria) this;
}
public Criteria andTestPlanIdIsNotNull() {
addCriterion("test_plan_id is not null");
return (Criteria) this;
}
public Criteria andTestPlanIdEqualTo(String value) {
addCriterion("test_plan_id =", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotEqualTo(String value) {
addCriterion("test_plan_id <>", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdGreaterThan(String value) {
addCriterion("test_plan_id >", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdGreaterThanOrEqualTo(String value) {
addCriterion("test_plan_id >=", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdLessThan(String value) {
addCriterion("test_plan_id <", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdLessThanOrEqualTo(String value) {
addCriterion("test_plan_id <=", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdLike(String value) {
addCriterion("test_plan_id like", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotLike(String value) {
addCriterion("test_plan_id not like", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdIn(List<String> values) {
addCriterion("test_plan_id in", values, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotIn(List<String> values) {
addCriterion("test_plan_id not in", values, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdBetween(String value1, String value2) {
addCriterion("test_plan_id between", value1, value2, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotBetween(String value1, String value2) {
addCriterion("test_plan_id not between", value1, value2, "testPlanId");
return (Criteria) this;
}
public Criteria andCaseIdIsNull() {
addCriterion("case_id is null");
return (Criteria) this;
}
public Criteria andCaseIdIsNotNull() {
addCriterion("case_id is not null");
return (Criteria) this;
}
public Criteria andCaseIdEqualTo(String value) {
addCriterion("case_id =", value, "caseId");
return (Criteria) this;
}
public Criteria andCaseIdNotEqualTo(String value) {
addCriterion("case_id <>", value, "caseId");
return (Criteria) this;
}
public Criteria andCaseIdGreaterThan(String value) {
addCriterion("case_id >", value, "caseId");
return (Criteria) this;
}
public Criteria andCaseIdGreaterThanOrEqualTo(String value) {
addCriterion("case_id >=", value, "caseId");
return (Criteria) this;
}
public Criteria andCaseIdLessThan(String value) {
addCriterion("case_id <", value, "caseId");
return (Criteria) this;
}
public Criteria andCaseIdLessThanOrEqualTo(String value) {
addCriterion("case_id <=", value, "caseId");
return (Criteria) this;
}
public Criteria andCaseIdLike(String value) {
addCriterion("case_id like", value, "caseId");
return (Criteria) this;
}
public Criteria andCaseIdNotLike(String value) {
addCriterion("case_id not like", value, "caseId");
return (Criteria) this;
}
public Criteria andCaseIdIn(List<String> values) {
addCriterion("case_id in", values, "caseId");
return (Criteria) this;
}
public Criteria andCaseIdNotIn(List<String> values) {
addCriterion("case_id not in", values, "caseId");
return (Criteria) this;
}
public Criteria andCaseIdBetween(String value1, String value2) {
addCriterion("case_id between", value1, value2, "caseId");
return (Criteria) this;
}
public Criteria andCaseIdNotBetween(String value1, String value2) {
addCriterion("case_id not between", value1, value2, "caseId");
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 andDeletedIsNull() {
addCriterion("deleted is null");
return (Criteria) this;
}
public Criteria andDeletedIsNotNull() {
addCriterion("deleted is not null");
return (Criteria) this;
}
public Criteria andDeletedEqualTo(Boolean value) {
addCriterion("deleted =", value, "deleted");
return (Criteria) this;
}
public Criteria andDeletedNotEqualTo(Boolean value) {
addCriterion("deleted <>", value, "deleted");
return (Criteria) this;
}
public Criteria andDeletedGreaterThan(Boolean value) {
addCriterion("deleted >", value, "deleted");
return (Criteria) this;
}
public Criteria andDeletedGreaterThanOrEqualTo(Boolean value) {
addCriterion("deleted >=", value, "deleted");
return (Criteria) this;
}
public Criteria andDeletedLessThan(Boolean value) {
addCriterion("deleted <", value, "deleted");
return (Criteria) this;
}
public Criteria andDeletedLessThanOrEqualTo(Boolean value) {
addCriterion("deleted <=", value, "deleted");
return (Criteria) this;
}
public Criteria andDeletedIn(List<Boolean> values) {
addCriterion("deleted in", values, "deleted");
return (Criteria) this;
}
public Criteria andDeletedNotIn(List<Boolean> values) {
addCriterion("deleted not in", values, "deleted");
return (Criteria) this;
}
public Criteria andDeletedBetween(Boolean value1, Boolean value2) {
addCriterion("deleted between", value1, value2, "deleted");
return (Criteria) this;
}
public Criteria andDeletedNotBetween(Boolean value1, Boolean value2) {
addCriterion("deleted not between", value1, value2, "deleted");
return (Criteria) this;
}
public Criteria andNotifierIsNull() {
addCriterion("notifier is null");
return (Criteria) this;
}
public Criteria andNotifierIsNotNull() {
addCriterion("notifier is not null");
return (Criteria) this;
}
public Criteria andNotifierEqualTo(String value) {
addCriterion("notifier =", value, "notifier");
return (Criteria) this;
}
public Criteria andNotifierNotEqualTo(String value) {
addCriterion("notifier <>", value, "notifier");
return (Criteria) this;
}
public Criteria andNotifierGreaterThan(String value) {
addCriterion("notifier >", value, "notifier");
return (Criteria) this;
}
public Criteria andNotifierGreaterThanOrEqualTo(String value) {
addCriterion("notifier >=", value, "notifier");
return (Criteria) this;
}
public Criteria andNotifierLessThan(String value) {
addCriterion("notifier <", value, "notifier");
return (Criteria) this;
}
public Criteria andNotifierLessThanOrEqualTo(String value) {
addCriterion("notifier <=", value, "notifier");
return (Criteria) this;
}
public Criteria andNotifierLike(String value) {
addCriterion("notifier like", value, "notifier");
return (Criteria) this;
}
public Criteria andNotifierNotLike(String value) {
addCriterion("notifier not like", value, "notifier");
return (Criteria) this;
}
public Criteria andNotifierIn(List<String> values) {
addCriterion("notifier in", values, "notifier");
return (Criteria) this;
}
public Criteria andNotifierNotIn(List<String> values) {
addCriterion("notifier not in", values, "notifier");
return (Criteria) this;
}
public Criteria andNotifierBetween(String value1, String value2) {
addCriterion("notifier between", value1, value2, "notifier");
return (Criteria) this;
}
public Criteria andNotifierNotBetween(String value1, String value2) {
addCriterion("notifier not between", value1, value2, "notifier");
return (Criteria) this;
}
public Criteria andCreateUserIsNull() {
addCriterion("create_user is null");
return (Criteria) this;
}
public Criteria andCreateUserIsNotNull() {
addCriterion("create_user is not null");
return (Criteria) this;
}
public Criteria andCreateUserEqualTo(String value) {
addCriterion("create_user =", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotEqualTo(String value) {
addCriterion("create_user <>", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserGreaterThan(String value) {
addCriterion("create_user >", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserGreaterThanOrEqualTo(String value) {
addCriterion("create_user >=", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLessThan(String value) {
addCriterion("create_user <", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLessThanOrEqualTo(String value) {
addCriterion("create_user <=", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLike(String value) {
addCriterion("create_user like", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotLike(String value) {
addCriterion("create_user not like", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserIn(List<String> values) {
addCriterion("create_user in", values, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotIn(List<String> values) {
addCriterion("create_user not in", values, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserBetween(String value1, String value2) {
addCriterion("create_user between", value1, value2, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotBetween(String value1, String value2) {
addCriterion("create_user not between", value1, value2, "createUser");
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 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);
}
}
}

View File

@ -0,0 +1,40 @@
package io.metersphere.plan.mapper;
import io.metersphere.plan.domain.TestPlanCaseExecuteHistory;
import io.metersphere.plan.domain.TestPlanCaseExecuteHistoryExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TestPlanCaseExecuteHistoryMapper {
long countByExample(TestPlanCaseExecuteHistoryExample example);
int deleteByExample(TestPlanCaseExecuteHistoryExample example);
int deleteByPrimaryKey(String id);
int insert(TestPlanCaseExecuteHistory record);
int insertSelective(TestPlanCaseExecuteHistory record);
List<TestPlanCaseExecuteHistory> selectByExampleWithBLOBs(TestPlanCaseExecuteHistoryExample example);
List<TestPlanCaseExecuteHistory> selectByExample(TestPlanCaseExecuteHistoryExample example);
TestPlanCaseExecuteHistory selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") TestPlanCaseExecuteHistory record, @Param("example") TestPlanCaseExecuteHistoryExample example);
int updateByExampleWithBLOBs(@Param("record") TestPlanCaseExecuteHistory record, @Param("example") TestPlanCaseExecuteHistoryExample example);
int updateByExample(@Param("record") TestPlanCaseExecuteHistory record, @Param("example") TestPlanCaseExecuteHistoryExample example);
int updateByPrimaryKeySelective(TestPlanCaseExecuteHistory record);
int updateByPrimaryKeyWithBLOBs(TestPlanCaseExecuteHistory record);
int updateByPrimaryKey(TestPlanCaseExecuteHistory record);
int batchInsert(@Param("list") List<TestPlanCaseExecuteHistory> list);
int batchInsertSelective(@Param("list") List<TestPlanCaseExecuteHistory> list, @Param("selective") TestPlanCaseExecuteHistory.Column ... selective);
}

View File

@ -0,0 +1,394 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.plan.mapper.TestPlanCaseExecuteHistoryMapper">
<resultMap id="BaseResultMap" type="io.metersphere.plan.domain.TestPlanCaseExecuteHistory">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="test_plan_id" jdbcType="VARCHAR" property="testPlanId" />
<result column="case_id" jdbcType="VARCHAR" property="caseId" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="deleted" jdbcType="BIT" property="deleted" />
<result column="notifier" jdbcType="VARCHAR" property="notifier" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.plan.domain.TestPlanCaseExecuteHistory">
<result column="content" jdbcType="LONGVARBINARY" property="content" />
<result column="steps" jdbcType="LONGVARBINARY" property="steps" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, test_plan_id, case_id, `status`, deleted, notifier, create_user, create_time
</sql>
<sql id="Blob_Column_List">
content, steps
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.plan.domain.TestPlanCaseExecuteHistoryExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from test_plan_case_execute_history
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="io.metersphere.plan.domain.TestPlanCaseExecuteHistoryExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from test_plan_case_execute_history
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from test_plan_case_execute_history
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from test_plan_case_execute_history
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.plan.domain.TestPlanCaseExecuteHistoryExample">
delete from test_plan_case_execute_history
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.plan.domain.TestPlanCaseExecuteHistory">
insert into test_plan_case_execute_history (id, test_plan_id, case_id,
`status`, deleted, notifier,
create_user, create_time, content,
steps)
values (#{id,jdbcType=VARCHAR}, #{testPlanId,jdbcType=VARCHAR}, #{caseId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{deleted,jdbcType=BIT}, #{notifier,jdbcType=VARCHAR},
#{createUser,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{content,jdbcType=LONGVARBINARY},
#{steps,jdbcType=LONGVARBINARY})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.plan.domain.TestPlanCaseExecuteHistory">
insert into test_plan_case_execute_history
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="testPlanId != null">
test_plan_id,
</if>
<if test="caseId != null">
case_id,
</if>
<if test="status != null">
`status`,
</if>
<if test="deleted != null">
deleted,
</if>
<if test="notifier != null">
notifier,
</if>
<if test="createUser != null">
create_user,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="content != null">
content,
</if>
<if test="steps != null">
steps,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="testPlanId != null">
#{testPlanId,jdbcType=VARCHAR},
</if>
<if test="caseId != null">
#{caseId,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="deleted != null">
#{deleted,jdbcType=BIT},
</if>
<if test="notifier != null">
#{notifier,jdbcType=VARCHAR},
</if>
<if test="createUser != null">
#{createUser,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARBINARY},
</if>
<if test="steps != null">
#{steps,jdbcType=LONGVARBINARY},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.plan.domain.TestPlanCaseExecuteHistoryExample" resultType="java.lang.Long">
select count(*) from test_plan_case_execute_history
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update test_plan_case_execute_history
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.testPlanId != null">
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
</if>
<if test="record.caseId != null">
case_id = #{record.caseId,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
`status` = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.deleted != null">
deleted = #{record.deleted,jdbcType=BIT},
</if>
<if test="record.notifier != null">
notifier = #{record.notifier,jdbcType=VARCHAR},
</if>
<if test="record.createUser != null">
create_user = #{record.createUser,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARBINARY},
</if>
<if test="record.steps != null">
steps = #{record.steps,jdbcType=LONGVARBINARY},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update test_plan_case_execute_history
set id = #{record.id,jdbcType=VARCHAR},
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
case_id = #{record.caseId,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
deleted = #{record.deleted,jdbcType=BIT},
notifier = #{record.notifier,jdbcType=VARCHAR},
create_user = #{record.createUser,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
content = #{record.content,jdbcType=LONGVARBINARY},
steps = #{record.steps,jdbcType=LONGVARBINARY}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update test_plan_case_execute_history
set id = #{record.id,jdbcType=VARCHAR},
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
case_id = #{record.caseId,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
deleted = #{record.deleted,jdbcType=BIT},
notifier = #{record.notifier,jdbcType=VARCHAR},
create_user = #{record.createUser,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.plan.domain.TestPlanCaseExecuteHistory">
update test_plan_case_execute_history
<set>
<if test="testPlanId != null">
test_plan_id = #{testPlanId,jdbcType=VARCHAR},
</if>
<if test="caseId != null">
case_id = #{caseId,jdbcType=VARCHAR},
</if>
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="deleted != null">
deleted = #{deleted,jdbcType=BIT},
</if>
<if test="notifier != null">
notifier = #{notifier,jdbcType=VARCHAR},
</if>
<if test="createUser != null">
create_user = #{createUser,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="content != null">
content = #{content,jdbcType=LONGVARBINARY},
</if>
<if test="steps != null">
steps = #{steps,jdbcType=LONGVARBINARY},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.plan.domain.TestPlanCaseExecuteHistory">
update test_plan_case_execute_history
set test_plan_id = #{testPlanId,jdbcType=VARCHAR},
case_id = #{caseId,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
deleted = #{deleted,jdbcType=BIT},
notifier = #{notifier,jdbcType=VARCHAR},
create_user = #{createUser,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
content = #{content,jdbcType=LONGVARBINARY},
steps = #{steps,jdbcType=LONGVARBINARY}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.plan.domain.TestPlanCaseExecuteHistory">
update test_plan_case_execute_history
set test_plan_id = #{testPlanId,jdbcType=VARCHAR},
case_id = #{caseId,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
deleted = #{deleted,jdbcType=BIT},
notifier = #{notifier,jdbcType=VARCHAR},
create_user = #{createUser,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR}
</update>
<insert id="batchInsert" parameterType="map">
insert into test_plan_case_execute_history
(id, test_plan_id, case_id, `status`, deleted, notifier, create_user, create_time,
content, steps)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.testPlanId,jdbcType=VARCHAR}, #{item.caseId,jdbcType=VARCHAR},
#{item.status,jdbcType=VARCHAR}, #{item.deleted,jdbcType=BIT}, #{item.notifier,jdbcType=VARCHAR},
#{item.createUser,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.content,jdbcType=LONGVARBINARY},
#{item.steps,jdbcType=LONGVARBINARY})
</foreach>
</insert>
<insert id="batchInsertSelective" parameterType="map">
insert into test_plan_case_execute_history (
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
)
values
<foreach collection="list" item="item" separator=",">
(
<foreach collection="selective" item="column" separator=",">
<if test="'id'.toString() == column.value">
#{item.id,jdbcType=VARCHAR}
</if>
<if test="'test_plan_id'.toString() == column.value">
#{item.testPlanId,jdbcType=VARCHAR}
</if>
<if test="'case_id'.toString() == column.value">
#{item.caseId,jdbcType=VARCHAR}
</if>
<if test="'status'.toString() == column.value">
#{item.status,jdbcType=VARCHAR}
</if>
<if test="'deleted'.toString() == column.value">
#{item.deleted,jdbcType=BIT}
</if>
<if test="'notifier'.toString() == column.value">
#{item.notifier,jdbcType=VARCHAR}
</if>
<if test="'create_user'.toString() == column.value">
#{item.createUser,jdbcType=VARCHAR}
</if>
<if test="'create_time'.toString() == column.value">
#{item.createTime,jdbcType=BIGINT}
</if>
<if test="'content'.toString() == column.value">
#{item.content,jdbcType=LONGVARBINARY}
</if>
<if test="'steps'.toString() == column.value">
#{item.steps,jdbcType=LONGVARBINARY}
</if>
</foreach>
)
</foreach>
</insert>
</mapper>

View File

@ -42,6 +42,29 @@ CREATE INDEX idx_test_plan_id ON test_plan_allocation(test_plan_id);
ALTER TABLE test_plan_functional_case DROP COLUMN num; ALTER TABLE test_plan_functional_case DROP COLUMN num;
CREATE TABLE IF NOT EXISTS test_plan_case_execute_history(
`id` VARCHAR(50) NOT NULL COMMENT 'ID' ,
`test_plan_id` VARCHAR(50) NOT NULL COMMENT '测试计划ID' ,
`case_id` VARCHAR(50) NOT NULL COMMENT '用例ID' ,
`status` VARCHAR(64) NOT NULL COMMENT '执行结果:成功/失败/阻塞' ,
`content` LONGBLOB COMMENT '执行评论意见' ,
`steps` LONGBLOB COMMENT '用例步骤执行记录JSON)step_model 为 Step 时启用' ,
`deleted` BIT(1) NOT NULL DEFAULT 0 COMMENT '是否是取消关联或执行被删除的0-否1-是' ,
`notifier` VARCHAR(1000) COMMENT '通知人' ,
`create_user` VARCHAR(50) NOT NULL COMMENT '操作人' ,
`create_time` BIGINT NOT NULL COMMENT '操作时间' ,
PRIMARY KEY (id)
)ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci COMMENT = '功能用例执行历史表';
CREATE INDEX idx_case_id ON test_plan_case_execute_history(case_id);
CREATE INDEX idx_test_plan_id ON test_plan_case_execute_history(test_plan_id);
CREATE INDEX idx_test_plan_id_case_id ON test_plan_case_execute_history(test_plan_id,case_id);
CREATE INDEX idx_status ON test_plan_case_execute_history(status);
CREATE INDEX idx_deleted ON test_plan_case_execute_history(deleted);
-- set innodb lock wait timeout to default -- set innodb lock wait timeout to default
SET SESSION innodb_lock_wait_timeout = DEFAULT; SET SESSION innodb_lock_wait_timeout = DEFAULT;

View File

@ -6,6 +6,7 @@ import io.metersphere.dto.BugProviderDTO;
import io.metersphere.dto.TestCaseProviderDTO; import io.metersphere.dto.TestCaseProviderDTO;
import io.metersphere.functional.dto.FunctionalCaseTestDTO; import io.metersphere.functional.dto.FunctionalCaseTestDTO;
import io.metersphere.functional.dto.FunctionalCaseTestPlanDTO; import io.metersphere.functional.dto.FunctionalCaseTestPlanDTO;
import io.metersphere.functional.dto.TestPlanCaseExecuteHistoryDTO;
import io.metersphere.functional.request.AssociatePlanPageRequest; import io.metersphere.functional.request.AssociatePlanPageRequest;
import io.metersphere.functional.request.DisassociateOtherCaseRequest; import io.metersphere.functional.request.DisassociateOtherCaseRequest;
import io.metersphere.functional.request.FunctionalCaseTestRequest; import io.metersphere.functional.request.FunctionalCaseTestRequest;
@ -136,4 +137,12 @@ public class FunctionalTestCaseController {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize()); Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize());
return PageUtils.setPageInfo(page, functionalTestCaseService.hasAssociatePlanPage(request)); return PageUtils.setPageInfo(page, functionalTestCaseService.hasAssociatePlanPage(request));
} }
@GetMapping("/plan/comment/{caseId}")
@Operation(summary = "用例管理-功能用例-测试计划-获取执行评论历史")
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ)
@CheckOwner(resourceId = "#caseId", resourceType = "functional_case")
public List<TestPlanCaseExecuteHistoryDTO> getTestPlanCaseExecuteHistory(@PathVariable String caseId) {
return functionalTestCaseService.getTestPlanCaseExecuteHistory(caseId);
}
} }

View File

@ -0,0 +1,28 @@
package io.metersphere.functional.dto;
import io.metersphere.plan.domain.TestPlanCaseExecuteHistory;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class TestPlanCaseExecuteHistoryDTO extends TestPlanCaseExecuteHistory {
@Schema(description = "执行人头像")
private String userLogo;
@Schema(description = "执行人名")
private String userName;
@Schema(description = "执行人邮箱")
private String email;
@Schema(description = "执行解析内容")
private String contentText;
@Schema(description = "执行解析内容")
private String stepsText;
@Schema(description = "测试计划名称")
private String testPlanName;
}

View File

@ -2,6 +2,7 @@ package io.metersphere.functional.mapper;
import io.metersphere.functional.dto.FunctionalCaseTestDTO; import io.metersphere.functional.dto.FunctionalCaseTestDTO;
import io.metersphere.functional.dto.FunctionalCaseTestPlanDTO; import io.metersphere.functional.dto.FunctionalCaseTestPlanDTO;
import io.metersphere.functional.dto.TestPlanCaseExecuteHistoryDTO;
import io.metersphere.functional.request.AssociatePlanPageRequest; import io.metersphere.functional.request.AssociatePlanPageRequest;
import io.metersphere.functional.request.DisassociateOtherCaseRequest; import io.metersphere.functional.request.DisassociateOtherCaseRequest;
import io.metersphere.functional.request.FunctionalCaseTestRequest; import io.metersphere.functional.request.FunctionalCaseTestRequest;
@ -17,4 +18,6 @@ public interface ExtFunctionalCaseTestMapper {
List<FunctionalCaseTestPlanDTO> getPlanList(@Param("request") AssociatePlanPageRequest request); List<FunctionalCaseTestPlanDTO> getPlanList(@Param("request") AssociatePlanPageRequest request);
List<TestPlanCaseExecuteHistoryDTO>getPlanExecuteHistoryList(@Param("caseId") String caseId, @Param("planId") String planId);
} }

View File

@ -76,6 +76,34 @@
</include> </include>
</select> </select>
<select id="getPlanExecuteHistoryList" resultType="io.metersphere.functional.dto.TestPlanCaseExecuteHistoryDTO">
SELECT
tpceh.id,
tpceh.test_plan_id,
tpceh.case_id,
tpceh.status,
tpceh.notifier,
tpceh.create_user,
tpceh.create_time,
tpceh.content,
tpceh.deleted,
tpceh.steps,
u.name as userName,
ux.avatar as userLogo,
tp.name as testPlanName,
u.email as email
FROM
test_plan_case_execute_history tpceh
left join user u on tpceh.create_user = u.id
left join user_extend ux on tpceh.create_user = ux.id
left join test_plan tp on tpceh.test_plan_id = tp.id
where tpceh.case_id = #{caseId}
<if test="planId != null and planId != ''">
and tpceh.test_plan_id = #{planId}
</if>
order by tpceh.create_time desc
</select>
<sql id="queryWhereConditionByBaseQueryRequest"> <sql id="queryWhereConditionByBaseQueryRequest">
<if test="request.condition.keyword != null and request.sourceType == 'API'"> <if test="request.condition.keyword != null and request.sourceType == 'API'">
functional_case_test.source_id not in functional_case_test.source_id not in

View File

@ -9,6 +9,7 @@ import io.metersphere.functional.domain.FunctionalCaseTest;
import io.metersphere.functional.domain.FunctionalCaseTestExample; import io.metersphere.functional.domain.FunctionalCaseTestExample;
import io.metersphere.functional.dto.FunctionalCaseTestDTO; import io.metersphere.functional.dto.FunctionalCaseTestDTO;
import io.metersphere.functional.dto.FunctionalCaseTestPlanDTO; import io.metersphere.functional.dto.FunctionalCaseTestPlanDTO;
import io.metersphere.functional.dto.TestPlanCaseExecuteHistoryDTO;
import io.metersphere.functional.mapper.ExtFunctionalCaseModuleMapper; import io.metersphere.functional.mapper.ExtFunctionalCaseModuleMapper;
import io.metersphere.functional.mapper.ExtFunctionalCaseTestMapper; import io.metersphere.functional.mapper.ExtFunctionalCaseTestMapper;
import io.metersphere.functional.mapper.FunctionalCaseTestMapper; import io.metersphere.functional.mapper.FunctionalCaseTestMapper;
@ -32,6 +33,7 @@ import org.redisson.api.IdGenerator;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -254,4 +256,17 @@ public class FunctionalTestCaseService {
public List<FunctionalCaseTestPlanDTO> hasAssociatePlanPage(AssociatePlanPageRequest request) { public List<FunctionalCaseTestPlanDTO> hasAssociatePlanPage(AssociatePlanPageRequest request) {
return extFunctionalCaseTestMapper.getPlanList(request); return extFunctionalCaseTestMapper.getPlanList(request);
} }
public List<TestPlanCaseExecuteHistoryDTO> getTestPlanCaseExecuteHistory(String caseId) {
List<TestPlanCaseExecuteHistoryDTO> planExecuteHistoryList = extFunctionalCaseTestMapper.getPlanExecuteHistoryList(caseId, null);
for (TestPlanCaseExecuteHistoryDTO planCaseExecuteHistoryDTO : planExecuteHistoryList) {
if (planCaseExecuteHistoryDTO.getContent() != null) {
planCaseExecuteHistoryDTO.setContentText(new String(planCaseExecuteHistoryDTO.getContent(), StandardCharsets.UTF_8));
}
if (planCaseExecuteHistoryDTO.getSteps() != null) {
planCaseExecuteHistoryDTO.setStepsText(new String(planCaseExecuteHistoryDTO.getSteps(), StandardCharsets.UTF_8));
}
}
return planExecuteHistoryList;
}
} }

View File

@ -13,35 +13,45 @@ import io.metersphere.functional.domain.FunctionalCase;
import io.metersphere.functional.domain.FunctionalCaseTest; import io.metersphere.functional.domain.FunctionalCaseTest;
import io.metersphere.functional.dto.FunctionalCaseTestDTO; import io.metersphere.functional.dto.FunctionalCaseTestDTO;
import io.metersphere.functional.dto.FunctionalCaseTestPlanDTO; import io.metersphere.functional.dto.FunctionalCaseTestPlanDTO;
import io.metersphere.functional.dto.TestPlanCaseExecuteHistoryDTO;
import io.metersphere.functional.mapper.FunctionalCaseMapper; import io.metersphere.functional.mapper.FunctionalCaseMapper;
import io.metersphere.functional.mapper.FunctionalCaseTestMapper; import io.metersphere.functional.mapper.FunctionalCaseTestMapper;
import io.metersphere.functional.request.AssociatePlanPageRequest; import io.metersphere.functional.request.AssociatePlanPageRequest;
import io.metersphere.functional.request.DisassociateOtherCaseRequest; import io.metersphere.functional.request.DisassociateOtherCaseRequest;
import io.metersphere.functional.request.FunctionalCaseTestRequest; import io.metersphere.functional.request.FunctionalCaseTestRequest;
import io.metersphere.plan.domain.TestPlanCaseExecuteHistory;
import io.metersphere.plan.mapper.TestPlanCaseExecuteHistoryMapper;
import io.metersphere.provider.BaseAssociateApiProvider; import io.metersphere.provider.BaseAssociateApiProvider;
import io.metersphere.provider.BaseAssociateBugProvider; import io.metersphere.provider.BaseAssociateBugProvider;
import io.metersphere.provider.BaseAssociateScenarioProvider; import io.metersphere.provider.BaseAssociateScenarioProvider;
import io.metersphere.request.*; import io.metersphere.request.*;
import io.metersphere.sdk.constants.FunctionalCaseExecuteResult; import io.metersphere.sdk.constants.FunctionalCaseExecuteResult;
import io.metersphere.sdk.constants.SessionConstants;
import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.JSON;
import io.metersphere.system.base.BaseTest; import io.metersphere.system.base.BaseTest;
import io.metersphere.system.controller.handler.ResultHolder; import io.metersphere.system.controller.handler.ResultHolder;
import io.metersphere.system.dto.sdk.BaseTreeNode; import io.metersphere.system.dto.sdk.BaseTreeNode;
import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.Pager;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.*; import org.junit.jupiter.api.*;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlConfig; import org.springframework.test.context.jdbc.SqlConfig;
import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@AutoConfigureMockMvc @AutoConfigureMockMvc
@ -67,6 +77,7 @@ public class FunctionalTestCaseControllerTests extends BaseTest {
private static final String URL_ASSOCIATE_TEST_PLAN_PAGE = "/functional/case/test/has/associate/plan/page"; private static final String URL_ASSOCIATE_TEST_PLAN_PAGE = "/functional/case/test/has/associate/plan/page";
private static final String URL_TEST_PLAN_EXECUTE_HISTORY = "/functional/case/test/plan/comment/";
@Resource @Resource
@ -90,6 +101,9 @@ public class FunctionalTestCaseControllerTests extends BaseTest {
@Resource @Resource
BaseAssociateBugProvider baseAssociateBugProvider; BaseAssociateBugProvider baseAssociateBugProvider;
@Resource
private TestPlanCaseExecuteHistoryMapper testPlanCaseExecuteHistoryMapper;
@Test @Test
@Order(1) @Order(1)
@ -548,4 +562,47 @@ public class FunctionalTestCaseControllerTests extends BaseTest {
List<FunctionalCaseTestPlanDTO> list = tableData.getList(); List<FunctionalCaseTestPlanDTO> list = tableData.getList();
Assertions.assertEquals(2, list.size()); Assertions.assertEquals(2, list.size());
} }
@Test
@Order(13)
public void testPlanExecuteHistoryList() throws Exception {
TestPlanCaseExecuteHistory testPlanCaseExecuteHistory = new TestPlanCaseExecuteHistory();
testPlanCaseExecuteHistory.setTestPlanId("test_plan_associate_case_gyq_two");
testPlanCaseExecuteHistory.setCaseId("gyq_associate_function_case");
testPlanCaseExecuteHistory.setCreateUser("admin");
testPlanCaseExecuteHistory.setStatus(FunctionalCaseReviewStatus.RE_REVIEWED.toString());
testPlanCaseExecuteHistory.setId("test");
String content = "你好评论";
testPlanCaseExecuteHistory.setContent(content.getBytes());
testPlanCaseExecuteHistory.setCreateTime(System.currentTimeMillis());
testPlanCaseExecuteHistoryMapper.insertSelective(testPlanCaseExecuteHistory);
List<TestPlanCaseExecuteHistoryDTO> gyqReviewCaseTest = getPlanExecuteHistoryList("gyq_associate_function_case");
Assertions.assertTrue(StringUtils.isNotBlank(gyqReviewCaseTest.get(0).getContentText()));
testPlanCaseExecuteHistory = new TestPlanCaseExecuteHistory();
testPlanCaseExecuteHistory.setTestPlanId("test_plan_associate_case_gyq_two");
testPlanCaseExecuteHistory.setCaseId("gyq_associate_function_case");
testPlanCaseExecuteHistory.setCreateUser("admin");
testPlanCaseExecuteHistory.setStatus(FunctionalCaseReviewStatus.RE_REVIEWED.toString());
testPlanCaseExecuteHistory.setId("testNoContent");
testPlanCaseExecuteHistory.setCreateTime(System.currentTimeMillis());
String steps = "你好评论";
testPlanCaseExecuteHistory.setSteps(steps.getBytes());
testPlanCaseExecuteHistory.setCreateTime(System.currentTimeMillis());
testPlanCaseExecuteHistoryMapper.insertSelective(testPlanCaseExecuteHistory);
gyqReviewCaseTest = getPlanExecuteHistoryList("gyq_associate_function_case");
Assertions.assertTrue(gyqReviewCaseTest.size()>1);
}
public List<TestPlanCaseExecuteHistoryDTO> getPlanExecuteHistoryList(String caseId) throws Exception {
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(URL_TEST_PLAN_EXECUTE_HISTORY + caseId).header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
.header(SessionConstants.CURRENT_PROJECT, DEFAULT_PROJECT_ID)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
String contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
return JSON.parseArray(JSON.toJSONString(resultHolder.getData()), TestPlanCaseExecuteHistoryDTO.class);
}
} }

View File

@ -1,6 +1,7 @@
package io.metersphere.system.config.interceptor; package io.metersphere.system.config.interceptor;
import io.metersphere.plan.domain.TestPlanAllocation; import io.metersphere.plan.domain.TestPlanAllocation;
import io.metersphere.plan.domain.TestPlanCaseExecuteHistory;
import io.metersphere.sdk.util.CompressUtils; import io.metersphere.sdk.util.CompressUtils;
import io.metersphere.system.utils.MybatisInterceptorConfig; import io.metersphere.system.utils.MybatisInterceptorConfig;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -16,6 +17,8 @@ public class TestPlanInterceptor {
List<MybatisInterceptorConfig> configList = new ArrayList<>(); List<MybatisInterceptorConfig> configList = new ArrayList<>();
configList.add(new MybatisInterceptorConfig(TestPlanAllocation.class, "runModeConfig", CompressUtils.class, "zip", "unzip")); configList.add(new MybatisInterceptorConfig(TestPlanAllocation.class, "runModeConfig", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(TestPlanCaseExecuteHistory.class, "content", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(TestPlanCaseExecuteHistory.class, "steps", CompressUtils.class, "zip", "unzip"));
return configList; return configList;
} }