-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…page-test [Feat] #231 mypage 반환 테스트해요
- Loading branch information
Showing
4 changed files
with
128 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -762,4 +762,4 @@ | |
|
||
## 📱 사용 예시 | ||
|
||
> 실제 유저 사용 페이지 흐름 보여주기 ( 영상 x ) | ||
> 실제 유저 사용 페이지 흐름 보여주기 ( 영상 x ) |
58 changes: 58 additions & 0 deletions
58
src/test/java/team7/inplace/favoriteInfluencer/FavoriteInfluencerServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package team7.inplace.favoriteInfluencer; | ||
|
||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.BDDMockito.given; | ||
import static org.mockito.Mockito.verify; | ||
|
||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageImpl; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Pageable; | ||
import team7.inplace.favoriteInfluencer.application.FavoriteInfluencerService; | ||
import team7.inplace.favoriteInfluencer.domain.FavoriteInfluencer; | ||
import team7.inplace.favoriteInfluencer.persistent.FavoriteInfluencerRepository; | ||
import team7.inplace.influencer.application.dto.InfluencerInfo; | ||
import team7.inplace.influencer.domain.Influencer; | ||
import team7.inplace.user.domain.Role; | ||
import team7.inplace.user.domain.User; | ||
import team7.inplace.user.domain.UserType; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class FavoriteInfluencerServiceTest { | ||
|
||
@Mock | ||
private FavoriteInfluencerRepository favoriteRepository; | ||
|
||
@InjectMocks | ||
private FavoriteInfluencerService favoriteInfluencerService; | ||
|
||
@Test | ||
void getFavoriteInfluencers() { | ||
Pageable pageable = PageRequest.of(0, 10); | ||
Long userId = 1L; | ||
User user = new User("name", "password", "nickname", UserType.KAKAO, Role.USER); | ||
Influencer influencer1 = new Influencer("influencer1", "imgUrl1", "job1"); | ||
FavoriteInfluencer favoriteInfluencer1 = new FavoriteInfluencer(user, influencer1); | ||
favoriteInfluencer1.updateLike(true); | ||
Page<FavoriteInfluencer> favoriteInfluencersPage = new PageImpl<>( | ||
List.of(favoriteInfluencer1)); | ||
|
||
given(favoriteRepository.findByUserIdAndIsLikedTrue(userId, pageable)) | ||
.willReturn(favoriteInfluencersPage); | ||
|
||
Page<InfluencerInfo> result = favoriteInfluencerService.getFavoriteInfluencers(userId, | ||
pageable); | ||
|
||
verify(favoriteRepository).findByUserIdAndIsLikedTrue(userId, pageable); | ||
assertThat(result.getContent().get(0)).isInstanceOf(InfluencerInfo.class); | ||
assertThat(result.getContent().get(0).influencerName()).isEqualTo(influencer1.getName()); | ||
assertThat(result.getContent().get(0).likes()).isEqualTo(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters