From 9f4c31d58298fa2816f89f0b5724781a1f83f90c Mon Sep 17 00:00:00 2001 From: jaeyeon kim Date: Tue, 26 Sep 2023 12:19:03 +0900 Subject: [PATCH] =?UTF-8?q?refactor=20:=20AnnotationHandlerMappingTest=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mvc/tobe/AnnotationHandlerMappingTest.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mvc/src/test/java/webmvc/org/springframework/web/servlet/mvc/tobe/AnnotationHandlerMappingTest.java b/mvc/src/test/java/webmvc/org/springframework/web/servlet/mvc/tobe/AnnotationHandlerMappingTest.java index 8e4472cdbc..e7e04b8f6e 100644 --- a/mvc/src/test/java/webmvc/org/springframework/web/servlet/mvc/tobe/AnnotationHandlerMappingTest.java +++ b/mvc/src/test/java/webmvc/org/springframework/web/servlet/mvc/tobe/AnnotationHandlerMappingTest.java @@ -4,6 +4,7 @@ import jakarta.servlet.http.HttpServletResponse; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import webmvc.org.springframework.web.servlet.ModelAndView; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -12,11 +13,13 @@ class AnnotationHandlerMappingTest { private AnnotationHandlerMapping handlerMapping; + private AnnotationHandlerAdapter annotationHandlerAdapter; @BeforeEach void setUp() { handlerMapping = new AnnotationHandlerMapping("samples"); handlerMapping.initialize(); + annotationHandlerAdapter = new AnnotationHandlerAdapter(); } @Test @@ -28,8 +31,8 @@ void get() throws Exception { when(request.getRequestURI()).thenReturn("/get-test"); when(request.getMethod()).thenReturn("GET"); - final var handlerExecution = handlerMapping.getHandler(request); - final var modelAndView = handlerExecution.handle(request, response); + final var handler = handlerMapping.getHandler(request); + final var modelAndView = annotationHandlerAdapter.handle(handler, request, response); assertThat(modelAndView.getObject("id")).isEqualTo("gugu"); } @@ -43,8 +46,8 @@ void post() throws Exception { when(request.getRequestURI()).thenReturn("/post-test"); when(request.getMethod()).thenReturn("POST"); - final var handlerExecution = handlerMapping.getHandler(request); - final var modelAndView = handlerExecution.handle(request, response); + final var handler = handlerMapping.getHandler(request); + final var modelAndView = annotationHandlerAdapter.handle(handler, request, response); assertThat(modelAndView.getObject("id")).isEqualTo("gugu"); }