-
Notifications
You must be signed in to change notification settings - Fork 0
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 #88 from jisung-in/docs/86-userlibrary-rest-docs
[Docs] UserLibrary REST Docs 작성
- Loading branch information
Showing
7 changed files
with
267 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
=== 서재 단건 조회 | ||
|
||
image::https://jisungin-bucket.s3.ap-northeast-2.amazonaws.com/docs/get-userlibrary.png[] | ||
|
||
TIP: 상세 조회된 도서에 대한 사용자의 도서 상태를 조회 | ||
|
||
==== HTTP Request | ||
include::{snippets}/user-library/get/http-request.adoc[] | ||
include::{snippets}/user-library/get/query-parameters.adoc[] | ||
|
||
==== HTTP Response | ||
include::{snippets}/user-library/get/http-response.adoc[] | ||
===== Response Body | ||
include::{snippets}/user-library/get/response-body.adoc[] | ||
include::{snippets}/user-library/get/response-fields.adoc[] | ||
|
||
=== 서재 등록 | ||
|
||
TIP: 상세 조회된 도서에 대한 도서 상태를 생성 | ||
|
||
==== HTTP Request | ||
include::{snippets}/user-library/create/http-request.adoc[] | ||
===== Request Body | ||
include::{snippets}/user-library/create/request-body.adoc[] | ||
include::{snippets}/user-library/create/request-fields.adoc[] | ||
|
||
==== HTTP Response | ||
include::{snippets}/user-library/create/http-response.adoc[] | ||
===== Response Body | ||
include::{snippets}/user-library/create/response-body.adoc[] | ||
include::{snippets}/user-library/create/response-fields.adoc[] | ||
|
||
=== 서재 수정 | ||
|
||
TIP: 상세 조회된 도서에 대한 도서 상태를 수정 | ||
|
||
==== HTTP Request | ||
include::{snippets}/user-library/edit/http-request.adoc[] | ||
include::{snippets}/user-library/edit/path-parameters.adoc[] | ||
===== Request Body | ||
include::{snippets}/user-library/edit/request-body.adoc[] | ||
include::{snippets}/user-library/edit/request-fields.adoc[] | ||
|
||
==== HTTP Response | ||
include::{snippets}/user-library/edit/http-response.adoc[] | ||
===== Response Body | ||
include::{snippets}/user-library/edit/response-body.adoc[] | ||
include::{snippets}/user-library/edit/response-fields.adoc[] | ||
|
||
=== 서재 삭제 | ||
|
||
TIP: 상세 조회된 도서에 대한 도서 상태를 삭제 | ||
|
||
==== HTTP Request | ||
include::{snippets}/user-library/delete/http-request.adoc[] | ||
|
||
==== HTTP Response | ||
include::{snippets}/user-library/delete/http-response.adoc[] | ||
include::{snippets}/user-library/delete/path-parameters.adoc[] | ||
===== Response Body | ||
include::{snippets}/user-library/delete/response-body.adoc[] | ||
include::{snippets}/user-library/delete/response-fields.adoc[] |
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 |
---|---|---|
|
@@ -327,7 +327,7 @@ public void deleteUserLibrary() { | |
UserLibrary userLibrary = userLibraryRepository.save(create(user, book)); | ||
|
||
// when | ||
userLibraryService.deleteUserLibrary(userLibrary.getId(), user.getId(), book.getIsbn()); | ||
userLibraryService.deleteUserLibrary(userLibrary.getId(), user.getId()); | ||
|
||
// then | ||
List<UserLibrary> response = userLibraryRepository.findAll(); | ||
|
@@ -344,35 +344,20 @@ public void deleteUserLibraryWithoutUser() { | |
Book book = bookRepository.save(createBook()); | ||
|
||
// when // then | ||
assertThatThrownBy(() -> userLibraryService.deleteUserLibrary(userLibraryId, userId, book.getIsbn())) | ||
assertThatThrownBy(() -> userLibraryService.deleteUserLibrary(userLibraryId, userId)) | ||
.isInstanceOf(BusinessException.class) | ||
.hasMessage("사용자를 찾을 수 없습니다."); | ||
} | ||
|
||
@Test | ||
@DisplayName("서재 정보 삭제 시 책 정보가 존재해야 한다.") | ||
public void deleteUserLibraryWithoutBook() { | ||
// given | ||
Long userLibraryId = 1L; | ||
String bookIsbn = "0000X"; | ||
User user = userRepository.save(createUser()); | ||
|
||
// when // then | ||
assertThatThrownBy(() -> userLibraryService.deleteUserLibrary(userLibraryId, user.getId(), bookIsbn)) | ||
.isInstanceOf(BusinessException.class) | ||
.hasMessage("책을 찾을 수 없습니다."); | ||
} | ||
|
||
@Test | ||
@DisplayName("서재 정보 삭제 시 서재 정보가 존재해야 한다.") | ||
public void deleteUserLibraryWithoutUserLibrary() { | ||
// given | ||
Long userLibraryId = 1L; | ||
User user = userRepository.save(createUser()); | ||
Book book = bookRepository.save(createBook()); | ||
|
||
// when // then | ||
assertThatThrownBy(() -> userLibraryService.deleteUserLibrary(userLibraryId, user.getId(), book.getIsbn())) | ||
assertThatThrownBy(() -> userLibraryService.deleteUserLibrary(userLibraryId, user.getId())) | ||
.isInstanceOf(BusinessException.class) | ||
.hasMessage("서재 정보를 찾을 수 없습니다."); | ||
} | ||
|
@@ -390,29 +375,11 @@ public void deleteUserLibraryInvalidUser() { | |
|
||
// when // then | ||
assertThatThrownBy( | ||
() -> userLibraryService.deleteUserLibrary(userLibrary.getId(), anotherUser.getId(), book.getIsbn())) | ||
() -> userLibraryService.deleteUserLibrary(userLibrary.getId(), anotherUser.getId())) | ||
.isInstanceOf(BusinessException.class) | ||
.hasMessage("권한이 없는 사용자입니다."); | ||
} | ||
|
||
@Test | ||
@DisplayName("서재 정보 삭제 시 서재 정보와 도서 정보는 일치해야 한다.") | ||
public void deleteUserLibraryInvalidBook() { | ||
// given | ||
User user = userRepository.save(createUser()); | ||
|
||
Book book = bookRepository.save(createBookWithIsbn("00001")); | ||
Book anotherBook = bookRepository.save(createBookWithIsbn("00002")); | ||
|
||
UserLibrary userLibrary = userLibraryRepository.save(create(user, book)); | ||
|
||
// when // then | ||
assertThatThrownBy( | ||
() -> userLibraryService.deleteUserLibrary(userLibrary.getId(), user.getId(), anotherBook.getIsbn())) | ||
.isInstanceOf(BusinessException.class) | ||
.hasMessage("올바르지 않은 책 정보 입니다."); | ||
} | ||
|
||
private static User createUser() { | ||
return User.builder() | ||
.name("[email protected]") | ||
|
Oops, something went wrong.