feat(content-banner): 오디오 콘텐츠 배너를 언어별로 등록하고 노출한다
This commit is contained in:
@@ -0,0 +1,314 @@
|
||||
package kr.co.vividnext.sodalive.api.home
|
||||
|
||||
import kr.co.vividnext.sodalive.audition.AuditionService
|
||||
import kr.co.vividnext.sodalive.chat.character.service.ChatCharacterService
|
||||
import kr.co.vividnext.sodalive.content.AudioContentService
|
||||
import kr.co.vividnext.sodalive.content.ContentType
|
||||
import kr.co.vividnext.sodalive.content.SortType
|
||||
import kr.co.vividnext.sodalive.content.main.banner.AudioContentBannerService
|
||||
import kr.co.vividnext.sodalive.content.series.ContentSeriesService
|
||||
import kr.co.vividnext.sodalive.content.theme.AudioContentThemeService
|
||||
import kr.co.vividnext.sodalive.creator.admin.content.series.SeriesPublishedDaysOfWeek
|
||||
import kr.co.vividnext.sodalive.explorer.ExplorerQueryRepository
|
||||
import kr.co.vividnext.sodalive.i18n.Lang
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.live.room.LiveRoomService
|
||||
import kr.co.vividnext.sodalive.live.room.LiveRoomStatus
|
||||
import kr.co.vividnext.sodalive.query.recommend.RecommendChannelQueryService
|
||||
import kr.co.vividnext.sodalive.rank.ContentRankingSortType
|
||||
import kr.co.vividnext.sodalive.rank.RankingRepository
|
||||
import kr.co.vividnext.sodalive.rank.RankingService
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.Mockito
|
||||
import org.springframework.data.domain.Pageable
|
||||
import java.time.DayOfWeek
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
|
||||
class HomeServiceTest {
|
||||
private lateinit var liveRoomService: LiveRoomService
|
||||
private lateinit var auditionService: AuditionService
|
||||
private lateinit var seriesService: ContentSeriesService
|
||||
private lateinit var contentService: AudioContentService
|
||||
private lateinit var bannerService: AudioContentBannerService
|
||||
private lateinit var contentThemeService: AudioContentThemeService
|
||||
private lateinit var recommendChannelService: RecommendChannelQueryService
|
||||
private lateinit var characterService: ChatCharacterService
|
||||
private lateinit var rankingService: RankingService
|
||||
private lateinit var rankingRepository: RankingRepository
|
||||
private lateinit var explorerQueryRepository: ExplorerQueryRepository
|
||||
private lateinit var service: HomeService
|
||||
private val timezone = "Asia/Seoul"
|
||||
|
||||
@BeforeEach
|
||||
fun setUp() {
|
||||
liveRoomService = Mockito.mock(LiveRoomService::class.java)
|
||||
auditionService = Mockito.mock(AuditionService::class.java)
|
||||
seriesService = Mockito.mock(ContentSeriesService::class.java)
|
||||
contentService = Mockito.mock(AudioContentService::class.java)
|
||||
bannerService = Mockito.mock(AudioContentBannerService::class.java)
|
||||
contentThemeService = Mockito.mock(AudioContentThemeService::class.java)
|
||||
recommendChannelService = Mockito.mock(RecommendChannelQueryService::class.java)
|
||||
characterService = Mockito.mock(ChatCharacterService::class.java)
|
||||
rankingService = Mockito.mock(RankingService::class.java)
|
||||
rankingRepository = Mockito.mock(RankingRepository::class.java)
|
||||
explorerQueryRepository = Mockito.mock(ExplorerQueryRepository::class.java)
|
||||
service = HomeService(
|
||||
liveRoomService = liveRoomService,
|
||||
auditionService = auditionService,
|
||||
seriesService = seriesService,
|
||||
contentService = contentService,
|
||||
bannerService = bannerService,
|
||||
contentThemeService = contentThemeService,
|
||||
recommendChannelService = recommendChannelService,
|
||||
characterService = characterService,
|
||||
rankingService = rankingService,
|
||||
rankingRepository = rankingRepository,
|
||||
explorerQueryRepository = explorerQueryRepository,
|
||||
langContext = LangContext().apply { setLang(Lang.JA) },
|
||||
memberContentPreferenceService = Mockito.mock(
|
||||
kr.co.vividnext.sodalive.member.contentpreference.MemberContentPreferenceService::class.java
|
||||
),
|
||||
imageHost = "https://cdn.test"
|
||||
)
|
||||
|
||||
val systemTime = LocalDateTime.now()
|
||||
val zonedDateTime = systemTime
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.withZoneSameInstant(ZoneId.of(timezone))
|
||||
val expectedDayOfWeek = when (zonedDateTime.dayOfWeek) {
|
||||
DayOfWeek.MONDAY -> SeriesPublishedDaysOfWeek.MON
|
||||
DayOfWeek.TUESDAY -> SeriesPublishedDaysOfWeek.TUE
|
||||
DayOfWeek.WEDNESDAY -> SeriesPublishedDaysOfWeek.WED
|
||||
DayOfWeek.THURSDAY -> SeriesPublishedDaysOfWeek.THU
|
||||
DayOfWeek.FRIDAY -> SeriesPublishedDaysOfWeek.FRI
|
||||
DayOfWeek.SATURDAY -> SeriesPublishedDaysOfWeek.SAT
|
||||
DayOfWeek.SUNDAY -> SeriesPublishedDaysOfWeek.SUN
|
||||
null -> SeriesPublishedDaysOfWeek.RANDOM
|
||||
}
|
||||
val currentDateTime = LocalDateTime.now()
|
||||
val rankingStartDate = currentDateTime
|
||||
.withHour(15)
|
||||
.withMinute(0)
|
||||
.withSecond(0)
|
||||
.minusWeeks(1)
|
||||
.with(java.time.temporal.TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
|
||||
val rankingEndDate = rankingStartDate.plusDays(6)
|
||||
|
||||
Mockito.doReturn(emptyList<Any>()).`when`(liveRoomService)
|
||||
.getRoomList(null, LiveRoomStatus.NOW, Pageable.ofSize(10), null, timezone)
|
||||
Mockito.`when`(rankingRepository.getCreatorRankings(null)).thenReturn(emptyList())
|
||||
Mockito.`when`(
|
||||
contentThemeService.getActiveThemeOfContent(
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
ContentType.ALL,
|
||||
listOf("다시듣기")
|
||||
)
|
||||
).thenReturn(emptyList())
|
||||
Mockito.`when`(
|
||||
contentThemeService.getActiveThemeOfContent(
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
ContentType.ALL,
|
||||
emptyList()
|
||||
)
|
||||
).thenReturn(emptyList())
|
||||
Mockito.`when`(
|
||||
contentService.getLatestContentByTheme(
|
||||
null,
|
||||
emptyList(),
|
||||
ContentType.ALL,
|
||||
0,
|
||||
20,
|
||||
SortType.NEWEST,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
emptyList()
|
||||
)
|
||||
)
|
||||
.thenReturn(emptyList())
|
||||
Mockito.`when`(
|
||||
contentService.getLatestContentByTheme(
|
||||
null,
|
||||
emptyList(),
|
||||
ContentType.ALL,
|
||||
0,
|
||||
50,
|
||||
SortType.NEWEST,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
emptyList()
|
||||
)
|
||||
)
|
||||
.thenReturn(emptyList())
|
||||
Mockito.`when`(
|
||||
contentService.getLatestContentByTheme(
|
||||
null,
|
||||
emptyList(),
|
||||
ContentType.ALL,
|
||||
50,
|
||||
100,
|
||||
SortType.NEWEST,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
emptyList()
|
||||
)
|
||||
)
|
||||
.thenReturn(emptyList())
|
||||
Mockito.`when`(
|
||||
contentService.getLatestContentByTheme(
|
||||
null,
|
||||
emptyList(),
|
||||
ContentType.ALL,
|
||||
150,
|
||||
150,
|
||||
SortType.NEWEST,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
emptyList()
|
||||
)
|
||||
)
|
||||
.thenReturn(emptyList())
|
||||
Mockito.`when`(
|
||||
contentService.getLatestContentByTheme(
|
||||
null,
|
||||
emptyList(),
|
||||
ContentType.ALL,
|
||||
0,
|
||||
50,
|
||||
SortType.NEWEST,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
emptyList()
|
||||
)
|
||||
)
|
||||
.thenReturn(emptyList())
|
||||
Mockito.`when`(
|
||||
contentService.getLatestContentByTheme(
|
||||
null,
|
||||
emptyList(),
|
||||
ContentType.ALL,
|
||||
50,
|
||||
100,
|
||||
SortType.NEWEST,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
emptyList()
|
||||
)
|
||||
)
|
||||
.thenReturn(emptyList())
|
||||
Mockito.`when`(
|
||||
contentService.getLatestContentByTheme(
|
||||
null,
|
||||
emptyList(),
|
||||
ContentType.ALL,
|
||||
150,
|
||||
150,
|
||||
SortType.NEWEST,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
emptyList()
|
||||
)
|
||||
)
|
||||
.thenReturn(emptyList())
|
||||
Mockito.`when`(
|
||||
contentService.getLatestContentByTheme(
|
||||
null,
|
||||
emptyList(),
|
||||
ContentType.ALL,
|
||||
0,
|
||||
50,
|
||||
SortType.NEWEST,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
emptyList()
|
||||
)
|
||||
)
|
||||
.thenReturn(emptyList())
|
||||
Mockito.`when`(
|
||||
contentService.getLatestContentByTheme(
|
||||
null,
|
||||
emptyList(),
|
||||
ContentType.ALL,
|
||||
50,
|
||||
100,
|
||||
SortType.NEWEST,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
emptyList()
|
||||
)
|
||||
)
|
||||
.thenReturn(emptyList())
|
||||
Mockito.`when`(
|
||||
contentService.getLatestContentByTheme(
|
||||
null,
|
||||
emptyList(),
|
||||
ContentType.ALL,
|
||||
150,
|
||||
150,
|
||||
SortType.NEWEST,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
emptyList()
|
||||
)
|
||||
)
|
||||
.thenReturn(emptyList())
|
||||
Mockito.`when`(bannerService.getBannerList(1L, null, false, Lang.JA)).thenReturn(emptyList())
|
||||
Mockito.`when`(
|
||||
seriesService.getOriginalAudioDramaList(null, false, ContentType.ALL, 0, 20)
|
||||
).thenReturn(emptyList())
|
||||
Mockito.`when`(auditionService.getInProgressAuditionList(false)).thenReturn(emptyList())
|
||||
Mockito.`when`(
|
||||
seriesService.getDayOfWeekSeriesList(null, false, ContentType.ALL, expectedDayOfWeek, 0, 10)
|
||||
).thenReturn(emptyList())
|
||||
Mockito.`when`(characterService.getPopularCharacters("ja", 20)).thenReturn(emptyList())
|
||||
Mockito.`when`(
|
||||
rankingService.getContentRanking(
|
||||
null,
|
||||
false,
|
||||
ContentType.ALL,
|
||||
rankingStartDate.minusDays(1),
|
||||
rankingEndDate,
|
||||
0,
|
||||
12,
|
||||
ContentRankingSortType.REVENUE,
|
||||
""
|
||||
)
|
||||
)
|
||||
.thenReturn(emptyList())
|
||||
Mockito.`when`(recommendChannelService.getRecommendChannel(null, false, ContentType.ALL)).thenReturn(emptyList())
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("홈 fetchData는 현재 요청 언어를 배너 조회에 전달한다")
|
||||
fun shouldPassCurrentLangToBannerServiceWhenFetchingHome() {
|
||||
service.fetchData(timezone = timezone, member = null)
|
||||
|
||||
Mockito.verify(bannerService).getBannerList(1L, null, false, Lang.JA)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user