fix(测试计划): 去掉测试计划API-CASE接口

This commit is contained in:
song-cc-rock 2023-06-16 16:04:25 +08:00 committed by 刘瑞斌
parent 4c914e846b
commit bc2989bce0
3 changed files with 0 additions and 130 deletions

View File

@ -14,24 +14,4 @@ public class TestPlanApiCaseController {
@Resource @Resource
private TestPlanApiCaseService testPlanApiCaseService; private TestPlanApiCaseService testPlanApiCaseService;
@PostMapping("/add")
public void add(@Validated({Created.class}) @RequestBody TestPlanApiCaseDTO testPlanApiCaseDTO) {
testPlanApiCaseService.add(testPlanApiCaseDTO);
}
@PutMapping("/update")
public void update(@Validated({Updated.class}) @RequestBody TestPlanApiCaseDTO testPlanApiCaseDTO) {
testPlanApiCaseService.update(testPlanApiCaseDTO);
}
@DeleteMapping("/delete/{id}")
public int delete(@PathVariable String id) {
return testPlanApiCaseService.delete(id);
}
@GetMapping("/get/{id}")
public TestPlanApiCaseDTO get(@PathVariable String id) {
return testPlanApiCaseService.get(id);
}
} }

View File

@ -18,36 +18,6 @@ public class TestPlanApiCaseService {
@Resource @Resource
TestPlanApiCaseMapper testPlanApiCaseMapper; TestPlanApiCaseMapper testPlanApiCaseMapper;
public void add(TestPlanApiCaseDTO testPlanApiCaseDTO) {
TestPlanApiCase testPlanApiCase = new TestPlanApiCase();
BeanUtils.copyBean(testPlanApiCase, testPlanApiCaseDTO);
testPlanApiCase.setCreateTime(System.currentTimeMillis());
testPlanApiCase.setCreateUser("admin");
testPlanApiCaseMapper.insert(testPlanApiCase);
}
public void update(TestPlanApiCaseDTO testPlanApiCaseDTO) {
TestPlanApiCase testPlanApiCase = new TestPlanApiCase();
BeanUtils.copyBean(testPlanApiCase, testPlanApiCaseDTO);
testPlanApiCaseMapper.updateByPrimaryKeySelective(testPlanApiCase);
}
public int delete(String id) {
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
example.createCriteria().andIdEqualTo(id);
return testPlanApiCaseMapper.deleteByExample(example);
}
public TestPlanApiCaseDTO get(String id) {
TestPlanApiCaseDTO testPlanApiCaseDTO = new TestPlanApiCaseDTO();
TestPlanApiCase testPlanApiCase = testPlanApiCaseMapper.selectByPrimaryKey(id);
if (testPlanApiCase == null) {
return null;
}
BeanUtils.copyBean(testPlanApiCaseDTO, testPlanApiCase);
return testPlanApiCaseDTO;
}
public int deleteByTestPlanId(String testPlanId) { public int deleteByTestPlanId(String testPlanId) {
TestPlanApiCaseExample example = new TestPlanApiCaseExample(); TestPlanApiCaseExample example = new TestPlanApiCaseExample();
example.createCriteria().andTestPlanIdEqualTo(testPlanId); example.createCriteria().andTestPlanIdEqualTo(testPlanId);

View File

@ -32,84 +32,4 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED)) config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
public class TestPlanApiCaseControllerTests { public class TestPlanApiCaseControllerTests {
@Resource
private MockMvc mockMvc;
public static final String REQ_PREFIX = "/test-plan/api/case";
public static final String PARAM_TEST_ID = "test-plan-api-case-id";
private static String sessionId;
private static String csrfToken;
@Test
@Order(0)
public void login() throws Exception {
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/login")
.content("{\"username\":\"admin\",\"password\":\"metersphere\"}")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
sessionId = JsonPath.read(mvcResult.getResponse().getContentAsString(), "$.data.sessionId");
csrfToken = JsonPath.read(mvcResult.getResponse().getContentAsString(), "$.data.csrfToken");
}
@Test
@Order(1)
public void testAdd() throws Exception {
TestPlanApiCaseDTO testPlanApiCaseDTO = new TestPlanApiCaseDTO();
testPlanApiCaseDTO.setId(UUID.randomUUID().toString());
testPlanApiCaseDTO.setTestPlanId(UUID.randomUUID().toString());
testPlanApiCaseDTO.setApiCaseId(UUID.randomUUID().toString());
testPlanApiCaseDTO.setPos(10001L);
mockMvc.perform(MockMvcRequestBuilders.post(REQ_PREFIX + "/add")
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
.content(JSON.toJSONString(testPlanApiCaseDTO))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andDo(MockMvcResultHandlers.print());
}
@Test
@Order(2)
public void testGet() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get(REQ_PREFIX + "/get/" + PARAM_TEST_ID)
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken))
.andExpect(status().isOk())
.andDo(MockMvcResultHandlers.print());
}
@Test
@Order(3)
public void testUpdate() throws Exception {
TestPlanApiCaseDTO testPlanApiCaseDTO = new TestPlanApiCaseDTO();
testPlanApiCaseDTO.setId(PARAM_TEST_ID);
testPlanApiCaseDTO.setPos(15001L);
mockMvc.perform(MockMvcRequestBuilders.put(REQ_PREFIX + "/update")
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
.content(JSON.toJSONString(testPlanApiCaseDTO))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andDo(MockMvcResultHandlers.print());
mockMvc.perform(MockMvcRequestBuilders.get(REQ_PREFIX + "/get/" + PARAM_TEST_ID)
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken))
.andExpect(status().isOk()).andExpect(MockMvcResultMatchers.jsonPath("$.data.pos").value(15001L))
.andDo(MockMvcResultHandlers.print());
}
@Test
@Order(4)
public void testDelete() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.delete(REQ_PREFIX + "/delete/" + PARAM_TEST_ID)
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken))
.andExpect(status().isOk())
.andDo(MockMvcResultHandlers.print());
}
} }