feat(测试计划): 测试计划相关代码更改

测试计划相关代码更改
This commit is contained in:
song-tianyang 2023-05-24 15:50:09 +08:00 committed by 建国
parent cb3d719d09
commit a79e87ff87
12 changed files with 358 additions and 46 deletions

View File

@ -0,0 +1,92 @@
package io.metersphere.plan.domain;
import io.metersphere.validation.groups.Created;
import io.metersphere.validation.groups.Updated;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
import java.io.Serializable;
@ApiModel(value = "测试计划")
@Table("test_plan")
@Data
public class TestPlan implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@NotBlank(message = "{test_plan.id.not_blank}", groups = {Updated.class})
@ApiModelProperty(name = "ID", required = true, allowableValues = "range[1, 50]")
private String id;
@Size(min = 1, max = 50, message = "{test_plan.project_id.length_range}", groups = {Created.class, Updated.class})
@NotBlank(message = "{test_plan.project_id.not_blank}", groups = {Created.class})
@ApiModelProperty(name = "测试计划所属项目", required = true, allowableValues = "range[1, 50]")
private String projectId;
@Size(min = 1, max = 50, message = "{test_plan.parent_id.length_range}", groups = {Created.class, Updated.class})
@NotBlank(message = "{test_plan.parent_id.not_blank}", groups = {Created.class})
@ApiModelProperty(name = "测试计划父ID", required = true, allowableValues = "range[1, 50]")
private String parentId;
@Size(min = 1, max = 255, message = "{test_plan.name.length_range}", groups = {Created.class, Updated.class})
@NotBlank(message = "{test_plan.name.not_blank}", groups = {Created.class})
@ApiModelProperty(name = "测试计划名称", required = true, allowableValues = "range[1, 255]")
private String name;
@Size(min = 1, max = 20, message = "{test_plan.status.length_range}", groups = {Created.class, Updated.class})
@NotBlank(message = "{test_plan.status.not_blank}", groups = {Created.class})
@ApiModelProperty(name = "测试计划状态", required = true, allowableValues = "range[1, 20]")
private String status;
@Size(min = 1, max = 30, message = "{test_plan.stage.length_range}", groups = {Created.class, Updated.class})
@NotBlank(message = "{test_plan.stage.not_blank}", groups = {Created.class})
@ApiModelProperty(name = "测试阶段", required = true, allowableValues = "range[1, 30]")
private String stage;
@ApiModelProperty(name = "标签", allowableValues = "range[1, 500]")
private String tags;
@ApiModelProperty(name = "创建时间", required = true, dataType = "Long")
private Long createTime;
@Size(min = 1, max = 50, message = "{test_plan.create_user.length_range}", groups = {Created.class, Updated.class})
@NotBlank(message = "{test_plan.create_user.not_blank}", groups = {Created.class})
@ApiModelProperty(name = "创建人", required = true, allowableValues = "range[1, 50]")
private String createUser;
@ApiModelProperty(name = "更新时间", dataType = "Long")
private Long updateTime;
@ApiModelProperty(name = "更新人", allowableValues = "range[1, 50]")
private String updateUser;
@ApiModelProperty(name = "计划开始时间", dataType = "Long")
private Long plannedStartTime;
@ApiModelProperty(name = "计划结束时间", dataType = "Long")
private Long plannedEndTime;
@ApiModelProperty(name = "实际开始时间", dataType = "Long")
private Long actualStartTime;
@ApiModelProperty(name = "实际结束时间", dataType = "Long")
private Long actualEndTime;
@ApiModelProperty(name = "描述", allowableValues = "range[1, 2000]")
private String description;
}

View File

@ -1,3 +1,16 @@
test_plan.id.not_blank=
test_plan.project_id.length_range=
test_plan.project_id.not_blank=
test_plan.parent_id.length_range=
test_plan.parent_id.not_blank=
test_plan.name.length_range=
test_plan.name.not_blank=
test_plan.status.length_range=
test_plan.status.not_blank=
test_plan.stage.length_range=
test_plan.stage.not_blank=
test_plan.create_user.length_range=
test_plan.create_user.not_blank=
test_plan_report.id.not_blank=
test_plan_report.test_plan_id.length_range=
test_plan_report.test_plan_id.not_blank=

View File

@ -1,3 +1,16 @@
test_plan.id.not_blank=Test plan id cannot be empty
test_plan.project_id.length_range=Test plan project id length too long
test_plan.project_id.not_blank=Test plan project id cannot be empty
test_plan.parent_id.length_range=Test plan parent id length too long
test_plan.parent_id.not_blank=Test plan parent id cannot be empty
test_plan.name.length_range=Test plan name length too long
test_plan.name.not_blank=Test plan name cannot be empty
test_plan.status.length_range=Test plan status length too long
test_plan.status.not_blank=Test plan status cannot be empty
test_plan.stage.length_range=Test plan stage length too long
test_plan.stage.not_blank=Test plan stage cannot be empty
test_plan.create_user.length_range=Test plan create user length too long
test_plan.create_user.not_blank=Test plan create user cannot be empty
test_plan_report.id.not_blank=Test plan report id cannot be empty
test_plan_report.test_plan_id.length_range=Test plan id length too long
test_plan_report.test_plan_id.not_blank=Test plan id cannot be empty

View File

@ -1,3 +1,16 @@
test_plan.id.not_blank=\u6D4B\u8BD5\u8BA1\u5212ID\u4E0D\u80FD\u4E3A\u7A7A
test_plan.project_id.length_range=\u6D4B\u8BD5\u8BA1\u5212\u6240\u5C5E\u9879\u76EEID\u957F\u5EA6\u8FC7\u957F
test_plan.project_id.not_blank=\u6D4B\u8BD5\u8BA1\u5212\u6240\u5C5E\u9879\u76EEID\u4E0D\u80FD\u4E3A\u7A7A
test_plan.parent_id.length_range=\u6D4B\u8BD5\u8BA1\u5212\u7236ID\u957F\u5EA6\u8FC7\u957F
test_plan.parent_id.not_blank=\u6D4B\u8BD5\u8BA1\u5212\u7236ID\u4E0D\u80FD\u4E3A\u7A7A
test_plan.name.length_range=\u6D4B\u8BD5\u8BA1\u5212\u540D\u79F0\u957F\u5EA6\u8FC7\u957F
test_plan.name.not_blank=\u6D4B\u8BD5\u8BA1\u5212\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
test_plan.status.length_range=\u6D4B\u8BD5\u8BA1\u5212\u72B6\u6001\u957F\u5EA6\u8FC7\u957F
test_plan.status.not_blank=\u6D4B\u8BD5\u8BA1\u5212\u72B6\u6001\u4E0D\u80FD\u4E3A\u7A7A
test_plan.stage.length_range=\u6D4B\u8BD5\u8BA1\u5212\u9636\u6BB5\u957F\u5EA6\u8FC7\u957F
test_plan.stage.not_blank=\u6D4B\u8BD5\u8BA1\u5212\u9636\u6BB5\u4E0D\u80FD\u4E3A\u7A7A
test_plan.create_user.length_range=\u6D4B\u8BD5\u8BA1\u5212\u521B\u5EFA\u4EBA\u957F\u5EA6\u8FC7\u957F
test_plan.create_user.not_blank=\u6D4B\u8BD5\u8BA1\u5212\u521B\u5EFA\u4EBA\u4E0D\u80FD\u4E3A\u7A7A
test_plan_report.id.not_blank=\u6D4B\u8BD5\u8BA1\u5212\u62A5\u544AID\u4E0D\u80FD\u4E3A\u7A7A
test_plan_report.test_plan_id.length_range=\u6D4B\u8BD5\u8BA1\u5212ID\u957F\u5EA6\u8FC7\u957F
test_plan_report.test_plan_id.not_blank=\u6D4B\u8BD5\u8BA1\u5212ID\u4E0D\u80FD\u4E3A\u7A7A

View File

@ -1,3 +1,16 @@
test_plan.id.not_blank=\u6E2C\u8A66\u8A08\u5283ID\u4E0D\u80FD\u70BA\u7A7A
test_plan.project_id.length_range=\u6E2C\u8A66\u8A08\u5283\u6240\u5C6C\u9805\u76EEID\u9577\u5EA6\u904E\u9577
test_plan.project_id.not_blank=\u6E2C\u8A66\u8A08\u5283\u6240\u5C6C\u9805\u76EEID\u4E0D\u80FD\u70BA\u7A7A
test_plan.parent_id.length_range=\u6E2C\u8A66\u8A08\u5283\u7236ID\u9577\u5EA6\u904E\u9577
test_plan.parent_id.not_blank=\u6E2C\u8A66\u8A08\u5283\u7236ID\u4E0D\u80FD\u70BA\u7A7A
test_plan.name.length_range=\u6E2C\u8A66\u8A08\u5283\u540D\u7A31\u9577\u5EA6\u904E\u9577
test_plan.name.not_blank=\u6E2C\u8A66\u8A08\u5283\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A
test_plan.status.length_range=\u6E2C\u8A66\u8A08\u5283\u72C0\u614B\u9577\u5EA6\u904E\u9577
test_plan.status.not_blank=\u6E2C\u8A66\u8A08\u5283\u72C0\u614B\u4E0D\u80FD\u70BA\u7A7A
test_plan.stage.length_range=\u6E2C\u8A66\u8A08\u5283\u968E\u6BB5\u9577\u5EA6\u904E\u9577
test_plan.stage.not_blank=\u6E2C\u8A66\u8A08\u5283\u968E\u6BB5\u4E0D\u80FD\u70BA\u7A7A
test_plan.create_user.length_range=\u6E2C\u8A66\u8A08\u5283\u5275\u5EFA\u4EBA\u9577\u5EA6\u904E\u9577
test_plan.create_user.not_blank=\u6E2C\u8A66\u8A08\u5283\u5275\u5EFA\u4EBA\u4E0D\u80FD\u70BA\u7A7A
test_plan_report.id.not_blank=\u6E2C\u8A66\u8A08\u5283\u5831\u544AID\u4E0D\u80FD\u70BA\u7A7A
test_plan_report.test_plan_id.length_range=\u6E2C\u8A66\u8A08\u5283ID\u9577\u5EA6\u904E\u9577
test_plan_report.test_plan_id.not_blank=\u6E2C\u8A66\u8A08\u5283ID\u4E0D\u80FD\u70BA\u7A7A

View File

@ -0,0 +1,23 @@
package io.metersphere.plan.controller;
import io.metersphere.plan.domain.TestPlan;
import io.metersphere.plan.service.TestPlanService;
import io.metersphere.validation.groups.Created;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
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.RestController;
@RestController
@RequestMapping("/test-plan")
public class TestPlanController {
@Resource
private TestPlanService testPlanService;
@PostMapping("/add")
public boolean addUser(@Validated({Created.class}) @RequestBody TestPlan testPlan) {
return testPlanService.add(testPlan);
}
}

View File

@ -1,46 +0,0 @@
package io.metersphere.plan.domain;
import lombok.Data;
import java.io.Serializable;
@Data
public class TestPlan implements Serializable {
private String id;
private String workspaceId;
private String reportId;
private String name;
private String description;
private String status;
private String stage;
private Long createTime;
private Long updateTime;
private Long plannedStartTime;
private Long plannedEndTime;
private Long actualStartTime;
private Long actualEndTime;
private String creator;
private String projectId;
private Integer executionTimes;
private Boolean automaticStatusUpdate;
private Boolean repeatCase;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,14 @@
package io.metersphere.plan.service;
import io.metersphere.plan.domain.TestPlan;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional(rollbackFor = Exception.class)
public class TestPlanService {
public boolean add(TestPlan testPlan) {
return true;
}
}

View File

@ -0,0 +1,23 @@
package io.metersphere.system;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration;
import org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration;
import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication(exclude = {
QuartzAutoConfiguration.class,
LdapAutoConfiguration.class,
Neo4jAutoConfiguration.class
})
@ServletComponentScan
@ComponentScan(basePackages = {"io.metersphere.sdk", "io.metersphere.plan"})
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@ -0,0 +1,58 @@
package io.metersphere.system.controller;
import io.metersphere.plan.domain.TestPlan;
import io.metersphere.sdk.util.JSON;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTest
@AutoConfigureMockMvc
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class TestPlanControllerTests {
@Resource
private MockMvc mockMvc;
@Test
@Order(1)
public void testAddUserTrue() throws Exception {
TestPlan testPlan = new TestPlan();
testPlan.setName("test");
testPlan.setProjectId("1");
testPlan.setParentId("1");
testPlan.setCreateUser("JianGuo");
testPlan.setStage("Smock");
testPlan.setStatus("PREPARE");
mockMvc.perform(MockMvcRequestBuilders.post("/test-plan/add")
.content(JSON.toJSONString(testPlan))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON));
}
@Test
@Order(2)
public void testAddUserFalse() throws Exception {
TestPlan testPlan = new TestPlan();
testPlan.setName("test");
mockMvc.perform(MockMvcRequestBuilders.post("/test-plan/add")
.content(JSON.toJSONString(testPlan))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest())
.andExpect(content().contentType(MediaType.APPLICATION_JSON));
}
}

View File

@ -0,0 +1,83 @@
spring.application.name=metersphere
management.server.port=7071
server.port=8081
# ?? gzip ??
server.compression.enabled=true
server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,application/javascript,text/css,text/javascript,image/jpeg
server.compression.min-response-size=2048
#
quartz.enabled=false
quartz.scheduler-name=msScheduler
quartz.thread-count=10
quartz.properties.org.quartz.jobStore.acquireTriggersWithinLock=true
#
logging.file.path=/opt/metersphere/logs/metersphere
# Hikari
spring.datasource.url=jdbc:mysql://${embedded.mysql.host}:${embedded.mysql.port}/test?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
spring.datasource.username=${embedded.mysql.user}
spring.datasource.password=${embedded.mysql.password}
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.maximum-pool-size=100
spring.datasource.hikari.minimum-idle=10
spring.datasource.hikari.idle-timeout=300000
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1
#
# spring.kafka
spring.kafka.bootstrap-servers=${embedded.kafka.brokerList}
spring.kafka.consumer.group-id=metersphere_group_id
spring.kafka.consumer.debug.group-id=metersphere_group_id_${random.uuid}
spring.kafka.listener.missing-topics-fatal=false
spring.kafka.producer.properties.max.request.size=32428800
spring.kafka.producer.batch-size=16384
spring.kafka.consumer.properties.max.partition.fetch.bytes=52428800
# mybatis
mybatis.configuration.cache-enabled=true
mybatis.configuration.lazy-loading-enabled=false
mybatis.configuration.aggressive-lazy-loading=true
mybatis.configuration.multiple-result-sets-enabled=true
mybatis.configuration.use-column-label=true
mybatis.configuration.auto-mapping-behavior=full
mybatis.configuration.default-statement-timeout=25000
mybatis.configuration.map-underscore-to-camel-case=true
# view
spring.mvc.throw-exception-if-no-handler-found=true
# flyway enable
spring.flyway.enabled=true
spring.flyway.baseline-on-migrate=true
spring.flyway.locations=filesystem:../../app/src/main/resources/migration
spring.flyway.table=metersphere_version
spring.flyway.baseline-version=0
spring.flyway.encoding=UTF-8
spring.flyway.validate-on-migrate=false
# jmeter
jmeter.home=/opt/jmeter
# file upload
spring.servlet.multipart.max-file-size=500MB
spring.servlet.multipart.max-request-size=500MB
# i18n
spring.messages.basename=i18n/commons,i18n/api,i18n/issue,i18n/load,i18n/project,i18n/system,i18n/plan,i18n/functional,i18n/ui,i18n/workstation
# actuator
management.endpoints.web.exposure.include=*
management.endpoints.enabled-by-default=false
# redis
spring.session.timeout=43200s
spring.data.redis.host=${embedded.redis.host}
spring.data.redis.password=${embedded.redis.password}
spring.data.redis.port=${embedded.redis.port}
spring.session.redis.repository-type=indexed
#
spring.freemarker.check-template-location=false
spring.groovy.template.check-template-location=false
#
minio.endpoint=http://${embedded.minio.host}:${embedded.minio.port}
minio.access-key=${embedded.minio.accessKey}
minio.secret-key=${embedded.minio.secretKey}
logging.level.org.springframework.jdbc.core=debug
logging.level.io.metersphere.sdk.mapper=debug
logging.level.io.metersphere.system.mapper=debug

View File

@ -0,0 +1,13 @@
# embedded config
embedded.containers.enabled=true
embedded.containers.forceShutdown=true
# mysql
embedded.mysql.enabled=true
embedded.mysql.encoding=utf8mb4
embedded.mysql.collation=utf8mb4_general_ci
# redis
embedded.redis.enabled=true
# kafka
embedded.kafka.enabled=false
# minio
embedded.minio.enabled=false