You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.1 KiB
Java
30 lines
1.1 KiB
Java
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());
|
|
}
|
|
}
|