diff --git a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseCase.java b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseCase.java index adfa9935..bff50863 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseCase.java +++ b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseCase.java @@ -20,6 +20,7 @@ import static com.postgraduate.domain.senior.application.mapper.SeniorMapper.mapToSeniorDetail; import static com.postgraduate.domain.senior.application.mapper.SeniorMapper.mapToSeniorProfile; +import static com.postgraduate.domain.user.domain.entity.constant.Role.SENIOR; @Service @Transactional @@ -30,7 +31,7 @@ public class SeniorInfoUseCase { private final AvailableGetService availableGetService; public SeniorDetailResponse getSeniorDetail(User user, Long seniorId) { - if (user != null) + if (user != null && user.getRole() == SENIOR) return checkIsMine(user, seniorId); return getResponse(seniorId, false); } @@ -99,9 +100,4 @@ public AllSeniorIdResponse getAllSeniorId() { .toList(); return new AllSeniorIdResponse(seniorIds); } - - public Long getSeniorId(String nickName) { - Senior senior = seniorGetService.bySeniorNickName(nickName); - return senior.getSeniorId(); - } } diff --git a/src/test/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseCaseTest.java b/src/test/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseCaseTest.java index 51d96210..0df79663 100644 --- a/src/test/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseCaseTest.java +++ b/src/test/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseCaseTest.java @@ -30,6 +30,7 @@ import static java.lang.Boolean.TRUE; import static java.time.LocalDate.now; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; @ExtendWith(MockitoExtension.class) @@ -64,14 +65,14 @@ void setting() { LocalDateTime.now(), LocalDateTime.now()); } @Test - @DisplayName("선배 상세보기 테스트") + @DisplayName("선배 상세보기 테스트 USER") void getSeniorDetail() { Available available1 = new Available(1L, "월", "12:00", "18:00", senior); Available available2 = new Available(2L, "화", "12:00", "18:00", senior); Available available3 = new Available(3L, "수", "12:00", "18:00", senior); List availables = List.of(available1, available2, available3); - given(seniorGetService.byUser(user)) + given(seniorGetService.bySeniorIdWithCertification(any())) .willReturn(senior); given(availableGetService.bySenior(senior)) .willReturn(availables);