-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/board driving : 불필요한 코드 삭제 및 mapper config 외부 연결. #80
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
base: main
Are you sure you want to change the base?
Conversation
다음 이슈에 대해 이슈 페이지에서 자세히 설명해 주세요. |
@TestConfiguration | ||
class JacksonTestConfig { | ||
@Bean | ||
fun objectMapper(): ObjectMapper { | ||
return ObjectMapper() | ||
.registerModule(JavaTimeModule()) | ||
.setSerializationInclusion(JsonInclude.Include.NON_NULL) | ||
} | ||
|
||
@Bean | ||
fun mappingJackson2HttpMessageConverter(objectMapper: ObjectMapper): MappingJackson2HttpMessageConverter { | ||
return MappingJackson2HttpMessageConverter(objectMapper) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 이 설정 파일이 명시적으로 필요한 이유가 무엇인가요?
이 설정 파일이 어떨 때 필요하고, 있을 때와 없을 때 어떤 차이가 있는지 궁금합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@merge-simpson 바쁜 와중에도 질문 남겨주셔서 감사합니다.
메인 프로젝트의 Jackson 설정이 테스트 환경에 적용되지 않는 문제를 해결하기 위해,
테스트 환경에서도 동일한 설정이 유지되도록 ObjectMapper와 MappingJackson2HttpMessageConverter를 수동으로 @bean 등록하였습니다.
- ObjectMapper 설정
- registerModule(JavaTimeModule()) → 날짜 타입 변환을 지원하도록 설정
- setSerializationInclusion(JsonInclude.NON_NULL) → null 값이 JSON 직렬화되지 않도록 설정
- MappingJackson2HttpMessageConverter 등록 이유
- HTTP 요청/응답 변환 시, 등록한 ObjectMapper가 사용되도록 설정
이 설정 파일은 컨트롤러 테스트에서 활용하는 것이 적절해 보이며, 이를 적용하면 HTTP 통신 테스트에서 null 값이 JSON 직렬화되지 않는 차이가 있습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍작업하시느라 고생많으셨습니다~
설정과 관련된 코드를 Test 진행하는 코드와 분리해 작성해주셨군요! 다른 테스트 코드에서도 이 설정이 필요하다면 @Import
를 이용해서 쉽게 사용할 수 있을 것 같습니다~! 감사합니다~
Pull Request
Issues
Resolves #73
Resolves #75
Resolves #76
Description
: beforeSpec내의 110~114번줄, 이와 연결된 140,141번줄, 157번의 코드를 수정하였습니다. nonNullResponse >> boardDetailWithNull로 변경함.
: 내부에 있던 jackson mapper config 내용을 외부로 이동시켰습니다.(test의 core.config 내에 JacksonTestConfig.kt 파일 생성 후 이동시킴)
How Has This Been Tested?