-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature/#141-알림 목록 조회 API 구현 #162
Merged
The head ref may contain hidden characters: "Feature/#141-\uC54C\uB9BC_\uBAA9\uB85D_\uC870\uD68C_API_\uAD6C\uD604"
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
2 changes: 2 additions & 0 deletions
2
backend/emm-sale/src/main/java/com/emmsale/notification/domain/NotificationRepository.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package com.emmsale.notification.domain; | ||
|
||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface NotificationRepository extends JpaRepository<Notification, Long> { | ||
|
||
List<Notification> findAllByReceiverId(Long memberId); | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import com.emmsale.helper.ServiceIntegrationTestHelper; | ||
import com.emmsale.member.domain.Member; | ||
import com.emmsale.member.domain.MemberRepository; | ||
import com.emmsale.notification.application.dto.FcmTokenRequest; | ||
import com.emmsale.notification.application.dto.NotificationModifyRequest; | ||
import com.emmsale.notification.application.dto.NotificationRequest; | ||
|
@@ -18,12 +20,15 @@ | |
import com.emmsale.notification.domain.NotificationStatus; | ||
import com.emmsale.notification.exception.NotificationException; | ||
import com.emmsale.notification.exception.NotificationExceptionType; | ||
import java.util.List; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.test.context.jdbc.Sql; | ||
|
||
@Sql("/data-test.sql") | ||
class NotificationCommandServiceTest extends ServiceIntegrationTestHelper { | ||
|
||
@Autowired | ||
|
@@ -32,6 +37,8 @@ class NotificationCommandServiceTest extends ServiceIntegrationTestHelper { | |
private FcmTokenRepository fcmTokenRepository; | ||
@Autowired | ||
private NotificationRepository notificationRepository; | ||
@Autowired | ||
private MemberRepository memberRepository; | ||
|
||
@Test | ||
@DisplayName("create() : 알림을 새로 생성할 수 있다.") | ||
|
@@ -157,4 +164,30 @@ void test_modify() throws Exception { | |
//then | ||
assertEquals(request.getUpdatedStatus(), updatedNotification.getStatus()); | ||
} | ||
|
||
@Test | ||
@DisplayName("Member가 받은 모든 알림 목록을 조회한다.") | ||
void test_findAllNotifications() { | ||
//given | ||
final Member sender = memberRepository.findById(1L).get(); | ||
final Member receiver = memberRepository.findById(2L).get(); | ||
|
||
final String message1 = "message123"; | ||
final String message2 = "message321"; | ||
|
||
notificationRepository.save( | ||
new Notification(sender.getId(), receiver.getId(), 123L, message1) | ||
); | ||
notificationRepository.save( | ||
new Notification(sender.getId(), receiver.getId(), 321L, message2) | ||
); | ||
|
||
//when | ||
final List<NotificationResponse> notifications = notificationCommandService.findAllNotifications( | ||
receiver); | ||
|
||
//then | ||
assertThat(notifications).extracting("message", String.class) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요기는 Notification::getMessage를 사용했어도 좋았을 것 같아요. |
||
.containsExactly(message1, message2); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.
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.
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.
ServiceTest에서는 ServiceIntegerationTest를 상속받고 있어서, 굳이 @Sql(data-test.sql)을 명시할 필요는 없을거에요
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.
ㅇㅈ