From aba5340f014bcf3aa4971ee2ee33fd8a7e21ae7f Mon Sep 17 00:00:00 2001 From: William Harrington Date: Wed, 12 Feb 2025 20:14:48 -0600 Subject: Rename BuilddbHomeControllerTest, remove some public modifiers, fix some Assertions and change deprecated initMocks to openMocks. --- .../controllers/BuilddbHomeControllerTest.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/test/java/org/berzerkula/builddb/controllers/BuilddbHomeControllerTest.java (limited to 'src/test/java/org/berzerkula/builddb/controllers/BuilddbHomeControllerTest.java') diff --git a/src/test/java/org/berzerkula/builddb/controllers/BuilddbHomeControllerTest.java b/src/test/java/org/berzerkula/builddb/controllers/BuilddbHomeControllerTest.java new file mode 100644 index 0000000..b22277e --- /dev/null +++ b/src/test/java/org/berzerkula/builddb/controllers/BuilddbHomeControllerTest.java @@ -0,0 +1,33 @@ +package org.berzerkula.builddb.controllers; + +import org.berzerkula.builddb.config.SecurityConfig; +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.context.annotation.Import; +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.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; + +@Import(SecurityConfig.class) +@AutoConfigureMockMvc +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + +class BuilddbHomeControllerTest { + + @Autowired + private MockMvc mockMvc; + + @Test + void shouldReturnContactOk() throws Exception { + mockMvc.perform(get("/contact")) + .andExpect(status().isOk()) + .andExpect(view().name("contact")) + .andDo(print()); + } + +} -- cgit v1.2.3-54-g00ecf