package com.yau.digitalrmb.shared; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 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.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest @AutoConfigureMockMvc(addFilters = false) @ActiveProfiles("test") class GlobalExceptionHandlerTest { @Autowired private MockMvc mvc; @Test void blankParameterReturnsStandardBadRequest() throws Exception { mvc.perform(get("/api/v1/diagnostics/validation").param("value", "")) .andExpect(status().isBadRequest()) .andExpect(jsonPath("$.code").value("VALIDATION_ERROR")) .andExpect(jsonPath("$.traceId").isNotEmpty()); } }