From eda22647f4cf377f7145618e9ec06b9407e23a42 Mon Sep 17 00:00:00 2001 From: teho Date: Wed, 24 Apr 2024 21:47:38 +0900 Subject: [PATCH] =?UTF-8?q?[#47]=20feat:=20test=20=EC=BD=94=EB=93=9C=20mem?= =?UTF-8?q?ber=20->=20memberInfoDto=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ExperienceServiceTest.java | 20 ++++++++++++++---- .../festival/service/FestivalServiceTest.java | 20 ++++++++++++++---- .../market/service/MarketServiceTest.java | 21 +++++++++++++++---- .../domain/nana/service/NanaServiceTest.java | 20 ++++++++++++++---- .../nature/service/NatureServiceTest.java | 21 +++++++++++++++---- 5 files changed, 82 insertions(+), 20 deletions(-) diff --git a/src/test/java/com/jeju/nanaland/domain/experience/service/ExperienceServiceTest.java b/src/test/java/com/jeju/nanaland/domain/experience/service/ExperienceServiceTest.java index 9515ea9a..144c6153 100644 --- a/src/test/java/com/jeju/nanaland/domain/experience/service/ExperienceServiceTest.java +++ b/src/test/java/com/jeju/nanaland/domain/experience/service/ExperienceServiceTest.java @@ -10,6 +10,7 @@ import com.jeju.nanaland.domain.experience.entity.Experience; import com.jeju.nanaland.domain.favorite.dto.FavoriteResponse; import com.jeju.nanaland.domain.favorite.repository.FavoriteRepository; +import com.jeju.nanaland.domain.member.dto.MemberResponse.MemberInfoDto; import com.jeju.nanaland.domain.member.entity.Member; import com.jeju.nanaland.domain.member.entity.Provider; import com.jeju.nanaland.global.exception.BadRequestException; @@ -34,6 +35,7 @@ class ExperienceServiceTest { Language language; Member member1, member2; + MemberInfoDto memberInfoDto1, memberInfoDto2; Experience experience; Category category; @@ -67,6 +69,11 @@ void init() { .build(); em.persist(member1); + memberInfoDto1 = MemberInfoDto.builder() + .language(language) + .member(member1) + .build(); + member2 = Member.builder() .email("test2@naver.com") .provider(Provider.KAKAO) @@ -77,6 +84,11 @@ void init() { .build(); em.persist(member2); + memberInfoDto2 = MemberInfoDto.builder() + .language(language) + .member(member2) + .build(); + experience = Experience.builder() .imageFile(imageFile1) .build(); @@ -96,11 +108,11 @@ void toggleLikeStatusTest() { * member1 : toggleLikeStatus 2번 적용 * member2 : toggleLikeStatus 1번 적용 */ - experienceService.toggleLikeStatus(member1, experience.getId()); - FavoriteResponse.StatusDto result1 = experienceService.toggleLikeStatus(member1, + experienceService.toggleLikeStatus(memberInfoDto1, experience.getId()); + FavoriteResponse.StatusDto result1 = experienceService.toggleLikeStatus(memberInfoDto1, experience.getId()); - FavoriteResponse.StatusDto result2 = experienceService.toggleLikeStatus(member2, + FavoriteResponse.StatusDto result2 = experienceService.toggleLikeStatus(memberInfoDto2, experience.getId()); /** @@ -127,7 +139,7 @@ void toggleLikeStatusFailedWithNoSuchPostIdTest() { * * toggleLikeStatus 요청 시 BadRequestException 발생 */ - Assertions.assertThatThrownBy(() -> experienceService.toggleLikeStatus(member1, postId)) + Assertions.assertThatThrownBy(() -> experienceService.toggleLikeStatus(memberInfoDto1, postId)) .isInstanceOf(BadRequestException.class); } } \ No newline at end of file diff --git a/src/test/java/com/jeju/nanaland/domain/festival/service/FestivalServiceTest.java b/src/test/java/com/jeju/nanaland/domain/festival/service/FestivalServiceTest.java index 6116ebba..77afe164 100644 --- a/src/test/java/com/jeju/nanaland/domain/festival/service/FestivalServiceTest.java +++ b/src/test/java/com/jeju/nanaland/domain/festival/service/FestivalServiceTest.java @@ -10,6 +10,7 @@ import com.jeju.nanaland.domain.favorite.dto.FavoriteResponse; import com.jeju.nanaland.domain.favorite.repository.FavoriteRepository; import com.jeju.nanaland.domain.festival.entity.Festival; +import com.jeju.nanaland.domain.member.dto.MemberResponse.MemberInfoDto; import com.jeju.nanaland.domain.member.entity.Member; import com.jeju.nanaland.domain.member.entity.Provider; import com.jeju.nanaland.global.exception.BadRequestException; @@ -34,6 +35,7 @@ class FestivalServiceTest { Language language; Member member1, member2; + MemberInfoDto memberInfoDto1, memberInfoDto2; Festival festival; Category category; @@ -77,6 +79,16 @@ void init() { .build(); em.persist(member2); + memberInfoDto1 = MemberInfoDto.builder() + .language(language) + .member(member1) + .build(); + + memberInfoDto2 = MemberInfoDto.builder() + .language(language) + .member(member2) + .build(); + festival = Festival.builder() .imageFile(imageFile1) .build(); @@ -96,11 +108,11 @@ void toggleLikeStatusTest() { * member1 : toggleLikeStatus 2번 적용 * member2 : toggleLikeStatus 1번 적용 */ - festivalService.toggleLikeStatus(member1, festival.getId()); - FavoriteResponse.StatusDto result1 = festivalService.toggleLikeStatus(member1, + festivalService.toggleLikeStatus(memberInfoDto1, festival.getId()); + FavoriteResponse.StatusDto result1 = festivalService.toggleLikeStatus(memberInfoDto1, festival.getId()); - FavoriteResponse.StatusDto result2 = festivalService.toggleLikeStatus(member2, + FavoriteResponse.StatusDto result2 = festivalService.toggleLikeStatus(memberInfoDto2, festival.getId()); /** @@ -127,7 +139,7 @@ void toggleLikeStatusFailedWithNoSuchPostIdTest() { * * toggleLikeStatus 요청 시 BadRequestException 발생 */ - Assertions.assertThatThrownBy(() -> festivalService.toggleLikeStatus(member1, postId)) + Assertions.assertThatThrownBy(() -> festivalService.toggleLikeStatus(memberInfoDto1, postId)) .isInstanceOf(BadRequestException.class); } } \ No newline at end of file diff --git a/src/test/java/com/jeju/nanaland/domain/market/service/MarketServiceTest.java b/src/test/java/com/jeju/nanaland/domain/market/service/MarketServiceTest.java index 3ce39389..8ce0251f 100644 --- a/src/test/java/com/jeju/nanaland/domain/market/service/MarketServiceTest.java +++ b/src/test/java/com/jeju/nanaland/domain/market/service/MarketServiceTest.java @@ -10,6 +10,7 @@ import com.jeju.nanaland.domain.favorite.dto.FavoriteResponse; import com.jeju.nanaland.domain.favorite.repository.FavoriteRepository; import com.jeju.nanaland.domain.market.entity.Market; +import com.jeju.nanaland.domain.member.dto.MemberResponse.MemberInfoDto; import com.jeju.nanaland.domain.member.entity.Member; import com.jeju.nanaland.domain.member.entity.Provider; import com.jeju.nanaland.global.exception.BadRequestException; @@ -34,6 +35,8 @@ class MarketServiceTest { Language language; Member member1, member2; + MemberInfoDto memberInfoDto1, memberInfoDto2; + Market market; Category category; @@ -77,6 +80,16 @@ void init() { .build(); em.persist(member2); + memberInfoDto1 = MemberInfoDto.builder() + .language(language) + .member(member1) + .build(); + + memberInfoDto2 = MemberInfoDto.builder() + .language(language) + .member(member2) + .build(); + market = Market.builder() .imageFile(imageFile1) .build(); @@ -96,11 +109,11 @@ void toggleLikeStatusTest() { * member1 : toggleLikeStatus 2번 적용 * member2 : toggleLikeStatus 1번 적용 */ - marketService.toggleLikeStatus(member1, market.getId()); - FavoriteResponse.StatusDto result1 = marketService.toggleLikeStatus(member1, + marketService.toggleLikeStatus(memberInfoDto1, market.getId()); + FavoriteResponse.StatusDto result1 = marketService.toggleLikeStatus(memberInfoDto1, market.getId()); - FavoriteResponse.StatusDto result2 = marketService.toggleLikeStatus(member2, + FavoriteResponse.StatusDto result2 = marketService.toggleLikeStatus(memberInfoDto2, market.getId()); /** @@ -127,7 +140,7 @@ void toggleLikeStatusFailedWithNoSuchPostIdTest() { * * toggleLikeStatus 요청 시 BadRequestException 발생 */ - Assertions.assertThatThrownBy(() -> marketService.toggleLikeStatus(member1, postId)) + Assertions.assertThatThrownBy(() -> marketService.toggleLikeStatus(memberInfoDto1, postId)) .isInstanceOf(BadRequestException.class); } } \ No newline at end of file diff --git a/src/test/java/com/jeju/nanaland/domain/nana/service/NanaServiceTest.java b/src/test/java/com/jeju/nanaland/domain/nana/service/NanaServiceTest.java index b230f9ab..388e40fe 100644 --- a/src/test/java/com/jeju/nanaland/domain/nana/service/NanaServiceTest.java +++ b/src/test/java/com/jeju/nanaland/domain/nana/service/NanaServiceTest.java @@ -9,6 +9,7 @@ import com.jeju.nanaland.domain.common.entity.Locale; import com.jeju.nanaland.domain.favorite.dto.FavoriteResponse; import com.jeju.nanaland.domain.favorite.repository.FavoriteRepository; +import com.jeju.nanaland.domain.member.dto.MemberResponse.MemberInfoDto; import com.jeju.nanaland.domain.member.entity.Member; import com.jeju.nanaland.domain.member.entity.Provider; import com.jeju.nanaland.domain.nana.entity.Nana; @@ -34,6 +35,7 @@ class NanaServiceTest { Language language; Member member1, member2; + MemberInfoDto memberInfoDto1, memberInfoDto2; Nana nana; Category category; @@ -67,6 +69,11 @@ void init() { .build(); em.persist(member1); + memberInfoDto1 = MemberInfoDto.builder() + .language(language) + .member(member1) + .build(); + member2 = Member.builder() .email("test2@naver.com") .provider(Provider.KAKAO) @@ -77,6 +84,11 @@ void init() { .build(); em.persist(member2); + memberInfoDto2 = MemberInfoDto.builder() + .language(language) + .member(member2) + .build(); + nana = Nana.builder() .version("version1") .build(); @@ -96,11 +108,11 @@ void toggleLikeStatusTest() { * member1 : toggleLikeStatus 2번 적용 * member2 : toggleLikeStatus 1번 적용 */ - nanaService.toggleLikeStatus(member1, nana.getId()); - FavoriteResponse.StatusDto result1 = nanaService.toggleLikeStatus(member1, + nanaService.toggleLikeStatus(memberInfoDto1, nana.getId()); + FavoriteResponse.StatusDto result1 = nanaService.toggleLikeStatus(memberInfoDto1, nana.getId()); - FavoriteResponse.StatusDto result2 = nanaService.toggleLikeStatus(member2, + FavoriteResponse.StatusDto result2 = nanaService.toggleLikeStatus(memberInfoDto2, nana.getId()); /** @@ -127,7 +139,7 @@ void toggleLikeStatusFailedWithNoSuchPostIdTest() { * * toggleLikeStatus 요청 시 BadRequestException 발생 */ - Assertions.assertThatThrownBy(() -> nanaService.toggleLikeStatus(member1, postId)) + Assertions.assertThatThrownBy(() -> nanaService.toggleLikeStatus(memberInfoDto1, postId)) .isInstanceOf(BadRequestException.class); } } \ No newline at end of file diff --git a/src/test/java/com/jeju/nanaland/domain/nature/service/NatureServiceTest.java b/src/test/java/com/jeju/nanaland/domain/nature/service/NatureServiceTest.java index 579b72d6..d8088676 100644 --- a/src/test/java/com/jeju/nanaland/domain/nature/service/NatureServiceTest.java +++ b/src/test/java/com/jeju/nanaland/domain/nature/service/NatureServiceTest.java @@ -9,6 +9,7 @@ import com.jeju.nanaland.domain.common.entity.Locale; import com.jeju.nanaland.domain.favorite.dto.FavoriteResponse; import com.jeju.nanaland.domain.favorite.repository.FavoriteRepository; +import com.jeju.nanaland.domain.member.dto.MemberResponse.MemberInfoDto; import com.jeju.nanaland.domain.member.entity.Member; import com.jeju.nanaland.domain.member.entity.Provider; import com.jeju.nanaland.domain.nature.entity.Nature; @@ -34,6 +35,8 @@ class NatureServiceTest { Language language; Member member1, member2; + + MemberInfoDto memberInfoDto1, memberInfoDto2; Nature nature; Category category; @@ -77,6 +80,16 @@ void init() { .build(); em.persist(member2); + memberInfoDto1 = MemberInfoDto.builder() + .language(language) + .member(member1) + .build(); + + memberInfoDto2 = MemberInfoDto.builder() + .language(language) + .member(member2) + .build(); + nature = Nature.builder() .imageFile(imageFile1) .build(); @@ -96,11 +109,11 @@ void toggleLikeStatusTest() { * member1 : toggleLikeStatus 2번 적용 * member2 : toggleLikeStatus 1번 적용 */ - natureService.toggleLikeStatus(member1, nature.getId()); - FavoriteResponse.StatusDto result1 = natureService.toggleLikeStatus(member1, + natureService.toggleLikeStatus(memberInfoDto1, nature.getId()); + FavoriteResponse.StatusDto result1 = natureService.toggleLikeStatus(memberInfoDto1, nature.getId()); - FavoriteResponse.StatusDto result2 = natureService.toggleLikeStatus(member2, + FavoriteResponse.StatusDto result2 = natureService.toggleLikeStatus(memberInfoDto2, nature.getId()); /** @@ -127,7 +140,7 @@ void toggleLikeStatusFailedWithNoSuchPostIdTest() { * * toggleLikeStatus 요청 시 BadRequestException 발생 */ - Assertions.assertThatThrownBy(() -> natureService.toggleLikeStatus(member1, postId)) + Assertions.assertThatThrownBy(() -> natureService.toggleLikeStatus(memberInfoDto1, postId)) .isInstanceOf(BadRequestException.class); } } \ No newline at end of file