-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from cvs-go/feature#113
리뷰 삭제 기능 추가
- Loading branch information
Showing
5 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
|
@@ -432,6 +432,36 @@ void succeed_to_read_user_review() { | |
assertThat(reviews.size()).isEqualTo(1); | ||
} | ||
|
||
@Test | ||
@DisplayName("특정 리뷰를 정상적으로 삭제한다.") | ||
void succeed_to_delete_review() { | ||
given(reviewRepository.findById(any())).willReturn(Optional.of(review)); | ||
|
||
reviewService.deleteReview(user2, 1L); | ||
|
||
then(reviewRepository).should(times(1)).findById(anyLong()); | ||
then(reviewRepository).should(times(1)).delete(any()); | ||
} | ||
|
||
@Test | ||
@DisplayName("리뷰 작성자가 아닌 사용자가 리뷰 삭제를 시도하면 ForbiddenException이 발생한다.") | ||
void should_throw_ForbiddenException_when_delete_review_but_review_does_not_exist() { | ||
given(reviewRepository.findById(any())).willReturn(Optional.of(review)); | ||
|
||
assertThrows(ForbiddenException.class, | ||
() -> reviewService.deleteReview(user1, 1L)); | ||
} | ||
|
||
@Test | ||
@DisplayName("존재하지 않는 리뷰를 삭제하면 NotFoundException이 발생한다.") | ||
void should_throw_NotFoundException_when_delete_review_but_review_does_not_exist() { | ||
given(reviewRepository.findById(any())).willReturn(Optional.empty()); | ||
|
||
assertThrows(NotFoundException.class, | ||
() -> reviewService.deleteReview(user1, 1000L)); | ||
} | ||
|
||
|
||
User user1 = User.builder() | ||
.id(1L) | ||
.userId("[email protected]") | ||
|