Skip to content

Commit

Permalink
[feature/InhaBas#204] review 반영 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
whitem4rk committed Jan 4, 2024
1 parent bbad31f commit b0584c7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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("입력값이 없거나, 타입이 유효하지 않습니다.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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("입력값이 없거나, 타입이 유효하지 않습니다.");
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -45,7 +46,7 @@ void Positive_Test() {
Set<ConstraintViolation<ClubHistoryDto>> violations = validator.validate(clubHistoryDto);

//then
Assertions.assertThat(violations.size()).isEqualTo(2);
assertThat(violations).hasSize(2);

}

Expand All @@ -65,7 +66,7 @@ void NotNull_Test() {
Set<ConstraintViolation<ClubHistoryDto>> violations = validator.validate(clubHistoryDto);

//then
Assertions.assertThat(violations.size()).isEqualTo(3);
assertThat(violations).hasSize(3);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -76,7 +78,8 @@ void writeClubHistory_Member_Not_Found() {

// then
assertThatThrownBy(() -> clubHistoryService.writeClubHistory(1L, saveClubHistoryDto))
.isInstanceOf(MemberNotFoundException.class);
.isInstanceOf(MemberNotFoundException.class)
.hasMessage("존재 하지 않는 유저입니다.");

}

Expand All @@ -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());

}
Expand All @@ -110,7 +114,8 @@ void findClubHistory_Not_Found() {

//then
assertThatThrownBy(() -> clubHistoryService.findClubHistory(any()))
.isInstanceOf(NotFoundException.class);
.isInstanceOf(NotFoundException.class)
.hasMessage("데이터가 존재하지 않습니다.");

}

Expand Down

0 comments on commit b0584c7

Please sign in to comment.