Skip to content

Commit

Permalink
refactor : AnnotationHandlerMappingTest 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kpeel5839 committed Sep 26, 2023
1 parent 63223b3 commit 9f4c31d
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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");
}
Expand All @@ -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");
}
Expand Down

0 comments on commit 9f4c31d

Please sign in to comment.