Conversation
• addComment • 저장 직후 post.getComments().add(comment) 추가해 Post-Comment 컬렉션 일관성 확보 • basePostPersistencePort.save(post) 삭제 – Managed 상태이므로 자동 flush • deleteComment • 자식·부모 댓글 삭제 후 컬렉션에서 removeAll / remove 로 참조 제거 • 댓글 수 감소 후 post 저장 호출 제거 → ObjectDeletedException 발생 원인 해소
• 서비스 메서드로만 댓글/대댓글 생성해 실제 동선 그대로 재현 • flush + clear 및 ID 기반 단정으로 삭제-cascade 안정적으로 확인 • 알림 호출(NotificationUseCase.create)·권한 예외·카운터 갱신 등 핵심 시나리오 추가 • Mock 설정 최소화, 테스트 가독성 향상을 위해 픽스처 재구성
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
변경 내용
CommentService
post.getComments().add(comment)로 Post‑Comment 컬렉션 동기화basePostPersistencePort.save(post)제거 → Managed 상태 자동 flushpost.getComments().removeAll(children)/remove(comment)로 참조 제거commentCount감소 후 별도 merge 없이 트랜잭션 flush에 맡김→
ObjectDeletedException근본 해결CommentServiceTest
flush()+clear()및 ID 기반 검증으로 테스트 안정성 향상times(1)·eq(...)제거 → Mockito 호출 단순화문제점 & 해결
post를 merge할 때 이미 REMOVED 된 객체가 cascade‑merge 되어ObjectDeletedException이 간헐적으로 발생.