From 9d98903bf2e896e26980a9ee32bb678a58715c92 Mon Sep 17 00:00:00 2001 From: yunseongoh Date: Mon, 8 Dec 2025 00:38:12 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix=20:=20=EC=95=8C=EB=A6=BC=20=ED=98=84?= =?UTF-8?q?=ED=99=A9=20=EC=A1=B0=ED=9A=8C=20=EC=9C=A0=ED=9A=A8=ED=95=9C=20?= =?UTF-8?q?=EC=95=8C=EB=A6=BC=20=EC=A1=B0=EA=B1=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/service/NotificationQueryService.java | 2 +- .../com/chooz/notification/domain/NotificationRepository.java | 2 +- .../notification/persistence/NotificationJpaRepository.java | 2 +- .../notification/persistence/NotificationRepositoryImpl.java | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/chooz/notification/application/service/NotificationQueryService.java b/src/main/java/com/chooz/notification/application/service/NotificationQueryService.java index e68243f..c4acfa5 100644 --- a/src/main/java/com/chooz/notification/application/service/NotificationQueryService.java +++ b/src/main/java/com/chooz/notification/application/service/NotificationQueryService.java @@ -56,7 +56,7 @@ public List findVoteUsersByPostId(Long postId) { return notificationQueryRepository.findVoteUsersByPostId(postId); } public NotificationPresentResponse present(Long userId) { - return NotificationPresentResponse.of(notificationRepository.existsByReceiverIdAndIsReadFalseAndDeletedFalse(userId)); + return NotificationPresentResponse.of(notificationRepository.existsByReceiverIdAndIsReadFalseAndDeletedFalseAndIsValidTrue(userId)); } public List findByTargetIdAndType(Long id, TargetType targetType) { return notificationRepository.findByTargetIdAndType(id, targetType); diff --git a/src/main/java/com/chooz/notification/domain/NotificationRepository.java b/src/main/java/com/chooz/notification/domain/NotificationRepository.java index c99413c..440eb9c 100644 --- a/src/main/java/com/chooz/notification/domain/NotificationRepository.java +++ b/src/main/java/com/chooz/notification/domain/NotificationRepository.java @@ -7,7 +7,7 @@ public interface NotificationRepository { Notification save(Notification notification); void saveAll(List notifications); Optional findNotificationById(Long id); - boolean existsByReceiverIdAndIsReadFalseAndDeletedFalse(Long userId); + boolean existsByReceiverIdAndIsReadFalseAndDeletedFalseAndIsValidTrue(Long userId); List findByTargetIdAndType(Long targetId, TargetType targetType); void deleteAllByUserId(Long userId); diff --git a/src/main/java/com/chooz/notification/persistence/NotificationJpaRepository.java b/src/main/java/com/chooz/notification/persistence/NotificationJpaRepository.java index c6d0ee7..bfe1cb9 100644 --- a/src/main/java/com/chooz/notification/persistence/NotificationJpaRepository.java +++ b/src/main/java/com/chooz/notification/persistence/NotificationJpaRepository.java @@ -11,7 +11,7 @@ @Repository public interface NotificationJpaRepository extends JpaRepository { - boolean existsByReceiverIdAndIsReadFalseAndDeletedFalse(Long userId); + boolean existsByReceiverIdAndIsReadFalseAndDeletedFalseAndIsValidTrue(Long userId); @Query(""" SELECT distinct n FROM Notification n diff --git a/src/main/java/com/chooz/notification/persistence/NotificationRepositoryImpl.java b/src/main/java/com/chooz/notification/persistence/NotificationRepositoryImpl.java index 906ba74..830c1c1 100644 --- a/src/main/java/com/chooz/notification/persistence/NotificationRepositoryImpl.java +++ b/src/main/java/com/chooz/notification/persistence/NotificationRepositoryImpl.java @@ -32,8 +32,8 @@ public Optional findNotificationById(Long id) { } @Override - public boolean existsByReceiverIdAndIsReadFalseAndDeletedFalse(Long userId) { - return notificationJpaRepository.existsByReceiverIdAndIsReadFalseAndDeletedFalse(userId); + public boolean existsByReceiverIdAndIsReadFalseAndDeletedFalseAndIsValidTrue(Long userId) { + return notificationJpaRepository.existsByReceiverIdAndIsReadFalseAndDeletedFalseAndIsValidTrue(userId); } @Override From 23eeba2391db1a4c9b0dcb84e8f18b673eed70d2 Mon Sep 17 00:00:00 2001 From: yunseongoh Date: Mon, 8 Dec 2025 00:38:59 +0900 Subject: [PATCH 2/2] =?UTF-8?q?test=20:=20=EC=95=8C=EB=A6=BC=20invalid?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EC=8B=9C=20=ED=98=84=ED=99=A9=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotificationInvalidListenerTest.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/chooz/notification/application/NotificationInvalidListenerTest.java b/src/test/java/com/chooz/notification/application/NotificationInvalidListenerTest.java index ac8627e..dc89d2a 100644 --- a/src/test/java/com/chooz/notification/application/NotificationInvalidListenerTest.java +++ b/src/test/java/com/chooz/notification/application/NotificationInvalidListenerTest.java @@ -6,6 +6,7 @@ import com.chooz.commentLike.application.CommentLikeService; import com.chooz.notification.application.web.dto.NotificationDto; import com.chooz.notification.domain.NotificationQueryRepository; +import com.chooz.notification.presentation.dto.NotificationPresentResponse; import com.chooz.post.application.PostCommandService; import com.chooz.post.domain.PollChoiceRepository; import com.chooz.post.domain.Post; @@ -60,6 +61,9 @@ class NotificationInvalidListenerTest extends IntegrationTest { @Autowired PostCommandService postCommandService; + @Autowired + NotificationService notificationQueryService; + @AfterEach void tearDown() { voteRepository.deleteAllInBatch(); @@ -99,8 +103,11 @@ void InvalidNotificationByDeleteComment() throws Exception { null, PageRequest.ofSize(10) ).getContent(); + NotificationPresentResponse notificationPresentResponse = notificationQueryService.present(receiver.getId()); assertAll( - () -> assertThat(notifications.size()).isZero() + () -> assertThat(notifications.size()).isZero(), + () -> assertThat(notificationPresentResponse.present()).isFalse() + ); } @Test @@ -128,9 +135,11 @@ void InvalidNotificationByDeletePost() throws Exception { null, PageRequest.ofSize(10) ).getContent(); + NotificationPresentResponse notificationPresentResponse = notificationQueryService.present(user.getId()); assertAll( - () -> assertThat(notifications.size()).isZero() + () -> assertThat(notifications.size()).isZero(), + () -> assertThat(notificationPresentResponse.present()).isFalse() ); } }