-
Notifications
You must be signed in to change notification settings - Fork 1
[test] 스터디 가입 요청/수락/거절 API 인수 테스트 추가 #54
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
Open
crtEvent
wants to merge
16
commits into
feat/#25-impl-join-request-3
Choose a base branch
from
test/#25-add-join-request-test-2
base: feat/#25-impl-join-request-3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ad677a8
rename: AcceptanceTest 패키지 위치 acceptance로 변경
crtEvent 3861e98
refactor: AcceptanceTest에 응답코드 검증 세분화
crtEvent ee46111
chore: AcceptanceTest에 Redis Test Container 설정 추가
crtEvent f718c6d
test: 테스트용 로그인 Step 메서드 추가
crtEvent bdf8a22
test: JoinRequestStep 추가
crtEvent f3cba4b
test: JoinRequestFixture 추가
crtEvent 9618f2f
test: 스터디 가입 요청 인수 테스트 추가
crtEvent e15ff41
test: 스터디 가입 요청 수락 인수 테스트 추가
crtEvent 9cc975b
test: 스터디 가입 요청 거절 인수 테스트 추가
crtEvent 0820ef5
fix: JoinRequestStep 스터디 가입 요청/거절 API 요청 patch 메서드로 수정
crtEvent bb3119c
chore: 테스트 설정 파일에 session-name 추가
crtEvent 0932f6f
chore: reset.sql에 join_request 테이블 추가
crtEvent 87cd02b
test: 스터디 가입 요청 수락/거절시 study_id 검증 케이스 추가
crtEvent 5c3a754
fix: 오타 수정
crtEvent 71f4877
rename: Fixture 분리 및 위치 변경
crtEvent 6108631
fix: EnableJpaAuditing 중복된 설정 제거
crtEvent 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
125 changes: 125 additions & 0 deletions
125
...est/java/com/flytrap/venusplanner/acceptance/join_request/test/CreateJoinRequestTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| package com.flytrap.venusplanner.acceptance.join_request.test; | ||
|
|
||
| import static com.flytrap.venusplanner.acceptance.join_request.fixture.JoinRequestFixture.리더; | ||
| import static com.flytrap.venusplanner.acceptance.join_request.fixture.JoinRequestFixture.리더_멤버_스터디; | ||
| import static com.flytrap.venusplanner.acceptance.join_request.fixture.JoinRequestFixture.멤버_01; | ||
| import static com.flytrap.venusplanner.acceptance.join_request.fixture.JoinRequestFixture.멤버_스터디; | ||
| import static com.flytrap.venusplanner.acceptance.join_request.fixture.JoinRequestFixture.수락된_가입_요청; | ||
| import static com.flytrap.venusplanner.acceptance.join_request.fixture.JoinRequestFixture.신규_가입_요청; | ||
| import static com.flytrap.venusplanner.acceptance.join_request.fixture.JoinRequestFixture.알고리즘_스터디; | ||
| import static com.flytrap.venusplanner.acceptance.join_request.step.JoinRequestStep.스터디_가입_요청; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.junit.jupiter.api.Assertions.assertAll; | ||
|
|
||
| import com.flytrap.venusplanner.acceptance.AcceptanceTest; | ||
| import com.flytrap.venusplanner.api.join_request.domain.JoinRequestState; | ||
| import com.flytrap.venusplanner.api.join_request.infrastructure.repository.JoinRequestRepository; | ||
| import com.flytrap.venusplanner.api.member.domain.Member; | ||
| import com.flytrap.venusplanner.api.member.infrastructure.repository.MemberRepository; | ||
| import com.flytrap.venusplanner.api.member_study.infrastructure.repository.MemberStudyRepository; | ||
| import com.flytrap.venusplanner.api.study.domain.Study; | ||
| import com.flytrap.venusplanner.api.study.infrastructure.repository.StudyRepository; | ||
| import io.restassured.response.ExtractableResponse; | ||
| import io.restassured.response.Response; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
|
|
||
| @DisplayName("[인수테스트] 스터디 가입 요청 케이스") | ||
| public class CreateJoinRequestTest extends AcceptanceTest { | ||
|
|
||
| @Autowired | ||
| MemberRepository memberRepository; | ||
|
|
||
| @Autowired | ||
| StudyRepository studyRepository; | ||
|
|
||
| @Autowired | ||
| MemberStudyRepository memberStudyRepository; | ||
|
|
||
| @Autowired | ||
| JoinRequestRepository joinRequestRepository; | ||
|
|
||
| @Test | ||
| void 유저는_스터디에_가입_요청을_할_수_있다() { | ||
| // given | ||
| var leader = memberRepository.save(리더()); | ||
| var member = memberRepository.save(멤버_01()); | ||
| var study = studyRepository.save(알고리즘_스터디()); | ||
| var leaderMemberStudy = memberStudyRepository.save(리더_멤버_스터디(study, leader)); | ||
| var sessionCookie = 테스트_로그인(member.getId()); | ||
|
|
||
| // when | ||
| var response = 스터디_가입_요청(study.getId(), sessionCookie); | ||
|
|
||
| // then | ||
| 응답_코드는_201_CREATED_를_반환한다(response); | ||
| 응답_바디로_생성된_가입_요청의_ID를_반환한다(response); | ||
| 스터디_가입_요청이_생성되었는지_검증(response, study, member); | ||
| } | ||
|
|
||
| @Test | ||
| void 존재하지_않는_스터디에_가입_요청을_보낼_수_없다() { | ||
| // given | ||
| var member = memberRepository.save(멤버_01()); | ||
| var sessionCookie = 테스트_로그인(member.getId()); | ||
|
|
||
| // when | ||
| var response = 스터디_가입_요청(999L, sessionCookie); | ||
|
|
||
| // then | ||
| 응답_코드는_404_NOT_FOUND_를_반환한다(response); | ||
| } | ||
|
|
||
| @Test | ||
| void 이미_가입_요청된_상태의_스터디에_가입_요청을_보낼_수_없다() { | ||
| // given | ||
| var leader = memberRepository.save(리더()); | ||
| var member = memberRepository.save(멤버_01()); | ||
| var study = studyRepository.save(알고리즘_스터디()); | ||
| var leaderMemberStudy = memberStudyRepository.save(리더_멤버_스터디(study, leader)); | ||
| var joinRequest = joinRequestRepository.save(신규_가입_요청(study, member)); | ||
| var sessionCookie = 테스트_로그인(member.getId()); | ||
|
|
||
| // when | ||
| var response = 스터디_가입_요청(study.getId(), sessionCookie); | ||
|
|
||
| // then | ||
| 응답_코드는_409_CONFLICT_를_반환한다(response); | ||
| } | ||
|
|
||
| @Test | ||
| void 이미_가입된_스터디에_가입_요청을_보낼_수_없다() { | ||
| // given | ||
| var leader = memberRepository.save(리더()); | ||
| var member = memberRepository.save(멤버_01()); | ||
| var study = studyRepository.save(알고리즘_스터디()); | ||
| var leaderMemberStudy = memberStudyRepository.save(리더_멤버_스터디(study, leader)); | ||
| var memberStudy = memberStudyRepository.save(멤버_스터디(study, member)); | ||
| var joinRequest = joinRequestRepository.save(수락된_가입_요청(study, member)); | ||
| var sessionCookie = 테스트_로그인(member.getId()); | ||
|
|
||
| // when | ||
| var response = 스터디_가입_요청(study.getId(), sessionCookie); | ||
|
|
||
| // then | ||
| 응답_코드는_409_CONFLICT_를_반환한다(response); | ||
| } | ||
|
|
||
| private void 응답_바디로_생성된_가입_요청의_ID를_반환한다(ExtractableResponse<Response> response) { | ||
| assertThat(response.body().jsonPath().getLong("id")) | ||
| .isNotNull(); | ||
| } | ||
|
|
||
| private void 스터디_가입_요청이_생성되었는지_검증(ExtractableResponse<Response> response, Study study, Member member) { | ||
| var createdId = response.body().jsonPath().getLong("id"); | ||
| var created = joinRequestRepository.findById(createdId).get(); | ||
|
|
||
|
Comment on lines
+114
to
+117
Member
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. 저는 actual expected 이런식으로 네이밍했어요! |
||
| assertAll( | ||
| () -> assertThat(created.getStudyId()).isEqualTo(study.getId()), | ||
| () -> assertThat(created.getMemberId()).isEqualTo(member.getId()), | ||
| () -> assertThat(created.getState()).isEqualTo(JoinRequestState.WAIT) | ||
| ); | ||
| } | ||
|
|
||
| } | ||
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.
저는 API 요청을 날렸는데 에이프는 레포지토리에 직접 저장하셨군요