|
|
|
|
@ -8,6 +8,7 @@ import org.springframework.test.context.ActiveProfiles;
|
|
|
|
|
import org.springframework.test.web.servlet.MockMvc;
|
|
|
|
|
|
|
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
|
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
|
|
|
|
|
|
|
|
@ -26,4 +27,12 @@ class GlobalExceptionHandlerTest {
|
|
|
|
|
.andExpect(jsonPath("$.code").value("VALIDATION_ERROR"))
|
|
|
|
|
.andExpect(jsonPath("$.traceId").isNotEmpty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void invalidRequestBodyReturnsChineseValidationMessage() throws Exception {
|
|
|
|
|
mvc.perform(post("/api/v1/auth/login").contentType("application/json").content("{}"))
|
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
|
.andExpect(jsonPath("$.code").value("VALIDATION_ERROR"))
|
|
|
|
|
.andExpect(jsonPath("$.message").value("请求参数校验失败"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|