Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MVC 구현하기 - 3단계] 아벨(신준혁) 미션 제출합니다. #608

Merged
merged 9 commits into from
Sep 25, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import webmvc.org.springframework.web.servlet.ModelAndView;
import webmvc.org.springframework.web.servlet.mvc.tobe.AnnotationHandlerMapping;
import webmvc.org.springframework.web.servlet.mvc.tobe.HandlerExecution;
import webmvc.org.springframework.web.servlet.view.JspView;

class AnnotationHandlerMappingTest {

Expand All @@ -36,7 +37,7 @@ void register() throws Exception {
final var handlerExecution = (HandlerExecution) handlerMapping.getHandler(request);
final var modelAndView = (ModelAndView) handlerExecution.handle(request, response);

assertThat(modelAndView.getView().getViewName()).isEqualTo("redirect:/index.jsp");
assertThat(modelAndView.getView()).usingRecursiveComparison().isEqualTo(new JspView("redirect:/index.jsp"));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usingRecursiveComparison 👍

}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package webmvc.org.springframework.web.servlet.view;

import static jakarta.servlet.http.HttpServletResponse.SC_NOT_FOUND;
import static jakarta.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;

import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletRequest;
Expand All @@ -16,7 +16,7 @@ public class JsonView implements View {
public void render(final Map<String, ?> model, final HttpServletRequest request, HttpServletResponse response)
throws Exception {
if (model == null || model.isEmpty()) {
response.setStatus(SC_NOT_FOUND);
response.setStatus(SC_INTERNAL_SERVER_ERROR);
return;
}
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
Expand Down