From 14bcf14a112c5330bd23f3ad81473efba48515b3 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Mon, 15 May 2023 15:12:29 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E5=8F=82=E6=95=B0=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E8=BF=94=E5=9B=9Edemo=E5=8A=A0=E4=B8=8A=E6=96=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/UserControllerTests.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserControllerTests.java index 285a3461b7..afe7ff7ddc 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserControllerTests.java @@ -10,9 +10,10 @@ import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import java.util.regex.Matcher; + import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @SpringBootTest @@ -44,10 +45,12 @@ public class UserControllerTests { User user = new User(); user.setId("admin"); user.setName("admin"); - mockMvc.perform(MockMvcRequestBuilders.post("/user/add").content(JSON.toJSONString(user)).contentType(MediaType.APPLICATION_JSON)) -// .andExpect(status().isOk()) -// .andExpect(content().contentType(MediaType.APPLICATION_JSON)) -// .andExpect(jsonPath("$.person.name").value("Jason")) + mockMvc.perform(MockMvcRequestBuilders.post("/user/add") + .content(JSON.toJSONString(user)) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isBadRequest()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("$.code").value("40000")) .andDo(print()); }