This is an automated email from the ASF dual-hosted git repository.

zhangzicheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 80b515e0d [Task] add mockrequestrecord (#4029) (#4221)
80b515e0d is described below

commit 80b515e0d7a445113e67b1e28d84fd00f6f34aef
Author: mahaitao <[email protected]>
AuthorDate: Wed Nov 30 15:42:17 2022 +0800

    [Task] add mockrequestrecord (#4029) (#4221)
    
    * feat:add mockrequestrecord
    
    * feat:fix checkstyle
    
    * feat:fix unit test
    
    * feat:fix
    
    Co-authored-by: mahaitao617 <[email protected]>
    Co-authored-by: dragon-zhang <[email protected]>
---
 .../controller/MockRequestRecordController.java    |  96 ++++
 .../admin/mapper/MockRequestRecordMapper.java      |  15 +
 .../admin/model/dto/MockRequestRecordDTO.java      | 308 ++++++++++++
 .../admin/model/query/MockRequestRecordQuery.java  | 201 ++++++++
 .../org/apache/shenyu/admin/model/vo/ApiVO.java    |   1 -
 .../shenyu/admin/model/vo/MockRequestRecordVO.java | 518 +++++++++++++++++++++
 .../admin/service/MockRequestRecordService.java    |  71 +++
 .../shenyu/admin/service/impl/ApiServiceImpl.java  |   1 -
 .../service/impl/MockRequestRecordServiceImpl.java | 123 +++++
 .../mappers/mock-request-record-sqlmap.xml         |  32 ++
 .../MockRequestRecordControllerTest.java           | 112 +++++
 .../admin/mapper/MockRequestRecordMapperTest.java  |  56 ++-
 .../service/MockRequestRecordServiceTest.java      | 118 +++++
 13 files changed, 1635 insertions(+), 17 deletions(-)

diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/MockRequestRecordController.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/MockRequestRecordController.java
new file mode 100644
index 000000000..e653f06fd
--- /dev/null
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/MockRequestRecordController.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.controller;
+
+import java.util.List;
+import javax.validation.Valid;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import org.apache.shenyu.admin.model.dto.MockRequestRecordDTO;
+import org.apache.shenyu.admin.model.page.PageParameter;
+import org.apache.shenyu.admin.model.query.MockRequestRecordQuery;
+import org.apache.shenyu.admin.model.result.ShenyuAdminResult;
+import org.apache.shenyu.admin.service.MockRequestRecordService;
+import org.apache.shenyu.admin.utils.ShenyuResultMessage;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * AlertTemplate MockRequestRecordController.
+ */
+@Validated
+@RestController
+@RequestMapping("/mock")
+public class MockRequestRecordController {
+
+    private final MockRequestRecordService mockRequestRecordService;
+
+    public MockRequestRecordController(final MockRequestRecordService 
mockRequestRecordService) {
+        this.mockRequestRecordService = mockRequestRecordService;
+    }
+
+    /**
+     * create or update mockRequestRecord.
+     *
+     * @param mockRequestRecordDTO mockRequestRecordDTO.
+     * @return {@linkplain ShenyuAdminResult}
+     */
+    @PostMapping("/insertOrUpdate")
+    public ShenyuAdminResult createOrUpdate(@Valid @RequestBody final 
MockRequestRecordDTO mockRequestRecordDTO) {
+        return ShenyuAdminResult.success(ShenyuResultMessage.SUCCESS, 
mockRequestRecordService.createOrUpdate(mockRequestRecordDTO));
+    }
+
+    /**
+     * batch delete.
+     * @param ids ids
+     * @return {@linkplain ShenyuAdminResult}
+     */
+    @DeleteMapping("/batchDelete")
+    public ShenyuAdminResult batchDelete(@RequestBody @NotEmpty final 
List<@NotBlank String> ids) {
+        Integer deleteCount = mockRequestRecordService.batchDelete(ids);
+        return ShenyuAdminResult.success(ShenyuResultMessage.DELETE_SUCCESS, 
deleteCount);
+    }
+
+    /**
+     * findPageByQuery.
+     * @param apiId apiId
+     * @param host host
+     * @param url url
+     * @param pathVariable pathVariable
+     * @param header header
+     * @param currentPage currentPage
+     * @param pageSize pageSize
+     * @return ShenyuAdminResult
+     */
+    @GetMapping("/findPageByQuery")
+    public ShenyuAdminResult listByPage(final String apiId, final String host, 
final String url,
+                                        final String pathVariable, final 
String header,
+                                        @RequestParam @NotNull(message = 
"currentPage not null") final Integer currentPage,
+                                        @RequestParam @NotNull(message = 
"pageSize not null") final Integer pageSize) {
+        PageParameter pageParameter = new PageParameter(currentPage, pageSize);
+        return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS, 
this.mockRequestRecordService.listByPage(new MockRequestRecordQuery(apiId, 
host, url,
+                pathVariable, header, pageParameter)));
+    }
+}
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/MockRequestRecordMapper.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/MockRequestRecordMapper.java
index d84ec4414..63cb3a9b5 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/MockRequestRecordMapper.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/MockRequestRecordMapper.java
@@ -20,6 +20,7 @@ package org.apache.shenyu.admin.mapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.shenyu.admin.model.entity.MockRequestRecordDO;
+import org.apache.shenyu.admin.model.query.MockRequestRecordQuery;
 import org.apache.shenyu.admin.validation.ExistProvider;
 
 import java.io.Serializable;
@@ -103,5 +104,19 @@ public interface MockRequestRecordMapper extends 
ExistProvider {
      */
     int deleteById(String id);
 
+    /**
+     * batchDelete.
+     * @param ids ids
+     * @return Number of rows deleted
+     */
+    int batchDelete(List<String> ids);
+
+    /**
+     * selectByQuery.
+     * @param mockRequestRecordQuery mockRequestRecordQuery
+     * @return list of MockRequestRecordDO
+     */
+    List<MockRequestRecordDO> selectByQuery(MockRequestRecordQuery 
mockRequestRecordQuery);
+
 }
 
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/MockRequestRecordDTO.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/MockRequestRecordDTO.java
new file mode 100644
index 000000000..057011cf4
--- /dev/null
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/MockRequestRecordDTO.java
@@ -0,0 +1,308 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.model.dto;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Objects;
+import org.apache.shenyu.admin.mapper.MockRequestRecordMapper;
+import org.apache.shenyu.admin.validation.annotation.Existed;
+
+/**
+ * this is mockrequestrecord from by web front.
+ */
+public class MockRequestRecordDTO implements Serializable {
+
+    private static final long serialVersionUID = -6779456713216687114L;
+
+    /**
+     * primary key.
+     */
+    private String id;
+
+    /**
+     * apiId.
+     */
+    @Existed(provider = MockRequestRecordMapper.class, nullOfIgnore = true, 
message = "the apiId is not exited")
+    private String apiId;
+
+    /**
+     * the request host.
+     */
+    private String host;
+
+    /**
+     * the request port.
+     */
+    private Integer port;
+
+    /**
+     * whole url,such as curl http://domain//test1/**?param=test .
+     */
+    private String url;
+
+    /**
+     * the request param in url.
+     */
+    private String pathVariable;
+
+    /**
+     * the request param after url.
+     */
+    private String query;
+
+    /**
+     * the request param in header.
+     */
+    private String header;
+
+    /**
+     * the request body.
+     */
+    private String body;
+
+    /**
+     * create time.
+     */
+    private Date dateCreated;
+
+    /**
+     * update time.
+     */
+    private Date dateUpdated;
+
+    /**
+     * getId.
+     *
+     * @return id
+     */
+    public String getId() {
+        return id;
+    }
+
+    /**
+     * set id.
+     *
+     * @param id id
+     */
+    public void setId(final String id) {
+        this.id = id;
+    }
+
+    /**
+     * Gets the value of apiId.
+     *
+     * @return the value of apiId
+     */
+    public String getApiId() {
+        return apiId;
+    }
+
+    /**
+     * Sets the apiId.
+     *
+     * @param apiId apiId
+     */
+    public void setApiId(final String apiId) {
+        this.apiId = apiId;
+    }
+
+    /**
+     * Gets the value of host.
+     *
+     * @return the value of host
+     */
+    public String getHost() {
+        return host;
+    }
+
+    /**
+     * Sets the host.
+     *
+     * @param host host
+     */
+    public void setHost(final String host) {
+        this.host = host;
+    }
+
+    /**
+     * Gets the value of port.
+     *
+     * @return the value of port
+     */
+    public Integer getPort() {
+        return port;
+    }
+
+    /**
+     * Sets the port.
+     *
+     * @param port port
+     */
+    public void setPort(final Integer port) {
+        this.port = port;
+    }
+
+    /**
+     * Gets the value of url.
+     *
+     * @return the value of url
+     */
+    public String getUrl() {
+        return url;
+    }
+
+    /**
+     * Sets the url.
+     *
+     * @param url url
+     */
+    public void setUrl(final String url) {
+        this.url = url;
+    }
+
+    /**
+     * Gets the value of pathVariable.
+     *
+     * @return the value of pathVariable
+     */
+    public String getPathVariable() {
+        return pathVariable;
+    }
+
+    /**
+     * Sets the pathVariable.
+     *
+     * @param pathVariable pathVariable
+     */
+    public void setPathVariable(final String pathVariable) {
+        this.pathVariable = pathVariable;
+    }
+
+    /**
+     * Gets the value of query.
+     *
+     * @return the value of query
+     */
+    public String getQuery() {
+        return query;
+    }
+
+    /**
+     * Sets the query.
+     *
+     * @param query query
+     */
+    public void setQuery(final String query) {
+        this.query = query;
+    }
+
+    /**
+     * Gets the value of header.
+     *
+     * @return the value of header
+     */
+    public String getHeader() {
+        return header;
+    }
+
+    /**
+     * Sets the header.
+     *
+     * @param header header
+     */
+    public void setHeader(final String header) {
+        this.header = header;
+    }
+
+    /**
+     * Gets the value of body.
+     *
+     * @return the value of body
+     */
+    public String getBody() {
+        return body;
+    }
+
+    /**
+     * Sets the body.
+     *
+     * @param body body
+     */
+    public void setBody(final String body) {
+        this.body = body;
+    }
+
+    /**
+     * getDateCreated.
+     *
+     * @return dateCreated
+     */
+    public Date getDateCreated() {
+        return dateCreated;
+    }
+
+    /**
+     * setDateCreated.
+     *
+     * @param dateCreated dateCreated
+     */
+    public void setDateCreated(final Date dateCreated) {
+        this.dateCreated = dateCreated;
+    }
+
+    /**
+     * getDateUpdated.
+     *
+     * @return dateUpdated
+     */
+    public Date getDateUpdated() {
+        return dateUpdated;
+    }
+
+    /**
+     * setDateUpdated.
+     *
+     * @param dateUpdated dateUpdated
+     */
+    public void setDateUpdated(final Date dateUpdated) {
+        this.dateUpdated = dateUpdated;
+    }
+
+    @Override
+    public boolean equals(final Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof MockRequestRecordDTO)) {
+            return false;
+        }
+        MockRequestRecordDTO dto = (MockRequestRecordDTO) o;
+        return Objects.equals(id, dto.id) && Objects.equals(apiId, 
dto.getApiId())
+                && Objects.equals(host, dto.getHost()) && 
Objects.equals(pathVariable, dto.getPathVariable())
+                && Objects.equals(query, dto.getQuery()) && 
Objects.equals(header, dto.getHeader())
+                && Objects.equals(body, dto.getBody()) && 
Objects.equals(dateCreated, dto.dateCreated)
+                && Objects.equals(dateUpdated, dto.dateUpdated);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id, apiId, host, pathVariable, query, header, 
body, dateCreated, dateUpdated);
+    }
+
+}
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/MockRequestRecordQuery.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/MockRequestRecordQuery.java
new file mode 100644
index 000000000..87b9ce422
--- /dev/null
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/MockRequestRecordQuery.java
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.model.query;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.apache.shenyu.admin.model.page.PageParameter;
+
+/**
+ * this is mock request record query.
+ */
+public class MockRequestRecordQuery implements Serializable {
+
+    private static final long serialVersionUID = 6736947701814601503L;
+
+    /**
+     * the api id.
+     */
+    private String apiId;
+
+    /**
+     * the request host.
+     */
+    private String host;
+
+    /**
+     * the request url.
+     */
+    private String url;
+
+    /**
+     * the request param in url.
+     */
+    private String pathVariable;
+
+    /**
+     * the request param after url.
+     */
+    private String header;
+
+    /**
+     * page parameter.
+     */
+    private PageParameter pageParameter;
+
+    public MockRequestRecordQuery() {
+
+    }
+
+    public MockRequestRecordQuery(final String apiId, final String host, final 
String url,
+                                  final String pathVariable, final String 
header, final PageParameter pageParameter) {
+        this.apiId = apiId;
+        this.host = host;
+        this.url = url;
+        this.pageParameter = pageParameter;
+        this.pathVariable = pathVariable;
+        this.header = header;
+    }
+
+    /**
+     * Gets the value of apiId.
+     *
+     * @return the value of apiId
+     */
+    public String getApiId() {
+        return apiId;
+    }
+
+    /**
+     * Sets the apiId.
+     *
+     * @param apiId apiId
+     */
+    public void setApiId(final String apiId) {
+        this.apiId = apiId;
+    }
+
+    /**
+     * Gets the value of host.
+     *
+     * @return the value of host
+     */
+    public String getHost() {
+        return host;
+    }
+
+    /**
+     * Sets the host.
+     *
+     * @param host host
+     */
+    public void setHost(final String host) {
+        this.host = host;
+    }
+
+    /**
+     * Gets the value of url.
+     *
+     * @return the value of url
+     */
+    public String getUrl() {
+        return url;
+    }
+
+    /**
+     * Sets the url.
+     *
+     * @param url url
+     */
+    public void setUrl(final String url) {
+        this.url = url;
+    }
+
+    /**
+     * Gets the value of pathVariable.
+     *
+     * @return the value of pathVariable
+     */
+    public String getPathVariable() {
+        return pathVariable;
+    }
+
+    /**
+     * Sets the pathVariable.
+     *
+     * @param pathVariable pathVariable
+     */
+    public void setPathVariable(final String pathVariable) {
+        this.pathVariable = pathVariable;
+    }
+
+    /**
+     * Gets the value of header.
+     *
+     * @return the value of header
+     */
+    public String getHeader() {
+        return header;
+    }
+
+    /**
+     * Sets the header.
+     *
+     * @param header header
+     */
+    public void setHeader(final String header) {
+        this.header = header;
+    }
+
+    /**
+     * get pageParameter.
+     *
+     * @return pageParameter
+     */
+    public PageParameter getPageParameter() {
+        return pageParameter;
+    }
+
+    /**
+     * set pageParameter.
+     *
+     * @param pageParameter pageParameter
+     */
+    public void setPageParameter(final PageParameter pageParameter) {
+        this.pageParameter = pageParameter;
+    }
+
+    @Override
+    public boolean equals(final Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof MockRequestRecordQuery)) {
+            return false;
+        }
+        MockRequestRecordQuery mockRequestRecordQuery = 
(MockRequestRecordQuery) o;
+        return apiId.equals(mockRequestRecordQuery.apiId) && 
header.equals(mockRequestRecordQuery.getHeader())
+                && host.equals(mockRequestRecordQuery.getHost()) && 
url.equals(mockRequestRecordQuery.getUrl())
+                && 
pathVariable.equals(mockRequestRecordQuery.getPathVariable());
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(apiId, header, host, url, pathVariable);
+    }
+}
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/ApiVO.java 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/ApiVO.java
index 941515aa8..c264e4a6b 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/ApiVO.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/ApiVO.java
@@ -426,7 +426,6 @@ public class ApiVO implements Serializable {
         this.dateUpdated = dateUpdated;
     }
 
-
     /**
      * getTags.
      *
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/MockRequestRecordVO.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/MockRequestRecordVO.java
new file mode 100644
index 000000000..f38bd5bff
--- /dev/null
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/MockRequestRecordVO.java
@@ -0,0 +1,518 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.model.vo;
+
+import java.io.Serializable;
+import org.apache.shenyu.admin.model.entity.MockRequestRecordDO;
+
+/**
+ * MockRequestRecordVO.
+ */
+public class MockRequestRecordVO implements Serializable {
+    private static final long serialVersionUID = -7675972300371815619L;
+
+    /**
+     * primary key id.
+     */
+    private String id;
+
+    /**
+     * the api id.
+     */
+    private String apiId;
+
+    /**
+     * the request host.
+     */
+    private String host;
+
+    /**
+     * the request port.
+     */
+    private Integer port;
+
+    /**
+     * the request url.
+     */
+    private String url;
+
+    /**
+     * the request param in url.
+     */
+    private String pathVariable;
+
+    /**
+     * the request param after url.
+     */
+    private String query;
+
+    /**
+     * the request param in header.
+     */
+    private String header;
+
+    /**
+     * the request body.
+     */
+    private String body;
+
+    /**
+     * dateCreated.
+     */
+    private String dateCreated;
+
+    /**
+     * dateUpdated.
+     */
+    private String dateUpdated;
+
+    public MockRequestRecordVO() {
+    }
+
+    public MockRequestRecordVO(final String id, final String apiId, final 
String host, final Integer port,
+                               final String url, final String pathVariable, 
final String query, final String header,
+                               final String body, final String dateCreated, 
final String dateUpdated) {
+        this.id = id;
+        this.apiId = apiId;
+        this.host = host;
+        this.port = port;
+        this.url = url;
+        this.pathVariable = pathVariable;
+        this.query = query;
+        this.header = header;
+        this.body = body;
+        this.dateCreated = dateCreated;
+        this.dateUpdated = dateUpdated;
+    }
+
+    /**
+     * getId.
+     *
+     * @return id
+     */
+    public String getId() {
+        return id;
+    }
+
+    /**
+     * set id.
+     *
+     * @param id id
+     */
+    public void setId(final String id) {
+        this.id = id;
+    }
+
+    /**
+     * Gets the value of apiId.
+     *
+     * @return the value of apiId
+     */
+    public String getApiId() {
+        return apiId;
+    }
+
+    /**
+     * Sets the apiId.
+     *
+     * @param apiId apiId
+     */
+    public void setApiId(final String apiId) {
+        this.apiId = apiId;
+    }
+
+    /**
+     * Gets the value of host.
+     *
+     * @return the value of host
+     */
+    public String getHost() {
+        return host;
+    }
+
+    /**
+     * Sets the host.
+     *
+     * @param host host
+     */
+    public void setHost(final String host) {
+        this.host = host;
+    }
+
+    /**
+     * Gets the value of port.
+     *
+     * @return the value of port
+     */
+    public Integer getPort() {
+        return port;
+    }
+
+    /**
+     * Sets the port.
+     *
+     * @param port port
+     */
+    public void setPort(final Integer port) {
+        this.port = port;
+    }
+
+    /**
+     * Gets the value of url.
+     *
+     * @return the value of url
+     */
+    public String getUrl() {
+        return url;
+    }
+
+    /**
+     * Sets the url.
+     *
+     * @param url url
+     */
+    public void setUrl(final String url) {
+        this.url = url;
+    }
+
+    /**
+     * Gets the value of pathVariable.
+     *
+     * @return the value of pathVariable
+     */
+    public String getPathVariable() {
+        return pathVariable;
+    }
+
+    /**
+     * Sets the pathVariable.
+     *
+     * @param pathVariable pathVariable
+     */
+    public void setPathVariable(final String pathVariable) {
+        this.pathVariable = pathVariable;
+    }
+
+    /**
+     * Gets the value of query.
+     *
+     * @return the value of query
+     */
+    public String getQuery() {
+        return query;
+    }
+
+    /**
+     * Sets the query.
+     *
+     * @param query query
+     */
+    public void setQuery(final String query) {
+        this.query = query;
+    }
+
+    /**
+     * Gets the value of header.
+     *
+     * @return the value of header
+     */
+    public String getHeader() {
+        return header;
+    }
+
+    /**
+     * Sets the header.
+     *
+     * @param header header
+     */
+    public void setHeader(final String header) {
+        this.header = header;
+    }
+
+    /**
+     * Gets the value of body.
+     *
+     * @return the value of body
+     */
+    public String getBody() {
+        return body;
+    }
+
+    /**
+     * Sets the body.
+     *
+     * @param body body
+     */
+    public void setBody(final String body) {
+        this.body = body;
+    }
+
+    /**
+     * Gets the value of dateCreated.
+     *
+     * @return the value of dateCreated
+     */
+    public String getDateCreated() {
+        return dateCreated;
+    }
+
+    /**
+     * Sets the dateCreated.
+     *
+     * @param dateCreated dateCreated
+     */
+    public void setDateCreated(final String dateCreated) {
+        this.dateCreated = dateCreated;
+    }
+
+    /**
+     * Gets the value of dateUpdated.
+     *
+     * @return the value of dateUpdated
+     */
+    public String getDateUpdated() {
+        return dateUpdated;
+    }
+
+    /**
+     * Sets the dateUpdated.
+     *
+     * @param dateUpdated dateUpdated
+     */
+    public void setDateUpdated(final String dateUpdated) {
+        this.dateUpdated = dateUpdated;
+    }
+
+    /**
+     * builder.
+     *
+     * @return ApiVOBuilder
+     */
+    public static MockRequestRecordVO.MockRequestRecordVOBuilder builder() {
+        return new MockRequestRecordVO.MockRequestRecordVOBuilder();
+    }
+
+    /**
+     * buildMockRequestRecordVO.
+     * @param mockRequestRecordDO mockRequestRecordDO
+     * @return MockRequestRecordVO
+     */
+    public static MockRequestRecordVO buildMockRequestRecordVO(final 
MockRequestRecordDO mockRequestRecordDO) {
+        return MockRequestRecordVO.builder()
+                .id(mockRequestRecordDO.getId())
+                .apiId(mockRequestRecordDO.getApiId())
+                .header(mockRequestRecordDO.getHeader())
+                .host(mockRequestRecordDO.getHost())
+                .port(mockRequestRecordDO.getPort())
+                .query(mockRequestRecordDO.getQuery())
+                .pathVariable(mockRequestRecordDO.getPathVariable())
+                .url(mockRequestRecordDO.getUrl())
+                .body(mockRequestRecordDO.getBody())
+                .dateCreated("")
+                .dateUpdated("")
+                .build();
+    }
+
+    public static final class MockRequestRecordVOBuilder {
+        /**
+         * primary key id.
+         */
+        private String id;
+
+        /**
+         * the api id.
+         */
+        private String apiId;
+
+        /**
+         * the request host.
+         */
+        private String host;
+
+        /**
+         * the request port.
+         */
+        private Integer port;
+
+        /**
+         * the request url.
+         */
+        private String url;
+
+        /**
+         * the request param in url.
+         */
+        private String pathVariable;
+
+        /**
+         * the request param after url.
+         */
+        private String query;
+
+        /**
+         * the request param in header.
+         */
+        private String header;
+
+        /**
+         * the request body.
+         */
+        private String body;
+
+        /**
+         * dateCreated.
+         */
+        private String dateCreated;
+
+        /**
+         * dateUpdated.
+         */
+        private String dateUpdated;
+
+        /**
+         * set id.
+         * @param id id
+         * @return MockRequestRecordVOBuilder
+         */
+        public MockRequestRecordVOBuilder id(final String id) {
+            this.id = id;
+            return this;
+        }
+
+        /**
+         * set apiId.
+         * @param apiId apiId
+         * @return MockRequestRecordVOBuilder
+         */
+        public MockRequestRecordVOBuilder apiId(final String apiId) {
+            this.apiId = apiId;
+            return this;
+        }
+
+        /**
+         * set host.
+         * @param host host
+         * @return MockRequestRecordVOBuilder
+         */
+        public MockRequestRecordVOBuilder host(final String host) {
+            this.host = host;
+            return this;
+        }
+
+        /**
+         * set port.
+         * @param port port
+         * @return MockRequestRecordVOBuilder
+         */
+        public MockRequestRecordVOBuilder port(final Integer port) {
+            this.port = port;
+            return this;
+        }
+
+        /**
+         * set url.
+         * @param url url
+         * @return MockRequestRecordVOBuilder
+         */
+        public MockRequestRecordVOBuilder url(final String url) {
+            this.url = url;
+            return this;
+        }
+
+        /**
+         * set pathVariable.
+         * @param pathVariable pathVariable
+         * @return MockRequestRecordVOBuilder
+         */
+        public MockRequestRecordVOBuilder pathVariable(final String 
pathVariable) {
+            this.pathVariable = pathVariable;
+            return this;
+        }
+
+        /**
+         * set query.
+         * @param query query
+         * @return MockRequestRecordVOBuilder
+         */
+        public MockRequestRecordVOBuilder query(final String query) {
+            this.query = query;
+            return this;
+        }
+
+        /**
+         * set header.
+         * @param header header
+         * @return MockRequestRecordVOBuilder
+         */
+        public MockRequestRecordVOBuilder header(final String header) {
+            this.header = header;
+            return this;
+        }
+
+        /**
+         * set body.
+         * @param body body
+         * @return MockRequestRecordVOBuilder
+         */
+        public MockRequestRecordVOBuilder body(final String body) {
+            this.body = body;
+            return this;
+        }
+
+        /**
+         * set dateCreated.
+         * @param dateCreated dateCreated
+         * @return MockRequestRecordVOBuilder
+         */
+        public MockRequestRecordVOBuilder dateCreated(final String 
dateCreated) {
+            this.dateCreated = dateCreated;
+            return this;
+        }
+
+        /**
+         * set dateUpdated.
+         * @param dateUpdated dateUpdated.
+         * @return MockRequestRecordVOBuilder
+         */
+        public MockRequestRecordVOBuilder dateUpdated(final String 
dateUpdated) {
+            this.dateUpdated = dateUpdated;
+            return this;
+        }
+
+        /**
+         * build.
+         * @return MockRequestRecordVO
+         */
+        public MockRequestRecordVO build() {
+            MockRequestRecordVO mockRequestRecordVO = new 
MockRequestRecordVO();
+            mockRequestRecordVO.setId(id);
+            mockRequestRecordVO.setApiId(apiId);
+            mockRequestRecordVO.setDateCreated(dateCreated);
+            mockRequestRecordVO.setDateUpdated(dateUpdated);
+            mockRequestRecordVO.setHeader(header);
+            mockRequestRecordVO.setHost(host);
+            mockRequestRecordVO.setQuery(query);
+            mockRequestRecordVO.setBody(body);
+            mockRequestRecordVO.setUrl(url);
+            mockRequestRecordVO.setPort(port);
+            mockRequestRecordVO.setPathVariable(pathVariable);
+            return mockRequestRecordVO;
+        }
+    }
+
+}
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/MockRequestRecordService.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/MockRequestRecordService.java
new file mode 100644
index 000000000..e5b797c25
--- /dev/null
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/MockRequestRecordService.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.service;
+
+import java.util.List;
+import org.apache.shenyu.admin.model.dto.MockRequestRecordDTO;
+import org.apache.shenyu.admin.model.page.CommonPager;
+import org.apache.shenyu.admin.model.query.MockRequestRecordQuery;
+import org.apache.shenyu.admin.model.vo.MockRequestRecordVO;
+import org.apache.shenyu.admin.model.vo.PluginVO;
+
+/**
+ * this is mock request record service.
+ */
+public interface MockRequestRecordService {
+
+    /**
+     *  createOrUpdate.
+     * @param mockRequestRecordDTO mockRequestRecordDTO
+     * @return rows
+     */
+    int createOrUpdate(MockRequestRecordDTO mockRequestRecordDTO);
+
+    /**
+     * Delete string.
+     *
+     * @param id the key
+     * @return the string
+     */
+    int delete(String id);
+
+    /**
+     * batch delete.
+     * @param ids ids
+     * @return delete rows
+     */
+    int batchDelete(List<String> ids);
+
+    /**
+     * find mockrequestrecord by id.
+     *
+     * @param id pk.
+     * @return {@linkplain PluginVO}
+     */
+    MockRequestRecordVO findById(String id);
+
+
+    /**
+     * find page of api by query.
+     *
+     * @param mockRequestRecordQuery {@linkplain MockRequestRecordQuery}
+     * @return {@linkplain CommonPager}
+     */
+    CommonPager<MockRequestRecordVO> listByPage(MockRequestRecordQuery 
mockRequestRecordQuery);
+
+}
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ApiServiceImpl.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ApiServiceImpl.java
index 3aa1cd07f..b312f3cbc 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ApiServiceImpl.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ApiServiceImpl.java
@@ -90,7 +90,6 @@ public class ApiServiceImpl implements ApiService {
                         .id(UUIDUtils.getInstance().generateShortUuid())
                         .apiId(apiDO.getId())
                         .tagId(tagId)
-                        .dateCreated(currentTime)
                         .dateUpdated(currentTime)
                         .build());
             }
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/MockRequestRecordServiceImpl.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/MockRequestRecordServiceImpl.java
new file mode 100644
index 000000000..ab689437e
--- /dev/null
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/MockRequestRecordServiceImpl.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.service.impl;
+
+import java.sql.Timestamp;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shenyu.admin.mapper.MockRequestRecordMapper;
+import org.apache.shenyu.admin.model.dto.MockRequestRecordDTO;
+import org.apache.shenyu.admin.model.entity.MockRequestRecordDO;
+import org.apache.shenyu.admin.model.page.CommonPager;
+import org.apache.shenyu.admin.model.page.PageResultUtils;
+import org.apache.shenyu.admin.model.query.MockRequestRecordQuery;
+import org.apache.shenyu.admin.model.vo.MockRequestRecordVO;
+import org.apache.shenyu.admin.service.MockRequestRecordService;
+import org.springframework.stereotype.Service;
+
+/**
+ * Implementation of the {@link MockRequestRecordService}.
+ */
+@Service
+public class MockRequestRecordServiceImpl implements MockRequestRecordService {
+
+    private final MockRequestRecordMapper mockRequestRecordMapper;
+
+    public MockRequestRecordServiceImpl(final MockRequestRecordMapper 
mockRequestRecordMapper) {
+        this.mockRequestRecordMapper = mockRequestRecordMapper;
+
+    }
+
+    @Override
+    public int createOrUpdate(final MockRequestRecordDTO mockRequestRecordDTO) 
{
+        return StringUtils.isBlank(mockRequestRecordDTO.getId()) ? 
this.create(mockRequestRecordDTO) : this.update(mockRequestRecordDTO);
+    }
+
+    @Override
+    public int delete(final String id) {
+        MockRequestRecordDO mockRequestRecordDO = 
mockRequestRecordMapper.queryById(id);
+        if (mockRequestRecordDO == null) {
+            return 0;
+        }
+        return mockRequestRecordMapper.deleteById(id);
+    }
+
+    @Override
+    public int batchDelete(final List<String> ids) {
+        return mockRequestRecordMapper.batchDelete(ids);
+    }
+
+    @Override
+    public MockRequestRecordVO findById(final String id) {
+        MockRequestRecordVO mockRequestRecordVO = new MockRequestRecordVO();
+        if (StringUtils.isBlank(id)) {
+            return mockRequestRecordVO;
+        }
+        MockRequestRecordDO mockRequestRecordDO = 
mockRequestRecordMapper.queryById(id);
+        if (mockRequestRecordDO == null) {
+            return mockRequestRecordVO;
+        }
+        return 
MockRequestRecordVO.buildMockRequestRecordVO(mockRequestRecordDO);
+    }
+
+    @Override
+    public CommonPager<MockRequestRecordVO> listByPage(final 
MockRequestRecordQuery mockRequestRecordQuery) {
+        List<MockRequestRecordDO> list = 
mockRequestRecordMapper.selectByQuery(mockRequestRecordQuery);
+        return 
PageResultUtils.result(mockRequestRecordQuery.getPageParameter(), () -> 
list.stream().map(MockRequestRecordVO::buildMockRequestRecordVO).collect(Collectors.toList()));
+    }
+
+    private int update(final MockRequestRecordDTO mockRequestRecordDTO) {
+        if (mockRequestRecordDTO == null || mockRequestRecordDTO.getId() == 
null) {
+            return 0;
+        }
+        Timestamp currentTime = new Timestamp(System.currentTimeMillis());
+        MockRequestRecordDO mockRequestRecordDO = MockRequestRecordDO.builder()
+                .id(mockRequestRecordDTO.getId())
+                .apiId(mockRequestRecordDTO.getApiId())
+                .header(mockRequestRecordDTO.getHeader())
+                .host(mockRequestRecordDTO.getHost())
+                .query(mockRequestRecordDTO.getQuery())
+                .url(mockRequestRecordDTO.getUrl())
+                .pathVariable(mockRequestRecordDTO.getPathVariable())
+                .body(mockRequestRecordDTO.getBody())
+                .dateUpdated(currentTime)
+                .build();
+        return mockRequestRecordMapper.update(mockRequestRecordDO);
+    }
+
+    private int create(final MockRequestRecordDTO mockRequestRecordDTO) {
+        if (mockRequestRecordDTO == null) {
+            return 0;
+        }
+        Timestamp currentTime = new Timestamp(System.currentTimeMillis());
+        MockRequestRecordDO mockRequestRecordDO = MockRequestRecordDO.builder()
+                .id(mockRequestRecordDTO.getId())
+                .apiId(mockRequestRecordDTO.getApiId())
+                .header(mockRequestRecordDTO.getHeader())
+                .host(mockRequestRecordDTO.getHost())
+                .query(mockRequestRecordDTO.getQuery())
+                .url(mockRequestRecordDTO.getUrl())
+                .pathVariable(mockRequestRecordDTO.getPathVariable())
+                .body(mockRequestRecordDTO.getBody())
+                .dateUpdated(currentTime)
+                .dateCreated(currentTime)
+                .build();
+        return mockRequestRecordMapper.insert(mockRequestRecordDO);
+    }
+}
diff --git 
a/shenyu-admin/src/main/resources/mappers/mock-request-record-sqlmap.xml 
b/shenyu-admin/src/main/resources/mappers/mock-request-record-sqlmap.xml
index 48a4f64e5..3d574d588 100644
--- a/shenyu-admin/src/main/resources/mappers/mock-request-record-sqlmap.xml
+++ b/shenyu-admin/src/main/resources/mappers/mock-request-record-sqlmap.xml
@@ -42,6 +42,30 @@
         where id = #{id}
     </select>
 
+    <select id="selectByQuery" 
parameterType="org.apache.shenyu.admin.model.query.MockRequestRecordQuery"
+            resultMap="MockRequestRecordMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM mock_request_record
+        <where>
+            <if test="apiId != null">
+               and api_id = #{apiId, jdbcType=VARCHAR}
+            </if>
+            <if test="host != null">
+              and  `host` = #{host, jdbcType=VARCHAR}
+            </if>
+            <if test="url != null">
+              and  `url` = #{url, jdbcType=VARCHAR}
+            </if>
+            <if test="pathVariable != null">
+              and  path_variable = #{pathVariable, jdbcType=VARCHAR}
+            </if>
+            <if test="header != null">
+              and  `header` = #{header, jdbcType=VARCHAR}
+            </if>
+        </where>
+    </select>
+
     <select id="queryAll" resultMap="MockRequestRecordMap">
         select
         <include refid="Base_Column_List"/>
@@ -262,5 +286,13 @@
         delete from mock_request_record where id = #{id}
     </delete>
 
+    <delete id="batchDelete" parameterType="java.util.List">
+        DELETE FROM mock_request_record
+        WHERE id IN
+        <foreach item="id" collection="list" open="(" separator="," close=")">
+            #{id, jdbcType=VARCHAR}
+        </foreach>
+    </delete>
+
 </mapper>
 
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/MockRequestRecordControllerTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/MockRequestRecordControllerTest.java
new file mode 100644
index 000000000..0cb4a84e6
--- /dev/null
+++ 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/MockRequestRecordControllerTest.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.controller;
+
+import com.google.common.collect.Lists;
+import org.apache.shenyu.admin.exception.ExceptionHandlers;
+import org.apache.shenyu.admin.model.dto.MockRequestRecordDTO;
+import org.apache.shenyu.admin.model.page.CommonPager;
+import org.apache.shenyu.admin.model.vo.MockRequestRecordVO;
+import org.apache.shenyu.admin.service.MockRequestRecordService;
+import org.apache.shenyu.admin.utils.ShenyuResultMessage;
+import org.apache.shenyu.common.utils.GsonUtils;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+import static org.hamcrest.core.Is.is;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.BDDMockito.given;
+import static 
org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static 
org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+/**
+ * Test cases for MockRequestRecordControllerTest.
+ */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.LENIENT)
+public class MockRequestRecordControllerTest {
+
+    private MockMvc mockMvc;
+
+    @InjectMocks
+    private MockRequestRecordController mockRequestRecordController;
+
+    @Mock
+    private MockRequestRecordService mockRequestRecordService;
+
+    @BeforeEach
+    public void setUp() {
+        this.mockMvc = 
MockMvcBuilders.standaloneSetup(mockRequestRecordController)
+                .setControllerAdvice(new ExceptionHandlers())
+                .build();
+    }
+
+    @Test
+    public void testCreateOrUpdate() throws Exception {
+        given(mockRequestRecordService.createOrUpdate(any())).willReturn(1);
+        
this.mockMvc.perform(MockMvcRequestBuilders.post("/mock/insertOrUpdate")
+                        .contentType(MediaType.APPLICATION_JSON)
+                        .content(GsonUtils.getInstance().toJson(new 
MockRequestRecordDTO())))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.message", 
is(ShenyuResultMessage.SUCCESS)))
+                .andReturn();
+    }
+
+    @Test
+    public void testBatchDelete() throws Exception {
+        given(mockRequestRecordService.batchDelete(any())).willReturn(1);
+        this.mockMvc.perform(MockMvcRequestBuilders.delete("/mock/batchDelete")
+                        .contentType(MediaType.APPLICATION_JSON)
+                        
.content(GsonUtils.getInstance().toJson(Lists.newArrayList("1"))))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.message", 
is(ShenyuResultMessage.DELETE_SUCCESS)))
+                .andReturn();
+    }
+
+    @Test
+    public void testListByPage() throws Exception {
+        CommonPager<MockRequestRecordVO> commonPager = new CommonPager<>();
+        
commonPager.setDataList(Lists.newArrayList(buildMockRequestRecordVO()));
+        
given(mockRequestRecordService.listByPage(any())).willReturn(commonPager);
+        
this.mockMvc.perform(MockMvcRequestBuilders.get("/mock/findPageByQuery")
+                        .param("apiId", "123")
+                        .param("currentPage", 1 + "")
+                        .param("pageSize", 10 + ""))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.message", 
is(ShenyuResultMessage.QUERY_SUCCESS)))
+                .andExpect(jsonPath("$.data.dataList[0].apiId", is("123")))
+                .andReturn();
+    }
+
+    private MockRequestRecordVO buildMockRequestRecordVO() {
+        MockRequestRecordVO mockRequestRecordVO = new MockRequestRecordVO();
+        mockRequestRecordVO.setApiId("123");
+        mockRequestRecordVO.setId("123");
+        return mockRequestRecordVO;
+    }
+}
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/MockRequestRecordMapperTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/MockRequestRecordMapperTest.java
index ae6011a2e..b9dbc5e64 100644
--- 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/MockRequestRecordMapperTest.java
+++ 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/MockRequestRecordMapperTest.java
@@ -17,8 +17,11 @@
 
 package org.apache.shenyu.admin.mapper;
 
+import com.google.common.collect.Lists;
+import java.util.ArrayList;
 import org.apache.shenyu.admin.AbstractSpringIntegrationTest;
 import org.apache.shenyu.admin.model.entity.MockRequestRecordDO;
+import org.apache.shenyu.admin.model.query.MockRequestRecordQuery;
 import org.apache.shenyu.common.utils.UUIDUtils;
 import org.junit.jupiter.api.Test;
 import org.springframework.transaction.annotation.Transactional;
@@ -43,13 +46,13 @@ public class MockRequestRecordMapperTest extends 
AbstractSpringIntegrationTest {
     @Test
     @Transactional
     public void insert() {
-        assertEquals(mockRequestRecordMapper.insert(buildTagDO()), 1);
+        
assertEquals(mockRequestRecordMapper.insert(buildMockRequestRecordDO()), 1);
     }
 
     @Test
     @Transactional
     public void insertSelective() {
-        MockRequestRecordDO mockRequestRecordDO = buildTagDO();
+        MockRequestRecordDO mockRequestRecordDO = buildMockRequestRecordDO();
         mockRequestRecordDO.setPathVariable(null);
         mockRequestRecordDO.setQuery(null);
         mockRequestRecordDO.setHeader(null);
@@ -65,14 +68,14 @@ public class MockRequestRecordMapperTest extends 
AbstractSpringIntegrationTest {
     @Test
     @Transactional
     public void insertBatch() {
-        List<MockRequestRecordDO> mockRequestRecordDOS = 
Arrays.asList(buildTagDO(), buildTagDO(), buildTagDO());
+        List<MockRequestRecordDO> mockRequestRecordDOS = 
Arrays.asList(buildMockRequestRecordDO(), buildMockRequestRecordDO(), 
buildMockRequestRecordDO());
         
assertEquals(mockRequestRecordMapper.insertBatch(mockRequestRecordDOS), 3);
     }
 
     @Test
     @Transactional
     public void deleteById() {
-        MockRequestRecordDO mockRequestRecordDO = buildTagDO();
+        MockRequestRecordDO mockRequestRecordDO = buildMockRequestRecordDO();
         assertEquals(mockRequestRecordMapper.insert(mockRequestRecordDO), 1);
         
assertEquals(mockRequestRecordMapper.deleteById(mockRequestRecordDO.getId()), 
1);
         assertEquals(mockRequestRecordMapper.count(mockRequestRecordDO), 0);
@@ -81,7 +84,7 @@ public class MockRequestRecordMapperTest extends 
AbstractSpringIntegrationTest {
     @Test
     @Transactional
     public void queryById() {
-        MockRequestRecordDO mockRequestRecordDO = buildTagDO();
+        MockRequestRecordDO mockRequestRecordDO = buildMockRequestRecordDO();
         assertEquals(mockRequestRecordMapper.insert(mockRequestRecordDO), 1);
         MockRequestRecordDO queryResult = 
mockRequestRecordMapper.queryById(mockRequestRecordDO.getId());
         assertEquals(queryResult.getDateCreated(), 
mockRequestRecordDO.getDateCreated());
@@ -98,7 +101,7 @@ public class MockRequestRecordMapperTest extends 
AbstractSpringIntegrationTest {
     @Test
     @Transactional
     public void queryAll() {
-        MockRequestRecordDO mockRequestRecordDO = buildTagDO();
+        MockRequestRecordDO mockRequestRecordDO = buildMockRequestRecordDO();
         assertEquals(mockRequestRecordMapper.insert(mockRequestRecordDO), 1);
         List<MockRequestRecordDO> mockRequestRecordDOS = 
mockRequestRecordMapper.queryAll(mockRequestRecordDO);
         assertEquals(mockRequestRecordDOS.size(), 1);
@@ -108,7 +111,7 @@ public class MockRequestRecordMapperTest extends 
AbstractSpringIntegrationTest {
     @Test
     @Transactional
     public void existed() {
-        MockRequestRecordDO mockRequestRecordDO = buildTagDO();
+        MockRequestRecordDO mockRequestRecordDO = buildMockRequestRecordDO();
         
assertNull(mockRequestRecordMapper.existed(mockRequestRecordDO.getId()));
         int insertRows = mockRequestRecordMapper.insert(mockRequestRecordDO);
         assertEquals(insertRows, 1);
@@ -118,21 +121,25 @@ public class MockRequestRecordMapperTest extends 
AbstractSpringIntegrationTest {
     @Test
     @Transactional
     public void count() {
-        List<MockRequestRecordDO> mockRequestRecordDOS = 
Arrays.asList(buildTagDO(), buildTagDO(), buildTagDO());
+        List<MockRequestRecordDO> mockRequestRecordDOS = new ArrayList<>();
+        MockRequestRecordDO mockRequestRecordDO = buildMockRequestRecordDO();
+        mockRequestRecordDO.setApiId("456");
+        mockRequestRecordDOS.add(mockRequestRecordDO);
         int insertRows = 
mockRequestRecordMapper.insertBatch(mockRequestRecordDOS);
-        assertEquals(insertRows, 3);
-        MockRequestRecordDO queryRecord = buildTagDO();
+        assertEquals(insertRows, 1);
+        MockRequestRecordDO queryRecord = buildMockRequestRecordDO();
         queryRecord.setId(null);
+        queryRecord.setApiId("456");
         queryRecord.setDateCreated(null);
         queryRecord.setDateUpdated(null);
-        long count = mockRequestRecordMapper.count(queryRecord);
-        assertEquals(count, 3);
+        long queryCnt = mockRequestRecordMapper.count(queryRecord);
+        assertEquals(queryCnt, 1);
     }
 
     @Test
     @Transactional
     public void update() {
-        MockRequestRecordDO mockRequestRecordDO = buildTagDO();
+        MockRequestRecordDO mockRequestRecordDO = buildMockRequestRecordDO();
         int insertRows = mockRequestRecordMapper.insert(mockRequestRecordDO);
         assertEquals(insertRows, 1);
         MockRequestRecordDO updateRecord = MockRequestRecordDO.builder()
@@ -159,7 +166,26 @@ public class MockRequestRecordMapperTest extends 
AbstractSpringIntegrationTest {
         assertEquals(updateAfter.getDateUpdated(), 
updateRecord.getDateUpdated());
     }
 
-    private MockRequestRecordDO buildTagDO() {
+    @Test
+    public void testSelectByQuery() {
+        MockRequestRecordDO mockRequestRecordDO = buildMockRequestRecordDO();
+        mockRequestRecordMapper.insert(mockRequestRecordDO);
+        MockRequestRecordQuery mockRequestRecordQuery = new 
MockRequestRecordQuery();
+        mockRequestRecordQuery.setApiId("1");
+        mockRequestRecordQuery.setUrl("http://baidu.com/test";);
+        List<MockRequestRecordDO> mockRequestRecordDOS = 
mockRequestRecordMapper.selectByQuery(mockRequestRecordQuery);
+        assertEquals(mockRequestRecordDOS.size(), 1);
+    }
+
+    @Test
+    public void testBatchDelete() {
+        MockRequestRecordDO mockRequestRecordDO = buildMockRequestRecordDO();
+        mockRequestRecordMapper.insert(mockRequestRecordDO);
+        int cnt = 
mockRequestRecordMapper.batchDelete(Lists.newArrayList(mockRequestRecordDO.getId()));
+        assertEquals(1, cnt);
+    }
+
+    private MockRequestRecordDO buildMockRequestRecordDO() {
         Timestamp now = new Timestamp(System.currentTimeMillis());
         String id = UUIDUtils.getInstance().generateShortUuid();
         return MockRequestRecordDO.builder()
@@ -170,7 +196,7 @@ public class MockRequestRecordMapperTest extends 
AbstractSpringIntegrationTest {
                 .body("{\"name\": \"julia\"}")
                 .header("userId: 1;")
                 .host("192.168.1.1")
-                .url("http://192.168.1.1:8080/test";)
+                .url("http://baidu.com/test";)
                 .pathVariable("")
                 .port(8080)
                 .query("")
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/MockRequestRecordServiceTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/MockRequestRecordServiceTest.java
new file mode 100644
index 000000000..2c3eae9f3
--- /dev/null
+++ 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/MockRequestRecordServiceTest.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.service;
+
+import com.google.common.collect.Lists;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import org.apache.shenyu.admin.mapper.MockRequestRecordMapper;
+import org.apache.shenyu.admin.model.dto.MockRequestRecordDTO;
+import org.apache.shenyu.admin.model.entity.MockRequestRecordDO;
+import org.apache.shenyu.admin.model.page.CommonPager;
+import org.apache.shenyu.admin.model.query.MockRequestRecordQuery;
+import org.apache.shenyu.admin.model.vo.MockRequestRecordVO;
+import org.apache.shenyu.admin.service.impl.MockRequestRecordServiceImpl;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.BDDMockito.given;
+
+/**
+ * Test cases for MockRequestRecordService.
+ */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.LENIENT)
+public class MockRequestRecordServiceTest {
+
+    @InjectMocks
+    private MockRequestRecordServiceImpl mockRequestRecordService;
+
+    @Mock
+    private MockRequestRecordMapper mockRequestRecordMapper;
+
+    @Test
+    public void testCreateOrUpdate() {
+        MockRequestRecordDTO mockRequestRecordDTO = 
buildMockRequestRecordDTO();
+        given(this.mockRequestRecordMapper.insert(any())).willReturn(1);
+        given(this.mockRequestRecordMapper.update(any())).willReturn(1);
+        int cnt = 
mockRequestRecordService.createOrUpdate(mockRequestRecordDTO);
+        assertEquals(1, cnt);
+        mockRequestRecordDTO.setId("1");
+        cnt = mockRequestRecordService.createOrUpdate(mockRequestRecordDTO);
+        assertEquals(1, cnt);
+    }
+
+    @Test
+    public void testFindById() {
+        
given(this.mockRequestRecordMapper.queryById("1")).willReturn(buildMockRequestRecordDO());
+        MockRequestRecordVO mockRequestRecordVO = 
mockRequestRecordService.findById("1");
+        assertEquals("123", mockRequestRecordVO.getApiId());
+    }
+
+    @Test
+    public void testDelete() {
+        given(this.mockRequestRecordMapper.deleteById(any())).willReturn(1);
+        given(this.mockRequestRecordMapper.queryById("1")).willReturn(new 
MockRequestRecordDO());
+        int cnt = mockRequestRecordService.delete("1");
+        assertEquals(1, cnt);
+    }
+
+    @Test
+    public void testListByPage() {
+        MockRequestRecordQuery mockRequestRecordQuery = new 
MockRequestRecordQuery();
+        mockRequestRecordQuery.setApiId("123");
+        List<MockRequestRecordDO> list = new ArrayList<>();
+        list.add(buildMockRequestRecordDO());
+        
given(this.mockRequestRecordMapper.selectByQuery(mockRequestRecordQuery)).willReturn(list);
+        CommonPager<MockRequestRecordVO> commonPager = 
mockRequestRecordService.listByPage(mockRequestRecordQuery);
+        assertEquals(1, commonPager.getDataList().size());
+    }
+
+    @Test
+    public void testBatchDelete() {
+        given(this.mockRequestRecordMapper.batchDelete(any())).willReturn(1);
+        int cnt = 
this.mockRequestRecordService.batchDelete(Lists.newArrayList("1"));
+        assertEquals(1, cnt);
+    }
+
+    private MockRequestRecordDTO buildMockRequestRecordDTO() {
+        MockRequestRecordDTO mockRequestRecordDTO = new MockRequestRecordDTO();
+        mockRequestRecordDTO.setApiId("1");
+        mockRequestRecordDTO.setHost("127.0.0.1");
+        mockRequestRecordDTO.setQuery("");
+        mockRequestRecordDTO.setUrl("http://127.0.0.1:8080/v1/test";);
+        mockRequestRecordDTO.setDateUpdated(new Date());
+        mockRequestRecordDTO.setPort(8080);
+        return mockRequestRecordDTO;
+    }
+
+    private MockRequestRecordDO buildMockRequestRecordDO() {
+        MockRequestRecordDO mockRequestRecordDO = new MockRequestRecordDO();
+        mockRequestRecordDO.setApiId("123");
+        return mockRequestRecordDO;
+    }
+
+}

Reply via email to