Skip to content

Commit

Permalink
refactor(MeetingService): Meeting, Attendee 존재하지 않을 경우 에러코드 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
ikjo39 committed Aug 1, 2024
1 parent e7f0d85 commit 64dfca4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ private void validateHostPermission(Attendee attendee) {
@Transactional
public void unlock(String uuid, long id) {
Meeting meeting = meetingRepository.findByUuid(uuid)
.orElseThrow(() -> new MomoException(MeetingErrorCode.NOT_FOUND_MEETING));
.orElseThrow(() -> new MomoException(MeetingErrorCode.INVALID_UUID));
Attendee attendee = attendeeRepository.findByIdAndMeeting(id, meeting)
.orElseThrow(() -> new MomoException(AttendeeErrorCode.NOT_FOUND_ATTENDEE));
.orElseThrow(() -> new MomoException(AttendeeErrorCode.INVALID_ATTENDEE));
validateHostPermission(attendee);
meeting.unlock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void unlock() {
.statusCode(HttpStatus.OK.value());
}

@DisplayName("존재하지 않는 약속을 잠금 해제 시도하면 404 Not Found를 반환한다.")
@DisplayName("존재하지 않는 약속을 잠금 해제 시도하면 400 Bad Request를 반환한다.")
@Test
void unlockWithInvalidUUID() {
String invalidUUID = "INVALID_UUID";
Expand All @@ -224,7 +224,7 @@ void unlockWithInvalidUUID() {
.header("Authorization", "Bearer " + token)
.when().patch("/api/v1/meetings/{uuid}/unlock")
.then().log().all()
.statusCode(HttpStatus.NOT_FOUND.value());
.statusCode(HttpStatus.BAD_REQUEST.value());
}

@DisplayName("약속을 잠금을 해제할 때 호스트 권한이 없다면 403을 반환한다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void throwsExceptionWhenUnlockNoMeeting() {

assertThatThrownBy(() -> meetingService.unlock(uuid, id))
.isInstanceOf(MomoException.class)
.hasMessage(MeetingErrorCode.NOT_FOUND_MEETING.message());
.hasMessage(MeetingErrorCode.INVALID_UUID.message());
}

@DisplayName("약속 잠금을 해제할 때 참가자가 존재하지 않다면 예외가 발생한다.")
Expand All @@ -192,7 +192,7 @@ void throwsExceptionWhenUnlockNoAttendee() {

assertThatThrownBy(() -> meetingService.unlock(uuid, id))
.isInstanceOf(MomoException.class)
.hasMessage(AttendeeErrorCode.NOT_FOUND_ATTENDEE.message());
.hasMessage(AttendeeErrorCode.INVALID_ATTENDEE.message());
}

@DisplayName("약속 잠금을 해제할 때 로그인된 참가자가 호스트가 아니면 예외가 발생한다.")
Expand Down

0 comments on commit 64dfca4

Please sign in to comment.