From 1f61cf09b7c95377956bb8215871b4bc0624305d Mon Sep 17 00:00:00 2001 From: devholic22 Date: Thu, 22 Feb 2024 19:50:48 +0900 Subject: [PATCH] =?UTF-8?q?test:=20StyleName=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - StyleName 테스트 작성 --- .../domain/info/style/StyleNameTest.java | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/test/java/com/atwoz/member/domain/info/style/StyleNameTest.java diff --git a/src/test/java/com/atwoz/member/domain/info/style/StyleNameTest.java b/src/test/java/com/atwoz/member/domain/info/style/StyleNameTest.java new file mode 100644 index 00000000..69ef552f --- /dev/null +++ b/src/test/java/com/atwoz/member/domain/info/style/StyleNameTest.java @@ -0,0 +1,73 @@ +package com.atwoz.member.domain.info.style; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + +import com.atwoz.member.exception.exceptions.info.style.StyleDuplicateException; +import com.atwoz.member.exception.exceptions.info.style.StyleNotFoundException; +import com.atwoz.member.exception.exceptions.info.style.StyleSizeException; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Test; +import java.util.List; + +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +@SuppressWarnings("NonAsciiCharacters") +public class StyleNameTest { + + @Test + void 스타일이_존재하면_정상적으로_가져온다() { + // given + List styleNames = List.of("패션 센스", "다정다감", "유머 감각"); + List expectedStyleNames = List.of(StyleName.FASHION, StyleName.FRIENDLY, StyleName.FUNNY); + + // when + List findStyleNames = StyleName.findAllByNames(styleNames); + + // then + assertSoftly(softly -> { + softly.assertThat(findStyleNames.size()).isEqualTo(styleNames.size()); + softly.assertThat(findStyleNames).containsAll(expectedStyleNames); + }); + } + + @Test + void 스타일_갯수가_초과되면_예외가_발생한다() { + // given + List styleNames = List.of("패션 센스", "다정다감", "유머 감각", "좋은 비율"); + + // when & then + assertThatThrownBy(() -> StyleName.findAllByNames(styleNames)) + .isInstanceOf(StyleSizeException.class); + } + + @Test + void 아예_선택하지_않으면_예외가_발생한다() { + // given + List styleNames = List.of(); + + // when & then + assertThatThrownBy(() -> StyleName.findAllByNames(styleNames)) + .isInstanceOf(StyleSizeException.class); + } + + @Test + void 없는_스타일을_선택하면_예외가_발생한다() { + // given + List styleNames = List.of("hello"); + + // when & then + assertThatThrownBy(() -> StyleName.findAllByNames(styleNames)) + .isInstanceOf(StyleNotFoundException.class); + } + + @Test + void 중복_선택하면_예외가_발생한다() { + // given + List styleNames = List.of("패션 센스", "패션 센스"); + + // when & then + assertThatThrownBy(() -> StyleName.findAllByNames(styleNames)) + .isInstanceOf(StyleDuplicateException.class); + } +}