Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public List<TargetUserDto> 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<Notification> findByTargetIdAndType(Long id, TargetType targetType) {
return notificationRepository.findByTargetIdAndType(id, targetType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public interface NotificationRepository {
Notification save(Notification notification);
void saveAll(List<Notification> notifications);
Optional<Notification> findNotificationById(Long id);
boolean existsByReceiverIdAndIsReadFalseAndDeletedFalse(Long userId);
boolean existsByReceiverIdAndIsReadFalseAndDeletedFalseAndIsValidTrue(Long userId);
List<Notification> findByTargetIdAndType(Long targetId, TargetType targetType);

void deleteAllByUserId(Long userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@Repository
public interface NotificationJpaRepository extends JpaRepository<Notification, Long> {
boolean existsByReceiverIdAndIsReadFalseAndDeletedFalse(Long userId);
boolean existsByReceiverIdAndIsReadFalseAndDeletedFalseAndIsValidTrue(Long userId);
@Query("""
SELECT distinct n
FROM Notification n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public Optional<Notification> findNotificationById(Long id) {
}

@Override
public boolean existsByReceiverIdAndIsReadFalseAndDeletedFalse(Long userId) {
return notificationJpaRepository.existsByReceiverIdAndIsReadFalseAndDeletedFalse(userId);
public boolean existsByReceiverIdAndIsReadFalseAndDeletedFalseAndIsValidTrue(Long userId) {
return notificationJpaRepository.existsByReceiverIdAndIsReadFalseAndDeletedFalseAndIsValidTrue(userId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -60,6 +61,9 @@ class NotificationInvalidListenerTest extends IntegrationTest {
@Autowired
PostCommandService postCommandService;

@Autowired
NotificationService notificationQueryService;

@AfterEach
void tearDown() {
voteRepository.deleteAllInBatch();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
);
}
}