From 2908dc790f55644b26c1bb7398372d08ff4feef7 Mon Sep 17 00:00:00 2001 From: William Harrington Date: Wed, 12 Feb 2025 20:20:06 -0600 Subject: Rename test class and remove public modifiers. --- .../BuilddbDashboardControllerTest.java | 62 ++++++++++++++++++++++ .../BuilddbTestDashboardController.java | 62 ---------------------- 2 files changed, 62 insertions(+), 62 deletions(-) create mode 100644 src/test/java/org/berzerkula/builddb/controllers/BuilddbDashboardControllerTest.java delete mode 100644 src/test/java/org/berzerkula/builddb/controllers/BuilddbTestDashboardController.java (limited to 'src/test/java/org') diff --git a/src/test/java/org/berzerkula/builddb/controllers/BuilddbDashboardControllerTest.java b/src/test/java/org/berzerkula/builddb/controllers/BuilddbDashboardControllerTest.java new file mode 100644 index 0000000..c0860e3 --- /dev/null +++ b/src/test/java/org/berzerkula/builddb/controllers/BuilddbDashboardControllerTest.java @@ -0,0 +1,62 @@ +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.security.test.context.support.WithMockUser; +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 BuilddbDashboardControllerTest { + + @Autowired + private MockMvc mockMvc; + + @Test + @WithMockUser + void shouldReturnActuatorDashboardView() throws Exception { + this.mockMvc.perform(get("/actuatorDashboard")) + .andExpect(status().isOk()) + .andExpect(view().name("actuatorDashboard")) + .andDo(print()); + } + + @Test + @WithMockUser + void shouldReturnAdminView() throws Exception { + this.mockMvc.perform(get("/admin")) + .andExpect(status().isOk()) + .andExpect(view().name("admin")) + .andDo(print()); + } + + @Test + @WithMockUser + void shouldReturnClientView() throws Exception { + this.mockMvc.perform(get("/client")) + .andExpect(status().isOk()) + .andExpect(view().name("client")) + .andDo(print()); + } + + @Test + @WithMockUser + void shouldReturnUserView() throws Exception { + this.mockMvc.perform(get("/user")) + .andExpect(status().isOk()) + .andExpect(view().name("user")) + .andDo(print()); + } + +} diff --git a/src/test/java/org/berzerkula/builddb/controllers/BuilddbTestDashboardController.java b/src/test/java/org/berzerkula/builddb/controllers/BuilddbTestDashboardController.java deleted file mode 100644 index 27944ce..0000000 --- a/src/test/java/org/berzerkula/builddb/controllers/BuilddbTestDashboardController.java +++ /dev/null @@ -1,62 +0,0 @@ -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.security.test.context.support.WithMockUser; -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) - -public class BuilddbTestDashboardController { - - @Autowired - private MockMvc mockMvc; - - @Test - @WithMockUser - public void shouldReturnActuatorDashboardView() throws Exception { - this.mockMvc.perform(get("/actuatorDashboard")) - .andExpect(status().isOk()) - .andExpect(view().name("actuatorDashboard")) - .andDo(print()); - } - - @Test - @WithMockUser - public void shouldReturnAdminView() throws Exception { - this.mockMvc.perform(get("/admin")) - .andExpect(status().isOk()) - .andExpect(view().name("admin")) - .andDo(print()); - } - - @Test - @WithMockUser - public void shouldReturnClientView() throws Exception { - this.mockMvc.perform(get("/client")) - .andExpect(status().isOk()) - .andExpect(view().name("client")) - .andDo(print()); - } - - @Test - @WithMockUser - public void shouldReturnUserView() throws Exception { - this.mockMvc.perform(get("/user")) - .andExpect(status().isOk()) - .andExpect(view().name("user")) - .andDo(print()); - } - -} -- cgit v1.2.3-54-g00ecf