fix(Mock期望): #1007531 【接口测试】mock期望列表增加序号列

--bug=1007531 --user=宋天阳 【接口测试】mock期望列表增加序号列
https://www.tapd.cn/55049933/s/1062529
This commit is contained in:
song-tianyang 2021-11-01 18:54:12 +08:00 committed by song-tianyang
parent 04b1e49b0c
commit 213e9d0d01
12 changed files with 529 additions and 347 deletions

View File

@ -19,6 +19,8 @@ public class MockExpectConfigResponse {
private String id;
private String expectNum;
private String mockConfigId;
private String name;
@ -40,6 +42,7 @@ public class MockExpectConfigResponse {
public MockExpectConfigResponse(MockExpectConfigWithBLOBs expectConfig) {
this.id = expectConfig.getId();
this.mockConfigId = expectConfig.getMockConfigId();
this.expectNum = expectConfig.getExpectNum();
this.name = expectConfig.getName();
this.status = Boolean.parseBoolean(expectConfig.getStatus());
this.createTime = expectConfig.getCreateTime();

View File

@ -657,7 +657,7 @@ public class ApiDefinitionService {
apiDefinition.setId(UUID.randomUUID().toString());
apiDefinition.setOrder(getImportNextOrder(apiTestImportRequest.getProjectId()));
reSetImportCasesApiId(cases, originId, apiDefinition.getId());
reSetImportMocksApiId(mocks, originId, apiDefinition.getId());
reSetImportMocksApiId(mocks, originId, apiDefinition.getId(), apiDefinition.getNum());
if (StringUtils.equalsIgnoreCase(apiDefinition.getProtocol(), RequestType.HTTP)) {
batchMapper.insert(apiDefinition);
String request = setImportHashTree(apiDefinition);
@ -716,13 +716,16 @@ public class ApiDefinitionService {
}
}
private void reSetImportMocksApiId(List<MockConfigImportDTO> mocks, String originId, String newId) {
private void reSetImportMocksApiId(List<MockConfigImportDTO> mocks, String originId, String newId, int apiNum) {
if (CollectionUtils.isNotEmpty(mocks)) {
mocks.forEach(item -> {
int index = 1;
for(MockConfigImportDTO item : mocks){
if (StringUtils.equals(item.getApiId(), originId)) {
item.setApiId(newId);
}
});
item.setExpectNum(apiNum+"_"+index);
index++;
}
}
}

View File

@ -14,7 +14,6 @@ import io.metersphere.api.dto.mock.RequestMockParams;
import io.metersphere.api.dto.mockconfig.MockConfigImportDTO;
import io.metersphere.api.dto.mockconfig.MockConfigRequest;
import io.metersphere.api.dto.mockconfig.MockExpectConfigRequest;
import io.metersphere.api.dto.mockconfig.response.JsonSchemaReturnObj;
import io.metersphere.api.dto.mockconfig.response.MockConfigResponse;
import io.metersphere.api.dto.mockconfig.response.MockExpectConfigResponse;
import io.metersphere.base.domain.*;
@ -44,6 +43,7 @@ import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
@ -109,15 +109,38 @@ public class MockConfigService {
expectConfigResponseList.add(response);
}
MockConfigResponse returnRsp = new MockConfigResponse(config, expectConfigResponseList);
return returnRsp;
return new MockConfigResponse(config, expectConfigResponseList);
} else {
return new MockConfigResponse(null, new ArrayList<>());
}
}
public void initExpectNum(){
MockExpectConfigExample example = new MockExpectConfigExample();
example.createCriteria().andExpectNumIsNull();
List<MockExpectConfigWithBLOBs> mockExpectConfigList = mockExpectConfigMapper.selectByExampleWithBLOBs(example);
Map<String,List<MockExpectConfigWithBLOBs>> mockConfigIdMap = mockExpectConfigList.stream().collect(Collectors.groupingBy(MockExpectConfig::getMockConfigId));
for (Map.Entry<String, List<MockExpectConfigWithBLOBs>> entry :
mockConfigIdMap.entrySet()) {
String mockConfigId = entry.getKey();
List<MockExpectConfigWithBLOBs> list = entry.getValue();
String apiNum = extMockExpectConfigMapper.selectApiNumberByMockConfigId(mockConfigId);
if(StringUtils.isEmpty(apiNum) || StringUtils.equalsIgnoreCase(apiNum,"null")){
continue;
}
int expectNumIndex = this.getMockExpectNumIndex(mockConfigId,apiNum);
for (MockExpectConfigWithBLOBs config : list) {
config.setExpectNum(apiNum+"_"+expectNumIndex);
mockExpectConfigMapper.updateByPrimaryKeySelective(config);
expectNumIndex ++;
}
}
}
public MockConfigResponse genMockConfig(MockConfigRequest request) {
MockConfigResponse returnRsp = null;
MockConfigResponse returnRsp;
MockConfigExample example = new MockConfigExample();
MockConfigExample.Criteria criteria = example.createCriteria();
@ -193,8 +216,11 @@ public class MockConfigService {
this.checkNameIsExists(request);
}
long timeStmp = System.currentTimeMillis();
String expectNum = this.getMockExpectId(request.getMockConfigId());
MockExpectConfigWithBLOBs model = new MockExpectConfigWithBLOBs();
model.setId(request.getId());
model.setExpectNum(expectNum);
model.setMockConfigId(request.getMockConfigId());
model.setUpdateTime(timeStmp);
model.setStatus(request.getStatus());
@ -223,6 +249,54 @@ public class MockConfigService {
return model;
}
private String getMockExpectId(String mockConfigId) {
List<String> savedExpectNumber = extMockExpectConfigMapper.selectExlectNumByMockConfigId(mockConfigId);
String apiNum = extMockExpectConfigMapper.selectApiNumberByMockConfigId(mockConfigId);
if(StringUtils.isEmpty(apiNum)){
apiNum = "";
}else {
apiNum = apiNum + "_";
}
int index = 1;
for(String expectNum : savedExpectNumber){
if(StringUtils.startsWith(expectNum,apiNum)){
String numStr = StringUtils.substringAfter(expectNum,apiNum);
try{
int savedIndex = Integer.parseInt(numStr);
if(index <= savedIndex){
index = savedIndex+1;
}
}catch (Exception ignored){}
}
}
return apiNum + index;
}
private int getMockExpectNumIndex(String mockConfigId,String apiNumber) {
List<String> savedExpectNumber = extMockExpectConfigMapper.selectExlectNumByMockConfigId(mockConfigId);
String apiNum = apiNumber;
if(StringUtils.isEmpty(apiNum)){
apiNum = "";
}else {
apiNum = apiNum + "_";
}
int index = 1;
for(String expectNum : savedExpectNumber){
if(StringUtils.startsWith(expectNum,apiNum)){
String numStr = StringUtils.substringAfter(expectNum,apiNum);
try{
int savedIndex = Integer.parseInt(numStr);
if(index <= savedIndex){
index = savedIndex+1;
}
}catch (Exception ignored ){}
}
}
return index;
}
private void checkNameIsExists(MockExpectConfigRequest request) {
MockExpectConfigExample example = new MockExpectConfigExample();
example.createCriteria().andMockConfigIdEqualTo(request.getMockConfigId()).andNameEqualTo(request.getName().trim()).andIdNotEqualTo(request.getId());
@ -259,14 +333,14 @@ public class MockConfigService {
continue;
}
JSONObject mockExpectRequestObj = model.getRequest();
boolean mathing = false;
boolean isMatch;
if (mockExpectRequestObj.containsKey("params")) {
mathing = this.isRequestMockExpectMatchingByParams(requestHeaderMap, mockExpectRequestObj, requestMockParams);
isMatch = this.isRequestMockExpectMatchingByParams(requestHeaderMap, mockExpectRequestObj, requestMockParams);
} else {
mathing = this.isRequestMockExpectMatching(mockExpectRequestObj, requestMockParams.getQueryParamsObj());
isMatch = this.isRequestMockExpectMatching(mockExpectRequestObj, requestMockParams.getQueryParamsObj());
}
if (mathing) {
if (isMatch) {
returnModel = model;
break;
}

View File

@ -1,7 +1,6 @@
package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
@ -22,5 +21,7 @@ public class MockExpectConfig implements Serializable {
private String createUserId;
private String expectNum;
private static final long serialVersionUID = 1L;
}

View File

@ -643,6 +643,76 @@ public class MockExpectConfigExample {
addCriterion("create_user_id not between", value1, value2, "createUserId");
return (Criteria) this;
}
public Criteria andExpectNumIsNull() {
addCriterion("expect_num is null");
return (Criteria) this;
}
public Criteria andExpectNumIsNotNull() {
addCriterion("expect_num is not null");
return (Criteria) this;
}
public Criteria andExpectNumEqualTo(String value) {
addCriterion("expect_num =", value, "expectNum");
return (Criteria) this;
}
public Criteria andExpectNumNotEqualTo(String value) {
addCriterion("expect_num <>", value, "expectNum");
return (Criteria) this;
}
public Criteria andExpectNumGreaterThan(String value) {
addCriterion("expect_num >", value, "expectNum");
return (Criteria) this;
}
public Criteria andExpectNumGreaterThanOrEqualTo(String value) {
addCriterion("expect_num >=", value, "expectNum");
return (Criteria) this;
}
public Criteria andExpectNumLessThan(String value) {
addCriterion("expect_num <", value, "expectNum");
return (Criteria) this;
}
public Criteria andExpectNumLessThanOrEqualTo(String value) {
addCriterion("expect_num <=", value, "expectNum");
return (Criteria) this;
}
public Criteria andExpectNumLike(String value) {
addCriterion("expect_num like", value, "expectNum");
return (Criteria) this;
}
public Criteria andExpectNumNotLike(String value) {
addCriterion("expect_num not like", value, "expectNum");
return (Criteria) this;
}
public Criteria andExpectNumIn(List<String> values) {
addCriterion("expect_num in", values, "expectNum");
return (Criteria) this;
}
public Criteria andExpectNumNotIn(List<String> values) {
addCriterion("expect_num not in", values, "expectNum");
return (Criteria) this;
}
public Criteria andExpectNumBetween(String value1, String value2) {
addCriterion("expect_num between", value1, value2, "expectNum");
return (Criteria) this;
}
public Criteria andExpectNumNotBetween(String value1, String value2) {
addCriterion("expect_num not between", value1, value2, "expectNum");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -1,7 +1,6 @@
package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

View File

@ -3,9 +3,7 @@ package io.metersphere.base.mapper;
import io.metersphere.base.domain.MockExpectConfig;
import io.metersphere.base.domain.MockExpectConfigExample;
import io.metersphere.base.domain.MockExpectConfigWithBLOBs;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface MockExpectConfigMapper {

View File

@ -1,345 +1,356 @@
<?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.base.mapper.MockExpectConfigMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.MockExpectConfig">
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="mock_config_id" jdbcType="VARCHAR" property="mockConfigId"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="tags" jdbcType="VARCHAR" property="tags"/>
<result column="STATUS" jdbcType="VARCHAR" property="status"/>
<result column="create_time" jdbcType="BIGINT" property="createTime"/>
<result column="update_time" jdbcType="BIGINT" property="updateTime"/>
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs"
type="io.metersphere.base.domain.MockExpectConfigWithBLOBs">
<result column="request" jdbcType="LONGVARCHAR" property="request"/>
<result column="response" jdbcType="LONGVARCHAR" property="response"/>
</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>
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.MockExpectConfig">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="mock_config_id" jdbcType="VARCHAR" property="mockConfigId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="tags" jdbcType="VARCHAR" property="tags" />
<result column="STATUS" jdbcType="VARCHAR" property="status" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId" />
<result column="expect_num" jdbcType="VARCHAR" property="expectNum" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.MockExpectConfigWithBLOBs">
<result column="request" jdbcType="LONGVARCHAR" property="request" />
<result column="response" jdbcType="LONGVARCHAR" property="response" />
</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>
</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>
</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>
</where>
</sql>
<sql id="Base_Column_List">
id, mock_config_id, `name`, tags, `STATUS`, create_time, update_time, create_user_id
</sql>
<sql id="Blob_Column_List">
request, response
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.MockExpectConfigExample"
resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</trim>
</if>
<include refid="Base_Column_List"/>
,
<include refid="Blob_Column_List"/>
from mock_expect_config
<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.base.domain.MockExpectConfigExample"
resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List"/>
from mock_expect_config
<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 mock_expect_config
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete
from mock_expect_config
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.MockExpectConfigExample">
delete from mock_expect_config
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.MockExpectConfigWithBLOBs">
insert into mock_expect_config (id, mock_config_id, `name`,
tags, `STATUS`, create_time,
update_time, create_user_id, request,
response)
values (#{id,jdbcType=VARCHAR}, #{mockConfigId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{tags,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT}, #{createUserId,jdbcType=VARCHAR}, #{request,jdbcType=LONGVARCHAR},
#{response,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.MockExpectConfigWithBLOBs">
insert into mock_expect_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="mockConfigId != null">
mock_config_id,
</if>
<if test="name != null">
`name`,
</if>
<if test="tags != null">
tags,
</if>
<if test="status != null">
`STATUS`,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="createUserId != null">
create_user_id,
</if>
<if test="request != null">
request,
</if>
<if test="response != null">
response,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="mockConfigId != null">
#{mockConfigId,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="tags != null">
#{tags,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
<if test="createUserId != null">
#{createUserId,jdbcType=VARCHAR},
</if>
<if test="request != null">
#{request,jdbcType=LONGVARCHAR},
</if>
<if test="response != null">
#{response,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.MockExpectConfigExample"
resultType="java.lang.Long">
select count(*) from mock_expect_config
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update mock_expect_config
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.mockConfigId != null">
mock_config_id = #{record.mockConfigId,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
`name` = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.tags != null">
tags = #{record.tags,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
`STATUS` = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
<if test="record.createUserId != null">
create_user_id = #{record.createUserId,jdbcType=VARCHAR},
</if>
<if test="record.request != null">
request = #{record.request,jdbcType=LONGVARCHAR},
</if>
<if test="record.response != null">
response = #{record.response,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update mock_expect_config
set id = #{record.id,jdbcType=VARCHAR},
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, mock_config_id, `name`, tags, `STATUS`, create_time, update_time, create_user_id,
expect_num
</sql>
<sql id="Blob_Column_List">
request, response
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.MockExpectConfigExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from mock_expect_config
<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.base.domain.MockExpectConfigExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from mock_expect_config
<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 mock_expect_config
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from mock_expect_config
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.MockExpectConfigExample">
delete from mock_expect_config
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.MockExpectConfigWithBLOBs">
insert into mock_expect_config (id, mock_config_id, `name`,
tags, `STATUS`, create_time,
update_time, create_user_id, expect_num,
request, response)
values (#{id,jdbcType=VARCHAR}, #{mockConfigId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{tags,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT}, #{createUserId,jdbcType=VARCHAR}, #{expectNum,jdbcType=VARCHAR},
#{request,jdbcType=LONGVARCHAR}, #{response,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.MockExpectConfigWithBLOBs">
insert into mock_expect_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="mockConfigId != null">
mock_config_id,
</if>
<if test="name != null">
`name`,
</if>
<if test="tags != null">
tags,
</if>
<if test="status != null">
`STATUS`,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="createUserId != null">
create_user_id,
</if>
<if test="expectNum != null">
expect_num,
</if>
<if test="request != null">
request,
</if>
<if test="response != null">
response,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="mockConfigId != null">
#{mockConfigId,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="tags != null">
#{tags,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
<if test="createUserId != null">
#{createUserId,jdbcType=VARCHAR},
</if>
<if test="expectNum != null">
#{expectNum,jdbcType=VARCHAR},
</if>
<if test="request != null">
#{request,jdbcType=LONGVARCHAR},
</if>
<if test="response != null">
#{response,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.MockExpectConfigExample" resultType="java.lang.Long">
select count(*) from mock_expect_config
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update mock_expect_config
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.mockConfigId != null">
mock_config_id = #{record.mockConfigId,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
`name` = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.tags != null">
tags = #{record.tags,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
`STATUS` = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
<if test="record.createUserId != null">
create_user_id = #{record.createUserId,jdbcType=VARCHAR},
</if>
<if test="record.expectNum != null">
expect_num = #{record.expectNum,jdbcType=VARCHAR},
</if>
<if test="record.request != null">
request = #{record.request,jdbcType=LONGVARCHAR},
response = #{record.response,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByExample" parameterType="map">
update mock_expect_config
set id = #{record.id,jdbcType=VARCHAR},
mock_config_id = #{record.mockConfigId,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
tags = #{record.tags,jdbcType=VARCHAR},
`STATUS` = #{record.status,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
create_user_id = #{record.createUserId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.MockExpectConfigWithBLOBs">
update mock_expect_config
<set>
<if test="mockConfigId != null">
mock_config_id = #{mockConfigId,jdbcType=VARCHAR},
</if>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="tags != null">
tags = #{tags,jdbcType=VARCHAR},
</if>
<if test="status != null">
`STATUS` = #{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
</if>
<if test="createUserId != null">
create_user_id = #{createUserId,jdbcType=VARCHAR},
</if>
<if test="request != null">
request = #{request,jdbcType=LONGVARCHAR},
</if>
<if test="response != null">
response = #{response,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.MockExpectConfigWithBLOBs">
update mock_expect_config
set mock_config_id = #{mockConfigId,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
tags = #{tags,jdbcType=VARCHAR},
`STATUS` = #{status,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
create_user_id = #{createUserId,jdbcType=VARCHAR},
request = #{request,jdbcType=LONGVARCHAR},
response = #{response,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.MockExpectConfig">
update mock_expect_config
set mock_config_id = #{mockConfigId,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
tags = #{tags,jdbcType=VARCHAR},
`STATUS` = #{status,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
create_user_id = #{createUserId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</if>
<if test="record.response != null">
response = #{record.response,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update mock_expect_config
set id = #{record.id,jdbcType=VARCHAR},
mock_config_id = #{record.mockConfigId,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
tags = #{record.tags,jdbcType=VARCHAR},
`STATUS` = #{record.status,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
create_user_id = #{record.createUserId,jdbcType=VARCHAR},
expect_num = #{record.expectNum,jdbcType=VARCHAR},
request = #{record.request,jdbcType=LONGVARCHAR},
response = #{record.response,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update mock_expect_config
set id = #{record.id,jdbcType=VARCHAR},
mock_config_id = #{record.mockConfigId,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
tags = #{record.tags,jdbcType=VARCHAR},
`STATUS` = #{record.status,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
create_user_id = #{record.createUserId,jdbcType=VARCHAR},
expect_num = #{record.expectNum,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.MockExpectConfigWithBLOBs">
update mock_expect_config
<set>
<if test="mockConfigId != null">
mock_config_id = #{mockConfigId,jdbcType=VARCHAR},
</if>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="tags != null">
tags = #{tags,jdbcType=VARCHAR},
</if>
<if test="status != null">
`STATUS` = #{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
</if>
<if test="createUserId != null">
create_user_id = #{createUserId,jdbcType=VARCHAR},
</if>
<if test="expectNum != null">
expect_num = #{expectNum,jdbcType=VARCHAR},
</if>
<if test="request != null">
request = #{request,jdbcType=LONGVARCHAR},
</if>
<if test="response != null">
response = #{response,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.MockExpectConfigWithBLOBs">
update mock_expect_config
set mock_config_id = #{mockConfigId,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
tags = #{tags,jdbcType=VARCHAR},
`STATUS` = #{status,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
create_user_id = #{createUserId,jdbcType=VARCHAR},
expect_num = #{expectNum,jdbcType=VARCHAR},
request = #{request,jdbcType=LONGVARCHAR},
response = #{response,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.MockExpectConfig">
update mock_expect_config
set mock_config_id = #{mockConfigId,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
tags = #{tags,jdbcType=VARCHAR},
`STATUS` = #{status,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
create_user_id = #{createUserId,jdbcType=VARCHAR},
expect_num = #{expectNum,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -12,4 +12,8 @@ public interface ExtMockExpectConfigMapper {
List<MockExpectConfigWithBLOBs> selectByApiId(String apiId);
List<MockExpectConfigWithBLOBs> selectByApiIdIn(@Param("values") List<String> apiIds);
List<String> selectExlectNumByMockConfigId(String mockConfigId);
String selectApiNumberByMockConfigId(String mockConfigId);
}

View File

@ -21,4 +21,14 @@
</foreach>
)
</select>
<select id="selectExlectNumByMockConfigId" resultType="java.lang.String">
SELECT expect_num FROM mock_expect_config WHERE mock_config_id = #{0}
</select>
<select id="selectApiNumberByMockConfigId" resultType="java.lang.String">
SELECT num FROM api_definition WHERE id IN (
select api_id from mock_config WHERE id = #{0}
)
</select>
</mapper>

View File

@ -5,6 +5,7 @@ import io.metersphere.api.jmeter.NewDriverManager;
import io.metersphere.api.service.ApiAutomationService;
import io.metersphere.api.service.ApiDefinitionService;
import io.metersphere.api.service.ApiTestCaseService;
import io.metersphere.api.service.MockConfigService;
import io.metersphere.base.domain.JarConfig;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.RunInterface;
@ -63,6 +64,8 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve
private ApiDefinitionService apiDefinitionService;
@Resource
private TestReviewTestCaseService testReviewTestCaseService;
@Resource
private MockConfigService mockConfigService;
@Value("${jmeter.home}")
private String jmeterHome;
@ -132,7 +135,7 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve
initOnceOperate(testPlanLoadCaseService::initOrderField, "init.sort.plan.api.load");
initOnceOperate(testReviewTestCaseService::initOrderField, "init.sort.review.test.case");
initOnceOperate(apiDefinitionService::initDefaultModuleId, "init.default.module.id");
initOnceOperate(mockConfigService::initExpectNum,"init.mock.expectNum");
}
/**

View File

@ -21,6 +21,12 @@
ref="table"
>
<ms-table-column
prop="expectNum"
:label="$t('commons.id')"
min-width="120px">
</ms-table-column>
<ms-table-column
prop="name"
:label="$t('api_test.mock.table.name')"