-
Notifications
You must be signed in to change notification settings - Fork 4
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
[BE] 같은 스터디 진행 이후 다른 멤버 스터디 기록이 조회되지 않는 오류 수정 #758
Merged
MoonJeWoong
merged 4 commits into
develop
from
be/feature/757-fix-find-other-participants-in-study
Feb 28, 2024
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
||
import harustudy.backend.auth.dto.AuthMember; | ||
import harustudy.backend.auth.exception.AuthorizationException; | ||
import harustudy.backend.content.domain.Content; | ||
import harustudy.backend.content.dto.ContentResponse; | ||
import harustudy.backend.content.dto.ContentsResponse; | ||
|
@@ -45,19 +46,21 @@ class ContentServiceTest { | |
|
||
private Study study; | ||
private Member member; | ||
private Member member2; | ||
private Participant participant; | ||
private Content content; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
study = new Study("studyName", 1, 20); | ||
member = new Member("nickname", "email", "imageUrl", LoginType.GUEST); | ||
member2 = new Member("nickname2", "email2", "imageUrl2", LoginType.GUEST); | ||
participant = Participant.createParticipantOfStudy(study, member, "nickname"); | ||
|
||
content = new Content(participant, 1); | ||
|
||
entityManager.persist(study); | ||
entityManager.persist(member); | ||
entityManager.persist(member2); | ||
entityManager.persist(participant); | ||
entityManager.persist(content); | ||
|
||
|
@@ -224,6 +227,26 @@ void setUp() { | |
assertThat(content).isEqualTo(expectedContentResponses); | ||
} | ||
|
||
@Test | ||
void 스터디원은_같은_스터디_내_다른_멤버의_콘텐츠를_조회할_수_있다() { | ||
// given | ||
AuthMember authMember = new AuthMember(member.getId()); | ||
Participant participant2 = Participant.createParticipantOfStudy(study, member2, "nickname2"); | ||
Content contentOfMember2 = new Content(participant2, 1); | ||
|
||
entityManager.persist(participant2); | ||
entityManager.persist(contentOfMember2); | ||
|
||
EntityManagerUtil.flushAndClearContext(entityManager); | ||
|
||
// when | ||
ContentsResponse contentsWithFilter = contentService.findContentsWithFilter(authMember, | ||
study.getId(), participant2.getId(), null); | ||
|
||
// then | ||
assertThat(contentsWithFilter.content().size()).isEqualTo(1); | ||
} | ||
|
||
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. 테스트까지.. 💯 |
||
@Test | ||
void 스터디에_참여한_특정_스터디원의_콘텐츠를_조회시_스터디가_없으면_예외를_던진다() { | ||
// given | ||
|
@@ -247,4 +270,14 @@ void setUp() { | |
study.getId(), 999L, null)) | ||
.isInstanceOf(ParticipantNotFoundException.class); | ||
} | ||
|
||
@Test | ||
void 같은_스터디에_참여하지_않은_멤버가_다른_스터디_멤버의_콘텐츠를_조회하면_예외를_던진다() { | ||
// given | ||
AuthMember authMember = new AuthMember(member2.getId()); | ||
|
||
// when, then | ||
assertThatThrownBy(() -> contentService.findContentsWithFilter(authMember, | ||
study.getId(), participant.getId(), null)).isInstanceOf(AuthorizationException.class); | ||
} | ||
} |
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.
멤버가 참여자가 아니라면 true를 반환하는 메소드네요!
메소드명이
isMemberNotIncludedInParticipants
여야 할 것 같은데, 아마 오타가 난 것 같습니다!!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.
이래서 코드리뷰 하는거죠 ㅎㅎ 감사합니다 테오~ 😄