diff --git a/src/main/java/com/example/solidconnection/common/exception/ErrorCode.java b/src/main/java/com/example/solidconnection/common/exception/ErrorCode.java index fae3c4980..3c45c97f6 100644 --- a/src/main/java/com/example/solidconnection/common/exception/ErrorCode.java +++ b/src/main/java/com/example/solidconnection/common/exception/ErrorCode.java @@ -50,6 +50,7 @@ public enum ErrorCode { BLOCK_USER_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "차단 대상 사용자를 찾을 수 없습니다."), TERM_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "존재하지 않는 학기입니다."), CURRENT_TERM_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "현재 학기를 찾을 수 없습니다."), + MENTOR_APPLICATION_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "멘토 프로필이 존재하지 않습니다."), // auth USER_ALREADY_SIGN_OUT(HttpStatus.UNAUTHORIZED.value(), "로그아웃 되었습니다."), @@ -126,6 +127,7 @@ public enum ErrorCode { UNIVERSITY_ID_REQUIRED_FOR_CATALOG(HttpStatus.BAD_REQUEST.value(), "목록에서 학교를 선택한 경우 학교 정보가 필요합니다."), UNIVERSITY_ID_MUST_BE_NULL_FOR_OTHER(HttpStatus.BAD_REQUEST.value(), "기타 학교를 선택한 경우 학교 정보를 입력할 수 없습니다."), INVALID_UNIVERSITY_SELECT_TYPE(HttpStatus.BAD_REQUEST.value(), "지원하지 않는 학교 선택 방식입니다."), + MENTOR_ALREADY_EXISTS(HttpStatus.BAD_REQUEST.value(), "이미 멘토 마이 페이지가 존재합니다" ), // socket UNAUTHORIZED_SUBSCRIBE(HttpStatus.FORBIDDEN.value(), "구독 권한이 없습니다."), diff --git a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java index dd9289a3e..b346f076d 100644 --- a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java +++ b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java @@ -3,18 +3,22 @@ import com.example.solidconnection.common.resolver.AuthorizedUser; import com.example.solidconnection.mentor.dto.MentorMyPageResponse; import com.example.solidconnection.mentor.dto.MentorMyPageUpdateRequest; +import com.example.solidconnection.mentor.dto.MentorMyPageCreateRequest; import com.example.solidconnection.mentor.service.MentorMyPageService; import com.example.solidconnection.security.annotation.RequireRoleAccess; import com.example.solidconnection.siteuser.domain.Role; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +@Slf4j @RequiredArgsConstructor @RequestMapping("/mentor/my") @RestController @@ -22,7 +26,7 @@ public class MentorMyPageController { private final MentorMyPageService mentorMyPageService; - @RequireRoleAccess(roles = Role.MENTOR) + @RequireRoleAccess(roles = {Role.MENTOR, Role.TEMP_MENTOR}) @GetMapping public ResponseEntity getMentorMyPage( @AuthorizedUser long siteUserId @@ -31,7 +35,7 @@ public ResponseEntity getMentorMyPage( return ResponseEntity.ok(mentorMyPageResponse); } - @RequireRoleAccess(roles = Role.MENTOR) + @RequireRoleAccess(roles = {Role.MENTOR, Role.TEMP_MENTOR}) @PutMapping public ResponseEntity updateMentorMyPage( @AuthorizedUser long siteUserId, @@ -40,4 +44,14 @@ public ResponseEntity updateMentorMyPage( mentorMyPageService.updateMentorMyPage(siteUserId, mentorMyPageUpdateRequest); return ResponseEntity.ok().build(); } + + @RequireRoleAccess(roles = {Role.MENTOR, Role.TEMP_MENTOR}) + @PostMapping + public ResponseEntity createMentorMyPage( + @AuthorizedUser long siteUserId, + @Valid @RequestBody MentorMyPageCreateRequest request + ) { + mentorMyPageService.createMentorMyPage(siteUserId, request); + return ResponseEntity.ok().build(); + } } diff --git a/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java b/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java index 420170236..f93981db7 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java @@ -4,6 +4,8 @@ import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; @@ -33,17 +35,17 @@ public class Mentor extends BaseEntity { @Column private boolean hasBadge = false; - @Column(length = 1000, nullable = false) + @Column(length = 1000) private String introduction; - @Column(length = 1000, nullable = false) + @Column(length = 1000) private String passTip; @Column private long siteUserId; @Column - private long universityId; + private Long universityId; // 임시 멘토일 때, null 가능 @Column(nullable = false, name = "term_id") private long termId; @@ -53,6 +55,25 @@ public class Mentor extends BaseEntity { @OneToMany(mappedBy = "mentor", cascade = CascadeType.ALL, orphanRemoval = true) private List channels = new ArrayList<>(); + @Column(nullable = false) + @Enumerated(EnumType.STRING) + private MentorStatus mentorStatus; + + public Mentor( + String introduction, + String passTip, + long siteUserId, + Long universityId, + long termId + ) { + this.introduction = introduction; + this.passTip = passTip; + this.siteUserId = siteUserId; + this.universityId = universityId; + this.termId = termId; + this.mentorStatus = MentorStatus.TEMPORARY; + } + public void increaseMenteeCount() { this.menteeCount++; } @@ -82,4 +103,15 @@ public void updateChannels(List channels) { } } } -} + + public void createChannels(List channels) { + for(Channel channel : channels) { + channel.updateMentor(this); + this.channels.add(channel); + } + } + + public void approve(){ + this.mentorStatus = MentorStatus.APPROVED; + } +} \ No newline at end of file diff --git a/src/main/java/com/example/solidconnection/mentor/domain/MentorApplication.java b/src/main/java/com/example/solidconnection/mentor/domain/MentorApplication.java index 8f800dcff..aacd1e503 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/MentorApplication.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/MentorApplication.java @@ -53,6 +53,9 @@ public class MentorApplication extends BaseEntity { @Column(nullable = false, name = "mentor_proof_url", length = 500) private String mentorProofUrl; + @Column(length = 50, nullable = false) + private long termId; + private String rejectedReason; @Column(nullable = false) @@ -72,6 +75,7 @@ public MentorApplication( Long universityId, UniversitySelectType universitySelectType, String mentorProofUrl, + long termId, ExchangeStatus exchangeStatus ) { validateExchangeStatus(exchangeStatus); @@ -82,6 +86,7 @@ public MentorApplication( this.universityId = universityId; this.universitySelectType = universitySelectType; this.mentorProofUrl = mentorProofUrl; + this.termId = termId; this.exchangeStatus = exchangeStatus; } diff --git a/src/main/java/com/example/solidconnection/mentor/domain/MentorStatus.java b/src/main/java/com/example/solidconnection/mentor/domain/MentorStatus.java new file mode 100644 index 000000000..3891677c9 --- /dev/null +++ b/src/main/java/com/example/solidconnection/mentor/domain/MentorStatus.java @@ -0,0 +1,8 @@ +package com.example.solidconnection.mentor.domain; + +public enum MentorStatus { + + TEMPORARY, + APPROVED, + ; +} diff --git a/src/main/java/com/example/solidconnection/mentor/domain/UniversitySelectType.java b/src/main/java/com/example/solidconnection/mentor/domain/UniversitySelectType.java index 92c3622a1..4c958d14c 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/UniversitySelectType.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/UniversitySelectType.java @@ -3,5 +3,6 @@ public enum UniversitySelectType { CATALOG, - OTHER + OTHER, + ; } diff --git a/src/main/java/com/example/solidconnection/mentor/dto/MentorApplicationRequest.java b/src/main/java/com/example/solidconnection/mentor/dto/MentorApplicationRequest.java index da6d206ab..1007a074b 100644 --- a/src/main/java/com/example/solidconnection/mentor/dto/MentorApplicationRequest.java +++ b/src/main/java/com/example/solidconnection/mentor/dto/MentorApplicationRequest.java @@ -9,6 +9,7 @@ public record MentorApplicationRequest( ExchangeStatus exchangeStatus, UniversitySelectType universitySelectType, String country, - Long universityId + Long universityId, + String term ) { } diff --git a/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageCreateRequest.java b/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageCreateRequest.java new file mode 100644 index 000000000..723931084 --- /dev/null +++ b/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageCreateRequest.java @@ -0,0 +1,18 @@ +package com.example.solidconnection.mentor.dto; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import java.util.List; + +public record MentorMyPageCreateRequest( + @NotBlank(message = "자기소개를 입력해주세요.") + String introduction, + + @NotBlank(message = "합격 레시피를 입력해주세요.") + String passTip, + + @Valid + List channels +) { + +} diff --git a/src/main/java/com/example/solidconnection/mentor/repository/MentorApplicationRepository.java b/src/main/java/com/example/solidconnection/mentor/repository/MentorApplicationRepository.java index d03b53892..fb2ab5191 100644 --- a/src/main/java/com/example/solidconnection/mentor/repository/MentorApplicationRepository.java +++ b/src/main/java/com/example/solidconnection/mentor/repository/MentorApplicationRepository.java @@ -3,9 +3,12 @@ import com.example.solidconnection.mentor.domain.MentorApplication; import com.example.solidconnection.mentor.domain.MentorApplicationStatus; import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; public interface MentorApplicationRepository extends JpaRepository { boolean existsBySiteUserIdAndMentorApplicationStatusIn(long siteUserId, List mentorApplicationStatuses); + + Optional findBySiteUserId(long siteUserId); } diff --git a/src/main/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepository.java b/src/main/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepository.java index 27d6a80d3..5ca1f22b7 100644 --- a/src/main/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepository.java +++ b/src/main/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepository.java @@ -90,4 +90,4 @@ public Map getTermIdToNameMap(List mentors) { return termRepository.findAllById(termIds).stream() .collect(Collectors.toMap(Term::getId, Term::getName)); } -} +} \ No newline at end of file diff --git a/src/main/java/com/example/solidconnection/mentor/repository/MentorRepository.java b/src/main/java/com/example/solidconnection/mentor/repository/MentorRepository.java index 430602f1e..9837c903e 100644 --- a/src/main/java/com/example/solidconnection/mentor/repository/MentorRepository.java +++ b/src/main/java/com/example/solidconnection/mentor/repository/MentorRepository.java @@ -2,6 +2,8 @@ import com.example.solidconnection.location.region.domain.Region; import com.example.solidconnection.mentor.domain.Mentor; +import com.example.solidconnection.mentor.domain.MentorStatus; +import java.util.List; import java.util.Optional; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; @@ -15,12 +17,15 @@ public interface MentorRepository extends JpaRepository { Optional findBySiteUserId(long siteUserId); - Slice findAllBy(Pageable pageable); + Optional findByIdAndMentorStatus(long id, MentorStatus mentorStatus); + + Slice findAllByMentorStatus(MentorStatus mentorStatus, Pageable pageable); @Query(""" SELECT m FROM Mentor m JOIN University u ON m.universityId = u.id WHERE u.region = :region + AND m.mentorStatus = :mentorStatus """) - Slice findAllByRegion(@Param("region") Region region, Pageable pageable); + Slice findAllByRegionAndMentorStatus(@Param("region") Region region, @Param("mentorStatus") MentorStatus mentorStatus, Pageable pageable); } diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java index d0716a156..901b35637 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java @@ -8,8 +8,11 @@ import com.example.solidconnection.s3.domain.ImgType; import com.example.solidconnection.s3.dto.UploadedFileUrlResponse; import com.example.solidconnection.s3.service.S3Service; +import com.example.solidconnection.siteuser.domain.Role; import com.example.solidconnection.siteuser.domain.SiteUser; import com.example.solidconnection.siteuser.repository.SiteUserRepository; +import com.example.solidconnection.term.domain.Term; +import com.example.solidconnection.term.repository.TermRepository; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -18,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile; import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_APPLICATION_ALREADY_EXISTED; +import static com.example.solidconnection.common.exception.ErrorCode.TERM_NOT_FOUND; import static com.example.solidconnection.common.exception.ErrorCode.USER_NOT_FOUND; @Service @@ -26,6 +30,7 @@ public class MentorApplicationService { private final MentorApplicationRepository mentorApplicationRepository; + private final TermRepository termRepository; private final SiteUserRepository siteUserRepository; private final S3Service s3Service; @@ -35,24 +40,40 @@ public void submitMentorApplication( MentorApplicationRequest mentorApplicationRequest, MultipartFile file ) { - if (mentorApplicationRepository.existsBySiteUserIdAndMentorApplicationStatusIn( - siteUserId, - List.of(MentorApplicationStatus.PENDING, MentorApplicationStatus.APPROVED)) - ) { - throw new CustomException(MENTOR_APPLICATION_ALREADY_EXISTED); - } + ensureNoPendingOrApprovedMentorApplication(siteUserId); SiteUser siteUser = siteUserRepository.findById(siteUserId) .orElseThrow(() -> new CustomException(USER_NOT_FOUND)); + Term term = termRepository.findByName(mentorApplicationRequest.term()) + .orElseThrow(() -> new CustomException(TERM_NOT_FOUND)); UploadedFileUrlResponse uploadedFile = s3Service.uploadFile(file, ImgType.MENTOR_PROOF); + MentorApplication mentorApplication = new MentorApplication( siteUser.getId(), mentorApplicationRequest.country(), mentorApplicationRequest.universityId(), mentorApplicationRequest.universitySelectType(), uploadedFile.fileUrl(), + term.getId(), mentorApplicationRequest.exchangeStatus() ); mentorApplicationRepository.save(mentorApplication); + + promoteRoleMenteeToTempMentor(siteUser); + } + + private void ensureNoPendingOrApprovedMentorApplication(long siteUserId) { + if (mentorApplicationRepository.existsBySiteUserIdAndMentorApplicationStatusIn( + siteUserId, + List.of(MentorApplicationStatus.PENDING, MentorApplicationStatus.APPROVED)) + ) { + throw new CustomException(MENTOR_APPLICATION_ALREADY_EXISTED); + } + } + + private void promoteRoleMenteeToTempMentor(SiteUser siteUser) { + if(siteUser.getRole() == Role.MENTEE){ + siteUser.changeRole(Role.TEMP_MENTOR); + } } -} +} \ No newline at end of file diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java index 810891b2b..99eceed72 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java @@ -1,6 +1,8 @@ package com.example.solidconnection.mentor.service; import static com.example.solidconnection.common.exception.ErrorCode.CHANNEL_REGISTRATION_LIMIT_EXCEEDED; +import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_ALREADY_EXISTS; +import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_APPLICATION_NOT_FOUND; import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_NOT_FOUND; import static com.example.solidconnection.common.exception.ErrorCode.TERM_NOT_FOUND; import static com.example.solidconnection.common.exception.ErrorCode.UNIVERSITY_NOT_FOUND; @@ -9,9 +11,12 @@ import com.example.solidconnection.common.exception.CustomException; import com.example.solidconnection.mentor.domain.Channel; import com.example.solidconnection.mentor.domain.Mentor; +import com.example.solidconnection.mentor.domain.MentorApplication; import com.example.solidconnection.mentor.dto.ChannelRequest; import com.example.solidconnection.mentor.dto.MentorMyPageResponse; import com.example.solidconnection.mentor.dto.MentorMyPageUpdateRequest; +import com.example.solidconnection.mentor.dto.MentorMyPageCreateRequest; +import com.example.solidconnection.mentor.repository.MentorApplicationRepository; import com.example.solidconnection.mentor.repository.MentorRepository; import com.example.solidconnection.siteuser.domain.SiteUser; import com.example.solidconnection.siteuser.repository.SiteUserRepository; @@ -22,9 +27,11 @@ import java.util.ArrayList; import java.util.List; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +@Slf4j @RequiredArgsConstructor @Service public class MentorMyPageService { @@ -35,6 +42,7 @@ public class MentorMyPageService { private final MentorRepository mentorRepository; private final SiteUserRepository siteUserRepository; private final UniversityRepository universityRepository; + private final MentorApplicationRepository mentorApplicationRepository; private final TermRepository termRepository; @Transactional(readOnly = true) @@ -61,18 +69,57 @@ public void updateMentorMyPage(long siteUserId, MentorMyPageUpdateRequest reques updateChannel(request.channels(), mentor); } + private void updateChannel(List channelRequests, Mentor mentor) { + List newChannels = buildChannels(channelRequests); + mentor.updateChannels(newChannels); + } + + @Transactional + public void createMentorMyPage(long siteUserId, MentorMyPageCreateRequest request) { + validateUserCanCreateMentor(siteUserId); + validateChannelRegistrationLimit(request.channels()); + MentorApplication mentorApplication = mentorApplicationRepository.findBySiteUserId(siteUserId) + .orElseThrow(() -> new CustomException(MENTOR_APPLICATION_NOT_FOUND)); + + Mentor mentor = new Mentor( + request.introduction(), + request.passTip(), + siteUserId, + mentorApplication.getUniversityId(), + mentorApplication.getTermId() + ); + + createChannels(request.channels(), mentor); + mentorRepository.save(mentor); + } + + private void validateUserCanCreateMentor(long siteUserId) { + if (!siteUserRepository.existsById(siteUserId)) { + throw new CustomException(USER_NOT_FOUND); + } + + if (mentorRepository.existsBySiteUserId(siteUserId)) { + throw new CustomException(MENTOR_ALREADY_EXISTS); + } + } + private void validateChannelRegistrationLimit(List channelRequests) { if (channelRequests.size() > CHANNEL_REGISTRATION_LIMIT) { throw new CustomException(CHANNEL_REGISTRATION_LIMIT_EXCEEDED); } } - private void updateChannel(List channelRequests, Mentor mentor) { + private void createChannels(List channelRequests, Mentor mentor) { + List newChannels = buildChannels(channelRequests); + mentor.createChannels(newChannels); + } + + private List buildChannels(List channelRequests) { int sequence = CHANNEL_SEQUENCE_START_NUMBER; List newChannels = new ArrayList<>(); for (ChannelRequest request : channelRequests) { newChannels.add(new Channel(sequence++, request.type(), request.url())); } - mentor.updateChannels(newChannels); + return newChannels; } -} +} \ No newline at end of file diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java index a66b8d45d..47127a218 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java @@ -10,6 +10,7 @@ import com.example.solidconnection.location.region.domain.Region; import com.example.solidconnection.location.region.repository.RegionRepository; import com.example.solidconnection.mentor.domain.Mentor; +import com.example.solidconnection.mentor.domain.MentorStatus; import com.example.solidconnection.mentor.dto.MentorDetailResponse; import com.example.solidconnection.mentor.dto.MentorPreviewResponse; import com.example.solidconnection.mentor.repository.MentorBatchQueryRepository; @@ -25,6 +26,7 @@ import java.util.List; import java.util.Map; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; import org.springframework.stereotype.Service; @@ -32,6 +34,7 @@ @RequiredArgsConstructor @Service +@Slf4j public class MentorQueryService { private final MentorRepository mentorRepository; @@ -44,8 +47,8 @@ public class MentorQueryService { @Transactional(readOnly = true) public MentorDetailResponse getMentorDetails(long mentorId, long currentUserId) { - Mentor mentor = mentorRepository.findById(mentorId) - .orElseThrow(() -> new CustomException(MENTOR_NOT_FOUND)); + Mentor mentor = mentorRepository.findByIdAndMentorStatus(mentorId, MentorStatus.APPROVED) + .orElseThrow(()-> new CustomException(MENTOR_NOT_FOUND)); University university = universityRepository.findById(mentor.getUniversityId()) .orElseThrow(() -> new CustomException(UNIVERSITY_NOT_FOUND)); SiteUser mentorUser = siteUserRepository.findById(mentor.getSiteUserId()) @@ -68,11 +71,11 @@ public SliceResponse getMentorPreviews(String regionKorea private Slice filterMentorsByRegion(String regionKoreanName, Pageable pageable) { if (regionKoreanName == null || regionKoreanName.isEmpty()) { - return mentorRepository.findAll(pageable); + return mentorRepository.findAllByMentorStatus(MentorStatus.APPROVED, pageable); } Region region = regionRepository.findByKoreanName(regionKoreanName) .orElseThrow(() -> new CustomException(ErrorCode.REGION_NOT_FOUND_BY_KOREAN_NAME)); - return mentorRepository.findAllByRegion(region, pageable); + return mentorRepository.findAllByRegionAndMentorStatus(region, MentorStatus.APPROVED, pageable); } private List buildMentorPreviewsWithBatchQuery(List mentors, long currentUserId) { diff --git a/src/main/java/com/example/solidconnection/siteuser/domain/Role.java b/src/main/java/com/example/solidconnection/siteuser/domain/Role.java index 4ea5bf151..6d8c88e8e 100644 --- a/src/main/java/com/example/solidconnection/siteuser/domain/Role.java +++ b/src/main/java/com/example/solidconnection/siteuser/domain/Role.java @@ -4,5 +4,7 @@ public enum Role { ADMIN, MENTOR, - MENTEE; + MENTEE, + TEMP_MENTOR + ; } diff --git a/src/main/java/com/example/solidconnection/siteuser/domain/SiteUser.java b/src/main/java/com/example/solidconnection/siteuser/domain/SiteUser.java index 30afc423e..a2ae467c1 100644 --- a/src/main/java/com/example/solidconnection/siteuser/domain/SiteUser.java +++ b/src/main/java/com/example/solidconnection/siteuser/domain/SiteUser.java @@ -120,4 +120,8 @@ public SiteUser( public void updatePassword(String newEncodedPassword) { this.password = newEncodedPassword; } + + public void changeRole(Role role){ + this.role = role; + } } diff --git a/src/main/java/com/example/solidconnection/term/repository/TermRepository.java b/src/main/java/com/example/solidconnection/term/repository/TermRepository.java index 7badf27cb..763137dc9 100644 --- a/src/main/java/com/example/solidconnection/term/repository/TermRepository.java +++ b/src/main/java/com/example/solidconnection/term/repository/TermRepository.java @@ -7,4 +7,6 @@ public interface TermRepository extends JpaRepository { Optional findByIsCurrentTrue(); + + Optional findByName(String name); } diff --git a/src/main/resources/db/migration/V37__add_mentor_status_filed_and_temp_mentor_role.sql b/src/main/resources/db/migration/V37__add_mentor_status_filed_and_temp_mentor_role.sql new file mode 100644 index 000000000..96bae04c3 --- /dev/null +++ b/src/main/resources/db/migration/V37__add_mentor_status_filed_and_temp_mentor_role.sql @@ -0,0 +1,17 @@ +-- Mentor 테이블에 MentorStatus 추가 +-- 1) mentor_status 컬럼 생성 (임시로 NULL 허용) +ALTER TABLE mentor + ADD COLUMN mentor_status ENUM('TEMPORARY','APPROVED') NULL; + +-- 2) 기존 행 모두 APPROVED로 백필 +UPDATE mentor +SET mentor_status = 'APPROVED' +WHERE mentor_status IS NULL; + +-- 3) NOT NULL + 기본값 TEMPORARY 로 고정 +ALTER TABLE mentor + MODIFY COLUMN mentor_status ENUM('TEMPORARY','APPROVED') NOT NULL DEFAULT 'TEMPORARY'; + +-- Role 에 TEMP_MENTOR 추가 +ALTER TABLE site_user + MODIFY COLUMN `role` ENUM('MENTEE','MENTOR','ADMIN','TEMP_MENTOR') NOT NULL; diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixture.java b/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixture.java index d3c27c114..040268cda 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixture.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixture.java @@ -20,4 +20,4 @@ public class ChannelFixture { .mentor(mentor) .create(); } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixtureBuilder.java b/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixtureBuilder.java index 670b0e8b4..907ca0c8d 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixtureBuilder.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixtureBuilder.java @@ -53,4 +53,4 @@ public Channel create() { channel.updateMentor(mentor); return channelRepository.save(channel); } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixture.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixture.java index 918db7ef4..4a830e494 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixture.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixture.java @@ -4,6 +4,7 @@ import com.example.solidconnection.mentor.domain.MentorApplicationStatus; import com.example.solidconnection.mentor.domain.UniversitySelectType; import com.example.solidconnection.siteuser.domain.ExchangeStatus; +import com.example.solidconnection.term.fixture.TermFixture; import lombok.RequiredArgsConstructor; import org.springframework.boot.test.context.TestComponent; @@ -12,6 +13,7 @@ public class MentorApplicationFixture { private final MentorApplicationFixtureBuilder mentorApplicationFixtureBuilder; + private final TermFixture termFixture; private static final String DEFAULT_COUNTRY_CODE = "US"; private static final String DEFAULT_PROOF_URL = "/mentor-proof.pdf"; @@ -28,6 +30,7 @@ public class MentorApplicationFixture { .universityId(universityId) .universitySelectType(selectType) .mentorProofUrl(DEFAULT_PROOF_URL) + .termId(termFixture.현재_학기("2025-1").getId()) .exchangeStatus(DEFAULT_EXCHANGE_STATUS) .create(); } @@ -44,6 +47,7 @@ public class MentorApplicationFixture { .universitySelectType(selectType) .mentorProofUrl(DEFAULT_PROOF_URL) .exchangeStatus(DEFAULT_EXCHANGE_STATUS) + .termId(termFixture.현재_학기("2025-1").getId()) .mentorApplicationStatus(MentorApplicationStatus.APPROVED) .create(); } @@ -60,7 +64,8 @@ public class MentorApplicationFixture { .universitySelectType(selectType) .mentorProofUrl(DEFAULT_PROOF_URL) .exchangeStatus(DEFAULT_EXCHANGE_STATUS) + .termId(termFixture.현재_학기("2025-1").getId()) .mentorApplicationStatus(MentorApplicationStatus.REJECTED) .create(); } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java index fc6fe547d..bbd2503e1 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java @@ -5,6 +5,7 @@ import com.example.solidconnection.mentor.domain.UniversitySelectType; import com.example.solidconnection.mentor.repository.MentorApplicationRepository; import com.example.solidconnection.siteuser.domain.ExchangeStatus; +import com.example.solidconnection.term.domain.Term; import lombok.RequiredArgsConstructor; import org.springframework.boot.test.context.TestComponent; import org.springframework.test.util.ReflectionTestUtils; @@ -20,6 +21,7 @@ public class MentorApplicationFixtureBuilder { private Long universityId = null; private UniversitySelectType universitySelectType = UniversitySelectType.OTHER; private String mentorProofUrl = "/mentor-proof.pdf"; + private long termId; private ExchangeStatus exchangeStatus = ExchangeStatus.AFTER_EXCHANGE; private MentorApplicationStatus mentorApplicationStatus = MentorApplicationStatus.PENDING; @@ -52,6 +54,11 @@ public MentorApplicationFixtureBuilder mentorProofUrl(String mentorProofUrl) { return this; } + public MentorApplicationFixtureBuilder termId(long termId) { + this.termId = termId; + return this; + } + public MentorApplicationFixtureBuilder exchangeStatus(ExchangeStatus exchangeStatus) { this.exchangeStatus = exchangeStatus; return this; @@ -69,9 +76,10 @@ public MentorApplication create() { universityId, universitySelectType, mentorProofUrl, + termId, exchangeStatus ); ReflectionTestUtils.setField(mentorApplication, "mentorApplicationStatus", mentorApplicationStatus); return mentorApplicationRepository.save(mentorApplication); } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixture.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixture.java index 8e47d11d1..7b4a18f6b 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixture.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixture.java @@ -21,4 +21,14 @@ public class MentorFixture { .termId(termFixture.현재_학기("2025-1").getId()) .create(); } -} + + public Mentor 임시멘토(long siteUserId, long universityId) { + return mentorFixtureBuilder.mentor() + .siteUserId(siteUserId) + .universityId(universityId) + .introduction("멘토 소개") + .passTip("합격 팁") + .termId(termFixture.현재_학기("2025-1").getId()) + .createTempMentor(); + } +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java index 533d29494..2bfe79d3a 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java @@ -60,16 +60,24 @@ public MentorFixtureBuilder termId(long termId) { public Mentor create() { Mentor mentor = new Mentor( - null, - menteeCount, - hasBadge, introduction, passTip, siteUserId, universityId, - termId, - null + termId ); + mentor.approve(); return mentorRepository.save(mentor); } -} + + public Mentor createTempMentor(){ + Mentor tempMentor = new Mentor( + introduction, + passTip, + siteUserId, + universityId, + termId + ); + return mentorRepository.save(tempMentor); + } +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixture.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixture.java index 4779c643e..6a2d39d2e 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixture.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixture.java @@ -55,4 +55,4 @@ public class MentoringFixture { private ZonedDateTime getCurrentTime() { return ZonedDateTime.now(UTC).truncatedTo(MICROS); } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java index aaf63b600..412308ac9 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java @@ -17,9 +17,12 @@ import com.example.solidconnection.s3.dto.UploadedFileUrlResponse; import com.example.solidconnection.s3.service.S3Service; import com.example.solidconnection.siteuser.domain.ExchangeStatus; +import com.example.solidconnection.siteuser.domain.Role; import com.example.solidconnection.siteuser.domain.SiteUser; import com.example.solidconnection.siteuser.fixture.SiteUserFixture; +import com.example.solidconnection.siteuser.repository.SiteUserRepository; import com.example.solidconnection.support.TestContainerSpringBootTest; +import com.example.solidconnection.term.fixture.TermFixture; import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -38,9 +41,15 @@ public class MentorApplicationServiceTest { @Autowired private MentorApplicationRepository mentorApplicationRepository; + @Autowired + private SiteUserRepository siteUserRepository; + @Autowired private SiteUserFixture siteUserFixture; + @Autowired + private TermFixture termFixture; + @Autowired private MentorApplicationFixture mentorApplicationFixture; @@ -52,6 +61,7 @@ public class MentorApplicationServiceTest { @BeforeEach void setUp() { user = siteUserFixture.사용자(); + termFixture.현재_학기("2025-1"); } @Test @@ -69,6 +79,7 @@ void setUp() { mentorApplicationService.submitMentorApplication(user.getId(), request, file); // then + assertThat(siteUserRepository.findById(user.getId()).get().getRole()).isEqualTo(Role.TEMP_MENTOR); assertThat(mentorApplicationRepository.existsBySiteUserIdAndMentorApplicationStatusIn(user.getId(), List.of(MentorApplicationStatus.PENDING, MentorApplicationStatus.APPROVED))).isEqualTo(true); } @@ -87,6 +98,7 @@ void setUp() { mentorApplicationService.submitMentorApplication(user.getId(), request, file); // then + assertThat(siteUserRepository.findById(user.getId()).get().getRole()).isEqualTo(Role.TEMP_MENTOR); assertThat(mentorApplicationRepository.existsBySiteUserIdAndMentorApplicationStatusIn(user.getId(),List.of(MentorApplicationStatus.PENDING, MentorApplicationStatus.APPROVED))).isEqualTo(true); } @@ -173,6 +185,7 @@ void setUp() { mentorApplicationService.submitMentorApplication(user.getId(), request, file); // then + assertThat(siteUserRepository.findById(user.getId()).get().getRole()).isEqualTo(Role.TEMP_MENTOR); assertThat(mentorApplicationRepository.existsBySiteUserIdAndMentorApplicationStatusIn(user.getId(),List.of(MentorApplicationStatus.PENDING, MentorApplicationStatus.APPROVED))).isEqualTo(true); } @@ -190,7 +203,8 @@ private MentorApplicationRequest createMentorApplicationRequest(UniversitySelect ExchangeStatus.AFTER_EXCHANGE, universitySelectType, "US", - universityId + universityId, + "2025-1" ); } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java index 7beb2e4f0..2278f77d7 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java @@ -1,18 +1,29 @@ package com.example.solidconnection.mentor.service; +import static com.example.solidconnection.common.exception.ErrorCode.CHANNEL_REGISTRATION_LIMIT_EXCEEDED; +import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_ALREADY_EXISTS; +import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_APPLICATION_NOT_FOUND; import static com.example.solidconnection.mentor.domain.ChannelType.BLOG; +import static com.example.solidconnection.mentor.domain.ChannelType.BRUNCH; import static com.example.solidconnection.mentor.domain.ChannelType.INSTAGRAM; +import static com.example.solidconnection.mentor.domain.ChannelType.YOUTUBE; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.tuple; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode; import static org.junit.jupiter.api.Assertions.assertAll; +import com.example.solidconnection.common.exception.CustomException; import com.example.solidconnection.mentor.domain.Channel; import com.example.solidconnection.mentor.domain.Mentor; +import com.example.solidconnection.mentor.domain.MentorStatus; +import com.example.solidconnection.mentor.domain.UniversitySelectType; import com.example.solidconnection.mentor.dto.ChannelRequest; import com.example.solidconnection.mentor.dto.ChannelResponse; +import com.example.solidconnection.mentor.dto.MentorMyPageCreateRequest; import com.example.solidconnection.mentor.dto.MentorMyPageResponse; import com.example.solidconnection.mentor.dto.MentorMyPageUpdateRequest; import com.example.solidconnection.mentor.fixture.ChannelFixture; +import com.example.solidconnection.mentor.fixture.MentorApplicationFixture; import com.example.solidconnection.mentor.fixture.MentorFixture; import com.example.solidconnection.mentor.repository.ChannelRepositoryForTest; import com.example.solidconnection.mentor.repository.MentorRepository; @@ -57,9 +68,13 @@ class MentorMyPageServiceTest { @Autowired private ChannelRepositoryForTest channelRepositoryForTest; + @Autowired + private MentorApplicationFixture mentorApplicationFixture; + private SiteUser mentorUser; private Mentor mentor; private University university; + private SiteUser tempMentorUser; @BeforeEach void setUp() { @@ -67,6 +82,7 @@ void setUp() { university = universityFixture.메이지_대학(); mentorUser = siteUserFixture.멘토(1, "멘토"); mentor = mentorFixture.멘토(mentorUser.getId(), university.getId()); + tempMentorUser = siteUserFixture.임시멘토(); } @Nested @@ -155,4 +171,75 @@ class 멘토의_마이_페이지를_수정한다 { ); } } -} + + @Nested + class 멘토의_마이페이지를_생성한다 { + + @Test + void 멘토_정보를_생성한다() { + // given + String introduction = "멘토 자기소개"; + String passTip = "멘토의 합격 팁"; + List channels = List.of( + new ChannelRequest(BLOG, "https://blog.com"), + new ChannelRequest(INSTAGRAM, "https://instagram.com"), + new ChannelRequest(YOUTUBE, "https://youtubr.com"), + new ChannelRequest(BRUNCH, "https://brunch.com") + ); + MentorMyPageCreateRequest request = new MentorMyPageCreateRequest(introduction, passTip, channels); + mentorApplicationFixture.대기중_멘토신청(tempMentorUser.getId(), UniversitySelectType.CATALOG, university.getId()); + + // when + mentorMyPageService.createMentorMyPage(tempMentorUser.getId(), request); + + // then + Mentor createTempMentor = mentorRepository.findBySiteUserId(tempMentorUser.getId()).get(); + assertAll( + () -> assertThat(createTempMentor.getIntroduction()).isEqualTo(introduction), + () -> assertThat(createTempMentor.getPassTip()).isEqualTo(passTip), + () -> assertThat(createTempMentor.getMentorStatus()).isEqualTo(MentorStatus.TEMPORARY) + ); + } + + @Test + void 이미_멘토_정보가_존재하는데_생성_요청_시_예외가_발생한다() { + // given + MentorMyPageCreateRequest request = new MentorMyPageCreateRequest("introduction", "passTip", List.of()); + mentorFixture.멘토(tempMentorUser.getId(), university.getId()); + + // when & then + assertThatCode(() -> mentorMyPageService.createMentorMyPage(tempMentorUser.getId(), request)) + .isInstanceOf(CustomException.class) + .hasMessage(MENTOR_ALREADY_EXISTS.getMessage()); + } + + @Test + void 채널을_제한_이상_생성하면_예외가_발생한다() { + // given + List newChannels = List.of( + new ChannelRequest(BLOG, "https://blog.com"), + new ChannelRequest(INSTAGRAM, "https://instagram.com"), + new ChannelRequest(YOUTUBE, "https://youtubr.com"), + new ChannelRequest(BRUNCH, "https://brunch.com"), + new ChannelRequest(BLOG, "https://blog.com") + ); + MentorMyPageCreateRequest request = new MentorMyPageCreateRequest("introduction", "passTip", newChannels); + + // when & then + assertThatCode(() -> mentorMyPageService.createMentorMyPage(tempMentorUser.getId(), request)) + .isInstanceOf(CustomException.class) + .hasMessage(CHANNEL_REGISTRATION_LIMIT_EXCEEDED.getMessage()); + } + + @Test + void 멘토_승격_요청_없이_멘토_정보_생성_시_예외가_발생한다() { + // given + MentorMyPageCreateRequest request = new MentorMyPageCreateRequest("introduction", "passTip", List.of()); + + // when & then + assertThatCode(() -> mentorMyPageService.createMentorMyPage(tempMentorUser.getId(), request)) + .isInstanceOf(CustomException.class) + .hasMessage(MENTOR_APPLICATION_NOT_FOUND.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentorQueryServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentorQueryServiceTest.java index 8a4088845..5b6cde38d 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentorQueryServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorQueryServiceTest.java @@ -125,6 +125,18 @@ class 멘토_단일_조회_실패 { .isInstanceOf(CustomException.class) .hasMessageContaining(ErrorCode.MENTOR_NOT_FOUND.getMessage()); } + + @Test + void 임시멘토를_조회하면_예외가_발생한다() { + // given + SiteUser tempMentorUser = siteUserFixture.임시멘토(); + Mentor tempMentor = mentorFixture.임시멘토(tempMentorUser.getId(), university.getId()); + + // when & then + assertThatCode(() -> mentorQueryService.getMentorDetails(tempMentor.getId(), siteUserFixture.사용자().getId())) + .isInstanceOf(CustomException.class) + .hasMessageContaining(ErrorCode.MENTOR_NOT_FOUND.getMessage()); + } } @Nested @@ -176,6 +188,38 @@ void setUp() { ); } + @Test + void 임시멘토는_미리보기_목록에서_제외된다() { + // given + SiteUser tempMentorUser = siteUserFixture.임시멘토(); + Mentor tempMentor = mentorFixture.임시멘토(tempMentorUser.getId(), university1.getId()); + Channel channel1 = channelFixture.채널(1, mentor1); + Channel channel2 = channelFixture.채널(2, mentor2); + + // when + SliceResponse response = mentorQueryService.getMentorPreviews("", currentUser.getId(), PageRequest.of(0, 10)); + + // then + Map mentorPreviewMap = response.content().stream() + .collect(Collectors.toMap(MentorPreviewResponse::id, Function.identity())); + MentorPreviewResponse mentor1Response = mentorPreviewMap.get(mentor1.getId()); + MentorPreviewResponse mentor2Response = mentorPreviewMap.get(mentor2.getId()); + assertThat(mentorPreviewMap.get(tempMentor.getId())).isNull(); + assertAll( + () -> assertThat(mentor1Response.nickname()).isEqualTo(mentorUser1.getNickname()), + () -> assertThat(mentor1Response.universityName()).isEqualTo(university1.getKoreanName()), + () -> assertThat(mentor1Response.country()).isEqualTo(university1.getCountry().getKoreanName()), + () -> assertThat(mentor1Response.channels()).extracting(ChannelResponse::url) + .containsOnly(channel1.getUrl()), + + () -> assertThat(mentor2Response.nickname()).isEqualTo(mentorUser2.getNickname()), + () -> assertThat(mentor2Response.universityName()).isEqualTo(university2.getKoreanName()), + () -> assertThat(mentor2Response.country()).isEqualTo(university2.getCountry().getKoreanName()), + () -> assertThat(mentor2Response.channels()).extracting(ChannelResponse::url) + .containsOnly(channel2.getUrl()) + ); + } + @Test void 다음_페이지_번호를_응답한다() { // given @@ -232,6 +276,32 @@ void setUp() { ); } + @Test + void 권역으로_멘토_목록을_필터링_할때_임시멘토는_제외된다() { + // when + University americaUniversity = universityFixture.네바다주립_대학_라스베이거스(); + SiteUser tempMentorUser = siteUserFixture.임시멘토(); + Mentor tempMentor = mentorFixture.임시멘토(tempMentorUser.getId(), americaUniversity.getId()); + + SliceResponse asiaFilteredResponse = mentorQueryService.getMentorPreviews( + asiaUniversity.getRegion().getKoreanName(), currentUser.getId(), PageRequest.of(0, 10)); + SliceResponse europeFilteredResponse = mentorQueryService.getMentorPreviews( + europeUniversity.getRegion().getKoreanName(), currentUser.getId(), PageRequest.of(0, 10)); + SliceResponse americaFilteredResponse = mentorQueryService.getMentorPreviews( + americaUniversity.getRegion().getKoreanName(), currentUser.getId(), PageRequest.of(0, 10)); + + // then + assertAll( + () -> assertThat(americaFilteredResponse.content()).isEmpty(), + () -> assertThat(asiaFilteredResponse.content()).hasSize(1) + .extracting(MentorPreviewResponse::id) + .containsExactly(asiaMentor.getId()), + () -> assertThat(europeFilteredResponse.content()).hasSize(1) + .extracting(MentorPreviewResponse::id) + .containsExactly(europeMentor.getId()) + ); + } + @Test void 권역을_지정하지_않으면_전체_멘토_목록을_조회한다() { // when @@ -243,4 +313,4 @@ void setUp() { .containsExactlyInAnyOrder(asiaMentor.getId(), europeMentor.getId()); } } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentoringCheckServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentoringCheckServiceTest.java index c5f8a9463..c572ef34d 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentoringCheckServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentoringCheckServiceTest.java @@ -168,4 +168,4 @@ class 멘토가_확인하지_않은_멘토링_개수_조회_테스트 { } } } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java index 8c6a78468..6d192137d 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java @@ -6,7 +6,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertAll; -import static org.awaitility.Awaitility.await; + import com.example.solidconnection.chat.domain.ChatParticipant; import com.example.solidconnection.chat.domain.ChatRoom; import com.example.solidconnection.chat.repository.ChatRoomRepositoryForTest; @@ -25,7 +25,6 @@ import com.example.solidconnection.siteuser.domain.SiteUser; import com.example.solidconnection.siteuser.fixture.SiteUserFixture; import com.example.solidconnection.support.TestContainerSpringBootTest; -import java.time.Duration; import java.util.List; import java.util.Optional; import org.junit.jupiter.api.BeforeEach; @@ -226,4 +225,4 @@ class 멘토링_승인_거절_테스트 { .hasMessage(MENTORING_NOT_FOUND.getMessage()); } } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentoringQueryServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentoringQueryServiceTest.java index cb680b986..7effd9687 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentoringQueryServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentoringQueryServiceTest.java @@ -324,4 +324,4 @@ void setUp() { assertThat(response.nextPageNumber()).isEqualTo(NO_NEXT_PAGE_NUMBER); } } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/siteuser/fixture/SiteUserFixture.java b/src/test/java/com/example/solidconnection/siteuser/fixture/SiteUserFixture.java index 9c2eb12bc..4e503aac2 100644 --- a/src/test/java/com/example/solidconnection/siteuser/fixture/SiteUserFixture.java +++ b/src/test/java/com/example/solidconnection/siteuser/fixture/SiteUserFixture.java @@ -77,4 +77,15 @@ public class SiteUserFixture { .password("admin123") .create(); } + + public SiteUser 임시멘토(){ + return siteUserFixtureBuilder.siteUser() + .email("temp-mentor@example.com") + .authType(AuthType.EMAIL) + .nickname("임시멘토") + .profileImageUrl("profileImageUrl") + .role(Role.TEMP_MENTOR) + .password("temp-mentor123") + .create(); + } }