반응형 개인 프로젝트2 예외 처리 시, @JsonInclude의 쓰임 정리 존재하지 않는 게시글 조회 시, 예외 처리 테스트를 진행했다.@Test@DisplayName("존재하지 않는 게시글 조회")void test9 () throws Exception { mockMvc.perform(get("/post/{postId}", 1L) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isNotFound()) .andDo(print());} @Getterpublic class ErrorResponse { private final String code; private final String message; private Map validation.. 2025. 6. 10. 생성자 말고 Lombok / @Builder 활용하기 개인 프로젝트로 블로그를 만들고 있다. 테스트 클래스를 통한 검증을 해보았다.최초, PostCreate의 생성자를 이용하여 문자열을 보낸다.@Test@DisplayName("/posts 요청 시 문자 출력한다.")void test() throws Exception{ PostCreate request = new PostCreate("제목입니다.", "내용입니다."); ObjectMapper objectMapper = new ObjectMapper(); String json = objectMapper.writeValueAsString(request); System.out.println(json); mockMvc.perform(post("/post") .. 2025. 5. 27. 이전 1 다음 반응형