Skip to content

Commit

Permalink
[refactor/Inhabas#165] 테스트 코드 리펙토링- domain.budget
Browse files Browse the repository at this point in the history
  • Loading branch information
skytin1004 committed Jan 19, 2024
1 parent 9a0aa0b commit 0d7956b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spotless {
// 모든 Java 소스 파일에 포맷팅 규칙 적용
target("**/*.java")
// google 자바 포맷 적용
googleJavaFormat()

// 불필요한 임포트 제거
removeUnusedImports()
// 마지막줄 New Line 처리
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.inhabas.api.domain.budget.valueObject;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import com.inhabas.api.domain.budget.domain.valueObject.ApplicantAccount;

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;

public class ApplicantAccountTest {

@DisplayName("Account 타입에 문자열을 저장한다.")
Expand All @@ -29,21 +30,24 @@ public void tooLongApplicantAccountTest() {
String accountString = "지금이문장은10자임".repeat(10);

//then
assertThrows(IllegalArgumentException.class,
() -> new ApplicantAccount(accountString));
assertThatThrownBy(() -> new ApplicantAccount(accountString))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage(null);
}

@DisplayName("계좌정보는 null 일 수 없습니다.")
@Test
public void applicantAccountCannotBeNull() {
assertThrows(IllegalArgumentException.class,
() -> new ApplicantAccount(null));
assertThatThrownBy(() -> new ApplicantAccount(null))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage(null);
}

@DisplayName("계좌정보는 빈 문자열일 수 없습니다.")
@Test
public void applicantAccountCannotBeNullBlank() {
assertThrows(IllegalArgumentException.class,
() -> new ApplicantAccount("\t"));
assertThatThrownBy(() -> new ApplicantAccount("\t"))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage(null);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.inhabas.api.domain.budget.valueObject;

import com.inhabas.api.domain.budget.domain.valueObject.Details;
import com.inhabas.api.domain.budget.domain.valueObject.RejectReason;
import org.assertj.core.api.Assertions;
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;

public class DetailTest {

Expand All @@ -29,21 +30,26 @@ public void tooLongDetailsTest() {
String detailsString = "지금이문장은10자임".repeat(30);

//then
assertThrows(IllegalArgumentException.class,
() -> new Details(detailsString));
Assertions.assertThatThrownBy(() -> new Details(detailsString))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage(null);
}

@DisplayName("예산 내역 제목은 null 일 수 없습니다.")
@Test
public void detailsCannotBeNullTest() {
assertThrows(IllegalArgumentException.class,
() -> new Details(null));

Assertions.assertThatThrownBy(() -> new Details(null))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage(null);
}

@DisplayName("예산 상세내역 은 빈 문자열일 수 없습니다.")
@Test
public void detailsCannotBeBlankTest() {
assertThrows(IllegalArgumentException.class,
() -> new Details("\t"));

Assertions.assertThatThrownBy(() -> new Details("\t"))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage(null);
}
}

0 comments on commit 0d7956b

Please sign in to comment.