From 053c05ea26861ca12e02b9a6b52221b49fc22490 Mon Sep 17 00:00:00 2001 From: Tim <135014430+nagisa77@users.noreply.github.com> Date: Mon, 4 Aug 2025 21:29:45 +0800 Subject: [PATCH] test: mock PostMapper in CategoryControllerTest --- .../com/openisle/controller/CategoryControllerTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/src/test/java/com/openisle/controller/CategoryControllerTest.java b/backend/src/test/java/com/openisle/controller/CategoryControllerTest.java index 45e217605..90af32f61 100644 --- a/backend/src/test/java/com/openisle/controller/CategoryControllerTest.java +++ b/backend/src/test/java/com/openisle/controller/CategoryControllerTest.java @@ -1,5 +1,7 @@ package com.openisle.controller; +import com.openisle.mapper.CategoryMapper; +import com.openisle.mapper.PostMapper; import com.openisle.model.Category; import com.openisle.service.CategoryService; import com.openisle.service.PostService; @@ -9,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Import; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; @@ -20,6 +23,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @WebMvcTest(CategoryController.class) @AutoConfigureMockMvc(addFilters = false) +@Import(CategoryMapper.class) class CategoryControllerTest { @Autowired private MockMvc mockMvc; @@ -30,6 +34,9 @@ class CategoryControllerTest { @MockBean private PostService postService; + @MockBean + private PostMapper postMapper; + @Test void createAndGetCategory() throws Exception { Category c = new Category();