Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ public ReservationResponse getReservation(Member member, Long reservationId) {
Reservation reservation = reservationRepository.findByIdAndMember(reservationId, member.getId())
.orElseThrow(() -> new ServiceException(ReservationErrorCode.RESERVATION_NOT_ACCESSIBLE));

MentoringSession mentoringSession = mentoringSessionService.getMentoringSessionByReservation(reservation);
Optional<MentoringSession> mentoringSession = mentoringSessionService.findMentoringSessionByReservation(reservation);

return ReservationResponse.from(reservation, mentoringSession);
return mentoringSession
.map(session -> ReservationResponse.from(reservation, session))
.orElseGet(() -> ReservationResponse.from(reservation));
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
@RequiredArgsConstructor
public class MentoringSessionService {
Expand All @@ -28,6 +30,10 @@ public MentoringSession getMentoringSessionByReservation(Reservation reservation
.orElseThrow(() -> new ServiceException("404", "해당 예약의 세션이 없습니다."));
}

public Optional<MentoringSession> findMentoringSessionByReservation(Reservation reservation) {
return mentoringSessionRepository.findByReservation((reservation));
}

public MentoringSession getMentoringSessionByMentoring(Mentoring mentoring) {
return mentoringSessionRepository.findByMentoring(mentoring)
.orElseThrow(() -> new ServiceException("404", "해당 멘토링의 세션이 없습니다."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void runInitData() {
log.info(">>> Step 3: JobRoadmap 샘플 데이터 생성 완료");
} catch (Exception e) {
log.error("JobRoadmap 샘플 데이터 생성 실패", e);
throw e;
//throw e;
}

// 통합 로직 테스트
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void getReservation() {
when(reservationRepository.findByIdAndMember(reservationId, mentor.getMember().getId()))
.thenReturn(Optional.of(reservation));
MentoringSession session = MentoringSessionFixture.create(reservation);
when(mentoringSessionService.getMentoringSessionByReservation(reservation)).thenReturn(session);
when(mentoringSessionService.findMentoringSessionByReservation(reservation)).thenReturn(Optional.ofNullable(session));

// when
ReservationResponse response = reservationService.getReservation(
Expand Down