Skip to content

Commit

Permalink
Merge pull request #83 from Travel-in-nanaland/feat/#47-ci-cd
Browse files Browse the repository at this point in the history
[#47] feat: test 코드 member -> memberInfoDto로 변경
  • Loading branch information
Te-H0 authored Apr 24, 2024
2 parents 2ead457 + eda2264 commit c1123a0
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,6 +35,7 @@ class ExperienceServiceTest {

Language language;
Member member1, member2;
MemberInfoDto memberInfoDto1, memberInfoDto2;
Experience experience;
Category category;

Expand Down Expand Up @@ -67,6 +69,11 @@ void init() {
.build();
em.persist(member1);

memberInfoDto1 = MemberInfoDto.builder()
.language(language)
.member(member1)
.build();

member2 = Member.builder()
.email("[email protected]")
.provider(Provider.KAKAO)
Expand All @@ -77,6 +84,11 @@ void init() {
.build();
em.persist(member2);

memberInfoDto2 = MemberInfoDto.builder()
.language(language)
.member(member2)
.build();

experience = Experience.builder()
.imageFile(imageFile1)
.build();
Expand All @@ -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());

/**
Expand All @@ -127,7 +139,7 @@ void toggleLikeStatusFailedWithNoSuchPostIdTest() {
*
* toggleLikeStatus 요청 시 BadRequestException 발생
*/
Assertions.assertThatThrownBy(() -> experienceService.toggleLikeStatus(member1, postId))
Assertions.assertThatThrownBy(() -> experienceService.toggleLikeStatus(memberInfoDto1, postId))
.isInstanceOf(BadRequestException.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,6 +35,7 @@ class FestivalServiceTest {

Language language;
Member member1, member2;
MemberInfoDto memberInfoDto1, memberInfoDto2;
Festival festival;
Category category;

Expand Down Expand Up @@ -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();
Expand All @@ -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());

/**
Expand All @@ -127,7 +139,7 @@ void toggleLikeStatusFailedWithNoSuchPostIdTest() {
*
* toggleLikeStatus 요청 시 BadRequestException 발생
*/
Assertions.assertThatThrownBy(() -> festivalService.toggleLikeStatus(member1, postId))
Assertions.assertThatThrownBy(() -> festivalService.toggleLikeStatus(memberInfoDto1, postId))
.isInstanceOf(BadRequestException.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,6 +35,8 @@ class MarketServiceTest {

Language language;
Member member1, member2;
MemberInfoDto memberInfoDto1, memberInfoDto2;

Market market;
Category category;

Expand Down Expand Up @@ -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();
Expand All @@ -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());

/**
Expand All @@ -127,7 +140,7 @@ void toggleLikeStatusFailedWithNoSuchPostIdTest() {
*
* toggleLikeStatus 요청 시 BadRequestException 발생
*/
Assertions.assertThatThrownBy(() -> marketService.toggleLikeStatus(member1, postId))
Assertions.assertThatThrownBy(() -> marketService.toggleLikeStatus(memberInfoDto1, postId))
.isInstanceOf(BadRequestException.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,6 +35,7 @@ class NanaServiceTest {

Language language;
Member member1, member2;
MemberInfoDto memberInfoDto1, memberInfoDto2;
Nana nana;
Category category;

Expand Down Expand Up @@ -67,6 +69,11 @@ void init() {
.build();
em.persist(member1);

memberInfoDto1 = MemberInfoDto.builder()
.language(language)
.member(member1)
.build();

member2 = Member.builder()
.email("[email protected]")
.provider(Provider.KAKAO)
Expand All @@ -77,6 +84,11 @@ void init() {
.build();
em.persist(member2);

memberInfoDto2 = MemberInfoDto.builder()
.language(language)
.member(member2)
.build();

nana = Nana.builder()
.version("version1")
.build();
Expand All @@ -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());

/**
Expand All @@ -127,7 +139,7 @@ void toggleLikeStatusFailedWithNoSuchPostIdTest() {
*
* toggleLikeStatus 요청 시 BadRequestException 발생
*/
Assertions.assertThatThrownBy(() -> nanaService.toggleLikeStatus(member1, postId))
Assertions.assertThatThrownBy(() -> nanaService.toggleLikeStatus(memberInfoDto1, postId))
.isInstanceOf(BadRequestException.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,6 +35,8 @@ class NatureServiceTest {

Language language;
Member member1, member2;

MemberInfoDto memberInfoDto1, memberInfoDto2;
Nature nature;
Category category;

Expand Down Expand Up @@ -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();
Expand All @@ -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());

/**
Expand All @@ -127,7 +140,7 @@ void toggleLikeStatusFailedWithNoSuchPostIdTest() {
*
* toggleLikeStatus 요청 시 BadRequestException 발생
*/
Assertions.assertThatThrownBy(() -> natureService.toggleLikeStatus(member1, postId))
Assertions.assertThatThrownBy(() -> natureService.toggleLikeStatus(memberInfoDto1, postId))
.isInstanceOf(BadRequestException.class);
}
}

0 comments on commit c1123a0

Please sign in to comment.