-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 지원자 프로필 조회 API 통합 #159
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
Merged
Merged
Changes from 2 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 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
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
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
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
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
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
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
147 changes: 147 additions & 0 deletions
147
...va/com/slatto/domain/recruitment/service/RecruitmentApplicationDetailIntegrationTest.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,147 @@ | ||
| package com.slatto.domain.recruitment.service; | ||
|
|
||
| import com.slatto.domain.recruitment.dto.RecruitmentApplicationDetailResponse; | ||
| import com.slatto.domain.recruitment.entity.Recruitment; | ||
| import com.slatto.domain.recruitment.entity.RecruitmentApplication; | ||
| import com.slatto.domain.recruitment.repository.RecruitmentApplicationRepository; | ||
| import com.slatto.domain.recruitment.repository.RecruitmentRepository; | ||
| import com.slatto.domain.user.entity.UserPortfolio; | ||
| import com.slatto.domain.user.entity.UserPortfolioRole; | ||
| import com.slatto.domain.user.entity.Users; | ||
| import com.slatto.domain.user.enums.CategoryName; | ||
| import com.slatto.domain.user.enums.Kind; | ||
| import com.slatto.domain.user.enums.RegionName; | ||
| import com.slatto.domain.user.enums.RoleName; | ||
| import com.slatto.domain.user.enums.SocialType; | ||
| import com.slatto.domain.user.repository.UserPortfolioRepository; | ||
| import com.slatto.domain.user.repository.UserRepository; | ||
| import com.slatto.global.exception.BaseException; | ||
| import com.slatto.global.response.code.CommonErrorCode; | ||
| import jakarta.persistence.EntityManager; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
|
||
| @SpringBootTest | ||
| @Transactional | ||
| class RecruitmentApplicationDetailIntegrationTest { | ||
|
|
||
| @Autowired | ||
| private RecruitmentApplicationService recruitmentApplicationService; | ||
|
|
||
| @Autowired | ||
| private RecruitmentApplicationRepository recruitmentApplicationRepository; | ||
|
|
||
| @Autowired | ||
| private RecruitmentRepository recruitmentRepository; | ||
|
|
||
| @Autowired | ||
| private UserPortfolioRepository userPortfolioRepository; | ||
|
|
||
| @Autowired | ||
| private UserRepository userRepository; | ||
|
|
||
| @Autowired | ||
| private EntityManager entityManager; | ||
|
|
||
| private Users writer; | ||
| private Users applicant; | ||
| private Recruitment recruitment; | ||
| private RecruitmentApplication application; | ||
|
|
||
| @BeforeEach | ||
| void setUp() { | ||
| writer = saveUser("writer@example.com", "작성자", "google-writer"); | ||
| applicant = saveUser("applicant@example.com", "지원자", "google-applicant"); | ||
| applicant.updateProfile("지원자", "영상 편집 5년차입니다", null); | ||
|
|
||
| recruitment = recruitmentRepository.save(Recruitment.create( | ||
| writer, "공고 제목입니다", CategoryName.FILM_DRAMA, null, RoleName.DIRECTOR, | ||
| RegionName.SEOUL, null, null, "010-0000-0000", "설명", null | ||
| )); | ||
| application = recruitmentApplicationRepository.save( | ||
| RecruitmentApplication.create(applicant, recruitment, "지원합니다", "https://portfolio.example") | ||
| ); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("지원 상세가 지원자 프로필과 프로젝트 이력을 함께 반환한다") | ||
| void returnsApplicantProfileAndPortfolios() { | ||
| savePortfolio(CategoryName.FILM_DRAMA, RoleName.EDITOR); | ||
|
|
||
| RecruitmentApplicationDetailResponse response = recruitmentApplicationService.getApplicationDetail( | ||
| writer.getId(), recruitment.getId(), application.getId() | ||
| ); | ||
|
|
||
| RecruitmentApplicationDetailResponse.ApplicantProfile profile = response.getApplicant(); | ||
| assertThat(profile.getBio()).isEqualTo("영상 편집 5년차입니다"); | ||
| assertThat(profile.getPortfolios().getItems()).hasSize(1); | ||
| assertThat(profile.getStats().getProjectTypes()).hasSize(1); | ||
| assertThat(profile.getStats().getRoles()).hasSize(1); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("포트폴리오가 5건을 넘으면 hasNext 로 더 있음을 알린다") | ||
| void marksHasNextWhenPortfolioExceedsLimit() { | ||
| for (int i = 0; i < 6; i++) { | ||
| savePortfolio(CategoryName.FILM_DRAMA, RoleName.EDITOR); | ||
| } | ||
|
|
||
| RecruitmentApplicationDetailResponse response = recruitmentApplicationService.getApplicationDetail( | ||
| writer.getId(), recruitment.getId(), application.getId() | ||
| ); | ||
|
|
||
| assertThat(response.getApplicant().getPortfolios().getItems()).hasSize(5); | ||
| assertThat(response.getApplicant().getPortfolios().getHasNext()).isTrue(); | ||
| assertThat(response.getApplicant().getPortfolios().getNextCursor()).isNotNull(); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("탈퇴한 지원자의 지원도 상세 조회된다") | ||
| void returnsDetailForWithdrawnApplicant() { | ||
| // 지원자 목록은 탈퇴 여부를 거르지 않는다. 상세만 404 가 되면 작성자가 목록에서 연 항목이 열리지 않는다. | ||
| applicant.withdraw(LocalDateTime.now()); | ||
| entityManager.flush(); | ||
|
|
||
| RecruitmentApplicationDetailResponse response = recruitmentApplicationService.getApplicationDetail( | ||
| writer.getId(), recruitment.getId(), application.getId() | ||
| ); | ||
|
|
||
| assertThat(response.getApplicant().getId()).isEqualTo(applicant.getId()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("공고 작성자도 지원 본인도 아니면 상세를 볼 수 없다") | ||
| void deniesDetailToStranger() { | ||
| Users stranger = saveUser("stranger@example.com", "제삼자", "google-stranger"); | ||
|
|
||
| assertThatThrownBy(() -> recruitmentApplicationService.getApplicationDetail( | ||
| stranger.getId(), recruitment.getId(), application.getId() | ||
| )) | ||
| .isInstanceOf(BaseException.class) | ||
| .extracting(exception -> ((BaseException) exception).getErrorCode()) | ||
| .isEqualTo(CommonErrorCode.FORBIDDEN); | ||
| } | ||
|
|
||
| private Users saveUser(String email, String nickname, String socialId) { | ||
| return userRepository.save(Users.createSocialUser( | ||
| email, nickname, null, SocialType.GOOGLE, socialId | ||
| )); | ||
| } | ||
|
|
||
| private void savePortfolio(CategoryName type, RoleName roleName) { | ||
| UserPortfolio portfolio = userPortfolioRepository.save(UserPortfolio.create( | ||
| applicant, "작업 제목", type, null, Kind.PERSONAL, null, null, null, null, null | ||
| )); | ||
| entityManager.persist(UserPortfolioRole.create(portfolio, applicant, roleName)); | ||
| entityManager.flush(); | ||
| } | ||
| } |
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
포트폴리오 호출 안내를 조건부로 수정하세요.
Line 91-92는 포트폴리오 API를 호출할 필요가 없다고 설명합니다. Line 98-99는
hasNext가true이면 같은 API를 호출하라고 설명합니다.최초 5건만 필요한 경우에는 상세 응답만 사용하고, 전체 이력이 필요한 경우에는 포트폴리오 API를 호출한다고 명확히 설명하세요.
🤖 Prompt for AI Agents