Skip to content

Commit

Permalink
test: Category 도메인 테스트 검증 방식 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
apptie committed Sep 28, 2023
1 parent 3c37831 commit 0c831b3
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
import org.junit.jupiter.api.Test;
import org.springframework.test.util.ReflectionTestUtils;

@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class)
@SuppressWarnings("NonAsciiCharacters")
Expand All @@ -12,16 +13,20 @@ class CategoryTest {
@Test
void 카테고리_연관_관계를_세팅한다() {
// given
Category main = new Category("main");
Category sub = new Category("sub");
final Category main = new Category("main");
final Category sub = new Category("sub");

ReflectionTestUtils.setField(main, "id", 1L);
ReflectionTestUtils.setField(sub, "id", 2L);

// when
main.addSubCategory(sub);

// then
SoftAssertions.assertSoftly(softAssertions -> {
softAssertions.assertThat(main.getSubCategories()).hasSize(1);
softAssertions.assertThat(sub.getMainCategory()).isNotNull();
softAssertions.assertThat(main.getSubCategories()).contains(sub);
softAssertions.assertThat(sub.getMainCategory()).isEqualTo(main);
});
}
}

0 comments on commit 0c831b3

Please sign in to comment.