From b0584c790330618a9c2a800215902c9c3d415212 Mon Sep 17 00:00:00 2001 From: whitemark Date: Thu, 4 Jan 2024 22:37:11 +0900 Subject: [PATCH] =?UTF-8?q?[feature/#204]=20review=20=EB=B0=98=EC=98=81=20?= =?UTF-8?q?=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("데이터가 존재하지 않습니다."); }