|
4 | 4 | import static org.assertj.core.api.Assertions.assertThatCode; |
5 | 5 | import static org.junit.jupiter.api.Assertions.assertThrows; |
6 | 6 |
|
| 7 | +import eatda.domain.ImageKey; |
| 8 | +import eatda.domain.member.Member; |
| 9 | +import eatda.domain.store.District; |
| 10 | +import eatda.domain.store.Store; |
| 11 | +import eatda.domain.store.StoreCategory; |
7 | 12 | import eatda.exception.BusinessErrorCode; |
8 | 13 | import eatda.exception.BusinessException; |
9 | 14 | import java.util.Collections; |
10 | 15 | import java.util.List; |
11 | 16 | import org.junit.jupiter.api.Nested; |
12 | 17 | import org.junit.jupiter.api.Test; |
13 | 18 |
|
14 | | -class CheerTagNamesTest { |
| 19 | +class CheerTagsTest { |
| 20 | + |
| 21 | + private static final Member DEFAULT_MEMBER = new Member( "socialId", "[email protected]", "nickname"); |
| 22 | + private static final Store DEFAULT_STORE = Store.builder() |
| 23 | + .kakaoId("123456789") |
| 24 | + .category(StoreCategory.OTHER) |
| 25 | + .phoneNumber("010-1234-5678") |
| 26 | + .name("가게 이름") |
| 27 | + .placeUrl("https://place.kakao.com/123456789") |
| 28 | + .roadAddress("") |
| 29 | + .lotNumberAddress("서울특별시 강남구 역삼동 123-45") |
| 30 | + .district(District.GANGNAM) |
| 31 | + .latitude(37.5665) |
| 32 | + .longitude(126.978) |
| 33 | + .build(); |
| 34 | + private static final Cheer DEFAULT_CHEER = new Cheer(DEFAULT_MEMBER, DEFAULT_STORE, "Great store!", |
| 35 | + new ImageKey("imageKey")); |
15 | 36 |
|
16 | 37 | @Nested |
17 | | - class Validate { |
| 38 | + class SetTags { |
18 | 39 |
|
19 | 40 | @Test |
20 | 41 | void 각_카테고리별_태그는_최대_개수가_정해져있다() { |
21 | 42 | List<CheerTagName> tagNames = List.of( |
22 | 43 | CheerTagName.OLD_STORE_MOOD, CheerTagName.ENERGETIC, |
23 | 44 | CheerTagName.GROUP_RESERVATION, CheerTagName.LARGE_PARKING); |
| 45 | + CheerTags cheerTags = new CheerTags(); |
24 | 46 |
|
25 | | - assertThatCode(() -> new CheerTagNames(tagNames)).doesNotThrowAnyException(); |
| 47 | + assertThatCode(() -> cheerTags.setTags(DEFAULT_CHEER, tagNames)).doesNotThrowAnyException(); |
26 | 48 | } |
27 | 49 |
|
28 | 50 | @Test |
29 | 51 | void 태그_이름은_비어있을_수_있다() { |
30 | 52 | List<CheerTagName> tagNames = Collections.emptyList(); |
| 53 | + CheerTags cheerTags = new CheerTags(); |
31 | 54 |
|
32 | | - assertThatCode(() -> new CheerTagNames(tagNames)).doesNotThrowAnyException(); |
| 55 | + assertThatCode(() -> cheerTags.setTags(DEFAULT_CHEER, tagNames)).doesNotThrowAnyException(); |
33 | 56 | } |
34 | 57 |
|
35 | 58 | @Test |
36 | 59 | void 카테고리별_태그는_최대_개수를_초과할_수_없다() { |
37 | 60 | List<CheerTagName> tagNames = List.of( |
38 | 61 | CheerTagName.OLD_STORE_MOOD, CheerTagName.ENERGETIC, CheerTagName.GOOD_FOR_DATING); |
| 62 | + CheerTags cheerTags = new CheerTags(); |
39 | 63 |
|
40 | | - BusinessException exception = assertThrows(BusinessException.class, () -> new CheerTagNames(tagNames)); |
| 64 | + BusinessException exception = assertThrows(BusinessException.class, |
| 65 | + () -> cheerTags.setTags(DEFAULT_CHEER, tagNames)); |
41 | 66 |
|
42 | 67 | assertThat(exception.getErrorCode()).isEqualTo(BusinessErrorCode.EXCEED_CHEER_TAGS_PER_TYPE); |
43 | 68 | } |
44 | 69 |
|
45 | 70 | @Test |
46 | 71 | void 태그_이름은_중복될_수_없다() { |
47 | 72 | List<CheerTagName> tagNames = List.of(CheerTagName.OLD_STORE_MOOD, CheerTagName.OLD_STORE_MOOD); |
| 73 | + CheerTags cheerTags = new CheerTags(); |
48 | 74 |
|
49 | | - BusinessException exception = assertThrows(BusinessException.class, () -> new CheerTagNames(tagNames)); |
| 75 | + BusinessException exception = assertThrows(BusinessException.class, |
| 76 | + () -> cheerTags.setTags(DEFAULT_CHEER, tagNames)); |
50 | 77 |
|
51 | 78 | assertThat(exception.getErrorCode()).isEqualTo(BusinessErrorCode.CHEER_TAGS_DUPLICATED); |
52 | 79 | } |
53 | 80 | } |
| 81 | + |
54 | 82 | } |
0 commit comments