Bom dia tudo bem, no metodo não esta achando o .getstatus, teria outro modo.
package alua.com.br.med.voll.api.controller;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
@SpringBootTest
@AutoConfigureMockMvc
class ConsultaControllerTest {
@Autowired
private MockMvc mvc;
@Test
@DisplayName("Deveria devolver codigo 400 quando informações invalidas")
@WithMockUser //ignorar autenticação
void agendarCenario1() throws Exception {
var response = mvc.perform(post("/consultas"))
.andReturn().getRequest();
assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST.value());
}
}
Estou usando o Eclipse, e não tem o .getStatus no response dentro do assertThat.