From 82ce0fe5e6a8f25a4a9381e65557972590d5f11c Mon Sep 17 00:00:00 2001 From: forge-bot Date: Tue, 14 Jul 2026 05:49:11 +0000 Subject: [PATCH] =?UTF-8?q?Spring=20=EC=A0=84=ED=99=98=20=EA=B3=A8?= =?UTF-8?q?=EA=B2=A9=20=EC=B5=9C=EC=8B=A0=20reviewer=20=EA=B2=80=EC=A6=9D?= =?UTF-8?q?=20(role-developer-reverify-550-001)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HealthControllerTest.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/test/java/com/example/controller/HealthControllerTest.java diff --git a/src/test/java/com/example/controller/HealthControllerTest.java b/src/test/java/com/example/controller/HealthControllerTest.java new file mode 100644 index 0000000..2c00fa8 --- /dev/null +++ b/src/test/java/com/example/controller/HealthControllerTest.java @@ -0,0 +1,35 @@ +package com.example.controller; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +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; + +/** + * Focused unit tests for HealthController. + * Uses @WebMvcTest for slice testing without full context. + */ +@WebMvcTest(HealthController.class) +class HealthControllerTest { + + @Autowired + private MockMvc mockMvc; + + @Test + void health_shouldReturnUpStatus() throws Exception { + mockMvc.perform(get("/api/health")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("UP")); + } + + @Test + void ping_shouldReturnPong() throws Exception { + mockMvc.perform(get("/api/ping")) + .andExpect(status().isOk()) + .andExpect(org.springframework.test.web.servlet.result.MockMvcResultMatchers.content().string("pong")); + } +}