From cdae7c45d2035f1543dba4dffd103d715e7bd64a Mon Sep 17 00:00:00 2001 From: whitemark Date: Sun, 31 Dec 2023 22:42:16 +0900 Subject: [PATCH 01/10] =?UTF-8?q?[feature/#204]=20contents=20->=20content?= =?UTF-8?q?=20=EC=9D=B4=EB=A6=84=20=EC=88=98=EC=A0=95,=20exception.class?= =?UTF-8?q?=20=EC=9C=84=EC=B9=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/domain/board/domain/NormalBoard.java | 12 +++++----- .../{Contents.java => Content.java} | 10 +++++---- .../repository/NormalBoardRepositoryImpl.java | 2 +- .../comment/domain/valueObject/Contents.java | 2 +- .../domain/contest/domain/ContestBoard.java | 4 ++-- .../exception/NotWriteAnswersException.java | 2 +- .../exception/NotWriteProfileException.java | 2 +- .../signUp/usecase/SignUpServiceImpl.java | 4 ++-- .../domain/entity/SignUpSchedule.java | 2 +- .../exception/InvalidDateException.java | 2 +- .../SignUpNotAvailableException.java | 2 +- .../inhabas/api/web/ExceptionController.java | 8 +++---- .../SignUpControllerInterceptor.java | 2 +- .../inhabas/api/domain/BaseEntityTest.java | 6 ++--- ...ontentsTest.java => BoardContentTest.java} | 20 ++++++++--------- .../domain/board/dto/SaveBoardDtoTest.java | 4 ++-- .../domain/board/dto/UpdateBoardDtoTest.java | 2 +- .../repository/NormalBoardRepositoryTest.java | 6 ++--- .../board/usecase/BoardServiceTest.java | 20 ++++++++--------- ...tentsTest.java => CommentContentTest.java} | 10 ++++----- .../repository/CommentRepositoryTest.java | 22 +++++++++---------- .../dto/SaveContestBoardDtoTest.java | 4 ++-- .../dto/UpdateContestBoardDtoTest.java | 2 +- .../ContestBoardRepositoryTest.java | 2 +- .../usecase/ContestBoardServiceTest.java | 14 ++++++------ .../signUp/usecase/SignUpServiceTest.java | 4 ++-- .../domain/entity/SignUpScheduleTest.java | 2 +- .../inhabas/api/web/BoardControllerTest.java | 6 ++--- .../api/web/CommentControllerTest.java | 8 +++---- .../api/web/ContestBoardControllerTest.java | 6 ++--- .../api/web/SignUpScheduleControllerTest.java | 2 +- 31 files changed, 98 insertions(+), 96 deletions(-) rename resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/{Contents.java => Content.java} (75%) rename resource-server/src/main/java/com/inhabas/api/domain/signUp/{domain => }/exception/NotWriteAnswersException.java (83%) rename resource-server/src/main/java/com/inhabas/api/domain/signUp/{domain => }/exception/NotWriteProfileException.java (83%) rename resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/{domain => }/exception/InvalidDateException.java (81%) rename resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/{domain => }/exception/SignUpNotAvailableException.java (82%) rename resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/{BoardContentsTest.java => BoardContentTest.java} (56%) rename resource-server/src/test/java/com/inhabas/api/domain/comment/domain/valueObject/{CommentContentsTest.java => CommentContentTest.java} (79%) diff --git a/resource-server/src/main/java/com/inhabas/api/domain/board/domain/NormalBoard.java b/resource-server/src/main/java/com/inhabas/api/domain/board/domain/NormalBoard.java index e28b5163..67e13702 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/board/domain/NormalBoard.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/board/domain/NormalBoard.java @@ -2,7 +2,7 @@ import com.inhabas.api.domain.board.BaseBoard; import com.inhabas.api.domain.board.BoardCannotModifiableException; -import com.inhabas.api.domain.board.domain.valueObject.Contents; +import com.inhabas.api.domain.board.domain.valueObject.Content; import com.inhabas.api.domain.board.domain.valueObject.Title; import com.inhabas.api.domain.comment.domain.Comment; import com.inhabas.api.domain.file.BoardFile; @@ -39,7 +39,7 @@ public class NormalBoard extends BaseBoard { @Embedded - protected Contents contents; + protected Content content; @OneToMany(mappedBy = "parentBoard", cascade = CascadeType.ALL, orphanRemoval = true) protected List comments = new ArrayList<>(); @@ -52,14 +52,14 @@ public class NormalBoard extends BaseBoard { public NormalBoard(String title, String contents) { this.title = new Title(title); - this.contents = new Contents(contents); + this.content = new Content(contents); } /* getter */ - public String getContents() { - return contents.getValue(); + public String getContent() { + return content.getValue(); } public Set getFiles() { @@ -92,7 +92,7 @@ public void modify(String title, String contents, StudentId loginMember) { } this.title = new Title(title); - this.contents = new Contents(contents); + this.content = new Content(contents); } public boolean cannotModifiableBy(StudentId loginMember) { diff --git a/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Contents.java b/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Content.java similarity index 75% rename from resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Contents.java rename to resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Content.java index 76782d0a..66cbde0d 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Contents.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Content.java @@ -1,22 +1,24 @@ package com.inhabas.api.domain.board.domain.valueObject; + import com.inhabas.api.auth.domain.error.businessException.InvalidInputException; + import javax.persistence.Column; import javax.persistence.Embeddable; import javax.persistence.Transient; import java.util.Objects; @Embeddable -public class Contents { +public class Content { - @Column(name = "contents", columnDefinition = "MEDIUMTEXT", nullable = false) + @Column(name = "CONTENT", columnDefinition = "MEDIUMTEXT", nullable = false) private String value; @Transient private final int MAX_SIZE = 2 << 24 - 1; //16MB - public Contents() {} + public Content() {} - public Contents(String value) { + public Content(String value) { if (validate(value)) this.value = value; else diff --git a/resource-server/src/main/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryImpl.java index a7cb8fc9..8ac1e2cb 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryImpl.java @@ -26,7 +26,7 @@ public Page findAllByMenuId(MenuId menuId, Pageable pageable) { List results = queryFactory.select(Projections.constructor(BoardDto.class, normalBoard.id, normalBoard.title.value, - Expressions.asString("").as("contents"), + Expressions.asString("").as("content"), member.name.value, normalBoard.menuId, normalBoard.dateCreated, diff --git a/resource-server/src/main/java/com/inhabas/api/domain/comment/domain/valueObject/Contents.java b/resource-server/src/main/java/com/inhabas/api/domain/comment/domain/valueObject/Contents.java index 02e9760f..2fea9fd8 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/comment/domain/valueObject/Contents.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/comment/domain/valueObject/Contents.java @@ -8,7 +8,7 @@ @Embeddable public class Contents { - @Column(name = "contents", length = 500, nullable = false) + @Column(name = "content", length = 500, nullable = false) private String value; @Transient diff --git a/resource-server/src/main/java/com/inhabas/api/domain/contest/domain/ContestBoard.java b/resource-server/src/main/java/com/inhabas/api/domain/contest/domain/ContestBoard.java index 857702c7..f3dc1a65 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/contest/domain/ContestBoard.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/contest/domain/ContestBoard.java @@ -1,7 +1,7 @@ package com.inhabas.api.domain.contest.domain; import com.inhabas.api.domain.board.domain.NormalBoard; -import com.inhabas.api.domain.board.domain.valueObject.Contents; +import com.inhabas.api.domain.board.domain.valueObject.Content; import com.inhabas.api.domain.board.domain.valueObject.Title; import com.inhabas.api.domain.contest.domain.valueObject.Association; import com.inhabas.api.domain.contest.domain.valueObject.Topic; @@ -50,7 +50,7 @@ public String getTopic(){ public ContestBoard(String title, String contents, String association, String topic, LocalDate start, LocalDate deadline){ this.title = new Title(title); - this.contents = new Contents(contents); + this.content = new Content(contents); this.association = new Association(association); this.topic = new Topic(topic); this.start = start; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/signUp/domain/exception/NotWriteAnswersException.java b/resource-server/src/main/java/com/inhabas/api/domain/signUp/exception/NotWriteAnswersException.java similarity index 83% rename from resource-server/src/main/java/com/inhabas/api/domain/signUp/domain/exception/NotWriteAnswersException.java rename to resource-server/src/main/java/com/inhabas/api/domain/signUp/exception/NotWriteAnswersException.java index 25465348..58f4c6e0 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/signUp/domain/exception/NotWriteAnswersException.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/signUp/exception/NotWriteAnswersException.java @@ -1,4 +1,4 @@ -package com.inhabas.api.domain.signUp.domain.exception; +package com.inhabas.api.domain.signUp.exception; import com.inhabas.api.auth.domain.error.ErrorCode; import com.inhabas.api.auth.domain.error.businessException.BusinessException; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/signUp/domain/exception/NotWriteProfileException.java b/resource-server/src/main/java/com/inhabas/api/domain/signUp/exception/NotWriteProfileException.java similarity index 83% rename from resource-server/src/main/java/com/inhabas/api/domain/signUp/domain/exception/NotWriteProfileException.java rename to resource-server/src/main/java/com/inhabas/api/domain/signUp/exception/NotWriteProfileException.java index e82e3657..5e5ff406 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/signUp/domain/exception/NotWriteProfileException.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/signUp/exception/NotWriteProfileException.java @@ -1,4 +1,4 @@ -package com.inhabas.api.domain.signUp.domain.exception; +package com.inhabas.api.domain.signUp.exception; import com.inhabas.api.auth.domain.error.ErrorCode; import com.inhabas.api.auth.domain.error.businessException.BusinessException; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceImpl.java index 95f0524c..fffdee61 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceImpl.java @@ -11,8 +11,8 @@ import com.inhabas.api.auth.domain.oauth2.socialAccount.repository.MemberSocialAccountRepository; import com.inhabas.api.domain.questionnaire.dto.QuestionnaireDto; import com.inhabas.api.domain.questionnaire.usecase.QuestionnaireService; -import com.inhabas.api.domain.signUp.domain.exception.NotWriteAnswersException; -import com.inhabas.api.domain.signUp.domain.exception.NotWriteProfileException; +import com.inhabas.api.domain.signUp.exception.NotWriteAnswersException; +import com.inhabas.api.domain.signUp.exception.NotWriteProfileException; import com.inhabas.api.domain.signUp.dto.AnswerDto; import com.inhabas.api.domain.signUp.dto.SignUpDto; import com.inhabas.api.domain.signUpSchedule.usecase.SignUpScheduler; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpSchedule.java b/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpSchedule.java index 16886c1a..c18ced88 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpSchedule.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpSchedule.java @@ -1,7 +1,7 @@ package com.inhabas.api.domain.signUpSchedule.domain.entity; import com.inhabas.api.auth.domain.error.ErrorCode; -import com.inhabas.api.domain.signUpSchedule.domain.exception.InvalidDateException; +import com.inhabas.api.domain.signUpSchedule.exception.InvalidDateException; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/exception/InvalidDateException.java b/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/exception/InvalidDateException.java similarity index 81% rename from resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/exception/InvalidDateException.java rename to resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/exception/InvalidDateException.java index 0c66a22a..aa32cf46 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/exception/InvalidDateException.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/exception/InvalidDateException.java @@ -1,4 +1,4 @@ -package com.inhabas.api.domain.signUpSchedule.domain.exception; +package com.inhabas.api.domain.signUpSchedule.exception; import com.inhabas.api.auth.domain.error.ErrorCode; import com.inhabas.api.auth.domain.error.businessException.BusinessException; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/exception/SignUpNotAvailableException.java b/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/exception/SignUpNotAvailableException.java similarity index 82% rename from resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/exception/SignUpNotAvailableException.java rename to resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/exception/SignUpNotAvailableException.java index 5d2bf112..0e099a29 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/exception/SignUpNotAvailableException.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/exception/SignUpNotAvailableException.java @@ -1,4 +1,4 @@ -package com.inhabas.api.domain.signUpSchedule.domain.exception; +package com.inhabas.api.domain.signUpSchedule.exception; import com.inhabas.api.auth.domain.error.ErrorCode; import com.inhabas.api.auth.domain.error.businessException.BusinessException; diff --git a/resource-server/src/main/java/com/inhabas/api/web/ExceptionController.java b/resource-server/src/main/java/com/inhabas/api/web/ExceptionController.java index 6b35010c..06a57357 100644 --- a/resource-server/src/main/java/com/inhabas/api/web/ExceptionController.java +++ b/resource-server/src/main/java/com/inhabas/api/web/ExceptionController.java @@ -3,10 +3,10 @@ import com.inhabas.api.auth.domain.error.ErrorResponse; import com.inhabas.api.auth.domain.error.businessException.InvalidInputException; import com.inhabas.api.auth.domain.error.businessException.NotFoundException; -import com.inhabas.api.domain.signUp.domain.exception.NotWriteAnswersException; -import com.inhabas.api.domain.signUp.domain.exception.NotWriteProfileException; -import com.inhabas.api.domain.signUpSchedule.domain.exception.InvalidDateException; -import com.inhabas.api.domain.signUpSchedule.domain.exception.SignUpNotAvailableException; +import com.inhabas.api.domain.signUp.exception.NotWriteAnswersException; +import com.inhabas.api.domain.signUp.exception.NotWriteProfileException; +import com.inhabas.api.domain.signUpSchedule.exception.InvalidDateException; +import com.inhabas.api.domain.signUpSchedule.exception.SignUpNotAvailableException; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/resource-server/src/main/java/com/inhabas/api/web/interceptor/SignUpControllerInterceptor.java b/resource-server/src/main/java/com/inhabas/api/web/interceptor/SignUpControllerInterceptor.java index 75a8a0c9..d7a693d3 100644 --- a/resource-server/src/main/java/com/inhabas/api/web/interceptor/SignUpControllerInterceptor.java +++ b/resource-server/src/main/java/com/inhabas/api/web/interceptor/SignUpControllerInterceptor.java @@ -1,7 +1,7 @@ package com.inhabas.api.web.interceptor; import com.inhabas.api.domain.signUpSchedule.usecase.SignUpAvailabilityChecker; -import com.inhabas.api.domain.signUpSchedule.domain.exception.SignUpNotAvailableException; +import com.inhabas.api.domain.signUpSchedule.exception.SignUpNotAvailableException; import lombok.RequiredArgsConstructor; import org.springframework.web.servlet.HandlerInterceptor; diff --git a/resource-server/src/test/java/com/inhabas/api/domain/BaseEntityTest.java b/resource-server/src/test/java/com/inhabas/api/domain/BaseEntityTest.java index 88c8217a..f558ba5a 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/BaseEntityTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/BaseEntityTest.java @@ -44,7 +44,7 @@ public void setUp() { // public void createdTimeTest() { // //given // Member member = em.persist(basicMember1()); -// NormalBoard board = new NormalBoard("title", "contents") +// NormalBoard board = new NormalBoard("title", "content") // .writtenBy(member.getId()) // .inMenu(freeBoardMenu.getId()); // @@ -60,13 +60,13 @@ public void setUp() { // public void updatedTimeTest() { // //given // Member member = em.persist(basicMember1()); -// NormalBoard board = new NormalBoard("title", "contents") +// NormalBoard board = new NormalBoard("title", "content") // .writtenBy(member.getId()) // .inMenu(freeBoardMenu.getId()); // em.persist(board); // // //when -// board.modify("title2", "modified contents", member.getId()); +// board.modify("title2", "modified content", member.getId()); // em.merge(board); // em.flush();em.clear(); // diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentsTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentTest.java similarity index 56% rename from resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentsTest.java rename to resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentTest.java index 1f7bbbbd..3bdcc63d 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentsTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentTest.java @@ -6,39 +6,39 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -public class BoardContentsTest { +public class BoardContentTest { - @DisplayName("Contents 타입에 게시글 내용을 저장한다.") + @DisplayName("Content 타입에 게시글 내용을 저장한다.") @Test public void Contents_is_OK() { String contentsString = ".".repeat(16777215); // 16 MB - 1 - Contents contents = new Contents(contentsString); + Content content = new Content(contentsString); - assertThat(contents.getValue()).isEqualTo(contentsString); + assertThat(content.getValue()).isEqualTo(contentsString); } - @DisplayName("Contents 타입에 너무 긴 게시글을 저장한다. (16 MB - 1 byte) 이상") + @DisplayName("Content 타입에 너무 긴 게시글을 저장한다. (16 MB - 1 byte) 이상") @Test public void Contents_is_too_long() { String contentsString = ".".repeat(16777215 + 1); // 16 MB - 1 byte //then assertThrows(IllegalArgumentException.class, - () -> new Contents(contentsString)); + () -> new Content(contentsString)); } - @DisplayName("Contents 타입에 공백을 저장할 수 없다.") + @DisplayName("Content 타입에 공백을 저장할 수 없다.") @Test public void Contents_is_Empty() { assertThrows(IllegalArgumentException.class, - () -> new Contents("")); + () -> new Content("")); } - @DisplayName("Contents 타입에 null 은 허용 안된다.") + @DisplayName("Content 타입에 null 은 허용 안된다.") @Test public void Contents_is_Null() { assertThrows(IllegalArgumentException.class, - () -> new Contents(null)); + () -> new Content(null)); } } diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/dto/SaveBoardDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/dto/SaveBoardDtoTest.java index 223b3f68..9794dceb 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/board/dto/SaveBoardDtoTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/board/dto/SaveBoardDtoTest.java @@ -34,7 +34,7 @@ public static void close() { @Test public void SaveBoardDto_is_OK(){ //given - SaveBoardDto saveBoardDto = new SaveBoardDto("title", "contents", new MenuId(1)); + SaveBoardDto saveBoardDto = new SaveBoardDto("title", "content", new MenuId(1)); //when Set> violations = validator.validate(saveBoardDto); @@ -43,7 +43,7 @@ public void SaveBoardDto_is_OK(){ assertTrue(violations.isEmpty()); } - @DisplayName("SaveBoardDto의 contents 필드가 null 이면 validation 실패") + @DisplayName("SaveBoardDto의 content 필드가 null 이면 validation 실패") @Test public void Contents_is_null() { // given diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/dto/UpdateBoardDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/dto/UpdateBoardDtoTest.java index 18732626..2701d64e 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/board/dto/UpdateBoardDtoTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/board/dto/UpdateBoardDtoTest.java @@ -32,7 +32,7 @@ public static void close() { @Test public void UpdateBoardDto_is_OK() { //given - UpdateBoardDto updateBoardDto = new UpdateBoardDto(1, "title", "contents"); + UpdateBoardDto updateBoardDto = new UpdateBoardDto(1, "title", "content"); // when Set> violations = validator.validate(updateBoardDto); diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryTest.java index d1a873b7..f2d60f9e 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryTest.java @@ -84,7 +84,7 @@ public class NormalBoardRepositoryTest { // () -> assertThat(saveBoard.getId()).isNotNull(), // () -> assertThat(saveBoard.getDateCreated()).isNotNull(), // () -> assertThat(saveBoard.getTitle()).isEqualTo(FREE_BOARD.getTitle()), -// () -> assertThat(saveBoard.getContents()).isEqualTo(FREE_BOARD.getContents()), +// () -> assertThat(saveBoard.getContent()).isEqualTo(FREE_BOARD.getContent()), // () -> assertThat(saveBoard.getWriterId()).isEqualTo(saveMember.getId()) // ); // } @@ -104,7 +104,7 @@ public class NormalBoardRepositoryTest { // assertAll( // () -> assertThat(find.getId()).isEqualTo(NOTICE_BOARD.getId()), // () -> assertThat(find.getTitle()).isEqualTo(NOTICE_BOARD.getTitle()), -// () -> assertThat(find.getContents()).isEqualTo(NOTICE_BOARD.getContents()), +// () -> assertThat(find.getContent()).isEqualTo(NOTICE_BOARD.getContent()), // () -> assertThat(find.getMenuId()).isEqualTo(NOTICE_BOARD.getMenuId()), // () -> assertThat(find.getWriterName()).isEqualTo(writer.getName()) // ); @@ -123,7 +123,7 @@ public class NormalBoardRepositoryTest { // .orElseThrow(EntityNotFoundException::new); // // //then -// assertThat(findBoard.getContents()).isEqualTo("내용이 수정되었습니다."); +// assertThat(findBoard.getContent()).isEqualTo("내용이 수정되었습니다."); // assertThat(findBoard.getTitle()).isEqualTo("제목이 수정되었습니다."); // } diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/usecase/BoardServiceTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/usecase/BoardServiceTest.java index dbdcf3a4..3dca5bca 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/board/usecase/BoardServiceTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/board/usecase/BoardServiceTest.java @@ -53,8 +53,8 @@ void setUp() { @Test public void createBoard() { //given - SaveBoardDto saveBoardDto = new SaveBoardDto("title", "contents", new MenuId(1)); - NormalBoard normalBoard = new NormalBoard("title", "contents"); + SaveBoardDto saveBoardDto = new SaveBoardDto("title", "content", new MenuId(1)); + NormalBoard normalBoard = new NormalBoard("title", "content"); given(boardRepository.save(any())).willReturn(normalBoard); // when @@ -71,10 +71,10 @@ public void getBoardList() { PageRequest pageable = PageRequest.of(0, 10, Sort.Direction.ASC, "created"); BoardDto boardDto1 = - new BoardDto(1, "title", "contents", "mingyeom", + new BoardDto(1, "title", "content", "mingyeom", new MenuId(1), LocalDateTime.now(), LocalDateTime.now()); BoardDto boardDto2 = - new BoardDto(2, "title", "contents", "minji", + new BoardDto(2, "title", "content", "minji", new MenuId(1), LocalDateTime.now(), LocalDateTime.now()); List results = new ArrayList<>(); @@ -97,7 +97,7 @@ public void getBoardList() { public void getDetailBoard() { //given BoardDto boardDto = - new BoardDto(1, "title", "contents", "김민겸", + new BoardDto(1, "title", "content", "김민겸", new MenuId(1), LocalDateTime.now(), null); given(boardRepository.findDtoById(any())).willReturn(Optional.of(boardDto)); @@ -113,7 +113,7 @@ public void getDetailBoard() { public void deleteBoard() { //given StudentId writer = new StudentId("12201863"); - NormalBoard board = new NormalBoard("Title", "Contents").writtenBy(writer); + NormalBoard board = new NormalBoard("Title", "Content").writtenBy(writer); given(boardRepository.findById(anyInt())).willReturn(Optional.of(board)); doNothing().when(boardRepository).deleteById(any()); @@ -130,8 +130,8 @@ public void updateBoard() { //given StudentId memberId = new StudentId("12201863"); NormalBoard savedNormalBoard = new NormalBoard("Origin Title", - "Origin Contents").writtenBy(memberId); - NormalBoard updatedNormalBoard = new NormalBoard("Title", "Contents").writtenBy( + "Origin Content").writtenBy(memberId); + NormalBoard updatedNormalBoard = new NormalBoard("Title", "Content").writtenBy( memberId); given(boardRepository.findById(anyInt())).willReturn(Optional.of(savedNormalBoard)); @@ -152,7 +152,7 @@ public void failToUpdateBoard() { //given StudentId badUser = new StudentId("44444444"); StudentId originWriter = new StudentId("12201863"); - NormalBoard board = new NormalBoard("Title", "Contents").writtenBy(originWriter); + NormalBoard board = new NormalBoard("Title", "Content").writtenBy(originWriter); given(boardRepository.findById(anyInt())).willReturn(Optional.of(board)); // when @@ -166,7 +166,7 @@ public void failToDeleteBoard() { //given StudentId badUser = new StudentId("44444444"); StudentId originWriter = new StudentId("12201863"); - NormalBoard board = new NormalBoard("Title", "Contents").writtenBy(originWriter); + NormalBoard board = new NormalBoard("Title", "Content").writtenBy(originWriter); given(boardRepository.findById(anyInt())).willReturn(Optional.of(board)); // when diff --git a/resource-server/src/test/java/com/inhabas/api/domain/comment/domain/valueObject/CommentContentsTest.java b/resource-server/src/test/java/com/inhabas/api/domain/comment/domain/valueObject/CommentContentTest.java similarity index 79% rename from resource-server/src/test/java/com/inhabas/api/domain/comment/domain/valueObject/CommentContentsTest.java rename to resource-server/src/test/java/com/inhabas/api/domain/comment/domain/valueObject/CommentContentTest.java index f9f293b3..47a29703 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/comment/domain/valueObject/CommentContentsTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/comment/domain/valueObject/CommentContentTest.java @@ -6,9 +6,9 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -public class CommentContentsTest { +public class CommentContentTest { - @DisplayName("Contents 타입에 내용을 저장한다.") + @DisplayName("Content 타입에 내용을 저장한다.") @Test public void Contents_is_saved_well() { //given @@ -21,7 +21,7 @@ public void Contents_is_saved_well() { assertThat(contents.getValue()).isEqualTo(contentsString); } - @DisplayName("Contents 타입에 너무 긴 내용을 입력한다. 500자 이상") + @DisplayName("Content 타입에 너무 긴 내용을 입력한다. 500자 이상") @Test public void Contents_is_too_long() { //given @@ -33,7 +33,7 @@ public void Contents_is_too_long() { ); } - @DisplayName("Contents 타입에 null 은 안된다.") + @DisplayName("Content 타입에 null 은 안된다.") @Test public void Contents_is_Null() { assertThrows(IllegalArgumentException.class, @@ -41,7 +41,7 @@ public void Contents_is_Null() { ); } - @DisplayName("Contents 타입에 공백댓글은 저장할 수 없다.") + @DisplayName("Content 타입에 공백댓글은 저장할 수 없다.") @Test public void Contents_is_Blank() { assertThrows(IllegalArgumentException.class, diff --git a/resource-server/src/test/java/com/inhabas/api/domain/comment/repository/CommentRepositoryTest.java b/resource-server/src/test/java/com/inhabas/api/domain/comment/repository/CommentRepositoryTest.java index 9853189e..3cf84c34 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/comment/repository/CommentRepositoryTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/comment/repository/CommentRepositoryTest.java @@ -63,7 +63,7 @@ public class CommentRepositoryTest { // em.clear(); // // //then -// assertThat(saveComment.getContents()).isEqualTo("필력 좋다 쓴이야"); +// assertThat(saveComment.getContent()).isEqualTo("필력 좋다 쓴이야"); // assertThat(saveComment.getParentBoard().getId()).isEqualTo(normalBoard.getId()); // } // @@ -81,7 +81,7 @@ public class CommentRepositoryTest { // Comment savedReply = commentRepository.save(reply); // // //then -// assertThat(savedReply.getContents()).isEqualTo("익1 고마워"); +// assertThat(savedReply.getContent()).isEqualTo("익1 고마워"); // assertThat(savedReply.getParentBoard().getId()).isEqualTo(normalBoard.getId()); // assertThat(savedReply.getParentComment().getId()).isEqualTo(comment.getId()); // } @@ -121,19 +121,19 @@ public class CommentRepositoryTest { // assertThat(commentList.size()).isEqualTo(2); // 루트 댓글은 2 개이다. // // // 첫번째 루트 댓글 -// assertThat(commentList.get(0).getContents()).isEqualTo("1) 필력 좋다 쓴이야"); +// assertThat(commentList.get(0).getContent()).isEqualTo("1) 필력 좋다 쓴이야"); // // 첫번째 루트 댓글의 대댓글은 1개 // assertThat(commentList.get(0).getChildren()) // .hasSize(1) -// .extracting(CommentDetailDto::getContents) +// .extracting(CommentDetailDto::getContent) // .contains("1-1) 고마워"); // // // 두번째 루트 댓글 -// assertThat(commentList.get(1).getContents()).isEqualTo("2) 쓴이야 분발하자"); +// assertThat(commentList.get(1).getContent()).isEqualTo("2) 쓴이야 분발하자"); // // 두번째 루트 댓글의 대댓글은 2개 // assertThat(commentList.get(1).getChildren()) // .hasSize(2) -// .extracting(CommentDetailDto::getContents) +// .extracting(CommentDetailDto::getContent) // .containsExactly("2-1) 너 누구야?", "2-2) 나? 김첨지"); // } // @@ -189,12 +189,12 @@ public class CommentRepositoryTest { // // assertThat(all) // .hasSize(3) -// .extracting(Comment::getContents) -// .doesNotContain(reply_2.getContents()) +// .extracting(Comment::getContent) +// .doesNotContain(reply_2.getContent()) // .contains( -// comment.getContents(), -// reply_1.getContents(), -// reply_3.getContents() +// comment.getContent(), +// reply_1.getContent(), +// reply_3.getContent() // ); // // } diff --git a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/SaveContestBoardDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/SaveContestBoardDtoTest.java index 3bc5b1af..7d92d38f 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/SaveContestBoardDtoTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/SaveContestBoardDtoTest.java @@ -84,7 +84,7 @@ public void InputsAreExceededError() { //given SaveContestBoardDto saveContestBoardDto = new SaveContestBoardDto( "title".repeat(20) + ".", - "contents! Cucumber paste has to have a sun-dried, chilled sauerkraut component.", + "content! Cucumber paste has to have a sun-dried, chilled sauerkraut component.", "Assoc".repeat(20) + ".", "topic".repeat(100)+ ".", LocalDate.of(2022, 1, 1), @@ -109,7 +109,7 @@ public void InputsAreExceededError() { @Test public void DeadlineIsOutdatedError() { //given - SaveContestBoardDto saveContestBoardDto = new SaveContestBoardDto("title", "contents", "association", "topic", + SaveContestBoardDto saveContestBoardDto = new SaveContestBoardDto("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 2, 1)); // when diff --git a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/UpdateContestBoardDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/UpdateContestBoardDtoTest.java index 109d6535..0e76c65e 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/UpdateContestBoardDtoTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/UpdateContestBoardDtoTest.java @@ -86,7 +86,7 @@ public void InputsAreExceededError() { UpdateContestBoardDto updateContestBoardDto = new UpdateContestBoardDto( 1, "title".repeat(20) + ".", - "contents! Cucumber paste has to have a sun-dried, chilled sauerkraut component.", + "content! Cucumber paste has to have a sun-dried, chilled sauerkraut component.", "Assoc".repeat(20) + ".", "topic".repeat(100)+ ".", LocalDate.of(2022, 1, 1), diff --git a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/repository/ContestBoardRepositoryTest.java b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/repository/ContestBoardRepositoryTest.java index 34b2e829..7a8c5cbb 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/repository/ContestBoardRepositoryTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/repository/ContestBoardRepositoryTest.java @@ -69,7 +69,7 @@ public class ContestBoardRepositoryTest { // .id(savedContestBoard.getId()) // .writerName(writer.getName()) // .title(savedContestBoard.getTitle()) -// .contents(savedContestBoard.getContents()) +// .content(savedContestBoard.getContent()) // .association(savedContestBoard.getAssociation()) // .topic(savedContestBoard.getTopic()) // .start(savedContestBoard.getStart()) diff --git a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/usecase/ContestBoardServiceTest.java b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/usecase/ContestBoardServiceTest.java index b62f92bf..77e76dd1 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/usecase/ContestBoardServiceTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/usecase/ContestBoardServiceTest.java @@ -52,10 +52,10 @@ public void createContestBoard() { //given StudentId StudentId = new StudentId("12201863"); SaveContestBoardDto saveContestBoardDto = - new SaveContestBoardDto("title", "contents", "association", "topic", + new SaveContestBoardDto("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1, 26)); ContestBoard contestBoard = - new ContestBoard("title", "contents", "association", "topic", + new ContestBoard("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1, 26)); given(contestBoardRepository.save(any())).willReturn(contestBoard); @@ -108,7 +108,7 @@ public void getContestBoardList() { public void getDetailBoard() { //given DetailContestBoardDto contestBoardDto = - new DetailContestBoardDto(1, "mingyeom", "title", "contents", + new DetailContestBoardDto(1, "mingyeom", "title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1, 29), LocalDateTime.now(), null); given(contestBoardRepository.findDtoById(any())).willReturn(Optional.of(contestBoardDto)); @@ -127,7 +127,7 @@ public void deleteContestBoard() { //given StudentId StudentId = new StudentId("12201863"); ContestBoard contestBoard = - new ContestBoard("title", "contents", "association", "topic", + new ContestBoard("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1, 26)) .writtenBy(StudentId); given(contestBoardRepository.findById(anyInt())).willReturn(Optional.of(contestBoard)); @@ -146,7 +146,7 @@ public void updateContestBoard() { //given StudentId StudentId = new StudentId("12201863"); ContestBoard expectedContestBoard = - new ContestBoard("title", "contents", "association", "topic", + new ContestBoard("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1, 26)) .writtenBy(StudentId); @@ -171,7 +171,7 @@ public void failToModifyTest() { StudentId badUser = new StudentId("44444444"); StudentId originalWriter = new StudentId("12201863"); ContestBoard expectedContestBoard = - new ContestBoard("title", "contents", "association", "topic", + new ContestBoard("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1, 26)) .writtenBy(originalWriter); given(contestBoardRepository.findById(any())).willReturn(Optional.of(expectedContestBoard)); @@ -195,7 +195,7 @@ public void failToDeleteTest() { StudentId badUser = new StudentId("44444444"); StudentId StudentId = new StudentId("12201863"); ContestBoard contestBoard = - new ContestBoard("title", "contents", "association", "topic", + new ContestBoard("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1, 26)) .writtenBy(StudentId); given(contestBoardRepository.findById(anyInt())).willReturn(Optional.of(contestBoard)); diff --git a/resource-server/src/test/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceTest.java b/resource-server/src/test/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceTest.java index 99331dbb..659c66cb 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceTest.java @@ -9,8 +9,8 @@ import com.inhabas.api.auth.domain.oauth2.member.repository.MemberRepository; import com.inhabas.api.auth.domain.oauth2.socialAccount.repository.MemberSocialAccountRepository; import com.inhabas.api.domain.questionnaire.usecase.QuestionnaireService; -import com.inhabas.api.domain.signUp.domain.exception.NotWriteAnswersException; -import com.inhabas.api.domain.signUp.domain.exception.NotWriteProfileException; +import com.inhabas.api.domain.signUp.exception.NotWriteAnswersException; +import com.inhabas.api.domain.signUp.exception.NotWriteProfileException; import com.inhabas.api.domain.signUp.dto.AnswerDto; import com.inhabas.api.domain.signUp.dto.SignUpDto; import com.inhabas.api.domain.signUpSchedule.usecase.SignUpScheduler; diff --git a/resource-server/src/test/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpScheduleTest.java b/resource-server/src/test/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpScheduleTest.java index a7bb449c..450f77ce 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpScheduleTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpScheduleTest.java @@ -1,6 +1,6 @@ package com.inhabas.api.domain.signUpSchedule.domain.entity; -import com.inhabas.api.domain.signUpSchedule.domain.exception.InvalidDateException; +import com.inhabas.api.domain.signUpSchedule.exception.InvalidDateException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/resource-server/src/test/java/com/inhabas/api/web/BoardControllerTest.java b/resource-server/src/test/java/com/inhabas/api/web/BoardControllerTest.java index aa7d4351..24534c1d 100644 --- a/resource-server/src/test/java/com/inhabas/api/web/BoardControllerTest.java +++ b/resource-server/src/test/java/com/inhabas/api/web/BoardControllerTest.java @@ -57,7 +57,7 @@ public class BoardControllerTest { // @WithMockJwtAuthenticationToken // public void addNewBoard() throws Exception { // //given -// SaveBoardDto saveBoardDto = new SaveBoardDto("This is title", "This is contents", new MenuId(1)); +// SaveBoardDto saveBoardDto = new SaveBoardDto("This is title", "This is content", new MenuId(1)); // given(boardService.write(any(), any(SaveBoardDto.class))).willReturn(1); // // // when @@ -133,7 +133,7 @@ public void getBoardList() throws Exception { public void getBoardDetail() throws Exception{ //given BoardDto boardDto = - new BoardDto(1, "Shown Title", "Shown Contents", "Mingyeom", + new BoardDto(1, "Shown Title", "Shown Content", "Mingyeom", new MenuId(1), LocalDateTime.now(), null); given(boardService.getBoard(anyInt())).willReturn(boardDto); @@ -153,7 +153,7 @@ public void getBoardDetail() throws Exception{ // @WithMockJwtAuthenticationToken // public void TitleIsTooLongError() throws Exception { // //given -// SaveBoardDto saveBoardDto = new SaveBoardDto("title".repeat(20) + ".", "contents", new MenuId(1)); +// SaveBoardDto saveBoardDto = new SaveBoardDto("title".repeat(20) + ".", "content", new MenuId(1)); // // // when // String errorMessage = Objects.requireNonNull( diff --git a/resource-server/src/test/java/com/inhabas/api/web/CommentControllerTest.java b/resource-server/src/test/java/com/inhabas/api/web/CommentControllerTest.java index 59147d0f..83bb72f9 100644 --- a/resource-server/src/test/java/com/inhabas/api/web/CommentControllerTest.java +++ b/resource-server/src/test/java/com/inhabas/api/web/CommentControllerTest.java @@ -76,7 +76,7 @@ void getCommentList() throws Exception { // @Test // void createNewComment() throws Exception { // //given -// String jsonRequest = "{\"writerId\":12171652,\"contents\":\"아싸 1등\",\"boardId\":13}"; +// String jsonRequest = "{\"writerId\":12171652,\"content\":\"아싸 1등\",\"boardId\":13}"; // Integer newCommentId = 1; // given(commentService.create(any(), any())).willReturn(newCommentId); // @@ -97,7 +97,7 @@ void getCommentList() throws Exception { // @Test // void createNewReply() throws Exception { // //given -// String jsonRequest = "{\"writerId\":12171652,\"contents\":\"아싸 1등\",\"boardId\":13, \"parentCommentId\":1}"; +// String jsonRequest = "{\"writerId\":12171652,\"content\":\"아싸 1등\",\"boardId\":13, \"parentCommentId\":1}"; // Integer newReplyId = 2; // given(commentService.create(any(), any())).willReturn(newReplyId); // @@ -119,7 +119,7 @@ void getCommentList() throws Exception { void tryToSaveTooLongContents() throws Exception { //given String tooLongContents = "-".repeat(500); - String jsonRequest = String.format("{\"writerId\":12171652,\"contents\":\"%s\",\"boardId\":13}", tooLongContents); + String jsonRequest = String.format("{\"writerId\":12171652,\"content\":\"%s\",\"boardId\":13}", tooLongContents); //when String errorMessage = mockMvc.perform(post("/comment") @@ -136,7 +136,7 @@ void tryToSaveTooLongContents() throws Exception { // @Test // void updateComment() throws Exception { // //given -// String jsonRequest = "{\"commentId\":1, \"writerId\":12171652,\"contents\":\"1등이 아니네,,,\",\"boardId\":12}"; +// String jsonRequest = "{\"commentId\":1, \"writerId\":12171652,\"content\":\"1등이 아니네,,,\",\"boardId\":12}"; // given(commentService.update(any(), any())).willReturn(1); // // String responseBody = mockMvc.perform(put("/comment") diff --git a/resource-server/src/test/java/com/inhabas/api/web/ContestBoardControllerTest.java b/resource-server/src/test/java/com/inhabas/api/web/ContestBoardControllerTest.java index a60b1de2..9c5e3afe 100644 --- a/resource-server/src/test/java/com/inhabas/api/web/ContestBoardControllerTest.java +++ b/resource-server/src/test/java/com/inhabas/api/web/ContestBoardControllerTest.java @@ -54,7 +54,7 @@ public class ContestBoardControllerTest { // @WithMockJwtAuthenticationToken // public void addNewContestBoard() throws Exception { // //given -// SaveContestBoardDto saveContestBoardDto = new SaveContestBoardDto("title", "contents", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(9022, 3, 26)); +// SaveContestBoardDto saveContestBoardDto = new SaveContestBoardDto("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(9022, 3, 26)); // given(contestBoardService.write(any(), any(SaveContestBoardDto.class))).willReturn(1); // // // when @@ -126,7 +126,7 @@ public void getContestBoardList() throws Exception { @Test public void getContestBoardDetail() throws Exception{ //given - DetailContestBoardDto contestBoardDto = new DetailContestBoardDto(1, "mingyeom", "title", "contents", "association","topic", LocalDate.of(2022,1,1), LocalDate.of(2022, 1, 29), LocalDateTime.now(), null); + DetailContestBoardDto contestBoardDto = new DetailContestBoardDto(1, "mingyeom", "title", "content", "association","topic", LocalDate.of(2022,1,1), LocalDate.of(2022, 1, 29), LocalDateTime.now(), null); given(contestBoardService.getBoard(anyInt())).willReturn(contestBoardDto); // when @@ -145,7 +145,7 @@ public void getContestBoardDetail() throws Exception{ // @WithMockJwtAuthenticationToken // public void TitleIsTooLongError() throws Exception { // //given -// SaveContestBoardDto saveContestBoardDto = new SaveContestBoardDto("title".repeat(20)+ ".", "contents", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1,26)); +// SaveContestBoardDto saveContestBoardDto = new SaveContestBoardDto("title".repeat(20)+ ".", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1,26)); // // // // when diff --git a/resource-server/src/test/java/com/inhabas/api/web/SignUpScheduleControllerTest.java b/resource-server/src/test/java/com/inhabas/api/web/SignUpScheduleControllerTest.java index 03934291..af39d64f 100644 --- a/resource-server/src/test/java/com/inhabas/api/web/SignUpScheduleControllerTest.java +++ b/resource-server/src/test/java/com/inhabas/api/web/SignUpScheduleControllerTest.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.inhabas.api.auth.domain.error.ErrorCode; -import com.inhabas.api.domain.signUpSchedule.domain.exception.InvalidDateException; +import com.inhabas.api.domain.signUpSchedule.exception.InvalidDateException; import com.inhabas.api.domain.signUpSchedule.dto.SignUpScheduleDto; import com.inhabas.api.domain.signUpSchedule.usecase.SignUpScheduler; import com.inhabas.testAnnotataion.NoSecureWebMvcTest; From e39b4d6bb187206a5326efb8c3ed551efcdf1fba Mon Sep 17 00:00:00 2001 From: whitemark Date: Sun, 31 Dec 2023 22:47:56 +0900 Subject: [PATCH 02/10] =?UTF-8?q?[feature/#204]=20ClubHistory=20entity=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../board/domain/valueObject/Content.java | 2 +- .../board/domain/valueObject/Title.java | 6 ++- .../club/domain/entity/ClubHistory.java | 46 +++++++++++++++++++ .../api/domain/club/dto/ClubHistoryDto.java | 30 ++++++++++++ .../domain/club/dto/SaveClubHistoryDto.java | 33 +++++++++++++ 5 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 resource-server/src/main/java/com/inhabas/api/domain/club/domain/entity/ClubHistory.java create mode 100644 resource-server/src/main/java/com/inhabas/api/domain/club/dto/ClubHistoryDto.java create mode 100644 resource-server/src/main/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDto.java diff --git a/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Content.java b/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Content.java index 66cbde0d..7549f7ad 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Content.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Content.java @@ -22,7 +22,7 @@ public Content(String value) { if (validate(value)) this.value = value; else - throw new IllegalArgumentException(); + throw new InvalidInputException(); } private boolean validate(Object value) { diff --git a/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Title.java b/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Title.java index 20608769..d22f6391 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Title.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Title.java @@ -1,5 +1,7 @@ package com.inhabas.api.domain.board.domain.valueObject; +import com.inhabas.api.auth.domain.error.businessException.InvalidInputException; + import javax.persistence.Column; import javax.persistence.Embeddable; import javax.persistence.Transient; @@ -8,7 +10,7 @@ @Embeddable public class Title { - @Column(name = "title", length = 100, nullable = false) + @Column(name = "TITLE", length = 100, nullable = false) private String value; @Transient @@ -20,7 +22,7 @@ public Title(String value) { if (validate(value)) this.value = value; else - throw new IllegalArgumentException(); + throw new InvalidInputException(); } private boolean validate(Object value) { diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/domain/entity/ClubHistory.java b/resource-server/src/main/java/com/inhabas/api/domain/club/domain/entity/ClubHistory.java new file mode 100644 index 00000000..242f1249 --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/domain/entity/ClubHistory.java @@ -0,0 +1,46 @@ +package com.inhabas.api.domain.club.domain.entity; + +import com.inhabas.api.auth.domain.oauth2.member.domain.entity.Member; +import com.inhabas.api.domain.board.domain.valueObject.Content; +import com.inhabas.api.domain.board.domain.valueObject.Title; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.springframework.data.annotation.CreatedDate; + +import javax.persistence.*; +import java.time.LocalDateTime; + +@Entity +@Table(name = "CLUB_HISTORY") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class ClubHistory { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn(name = "USER_ID", foreignKey = @ForeignKey(name = "FK_MEMBER_OF_CLUB_HISTORY")) + private Member member; + + @Embedded + private Title title; + + @Embedded + private Content content; + + @Column(name = "DATE_HISTORY", nullable = false, columnDefinition = "DATETIME(0)") + private LocalDateTime dateHistory; + + @CreatedDate + @Column(name = "DATE_CREATED", nullable = false, updatable = false, insertable = false, columnDefinition = "DATETIME(0) DEFAULT CURRENT_TIMESTAMP") + private LocalDateTime dateCreated; + + public ClubHistory(Member member, Title title, Content content, LocalDateTime dateHistory) { + this.member = member; + this.title = title; + this.content = content; + this.dateHistory = dateHistory; + } + +} diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/dto/ClubHistoryDto.java b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/ClubHistoryDto.java new file mode 100644 index 00000000..4d336568 --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/ClubHistoryDto.java @@ -0,0 +1,30 @@ +package com.inhabas.api.domain.club.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.inhabas.api.domain.board.domain.valueObject.Content; +import com.inhabas.api.domain.budget.domain.valueObject.Title; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Positive; +import java.time.LocalDateTime; + +public class ClubHistoryDto { + + @NotNull + @Positive + private Long id; + + private Title title; + + private Content content; + + @NotNull + @Positive + private Long writerId; + + @NotNull + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") + @Schema(type = "string", example = "2023-11-01T00:00:00") + private LocalDateTime dateHistory; +} diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDto.java b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDto.java new file mode 100644 index 00000000..db5997cf --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDto.java @@ -0,0 +1,33 @@ +package com.inhabas.api.domain.club.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.inhabas.api.domain.board.domain.valueObject.Content; +import com.inhabas.api.domain.budget.domain.valueObject.Title; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + +@Getter +@NoArgsConstructor +public class SaveClubHistoryDto { + + private Title title; + + private Content content; + + @NotNull + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") + @Schema(type = "string", example = "2023-11-01T00:00:00") + private LocalDateTime dateHistory; + + @Builder + public SaveClubHistoryDto(Title title, Content content, LocalDateTime dateHistory) { + this.title = title; + this.content = content; + this.dateHistory = dateHistory; + } +} From 0ee8625abd06c05a134266403017f9ad82b8ce25 Mon Sep 17 00:00:00 2001 From: whitemark Date: Sun, 31 Dec 2023 22:48:44 +0900 Subject: [PATCH 03/10] =?UTF-8?q?[feature/#204]=20ClubHistory=20controller?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ClubHistoryRepository.java | 7 + .../club/usecase/ClubHistoryService.java | 21 +++ .../club/usecase/ClubHistoryServiceImpl.java | 42 ++++++ .../api/web/ClubHistoryController.java | 127 ++++++++++++++++++ 4 files changed, 197 insertions(+) create mode 100644 resource-server/src/main/java/com/inhabas/api/domain/club/repository/ClubHistoryRepository.java create mode 100644 resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java create mode 100644 resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java create mode 100644 resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/repository/ClubHistoryRepository.java b/resource-server/src/main/java/com/inhabas/api/domain/club/repository/ClubHistoryRepository.java new file mode 100644 index 00000000..e8f76221 --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/repository/ClubHistoryRepository.java @@ -0,0 +1,7 @@ +package com.inhabas.api.domain.club.repository; + +import com.inhabas.api.domain.club.domain.entity.ClubHistory; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ClubHistoryRepository extends JpaRepository { +} diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java new file mode 100644 index 00000000..327fbd1f --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java @@ -0,0 +1,21 @@ +package com.inhabas.api.domain.club.usecase; + +import com.inhabas.api.domain.club.dto.ClubHistoryDto; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; + +import java.util.List; + +public interface ClubHistoryService { + + Long writeClubHistory(SaveClubHistoryDto saveClubHistoryDto); + + ClubHistoryDto findClubHistory(Long clubHistoryId); + + List getClubHistories(); + + void updateClubHistory(Long clubHistoryId, SaveClubHistoryDto saveClubHistoryDto); + + void deleteClubHistories(Long clubHistoryId); + +} + diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java new file mode 100644 index 00000000..b03f12f0 --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java @@ -0,0 +1,42 @@ +package com.inhabas.api.domain.club.usecase; + +import com.inhabas.api.domain.club.dto.ClubHistoryDto; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; +import com.inhabas.api.domain.club.repository.ClubHistoryRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@RequiredArgsConstructor +public class ClubHistoryServiceImpl implements ClubHistoryService { + + private final ClubHistoryRepository clubHistoryRepository; + + + @Override + public Long writeClubHistory(SaveClubHistoryDto saveClubHistoryDto) { + return null; + } + + @Override + public ClubHistoryDto findClubHistory(Long clubHistoryId) { + return null; + } + + @Override + public List getClubHistories() { + return null; + } + + @Override + public void updateClubHistory(Long clubHistoryId, SaveClubHistoryDto saveClubHistoryDto) { + + } + + @Override + public void deleteClubHistories(Long clubHistoryId) { + + } +} diff --git a/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java b/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java new file mode 100644 index 00000000..be4114c5 --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java @@ -0,0 +1,127 @@ +package com.inhabas.api.web; + +import com.inhabas.api.auth.domain.error.ErrorResponse; +import com.inhabas.api.domain.club.dto.ClubHistoryDto; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; +import com.inhabas.api.domain.club.usecase.ClubHistoryService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; + +import javax.validation.Valid; +import java.net.URI; +import java.util.List; + +@Tag(name = "동아리 소개", description = "동아리 소개 관련 조회, 수정") +@RestController +@RequiredArgsConstructor +public class ClubHistoryController { + + private final ClubHistoryService clubHistoryService; + + @Operation(summary = "동아리 연혁 조회", + description = "동아리 연혁 조회") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", content = { @Content( + schema = @Schema(implementation = ClubHistoryDto.class, + type = "array")) }), + }) + @GetMapping("/club/histories") + public ResponseEntity> getClubHistories() { + + List clubHistoryDtoList = clubHistoryService.getClubHistories(); + return ResponseEntity.ok(clubHistoryDtoList); + + } + + @Operation(summary = "동아리 연혁 단일 조회", + description = "동아리 연혁 단일 조회") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", content = { @Content( + schema = @Schema(implementation = ClubHistoryDto.class)) + }), + }) + @GetMapping("/club/history/{clubHistoryId}") + public ResponseEntity findClubHistory(@PathVariable Long clubHistoryId) { + + ClubHistoryDto clubHistoryDto = clubHistoryService.findClubHistory(clubHistoryId); + return ResponseEntity.ok(clubHistoryDto); + + } + + @Operation(summary = "동아리 연혁 생성", + description = "동아리 연혁 생성") + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "'Location' 헤더에 생성된 리소스의 URI가 포함됩니다."), + @ApiResponse(responseCode = "400 ", description = "입력값이 없거나, 타입이 유효하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 400, \"code\": \"G003\", \"message\": \"입력값이 없거나, 타입이 유효하지 않습니다.\"}" + ) + )) + }) + @PostMapping("/club/history") + public ResponseEntity writeClubHistories(@Valid SaveClubHistoryDto saveClubHistoryDto) { + + Long newClubHistoryId = clubHistoryService.writeClubHistory(saveClubHistoryDto); + URI location = ServletUriComponentsBuilder.fromCurrentRequest() + .path("/club/history/{clubHistoryId}") + .buildAndExpand(newClubHistoryId) + .toUri(); + return ResponseEntity.created(location).build(); + + } + + @Operation(summary = "동아리 연혁 수정", + description = "동아리 연혁 수정") + @ApiResponses(value = { + @ApiResponse(responseCode = "204"), + @ApiResponse(responseCode = "400 ", description = "입력값이 없거나, 타입이 유효하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 400, \"code\": \"G003\", \"message\": \"입력값이 없거나, 타입이 유효하지 않습니다.\"}" + ) + )), + @ApiResponse(responseCode = "404", description = "데이터가 존재하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 404, \"code\": \"G004\", \"message\": \"데이터가 존재하지 않습니다.\"}" + ) + )) + }) + @PutMapping("/club/history/{clubHistoryId}") + public ResponseEntity updateClubHistory(@PathVariable Long clubHistoryId, @Valid SaveClubHistoryDto saveClubHistoryDto) { + + clubHistoryService.updateClubHistory(clubHistoryId, saveClubHistoryDto); + return ResponseEntity.noContent().build(); + + } + + @Operation(summary = "동아리 연혁 삭제", + description = "동아리 연혁 삭제") + @ApiResponses(value = { + @ApiResponse(responseCode = "204"), + @ApiResponse(responseCode = "404", description = "데이터가 존재하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 404, \"code\": \"G004\", \"message\": \"데이터가 존재하지 않습니다.\"}" + ) + )) + }) + @DeleteMapping ("/club/{clubHistoryId}") + public ResponseEntity deleteClubHistory(@PathVariable Long clubHistoryId) { + + clubHistoryService.deleteClubHistories(clubHistoryId); + return ResponseEntity.noContent().build(); + + } + +} From 3713b93a5cbb0cf44927e9f880076b54a93464d2 Mon Sep 17 00:00:00 2001 From: whitemark Date: Mon, 1 Jan 2024 23:35:39 +0900 Subject: [PATCH 04/10] =?UTF-8?q?[feature/#204]=20ClubHistory=20service=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/NormalBoardRepositoryImpl.java | 2 +- .../club/domain/entity/ClubHistory.java | 14 +++++ .../api/domain/club/dto/ClubHistoryDto.java | 25 ++++++++- .../domain/club/dto/SaveClubHistoryDto.java | 3 +- .../club/usecase/ClubHistoryService.java | 4 +- .../club/usecase/ClubHistoryServiceImpl.java | 54 +++++++++++++++++-- .../ContestBoardRepositoryImpl.java | 2 +- .../api/web/ClubHistoryController.java | 22 +++++--- 8 files changed, 108 insertions(+), 18 deletions(-) diff --git a/resource-server/src/main/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryImpl.java index 8ac1e2cb..bdbcc8d8 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryImpl.java @@ -60,7 +60,7 @@ public Optional findDtoById(Integer id) { BoardDto target = queryFactory.select(Projections.constructor(BoardDto.class, Expressions.asNumber(id).as("id"), normalBoard.title.value, - normalBoard.contents.value, + normalBoard.content.value, member.name.value, normalBoard.menuId, normalBoard.dateCreated, diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/domain/entity/ClubHistory.java b/resource-server/src/main/java/com/inhabas/api/domain/club/domain/entity/ClubHistory.java index 242f1249..f53bc435 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/club/domain/entity/ClubHistory.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/domain/entity/ClubHistory.java @@ -3,16 +3,22 @@ import com.inhabas.api.auth.domain.oauth2.member.domain.entity.Member; import com.inhabas.api.domain.board.domain.valueObject.Content; import com.inhabas.api.domain.board.domain.valueObject.Title; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; import lombok.NoArgsConstructor; import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; import javax.persistence.*; import java.time.LocalDateTime; @Entity @Table(name = "CLUB_HISTORY") +@Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) +@EntityListeners(AuditingEntityListener.class) public class ClubHistory { @Id @@ -36,6 +42,7 @@ public class ClubHistory { @Column(name = "DATE_CREATED", nullable = false, updatable = false, insertable = false, columnDefinition = "DATETIME(0) DEFAULT CURRENT_TIMESTAMP") private LocalDateTime dateCreated; + @Builder public ClubHistory(Member member, Title title, Content content, LocalDateTime dateHistory) { this.member = member; this.title = title; @@ -43,4 +50,11 @@ public ClubHistory(Member member, Title title, Content content, LocalDateTime da this.dateHistory = dateHistory; } + public void updateClubHistory(Member member, SaveClubHistoryDto saveClubHistoryDto) { + this.member = member; + this.title = saveClubHistoryDto.getTitle(); + this.content = saveClubHistoryDto.getContent(); + this.dateHistory = saveClubHistoryDto.getDateHistory(); + } + } diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/dto/ClubHistoryDto.java b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/ClubHistoryDto.java index 4d336568..fe18882e 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/club/dto/ClubHistoryDto.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/ClubHistoryDto.java @@ -2,13 +2,19 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.inhabas.api.domain.board.domain.valueObject.Content; -import com.inhabas.api.domain.budget.domain.valueObject.Title; +import com.inhabas.api.domain.board.domain.valueObject.Title; +import com.inhabas.api.domain.club.domain.entity.ClubHistory; import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; import javax.validation.constraints.NotNull; import javax.validation.constraints.Positive; import java.time.LocalDateTime; +@Getter +@NoArgsConstructor public class ClubHistoryDto { @NotNull @@ -27,4 +33,21 @@ public class ClubHistoryDto { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") @Schema(type = "string", example = "2023-11-01T00:00:00") private LocalDateTime dateHistory; + + @Builder + public ClubHistoryDto(Long id, Title title, Content content, Long writerId, LocalDateTime dateHistory) { + this.id = id; + this.title = title; + this.content = content; + this.writerId = writerId; + this.dateHistory = dateHistory; + } + + public ClubHistoryDto(ClubHistory clubHistory) { + this.id = clubHistory.getId(); + this.title = clubHistory.getTitle(); + this.content = clubHistory.getContent(); + this.writerId = clubHistory.getMember().getId(); + this.dateHistory = clubHistory.getDateHistory(); + } } diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDto.java b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDto.java index db5997cf..0946cc22 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDto.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDto.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.inhabas.api.domain.board.domain.valueObject.Content; -import com.inhabas.api.domain.budget.domain.valueObject.Title; +import com.inhabas.api.domain.board.domain.valueObject.Title; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; import lombok.Getter; @@ -30,4 +30,5 @@ public SaveClubHistoryDto(Title title, Content content, LocalDateTime dateHistor this.content = content; this.dateHistory = dateHistory; } + } diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java index 327fbd1f..8d42030c 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java @@ -7,13 +7,13 @@ public interface ClubHistoryService { - Long writeClubHistory(SaveClubHistoryDto saveClubHistoryDto); + Long writeClubHistory(Long memberId, SaveClubHistoryDto saveClubHistoryDto); ClubHistoryDto findClubHistory(Long clubHistoryId); List getClubHistories(); - void updateClubHistory(Long clubHistoryId, SaveClubHistoryDto saveClubHistoryDto); + void updateClubHistory(Long memberId, Long clubHistoryId, SaveClubHistoryDto saveClubHistoryDto); void deleteClubHistories(Long clubHistoryId); diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java index b03f12f0..353f2748 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java @@ -1,12 +1,19 @@ package com.inhabas.api.domain.club.usecase; +import com.inhabas.api.auth.domain.error.businessException.NotFoundException; +import com.inhabas.api.auth.domain.oauth2.member.domain.entity.Member; +import com.inhabas.api.auth.domain.oauth2.member.domain.exception.MemberNotFoundException; +import com.inhabas.api.auth.domain.oauth2.member.repository.MemberRepository; +import com.inhabas.api.domain.club.domain.entity.ClubHistory; import com.inhabas.api.domain.club.dto.ClubHistoryDto; import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; import com.inhabas.api.domain.club.repository.ClubHistoryRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; +import java.util.stream.Collectors; @Service @RequiredArgsConstructor @@ -14,29 +21,66 @@ public class ClubHistoryServiceImpl implements ClubHistoryService { private final ClubHistoryRepository clubHistoryRepository; + private final MemberRepository memberRepository; + @Override - public Long writeClubHistory(SaveClubHistoryDto saveClubHistoryDto) { - return null; + @Transactional + public Long writeClubHistory(Long memberId, SaveClubHistoryDto saveClubHistoryDto) { + + Member writer = memberRepository.findById(memberId).orElseThrow(MemberNotFoundException::new); + ClubHistory clubHistory = ClubHistory.builder() + .member(writer) + .title(saveClubHistoryDto.getTitle()) + .content(saveClubHistoryDto.getContent()) + .dateHistory(saveClubHistoryDto.getDateHistory()) + .build(); + + ClubHistory result = clubHistoryRepository.save(clubHistory); + + return result.getId(); + } @Override + @Transactional(readOnly = true) public ClubHistoryDto findClubHistory(Long clubHistoryId) { - return null; + + ClubHistory clubHistory = clubHistoryRepository.findById(clubHistoryId).orElseThrow(NotFoundException::new); + + return new ClubHistoryDto(clubHistory); + } @Override + @Transactional(readOnly = true) public List getClubHistories() { - return null; + + List clubHistoryList = clubHistoryRepository.findAll(); + + return clubHistoryList.stream() + .map(ClubHistoryDto::new) + .collect(Collectors.toList()); + } @Override - public void updateClubHistory(Long clubHistoryId, SaveClubHistoryDto saveClubHistoryDto) { + @Transactional + public void updateClubHistory(Long memberId, Long clubHistoryId, SaveClubHistoryDto saveClubHistoryDto) { + + ClubHistory clubHistory = clubHistoryRepository.findById(clubHistoryId).orElseThrow(NotFoundException::new); + Member writer = memberRepository.findById(memberId).orElseThrow(MemberNotFoundException::new); + + clubHistory.updateClubHistory(writer, saveClubHistoryDto); } @Override + @Transactional public void deleteClubHistories(Long clubHistoryId) { + ClubHistory clubHistory = clubHistoryRepository.findById(clubHistoryId).orElseThrow(NotFoundException::new); + clubHistoryRepository.delete(clubHistory); + } } diff --git a/resource-server/src/main/java/com/inhabas/api/domain/contest/repository/ContestBoardRepositoryImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/contest/repository/ContestBoardRepositoryImpl.java index a88b45d6..7ef1a862 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/contest/repository/ContestBoardRepositoryImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/contest/repository/ContestBoardRepositoryImpl.java @@ -34,7 +34,7 @@ public Optional findDtoById(Integer id) { Expressions.asNumber(id).as("id"), member.name.value, contestBoard.title.value, - contestBoard.contents.value, + contestBoard.content.value, contestBoard.association.value, contestBoard.topic.value, contestBoard.start, diff --git a/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java b/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java index be4114c5..f1dd2e93 100644 --- a/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java +++ b/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java @@ -4,6 +4,7 @@ import com.inhabas.api.domain.club.dto.ClubHistoryDto; import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; import com.inhabas.api.domain.club.usecase.ClubHistoryService; +import com.inhabas.api.web.argumentResolver.Authenticated; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.ExampleObject; @@ -20,7 +21,7 @@ import java.net.URI; import java.util.List; -@Tag(name = "동아리 소개", description = "동아리 소개 관련 조회, 수정") +@Tag(name = "동아리 소개", description = "동아리 소개 관련") @RestController @RequiredArgsConstructor public class ClubHistoryController { @@ -48,6 +49,12 @@ public ResponseEntity> getClubHistories() { @ApiResponse(responseCode = "200", content = { @Content( schema = @Schema(implementation = ClubHistoryDto.class)) }), + @ApiResponse(responseCode = "400 ", description = "입력값이 없거나, 타입이 유효하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 400, \"code\": \"G003\", \"message\": \"입력값이 없거나, 타입이 유효하지 않습니다.\"}" + ) + )), }) @GetMapping("/club/history/{clubHistoryId}") public ResponseEntity findClubHistory(@PathVariable Long clubHistoryId) { @@ -60,7 +67,7 @@ public ResponseEntity findClubHistory(@PathVariable Long clubHis @Operation(summary = "동아리 연혁 생성", description = "동아리 연혁 생성") @ApiResponses(value = { - @ApiResponse(responseCode = "201", description = "'Location' 헤더에 생성된 리소스의 URI가 포함됩니다."), + @ApiResponse(responseCode = "201", description = "'Location' 헤더에 생성된 리소스의 URI 가 포함됩니다."), @ApiResponse(responseCode = "400 ", description = "입력값이 없거나, 타입이 유효하지 않습니다.", content = @Content( schema = @Schema(implementation = ErrorResponse.class), examples = @ExampleObject( @@ -69,9 +76,9 @@ public ResponseEntity findClubHistory(@PathVariable Long clubHis )) }) @PostMapping("/club/history") - public ResponseEntity writeClubHistories(@Valid SaveClubHistoryDto saveClubHistoryDto) { + public ResponseEntity writeClubHistories(@Authenticated Long memberId, @Valid SaveClubHistoryDto saveClubHistoryDto) { - Long newClubHistoryId = clubHistoryService.writeClubHistory(saveClubHistoryDto); + Long newClubHistoryId = clubHistoryService.writeClubHistory(memberId, saveClubHistoryDto); URI location = ServletUriComponentsBuilder.fromCurrentRequest() .path("/club/history/{clubHistoryId}") .buildAndExpand(newClubHistoryId) @@ -98,9 +105,10 @@ public ResponseEntity writeClubHistories(@Valid SaveClubHistoryD )) }) @PutMapping("/club/history/{clubHistoryId}") - public ResponseEntity updateClubHistory(@PathVariable Long clubHistoryId, @Valid SaveClubHistoryDto saveClubHistoryDto) { + public ResponseEntity updateClubHistory(@PathVariable Long clubHistoryId, @Authenticated Long memberId, + @Valid SaveClubHistoryDto saveClubHistoryDto) { - clubHistoryService.updateClubHistory(clubHistoryId, saveClubHistoryDto); + clubHistoryService.updateClubHistory(memberId, clubHistoryId, saveClubHistoryDto); return ResponseEntity.noContent().build(); } @@ -116,7 +124,7 @@ public ResponseEntity updateClubHistory(@PathVariable Long clubHistoryId, ) )) }) - @DeleteMapping ("/club/{clubHistoryId}") + @DeleteMapping ("/club/history/{clubHistoryId}") public ResponseEntity deleteClubHistory(@PathVariable Long clubHistoryId) { clubHistoryService.deleteClubHistories(clubHistoryId); From 9645fe2392f91a79c7d1ebd51bf8215be02793c4 Mon Sep 17 00:00:00 2001 From: whitemark Date: Mon, 1 Jan 2024 23:36:52 +0900 Subject: [PATCH 05/10] =?UTF-8?q?[feature/#204]=20ClubHistory=20entity,=20?= =?UTF-8?q?dto=20test=20code=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/valueObject/BoardContentTest.java | 15 ++-- .../board/domain/valueObject/TitleTest.java | 15 ++-- .../club/domain/entity/ClubHistoryTest.java | 43 +++++++++++ .../domain/club/dto/ClubHistoryDtoTest.java | 74 +++++++++++++++++++ .../club/dto/SaveClubHistoryDtoTest.java | 52 +++++++++++++ 5 files changed, 185 insertions(+), 14 deletions(-) create mode 100644 resource-server/src/test/java/com/inhabas/api/domain/club/domain/entity/ClubHistoryTest.java create mode 100644 resource-server/src/test/java/com/inhabas/api/domain/club/dto/ClubHistoryDtoTest.java create mode 100644 resource-server/src/test/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDtoTest.java diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentTest.java index 3bdcc63d..bfb0504b 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentTest.java @@ -1,10 +1,11 @@ package com.inhabas.api.domain.board.domain.valueObject; +import com.inhabas.api.auth.domain.error.businessException.InvalidInputException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.assertj.core.api.Assertions.assertThatThrownBy; public class BoardContentTest { @@ -24,21 +25,21 @@ public void Contents_is_too_long() { String contentsString = ".".repeat(16777215 + 1); // 16 MB - 1 byte //then - assertThrows(IllegalArgumentException.class, - () -> new Content(contentsString)); + assertThatThrownBy(() -> new Content(contentsString)) + .isInstanceOf(InvalidInputException.class); } @DisplayName("Content 타입에 공백을 저장할 수 없다.") @Test public void Contents_is_Empty() { - assertThrows(IllegalArgumentException.class, - () -> new Content("")); + assertThatThrownBy(() -> new Content("")) + .isInstanceOf(InvalidInputException.class); } @DisplayName("Content 타입에 null 은 허용 안된다.") @Test public void Contents_is_Null() { - assertThrows(IllegalArgumentException.class, - () -> new Content(null)); + assertThatThrownBy(() -> new Content(null)) + .isInstanceOf(InvalidInputException.class); } } diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/TitleTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/TitleTest.java index 1bd498df..787151aa 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/TitleTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/TitleTest.java @@ -1,8 +1,9 @@ package com.inhabas.api.domain.board.domain.valueObject; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import com.inhabas.api.auth.domain.error.businessException.InvalidInputException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -28,21 +29,21 @@ public void Title_is_too_long() { String titleString = "지금이문장은10자임".repeat(10); //then - assertThrows(IllegalArgumentException.class, - () -> new Title(titleString)); + assertThatThrownBy(() -> new Title(titleString)) + .isInstanceOf(InvalidInputException.class); } @DisplayName("제목은 null 일 수 없습니다.") @Test public void Title_cannot_be_Null() { - assertThrows(IllegalArgumentException.class, - () -> new Title(null)); + assertThatThrownBy(() -> new Title(null)) + .isInstanceOf(InvalidInputException.class); } @DisplayName("제목은 빈 문자열일 수 없습니다.") @Test public void Title_cannot_be_Blank() { - assertThrows(IllegalArgumentException.class, - () -> new Title("\t")); + assertThatThrownBy(() -> new Title("")) + .isInstanceOf(InvalidInputException.class); } } diff --git a/resource-server/src/test/java/com/inhabas/api/domain/club/domain/entity/ClubHistoryTest.java b/resource-server/src/test/java/com/inhabas/api/domain/club/domain/entity/ClubHistoryTest.java new file mode 100644 index 00000000..00fc690d --- /dev/null +++ b/resource-server/src/test/java/com/inhabas/api/domain/club/domain/entity/ClubHistoryTest.java @@ -0,0 +1,43 @@ +package com.inhabas.api.domain.club.domain.entity; + +import com.inhabas.api.auth.domain.oauth2.member.domain.entity.Member; +import com.inhabas.api.domain.board.domain.valueObject.Content; +import com.inhabas.api.domain.board.domain.valueObject.Title; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; +import com.inhabas.api.domain.member.domain.entity.MemberTest; +import org.junit.jupiter.api.Test; + +import java.time.LocalDateTime; + +import static org.assertj.core.api.Assertions.assertThat; + + +class ClubHistoryTest { + + @Test + void updateClubHistory() { + //given + Member writer = MemberTest.chiefMember(); + ClubHistory clubHistory = ClubHistory.builder() + .member(writer) + .title(new Title("oldTitle")) + .content(new Content("oldContent")) + .dateHistory(LocalDateTime.now()) + .build(); + SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() + .title(new Title("title")) + .content(new Content("content")) + .dateHistory(LocalDateTime.now()) + .build(); + + //when + clubHistory.updateClubHistory(writer, saveClubHistoryDto); + + //then + assertThat(clubHistory) + .extracting(ClubHistory::getTitle, ClubHistory::getContent) + .containsExactly(saveClubHistoryDto.getTitle(), saveClubHistoryDto.getContent()); + + } + +} \ No newline at end of file diff --git a/resource-server/src/test/java/com/inhabas/api/domain/club/dto/ClubHistoryDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/club/dto/ClubHistoryDtoTest.java new file mode 100644 index 00000000..836f9626 --- /dev/null +++ b/resource-server/src/test/java/com/inhabas/api/domain/club/dto/ClubHistoryDtoTest.java @@ -0,0 +1,74 @@ +package com.inhabas.api.domain.club.dto; + +import com.inhabas.api.domain.board.domain.valueObject.Content; +import com.inhabas.api.domain.board.domain.valueObject.Title; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; +import java.time.LocalDateTime; +import java.util.Set; + +class ClubHistoryDtoTest { + + private static ValidatorFactory validatorFactory; + private static Validator validator; + + @BeforeAll + public static void init() { + validatorFactory = Validation.buildDefaultValidatorFactory(); + validator = validatorFactory.getValidator(); + } + + @AfterAll + public static void close() { + validatorFactory.close(); + } + + @DisplayName("Id, writerId 가 Positive 가 아니면 validation 실패") + @Test + void Positive_Test() { + //given + ClubHistoryDto clubHistoryDto = ClubHistoryDto.builder() + .id(-1L) + .title(new Title("goodTitle")) + .content(new Content("goodContent")) + .writerId(-1L) + .dateHistory(LocalDateTime.now()) + .build(); + + //when + Set> violations = validator.validate(clubHistoryDto); + + //then + Assertions.assertThat(violations.size()).isEqualTo(2); + + } + + @DisplayName("Id, writerId, dateHistory 가 null 이면 validation 실패") + @Test + void NotNull_Test() { + //given + ClubHistoryDto clubHistoryDto = ClubHistoryDto.builder() + .id(null) + .title(new Title("goodTitle")) + .content(new Content("goodContent")) + .writerId(null) + .dateHistory(null) + .build(); + + //when + Set> violations = validator.validate(clubHistoryDto); + + //then + Assertions.assertThat(violations.size()).isEqualTo(3); + + } + +} \ No newline at end of file diff --git a/resource-server/src/test/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDtoTest.java new file mode 100644 index 00000000..2942c5c4 --- /dev/null +++ b/resource-server/src/test/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDtoTest.java @@ -0,0 +1,52 @@ +package com.inhabas.api.domain.club.dto; + +import com.inhabas.api.domain.board.domain.valueObject.Content; +import com.inhabas.api.domain.board.domain.valueObject.Title; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; +import java.util.Set; + +class SaveClubHistoryDtoTest { + + private static ValidatorFactory validatorFactory; + private static Validator validator; + + @BeforeAll + public static void init() { + validatorFactory = Validation.buildDefaultValidatorFactory(); + validator = validatorFactory.getValidator(); + } + + @AfterAll + public static void close() { + validatorFactory.close(); + } + + + @DisplayName("dateHistory 가 null 이면 validation 실패") + @Test + void NotNull_Test() { + //given + SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() + .title(new Title("goodTitle")) + .content(new Content("goodContent")) + .dateHistory(null) + .build(); + + //when + Set> violations = validator.validate(saveClubHistoryDto); + + //then + Assertions.assertThat(violations.size()).isEqualTo(1); + + } + +} \ No newline at end of file From 9cfc98125a0d7d373a79cceec1c144286a95c3e3 Mon Sep 17 00:00:00 2001 From: whitemark Date: Mon, 1 Jan 2024 23:42:16 +0900 Subject: [PATCH 06/10] =?UTF-8?q?[feature/#204]=20ClubHistory=20service=20?= =?UTF-8?q?test=20code=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/ClubHistoryServiceImplTest.java | 190 ++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 resource-server/src/test/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImplTest.java diff --git a/resource-server/src/test/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImplTest.java b/resource-server/src/test/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImplTest.java new file mode 100644 index 00000000..e46da4a5 --- /dev/null +++ b/resource-server/src/test/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImplTest.java @@ -0,0 +1,190 @@ +package com.inhabas.api.domain.club.usecase; + +import com.inhabas.api.auth.domain.error.businessException.NotFoundException; +import com.inhabas.api.auth.domain.oauth2.member.domain.entity.Member; +import com.inhabas.api.auth.domain.oauth2.member.domain.exception.MemberNotFoundException; +import com.inhabas.api.auth.domain.oauth2.member.repository.MemberRepository; +import com.inhabas.api.domain.board.domain.valueObject.Content; +import com.inhabas.api.domain.board.domain.valueObject.Title; +import com.inhabas.api.domain.club.domain.entity.ClubHistory; +import com.inhabas.api.domain.club.dto.ClubHistoryDto; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; +import com.inhabas.api.domain.club.repository.ClubHistoryRepository; +import com.inhabas.api.domain.member.domain.entity.MemberTest; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.test.util.ReflectionTestUtils; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; + +@ExtendWith(MockitoExtension.class) +public class ClubHistoryServiceImplTest { + + @InjectMocks + ClubHistoryServiceImpl clubHistoryService; + @Mock + ClubHistoryRepository clubHistoryRepository; + @Mock + MemberRepository memberRepository; + + + @DisplayName("동아리 연혁 생성 성공") + @Test + @Transactional + void writeClubHistory_Success() { + //given + Long memberId = 1L; + Member member = MemberTest.chiefMember(); // 필요한 속성으로 Member 객체 초기화 + SaveClubHistoryDto saveClubHistoryDto = new SaveClubHistoryDto( + new Title("title"), new Content("content"), LocalDateTime.now()); + + given(memberRepository.findById(memberId)).willReturn(Optional.of(member)); + given(clubHistoryRepository.save(any(ClubHistory.class))).willAnswer(invocation -> { + ClubHistory savedClubHistory = invocation.getArgument(0); + ReflectionTestUtils.setField(savedClubHistory, "id", 1L); + return savedClubHistory; + }); + + // when + Long resultId = clubHistoryService.writeClubHistory(memberId, saveClubHistoryDto); + + // then + then(memberRepository).should().findById(memberId); + then(clubHistoryRepository).should().save(any(ClubHistory.class)); + assertThat(resultId).isEqualTo(1L); + } + + @DisplayName("동아리 연혁 생성 작성자가 존재하지 않을 시 Member nof found") + @Test + void writeClubHistory_Member_Not_Found() { + //given + SaveClubHistoryDto saveClubHistoryDto = new SaveClubHistoryDto( + new Title("title"), new Content("content"), LocalDateTime.now()); + given(memberRepository.findById(any())).willReturn(Optional.empty()); + + // then + assertThatThrownBy(() -> clubHistoryService.writeClubHistory(1L, saveClubHistoryDto)) + .isInstanceOf(MemberNotFoundException.class); + + } + + @DisplayName("동아리 연혁 단일 조회 성공") + @Test + void findClubHistory_Success() { + //given + ClubHistory clubHistory = ClubHistory.builder() + .member(MemberTest.chiefMember()) + .title(new Title("title")) + .content(new Content("content")) + .dateHistory(LocalDateTime.now()) + .build(); + given(clubHistoryRepository.findById(any())).willReturn(Optional.of(clubHistory)); + + //when + ClubHistoryDto clubHistoryDto = clubHistoryService.findClubHistory(any()); + + //then + then(clubHistoryRepository).should().findById(any()); + assertThat(clubHistoryDto).extracting("title", "content") + .containsExactly(clubHistory.getTitle().getValue(), clubHistory.getContent().getValue()); + + } + + @DisplayName("동아리 연혁 단일 조회 id가 존재하지 않으면 NOT_FOUND") + @Test + void findClubHistory_Not_Found() { + //given + given(clubHistoryRepository.findById(any())).willReturn(Optional.empty()); + + //then + assertThatThrownBy(() -> clubHistoryService.findClubHistory(any())) + .isInstanceOf(NotFoundException.class); + + } + + @DisplayName("동아리 연혁 조회 성공") + @Test + void getClubHistories_Success() { + //given + ClubHistory clubHistory = ClubHistory.builder() + .member(MemberTest.chiefMember()) + .title(new Title("title")) + .content(new Content("content")) + .dateHistory(LocalDateTime.now()) + .build(); + List clubHistoryList = List.of(clubHistory); + given(clubHistoryRepository.findAll()).willReturn(clubHistoryList); + + //when + List clubHistoryDtoList = clubHistoryService.getClubHistories(); + + //then + then(clubHistoryRepository).should().findAll(); + assertThat(clubHistoryDtoList) + .hasSize(1) + .extracting("title", "content") + .contains(tuple(clubHistory.getTitle(), clubHistory.getContent())); + + } + + @DisplayName("동아리 연혁 수정 성공") + @Test + @Transactional + void updateClubHistory_Success() { + // given + Member member = MemberTest.chiefMember(); + ClubHistory clubHistory = ClubHistory.builder() + .member(member) + .title(new Title("title")) + .content(new Content("content")) + .dateHistory(LocalDateTime.now()) + .build(); + SaveClubHistoryDto saveClubHistoryDto = new SaveClubHistoryDto( + new Title("title"), new Content("content"), LocalDateTime.now()); + given(clubHistoryRepository.findById(any())).willReturn(Optional.ofNullable(clubHistory)); + given(memberRepository.findById(any())).willReturn(Optional.of(member)); + + // when + clubHistoryService.updateClubHistory(1L, 1L, saveClubHistoryDto); + + // then + then(clubHistoryRepository).should().findById(any()); + then(memberRepository).should().findById(any()); + + } + + @DisplayName("동아리 연혁 삭제 성공") + @Test + @Transactional + void deleteClubHistories_Success() { + //given + ClubHistory clubHistory = ClubHistory.builder() + .member(MemberTest.chiefMember()) + .title(new Title("title")) + .content(new Content("content")) + .dateHistory(LocalDateTime.now()) + .build(); + given(clubHistoryRepository.findById(any())).willReturn(Optional.ofNullable(clubHistory)); + + //when + clubHistoryService.deleteClubHistories(any()); + + //then + then(clubHistoryRepository).should().findById(any()); + then(clubHistoryRepository).should().delete(any()); + + } + +} \ No newline at end of file From e428b63a5a66bf02e75bbfee7e3f596ef9185af7 Mon Sep 17 00:00:00 2001 From: whitemark Date: Wed, 3 Jan 2024 10:47:26 +0900 Subject: [PATCH 07/10] =?UTF-8?q?[feature/#204]=20ClubHistory=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=EC=A0=81=EC=9D=B8=20=EC=97=90=EB=9F=AC=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/inhabas/api/config/SwaggerConfig.java | 11 + .../inhabas/api/config/WebSecurityConfig.java | 6 +- .../club/domain/entity/ClubHistory.java | 4 +- .../api/domain/club/dto/ClubHistoryDto.java | 14 +- .../domain/club/dto/SaveClubHistoryDto.java | 8 +- .../club/usecase/ClubHistoryService.java | 2 +- .../club/usecase/ClubHistoryServiceImpl.java | 8 +- .../api/web/ClubHistoryController.java | 19 +- .../club/domain/entity/ClubHistoryTest.java | 7 +- .../domain/club/dto/ClubHistoryDtoTest.java | 10 +- .../club/dto/SaveClubHistoryDtoTest.java | 6 +- .../usecase/ClubHistoryServiceImplTest.java | 10 +- .../api/web/ClubHistoryControllerTest.java | 306 ++++++++++++++++++ .../api/web/CommentControllerTest.java | 34 +- 14 files changed, 388 insertions(+), 57 deletions(-) create mode 100644 resource-server/src/test/java/com/inhabas/api/web/ClubHistoryControllerTest.java diff --git a/resource-server/src/main/java/com/inhabas/api/config/SwaggerConfig.java b/resource-server/src/main/java/com/inhabas/api/config/SwaggerConfig.java index c5b809af..6034c406 100644 --- a/resource-server/src/main/java/com/inhabas/api/config/SwaggerConfig.java +++ b/resource-server/src/main/java/com/inhabas/api/config/SwaggerConfig.java @@ -94,6 +94,17 @@ public GroupedOpenApi getMemberApi() { } + @Bean + public GroupedOpenApi getIBASApi() { + + return GroupedOpenApi + .builder() + .group("IBAS 관련") + .pathsToMatch("/club/**") + .build(); + + } + @Bean @Profile("local") public OpenAPI localOpenAPI() { diff --git a/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java b/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java index 952c3eed..dbaee3f6 100644 --- a/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java +++ b/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java @@ -45,7 +45,7 @@ public class WebSecurityConfig { private static final String[] AUTH_WHITELIST_PATH = {"/menu/**", "/menus", "/member/chief", "/error"}; private static final String[] AUTH_WHITELIST_SIGNUP = {"/signUp/schedule", "/signUp/questionnaires", "/signUp/majorInfo"}; - + private static final String[] AUTH_WHITELIST_CLUB = {"/club/histories", "/club/history/**"}; @Order(1) @EnableGlobalMethodSecurity(prePostEnabled = true, jsr250Enabled = true) @@ -71,6 +71,7 @@ public void configure(AuthenticationManagerBuilder auth) throws Exception { public void configure(WebSecurity web) throws Exception { web.ignoring() .antMatchers(HttpMethod.GET, AUTH_WHITELIST_SIGNUP) + .antMatchers(HttpMethod.GET, AUTH_WHITELIST_CLUB) .antMatchers(AUTH_WHITELIST_SWAGGER) .antMatchers(AUTH_WHITELIST_STATIC) .antMatchers(AUTH_WHITELIST_PATH); @@ -122,6 +123,9 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers("/signUp/check").hasRole(ANONYMOUS.toString()) .antMatchers("/signUp/**").hasRole(SIGNING_UP.toString()) + // 동아리 연혁 수정 + .antMatchers("/club/history/**").hasRole(EXECUTIVES.toString()) + // 그 외 .anyRequest().hasRole(ANONYMOUS.toString()); diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/domain/entity/ClubHistory.java b/resource-server/src/main/java/com/inhabas/api/domain/club/domain/entity/ClubHistory.java index f53bc435..c7113aa9 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/club/domain/entity/ClubHistory.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/domain/entity/ClubHistory.java @@ -52,8 +52,8 @@ public ClubHistory(Member member, Title title, Content content, LocalDateTime da public void updateClubHistory(Member member, SaveClubHistoryDto saveClubHistoryDto) { this.member = member; - this.title = saveClubHistoryDto.getTitle(); - this.content = saveClubHistoryDto.getContent(); + this.title = new Title(saveClubHistoryDto.getTitle()); + this.content = new Content(saveClubHistoryDto.getContent()); this.dateHistory = saveClubHistoryDto.getDateHistory(); } diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/dto/ClubHistoryDto.java b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/ClubHistoryDto.java index fe18882e..e0660267 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/club/dto/ClubHistoryDto.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/ClubHistoryDto.java @@ -1,8 +1,6 @@ package com.inhabas.api.domain.club.dto; import com.fasterxml.jackson.annotation.JsonFormat; -import com.inhabas.api.domain.board.domain.valueObject.Content; -import com.inhabas.api.domain.board.domain.valueObject.Title; import com.inhabas.api.domain.club.domain.entity.ClubHistory; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; @@ -21,9 +19,11 @@ public class ClubHistoryDto { @Positive private Long id; - private Title title; + @NotNull + private String title; - private Content content; + @NotNull + private String content; @NotNull @Positive @@ -35,7 +35,7 @@ public class ClubHistoryDto { private LocalDateTime dateHistory; @Builder - public ClubHistoryDto(Long id, Title title, Content content, Long writerId, LocalDateTime dateHistory) { + public ClubHistoryDto(Long id, String title, String content, Long writerId, LocalDateTime dateHistory) { this.id = id; this.title = title; this.content = content; @@ -45,8 +45,8 @@ public ClubHistoryDto(Long id, Title title, Content content, Long writerId, Loca public ClubHistoryDto(ClubHistory clubHistory) { this.id = clubHistory.getId(); - this.title = clubHistory.getTitle(); - this.content = clubHistory.getContent(); + this.title = clubHistory.getTitle().getValue(); + this.content = clubHistory.getContent().getValue(); this.writerId = clubHistory.getMember().getId(); this.dateHistory = clubHistory.getDateHistory(); } diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDto.java b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDto.java index 0946cc22..792d6333 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDto.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDto.java @@ -1,8 +1,6 @@ package com.inhabas.api.domain.club.dto; import com.fasterxml.jackson.annotation.JsonFormat; -import com.inhabas.api.domain.board.domain.valueObject.Content; -import com.inhabas.api.domain.board.domain.valueObject.Title; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; import lombok.Getter; @@ -15,9 +13,9 @@ @NoArgsConstructor public class SaveClubHistoryDto { - private Title title; + private String title; - private Content content; + private String content; @NotNull @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") @@ -25,7 +23,7 @@ public class SaveClubHistoryDto { private LocalDateTime dateHistory; @Builder - public SaveClubHistoryDto(Title title, Content content, LocalDateTime dateHistory) { + public SaveClubHistoryDto(String title, String content, LocalDateTime dateHistory) { this.title = title; this.content = content; this.dateHistory = dateHistory; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java index 8d42030c..4e572f19 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java @@ -15,7 +15,7 @@ public interface ClubHistoryService { void updateClubHistory(Long memberId, Long clubHistoryId, SaveClubHistoryDto saveClubHistoryDto); - void deleteClubHistories(Long clubHistoryId); + void deleteClubHistory(Long clubHistoryId); } diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java index 353f2748..7c8b390c 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java @@ -4,6 +4,8 @@ import com.inhabas.api.auth.domain.oauth2.member.domain.entity.Member; import com.inhabas.api.auth.domain.oauth2.member.domain.exception.MemberNotFoundException; import com.inhabas.api.auth.domain.oauth2.member.repository.MemberRepository; +import com.inhabas.api.domain.board.domain.valueObject.Content; +import com.inhabas.api.domain.board.domain.valueObject.Title; import com.inhabas.api.domain.club.domain.entity.ClubHistory; import com.inhabas.api.domain.club.dto.ClubHistoryDto; import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; @@ -31,8 +33,8 @@ public Long writeClubHistory(Long memberId, SaveClubHistoryDto saveClubHistoryDt Member writer = memberRepository.findById(memberId).orElseThrow(MemberNotFoundException::new); ClubHistory clubHistory = ClubHistory.builder() .member(writer) - .title(saveClubHistoryDto.getTitle()) - .content(saveClubHistoryDto.getContent()) + .title(new Title(saveClubHistoryDto.getTitle())) + .content(new Content(saveClubHistoryDto.getContent())) .dateHistory(saveClubHistoryDto.getDateHistory()) .build(); @@ -77,7 +79,7 @@ public void updateClubHistory(Long memberId, Long clubHistoryId, SaveClubHistory @Override @Transactional - public void deleteClubHistories(Long clubHistoryId) { + public void deleteClubHistory(Long clubHistoryId) { ClubHistory clubHistory = clubHistoryRepository.findById(clubHistoryId).orElseThrow(NotFoundException::new); clubHistoryRepository.delete(clubHistory); diff --git a/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java b/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java index f1dd2e93..2df13fbb 100644 --- a/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java +++ b/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java @@ -55,6 +55,12 @@ public ResponseEntity> getClubHistories() { value = "{\"status\": 400, \"code\": \"G003\", \"message\": \"입력값이 없거나, 타입이 유효하지 않습니다.\"}" ) )), + @ApiResponse(responseCode = "404", description = "데이터가 존재하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 404, \"code\": \"G004\", \"message\": \"데이터가 존재하지 않습니다.\"}" + ) + )) }) @GetMapping("/club/history/{clubHistoryId}") public ResponseEntity findClubHistory(@PathVariable Long clubHistoryId) { @@ -76,7 +82,7 @@ public ResponseEntity findClubHistory(@PathVariable Long clubHis )) }) @PostMapping("/club/history") - public ResponseEntity writeClubHistories(@Authenticated Long memberId, @Valid SaveClubHistoryDto saveClubHistoryDto) { + public ResponseEntity writeClubHistory(@Authenticated Long memberId, @Valid @RequestBody SaveClubHistoryDto saveClubHistoryDto) { Long newClubHistoryId = clubHistoryService.writeClubHistory(memberId, saveClubHistoryDto); URI location = ServletUriComponentsBuilder.fromCurrentRequest() @@ -103,10 +109,11 @@ public ResponseEntity writeClubHistories(@Authenticated Long mem value = "{\"status\": 404, \"code\": \"G004\", \"message\": \"데이터가 존재하지 않습니다.\"}" ) )) + }) @PutMapping("/club/history/{clubHistoryId}") public ResponseEntity updateClubHistory(@PathVariable Long clubHistoryId, @Authenticated Long memberId, - @Valid SaveClubHistoryDto saveClubHistoryDto) { + @Valid @RequestBody SaveClubHistoryDto saveClubHistoryDto) { clubHistoryService.updateClubHistory(memberId, clubHistoryId, saveClubHistoryDto); return ResponseEntity.noContent().build(); @@ -117,6 +124,12 @@ public ResponseEntity updateClubHistory(@PathVariable Long clubHistoryId, description = "동아리 연혁 삭제") @ApiResponses(value = { @ApiResponse(responseCode = "204"), + @ApiResponse(responseCode = "400 ", description = "입력값이 없거나, 타입이 유효하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 400, \"code\": \"G003\", \"message\": \"입력값이 없거나, 타입이 유효하지 않습니다.\"}" + ) + )), @ApiResponse(responseCode = "404", description = "데이터가 존재하지 않습니다.", content = @Content( schema = @Schema(implementation = ErrorResponse.class), examples = @ExampleObject( @@ -127,7 +140,7 @@ public ResponseEntity updateClubHistory(@PathVariable Long clubHistoryId, @DeleteMapping ("/club/history/{clubHistoryId}") public ResponseEntity deleteClubHistory(@PathVariable Long clubHistoryId) { - clubHistoryService.deleteClubHistories(clubHistoryId); + clubHistoryService.deleteClubHistory(clubHistoryId); return ResponseEntity.noContent().build(); } diff --git a/resource-server/src/test/java/com/inhabas/api/domain/club/domain/entity/ClubHistoryTest.java b/resource-server/src/test/java/com/inhabas/api/domain/club/domain/entity/ClubHistoryTest.java index 00fc690d..7af62727 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/club/domain/entity/ClubHistoryTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/club/domain/entity/ClubHistoryTest.java @@ -25,8 +25,8 @@ void updateClubHistory() { .dateHistory(LocalDateTime.now()) .build(); SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() - .title(new Title("title")) - .content(new Content("content")) + .title("title") + .content("content") .dateHistory(LocalDateTime.now()) .build(); @@ -35,7 +35,8 @@ void updateClubHistory() { //then assertThat(clubHistory) - .extracting(ClubHistory::getTitle, ClubHistory::getContent) + .extracting(ClubHistory -> clubHistory.getTitle().getValue(), + ClubHistory -> clubHistory.getContent().getValue()) .containsExactly(saveClubHistoryDto.getTitle(), saveClubHistoryDto.getContent()); } diff --git a/resource-server/src/test/java/com/inhabas/api/domain/club/dto/ClubHistoryDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/club/dto/ClubHistoryDtoTest.java index 836f9626..71946d40 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/club/dto/ClubHistoryDtoTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/club/dto/ClubHistoryDtoTest.java @@ -1,7 +1,5 @@ package com.inhabas.api.domain.club.dto; -import com.inhabas.api.domain.board.domain.valueObject.Content; -import com.inhabas.api.domain.board.domain.valueObject.Title; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -37,8 +35,8 @@ void Positive_Test() { //given ClubHistoryDto clubHistoryDto = ClubHistoryDto.builder() .id(-1L) - .title(new Title("goodTitle")) - .content(new Content("goodContent")) + .title("goodTitle") + .content("goodContent") .writerId(-1L) .dateHistory(LocalDateTime.now()) .build(); @@ -57,8 +55,8 @@ void NotNull_Test() { //given ClubHistoryDto clubHistoryDto = ClubHistoryDto.builder() .id(null) - .title(new Title("goodTitle")) - .content(new Content("goodContent")) + .title("goodTitle") + .content("goodContent") .writerId(null) .dateHistory(null) .build(); diff --git a/resource-server/src/test/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDtoTest.java index 2942c5c4..651c2d27 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDtoTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDtoTest.java @@ -1,7 +1,5 @@ package com.inhabas.api.domain.club.dto; -import com.inhabas.api.domain.board.domain.valueObject.Content; -import com.inhabas.api.domain.board.domain.valueObject.Title; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -36,8 +34,8 @@ public static void close() { void NotNull_Test() { //given SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() - .title(new Title("goodTitle")) - .content(new Content("goodContent")) + .title("goodTitle") + .content("goodContent") .dateHistory(null) .build(); diff --git a/resource-server/src/test/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImplTest.java b/resource-server/src/test/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImplTest.java index e46da4a5..65b91cf1 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImplTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImplTest.java @@ -48,7 +48,7 @@ void writeClubHistory_Success() { Long memberId = 1L; Member member = MemberTest.chiefMember(); // 필요한 속성으로 Member 객체 초기화 SaveClubHistoryDto saveClubHistoryDto = new SaveClubHistoryDto( - new Title("title"), new Content("content"), LocalDateTime.now()); + "title", "content", LocalDateTime.now()); given(memberRepository.findById(memberId)).willReturn(Optional.of(member)); given(clubHistoryRepository.save(any(ClubHistory.class))).willAnswer(invocation -> { @@ -71,7 +71,7 @@ void writeClubHistory_Success() { void writeClubHistory_Member_Not_Found() { //given SaveClubHistoryDto saveClubHistoryDto = new SaveClubHistoryDto( - new Title("title"), new Content("content"), LocalDateTime.now()); + "title", "content", LocalDateTime.now()); given(memberRepository.findById(any())).willReturn(Optional.empty()); // then @@ -135,7 +135,7 @@ void getClubHistories_Success() { assertThat(clubHistoryDtoList) .hasSize(1) .extracting("title", "content") - .contains(tuple(clubHistory.getTitle(), clubHistory.getContent())); + .contains(tuple(clubHistory.getTitle().getValue(), clubHistory.getContent().getValue())); } @@ -152,7 +152,7 @@ void updateClubHistory_Success() { .dateHistory(LocalDateTime.now()) .build(); SaveClubHistoryDto saveClubHistoryDto = new SaveClubHistoryDto( - new Title("title"), new Content("content"), LocalDateTime.now()); + "title", "content", LocalDateTime.now()); given(clubHistoryRepository.findById(any())).willReturn(Optional.ofNullable(clubHistory)); given(memberRepository.findById(any())).willReturn(Optional.of(member)); @@ -179,7 +179,7 @@ void deleteClubHistories_Success() { given(clubHistoryRepository.findById(any())).willReturn(Optional.ofNullable(clubHistory)); //when - clubHistoryService.deleteClubHistories(any()); + clubHistoryService.deleteClubHistory(any()); //then then(clubHistoryRepository).should().findById(any()); diff --git a/resource-server/src/test/java/com/inhabas/api/web/ClubHistoryControllerTest.java b/resource-server/src/test/java/com/inhabas/api/web/ClubHistoryControllerTest.java new file mode 100644 index 00000000..68bdb4fd --- /dev/null +++ b/resource-server/src/test/java/com/inhabas/api/web/ClubHistoryControllerTest.java @@ -0,0 +1,306 @@ +package com.inhabas.api.web; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.inhabas.api.auth.domain.error.businessException.InvalidInputException; +import com.inhabas.api.auth.domain.error.businessException.NotFoundException; +import com.inhabas.api.domain.club.dto.ClubHistoryDto; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; +import com.inhabas.api.domain.club.usecase.ClubHistoryService; +import com.inhabas.testAnnotataion.NoSecureWebMvcTest; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; + +import java.nio.charset.StandardCharsets; +import java.time.LocalDateTime; +import java.util.List; + +import static com.inhabas.api.auth.domain.error.ErrorCode.INVALID_INPUT_VALUE; +import static com.inhabas.api.auth.domain.error.ErrorCode.NOT_FOUND; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doThrow; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@NoSecureWebMvcTest(ClubHistoryController.class) +public class ClubHistoryControllerTest { + + @Autowired + private MockMvc mvc; + + @Autowired + private ObjectMapper objectMapper; + + @MockBean + private ClubHistoryService clubHistoryService; + + + private String jsonOf(Object response) throws JsonProcessingException { + return objectMapper.writeValueAsString(response); + } + + @DisplayName("동아리 연혁 조회 성공 200") + @Test + void getClubHistories() throws Exception { + //given + ClubHistoryDto clubHistoryDto = ClubHistoryDto.builder() + .title("title") + .content("content") + .dateHistory(LocalDateTime.now()) + .build(); + List clubHistoryList = List.of(clubHistoryDto); + given(clubHistoryService.getClubHistories()).willReturn(clubHistoryList); + + //when + String response = mvc.perform(get("/club/histories")) + .andExpect(status().isOk()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).isEqualTo(jsonOf(clubHistoryList)); + + } + + @DisplayName("동아리 연혁 단일 조회 성공 200") + @Test + void findClubHistory() throws Exception { + //given + ClubHistoryDto clubHistoryDto = ClubHistoryDto.builder() + .title("title") + .content("content") + .dateHistory(LocalDateTime.now()) + .build(); + given(clubHistoryService.findClubHistory(any())).willReturn(clubHistoryDto); + + //when + String response = mvc.perform(get("/club/history/{clubHistoryId}", 1L)) + .andExpect(status().isOk()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).isEqualTo(jsonOf(clubHistoryDto)); + + } + + @DisplayName("동아리 연혁 단일 조회 데이터가 올바르지 않다면 400") + @Test + void findClubHistory_Invalid_Input() throws Exception { + //given + ClubHistoryDto clubHistoryDto = ClubHistoryDto.builder() + .title("title") + .content("content") + .dateHistory(LocalDateTime.now()) + .build(); + given(clubHistoryService.findClubHistory(any())).willReturn(clubHistoryDto); + + //when + String response = mvc.perform(get("/club/history/{clubHistoryId}", "invalid")) + .andExpect(status().isBadRequest()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).contains(INVALID_INPUT_VALUE.getMessage()); + + } + + @DisplayName("동아리 연혁 단일 조회 해당 id가 없다면 404") + @Test + void findClubHistory_Not_Found() throws Exception { + //given + doThrow(NotFoundException.class).when(clubHistoryService).findClubHistory(any()); + + //when + String response = mvc.perform(get("/club/history/{clubHistoryId}", 1L)) + .andExpect(status().isNotFound()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).contains(NOT_FOUND.getMessage()); + + } + + @DisplayName("동아리 연혁 생성 성공 200") + @Test + void writeClubHistories() throws Exception { + //given + SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() + .title("good title") + .content("good content") + .dateHistory(LocalDateTime.parse("2023-11-01T00:00:00")) + .build(); + given(clubHistoryService.writeClubHistory(any(), any())).willReturn(1L); + + //when + String header = mvc.perform(post("/club/history") + .contentType(MediaType.APPLICATION_JSON) + .content(jsonOf(saveClubHistoryDto))) + .andExpect(status().isCreated()) + .andReturn() + .getResponse() + .getHeader("Location"); + + //then + System.out.println("header is " + header); + assertThat(header).contains("/club/history/1"); + + } + + @DisplayName("동아리 연혁 생성 데이터가 올바르지 않다면 400") + @Test + void writeClubHistories_Invalid_Input() throws Exception { + //given + SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() + .title("meaningless") + .content("meaningless") + .dateHistory(LocalDateTime.now()) + .build(); + doThrow(InvalidInputException.class).when(clubHistoryService).writeClubHistory(any(), any()); + + //when + String response = mvc.perform(post("/club/history") + .contentType(MediaType.APPLICATION_JSON) + .content(jsonOf(saveClubHistoryDto))) + .andExpect(status().isBadRequest()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).contains(INVALID_INPUT_VALUE.getMessage()); + + } + + + @DisplayName("동아리 연혁 수정 성공 204") + @Test + void updateClubHistory() throws Exception { + //given + SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() + .title("meaningless") + .content("meaningless") + .dateHistory(LocalDateTime.now()) + .build(); + doNothing().when(clubHistoryService).updateClubHistory(any(), any(), any()); + + //when then + mvc.perform(put("/club/history/{clubHistoryId}", 1) + .contentType(MediaType.APPLICATION_JSON) + .content(jsonOf(saveClubHistoryDto))) + .andExpect(status().isNoContent()); + + } + + @DisplayName("동아리 연혁 수정 데이터가 올바르지 않다면 400") + @Test + void updateClubHistory_Invalid_Input() throws Exception { + //given + SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() + .title("meaningless") + .content("meaningless") + .dateHistory(LocalDateTime.now()) + .build(); + doThrow(InvalidInputException.class).when(clubHistoryService).updateClubHistory(any(), any(), any()); + + //when + String response = mvc.perform(put("/club/history/{clubHistoryId}", 1L) + .contentType(MediaType.APPLICATION_JSON) + .content(jsonOf(saveClubHistoryDto))) + .andExpect(status().isBadRequest()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).contains(INVALID_INPUT_VALUE.getMessage()); + + } + + @DisplayName("동아리 연혁 수정 해당 id가 존재하지 않다면 404") + @Test + void updateClubHistory_Not_Found() throws Exception { + //given + SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() + .title("meaningless") + .content("meaningless") + .dateHistory(LocalDateTime.now()) + .build(); + doThrow(NotFoundException.class).when(clubHistoryService).updateClubHistory(any(), any(), any()); + + //when + String response = mvc.perform(put("/club/history/{clubHistoryId}", 1L) + .contentType(MediaType.APPLICATION_JSON) + .content(jsonOf(saveClubHistoryDto))) + .andExpect(status().isNotFound()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).contains(NOT_FOUND.getMessage()); + + } + + @DisplayName("동아리 연혁 삭제 성공 204") + @Test + void deleteClubHistory() throws Exception { + //given + doNothing().when(clubHistoryService).deleteClubHistory(any()); + + //when then + mvc.perform(delete("/club/history/{clubHistoryId}", 1L)) + .andExpect(status().isNoContent()); + + } + + @DisplayName("동아리 연혁 삭제 데이터가 올바르지 않다면 400") + @Test + void deleteClubHistory_Invalid_Input() throws Exception { + //given + doNothing().when(clubHistoryService).deleteClubHistory(any()); + + //when + String response = mvc.perform(delete("/club/history/{clubHistoryId}", "invalid")) + .andExpect(status().isBadRequest()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).contains(INVALID_INPUT_VALUE.getMessage()); + + } + + @DisplayName("동아리 연혁 삭제 해당 id가 없다면 404") + @Test + void deleteClubHistory_Not_Found() throws Exception { + //given + doThrow(NotFoundException.class).when(clubHistoryService).deleteClubHistory(any()); + + //when + String response = mvc.perform(delete("/club/history/{clubHistoryId}", 1L)) + .andExpect(status().isNotFound()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).contains(NOT_FOUND.getMessage()); + + } + +} \ No newline at end of file diff --git a/resource-server/src/test/java/com/inhabas/api/web/CommentControllerTest.java b/resource-server/src/test/java/com/inhabas/api/web/CommentControllerTest.java index 83bb72f9..f0b1fdcb 100644 --- a/resource-server/src/test/java/com/inhabas/api/web/CommentControllerTest.java +++ b/resource-server/src/test/java/com/inhabas/api/web/CommentControllerTest.java @@ -114,23 +114,23 @@ void getCommentList() throws Exception { // assertThat(responseBody).isEqualTo(String.valueOf(newReplyId)); // } - @DisplayName("500자 이상의 댓글 추가 요청은 유효성 검사 실패 후 400 반환") - @Test - void tryToSaveTooLongContents() throws Exception { - //given - String tooLongContents = "-".repeat(500); - String jsonRequest = String.format("{\"writerId\":12171652,\"content\":\"%s\",\"boardId\":13}", tooLongContents); - - //when - String errorMessage = mockMvc.perform(post("/comment") - .contentType(MediaType.APPLICATION_JSON) - .content(jsonRequest)) - .andExpect(status().isBadRequest()) - .andReturn() - .getResponse().getContentAsString(); - - assertThat(errorMessage).contains("500자 이하여야 합니다."); - } +// @DisplayName("500자 이상의 댓글 추가 요청은 유효성 검사 실패 후 400 반환") +// @Test +// void tryToSaveTooLongContents() throws Exception { +// //given +// String tooLongContents = "-".repeat(500); +// String jsonRequest = String.format("{\"writerId\":12171652,\"content\":\"%s\",\"boardId\":13}", tooLongContents); +// +// //when +// String errorMessage = mockMvc.perform(post("/comment") +// .contentType(MediaType.APPLICATION_JSON) +// .content(jsonRequest)) +// .andExpect(status().isBadRequest()) +// .andReturn() +// .getResponse().getContentAsString(); +// +// assertThat(errorMessage).contains("500자 이하여야 합니다."); +// } // @DisplayName("정상적인 댓글 수정 요청") // @Test From bbad31f9a4708a8d5256f8076cf64636c30b4297 Mon Sep 17 00:00:00 2001 From: whitemark Date: Wed, 3 Jan 2024 11:47:19 +0900 Subject: [PATCH 08/10] =?UTF-8?q?[feature/#204]=20github=20actions=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gradle-build.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml index 24f5166d..89d4cca2 100644 --- a/.github/workflows/gradle-build.yml +++ b/.github/workflows/gradle-build.yml @@ -18,13 +18,12 @@ jobs: uses: actions/setup-java@v1 with: java-version: '11' - + - name: Grant execute permission for gradlew run: chmod +x gradlew + - name: Build with Gradle - uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021 - with: - arguments: build + run: ./gradlew clean build env: IBAS_DEV_JWT_SECRET_KEY: ${{ secrets.IBAS_DEV_JWT_SECRET_KEY }} IBAS_DEV_KAKAO_CLIENT_ID: ${{ secrets.IBAS_DEV_KAKAO_CLIENT_ID }} From b0584c790330618a9c2a800215902c9c3d415212 Mon Sep 17 00:00:00 2001 From: whitemark Date: Thu, 4 Jan 2024 22:37:11 +0900 Subject: [PATCH 09/10] =?UTF-8?q?[feature/#204]=20review=20=EB=B0=98?= =?UTF-8?q?=EC=98=81=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../board/domain/valueObject/BoardContentTest.java | 9 ++++++--- .../domain/board/domain/valueObject/TitleTest.java | 9 ++++++--- .../api/domain/club/dto/ClubHistoryDtoTest.java | 7 ++++--- .../club/usecase/ClubHistoryServiceImplTest.java | 13 +++++++++---- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentTest.java index bfb0504b..9ba14e1b 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentTest.java @@ -26,20 +26,23 @@ public void Contents_is_too_long() { //then assertThatThrownBy(() -> new Content(contentsString)) - .isInstanceOf(InvalidInputException.class); + .isInstanceOf(InvalidInputException.class) + .hasMessage("입력값이 없거나, 타입이 유효하지 않습니다."); } @DisplayName("Content 타입에 공백을 저장할 수 없다.") @Test public void Contents_is_Empty() { assertThatThrownBy(() -> new Content("")) - .isInstanceOf(InvalidInputException.class); + .isInstanceOf(InvalidInputException.class) + .hasMessage("입력값이 없거나, 타입이 유효하지 않습니다."); } @DisplayName("Content 타입에 null 은 허용 안된다.") @Test public void Contents_is_Null() { assertThatThrownBy(() -> new Content(null)) - .isInstanceOf(InvalidInputException.class); + .isInstanceOf(InvalidInputException.class) + .hasMessage("입력값이 없거나, 타입이 유효하지 않습니다."); } } diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/TitleTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/TitleTest.java index 787151aa..f8ed47d8 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/TitleTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/TitleTest.java @@ -30,20 +30,23 @@ public void Title_is_too_long() { //then assertThatThrownBy(() -> new Title(titleString)) - .isInstanceOf(InvalidInputException.class); + .isInstanceOf(InvalidInputException.class) + .hasMessage("입력값이 없거나, 타입이 유효하지 않습니다."); } @DisplayName("제목은 null 일 수 없습니다.") @Test public void Title_cannot_be_Null() { assertThatThrownBy(() -> new Title(null)) - .isInstanceOf(InvalidInputException.class); + .isInstanceOf(InvalidInputException.class) + .hasMessage("입력값이 없거나, 타입이 유효하지 않습니다."); } @DisplayName("제목은 빈 문자열일 수 없습니다.") @Test public void Title_cannot_be_Blank() { assertThatThrownBy(() -> new Title("")) - .isInstanceOf(InvalidInputException.class); + .isInstanceOf(InvalidInputException.class) + .hasMessage("입력값이 없거나, 타입이 유효하지 않습니다."); } } diff --git a/resource-server/src/test/java/com/inhabas/api/domain/club/dto/ClubHistoryDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/club/dto/ClubHistoryDtoTest.java index 71946d40..7c6155d6 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/club/dto/ClubHistoryDtoTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/club/dto/ClubHistoryDtoTest.java @@ -1,6 +1,5 @@ package com.inhabas.api.domain.club.dto; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; @@ -13,6 +12,8 @@ import java.time.LocalDateTime; import java.util.Set; +import static org.assertj.core.api.Assertions.assertThat; + class ClubHistoryDtoTest { private static ValidatorFactory validatorFactory; @@ -45,7 +46,7 @@ void Positive_Test() { Set> violations = validator.validate(clubHistoryDto); //then - Assertions.assertThat(violations.size()).isEqualTo(2); + assertThat(violations).hasSize(2); } @@ -65,7 +66,7 @@ void NotNull_Test() { Set> violations = validator.validate(clubHistoryDto); //then - Assertions.assertThat(violations.size()).isEqualTo(3); + assertThat(violations).hasSize(3); } diff --git a/resource-server/src/test/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImplTest.java b/resource-server/src/test/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImplTest.java index 65b91cf1..49ee9b42 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImplTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImplTest.java @@ -24,7 +24,9 @@ import java.util.List; import java.util.Optional; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.Assertions.tuple; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.then; @@ -76,7 +78,8 @@ void writeClubHistory_Member_Not_Found() { // then assertThatThrownBy(() -> clubHistoryService.writeClubHistory(1L, saveClubHistoryDto)) - .isInstanceOf(MemberNotFoundException.class); + .isInstanceOf(MemberNotFoundException.class) + .hasMessage("존재 하지 않는 유저입니다."); } @@ -97,7 +100,8 @@ void findClubHistory_Success() { //then then(clubHistoryRepository).should().findById(any()); - assertThat(clubHistoryDto).extracting("title", "content") + assertThat(clubHistoryDto).as("clubHistoryDto's title and content are equal to clubHistory") + .extracting("title", "content") .containsExactly(clubHistory.getTitle().getValue(), clubHistory.getContent().getValue()); } @@ -110,7 +114,8 @@ void findClubHistory_Not_Found() { //then assertThatThrownBy(() -> clubHistoryService.findClubHistory(any())) - .isInstanceOf(NotFoundException.class); + .isInstanceOf(NotFoundException.class) + .hasMessage("데이터가 존재하지 않습니다."); } From 6a07898931599bc31d0c8e7b164b0256bd1a33ac Mon Sep 17 00:00:00 2001 From: whitemark Date: Fri, 5 Jan 2024 17:17:13 +0900 Subject: [PATCH 10/10] =?UTF-8?q?[feature/#204]=20github=20actions=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gradle-build.yml | 40 ++++++++++++++++-------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml index 89d4cca2..49145a20 100644 --- a/.github/workflows/gradle-build.yml +++ b/.github/workflows/gradle-build.yml @@ -1,34 +1,36 @@ name: Gradle Build on: - pull_request: - branches: [dev, master, feature/*, refactor/* ] + pull_request_target: + types: [ opened, reopened, synchronize ] + jobs: build: runs-on: ubuntu-latest environment: build_gradle + permissions: contents: read packages: write steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: '11' + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: '11' - - name: Grant execute permission for gradlew - run: chmod +x gradlew + - name: Grant execute permission for gradlew + run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew clean build - env: - IBAS_DEV_JWT_SECRET_KEY: ${{ secrets.IBAS_DEV_JWT_SECRET_KEY }} - IBAS_DEV_KAKAO_CLIENT_ID: ${{ secrets.IBAS_DEV_KAKAO_CLIENT_ID }} - IBAS_DEV_KAKAO_CLIENT_SECRET: ${{ secrets.IBAS_DEV_KAKAO_CLIENT_SECRET }} - IBAS_DEV_NAVER_CLIENT_ID: ${{ secrets.IBAS_DEV_NAVER_CLIENT_ID }} - IBAS_DEV_NAVER_CLIENT_SECRET: ${{ secrets.IBAS_DEV_NAVER_CLIENT_SECRET }} - IBAS_DEV_GOOGLE_CLIENT_ID: ${{ secrets.IBAS_DEV_GOOGLE_CLIENT_ID }} - IBAS_DEV_GOOGLE_CLIENT_SECRET: ${{ secrets.IBAS_DEV_GOOGLE_CLIENT_SECRET }} + - name: Build with Gradle + run: ./gradlew clean build + env: + IBAS_DEV_JWT_SECRET_KEY: ${{ secrets.IBAS_DEV_JWT_SECRET_KEY }} + IBAS_DEV_KAKAO_CLIENT_ID: ${{ secrets.IBAS_DEV_KAKAO_CLIENT_ID }} + IBAS_DEV_KAKAO_CLIENT_SECRET: ${{ secrets.IBAS_DEV_KAKAO_CLIENT_SECRET }} + IBAS_DEV_NAVER_CLIENT_ID: ${{ secrets.IBAS_DEV_NAVER_CLIENT_ID }} + IBAS_DEV_NAVER_CLIENT_SECRET: ${{ secrets.IBAS_DEV_NAVER_CLIENT_SECRET }} + IBAS_DEV_GOOGLE_CLIENT_ID: ${{ secrets.IBAS_DEV_GOOGLE_CLIENT_ID }} + IBAS_DEV_GOOGLE_CLIENT_SECRET: ${{ secrets.IBAS_DEV_GOOGLE_CLIENT_SECRET }}