fix(content): 固定预览集查询顺序

This commit is contained in:
Zhou Weidong committed 2026-10-21 16:03:06 +08:00
1 parent 7ae05698fa
commit 3303a91e3c
2 files changed
+15 -9

No files matched your search

@@ -15,6 +15,7 @@ import com.fruitshorts.media.service.PlaybackSigner;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -56,12 +57,15 @@ class AppCatalogServiceTest {
drama.setLikeCount(3200L);
drama.setFavoriteCount(1800L);
drama.setViewCount(12400L);
DramaEpisode episode = episode(11L, 42L, 55L);
DramaEpisode firstEpisode = episode(11L, 42L, 55L);
DramaEpisode secondEpisode = episode(22L, 42L, 66L);
given(dramaService.getPublished(42L)).willReturn(drama);
given(episodeService.listPublishedByDrama(42L)).willReturn(List.of(episode));
given(episodeService.listPublishedByDrama(42L))
.willReturn(List.of(secondEpisode, firstEpisode));
given(dramaCategoryService.listBasic()).willReturn(List.of());
given(commentService.countByDrama(42L)).willReturn(96L);
given(commentService.countByEpisodes(List.of(11L))).willReturn(Map.of(11L, 2L));
given(commentService.countByEpisodes(List.of(11L, 22L)))
.willReturn(Map.of(11L, 2L, 22L, 4L));
AppDramaDetailVO detail = catalogService.dramaDetail(42L);
@@ -69,8 +73,8 @@ class AppCatalogServiceTest {
assertThat(detail.getLikeCount()).isEqualTo(3200L);
assertThat(detail.getFavoriteCount()).isEqualTo(1800L);
assertThat(detail.getCommentCount()).isEqualTo(96L);
assertThat(detail.getEpisodes().get(0).getLikeCount()).isEqualTo(55L);
assertThat(detail.getEpisodes().get(0).getCommentCount()).isEqualTo(2L);
assertThat(detail.getEpisodes().get(0).getLikeCount()).isEqualTo(66L);
assertThat(detail.getEpisodes().get(0).getCommentCount()).isEqualTo(4L);
verify(commentService).countByDrama(42L);
}
@@ -90,8 +94,10 @@ class AppCatalogServiceTest {
second.setFavoriteCount(80L);
DramaEpisode firstEpisode = episode(11L, 1L, 320L);
DramaEpisode secondEpisode = episode(22L, 2L, 120L);
given(episodeService.firstPlayableByDramas(List.of(1L, 2L)))
.willReturn(Map.of(1L, firstEpisode, 2L, secondEpisode));
Map<Long, DramaEpisode> previews = new LinkedHashMap<>();
previews.put(2L, secondEpisode);
previews.put(1L, firstEpisode);
given(episodeService.firstPlayableByDramas(List.of(1L, 2L))).willReturn(previews);
given(dramaCategoryService.listBasic()).willReturn(List.of());
given(commentService.countByEpisodes(List.of(11L, 22L)))
.willReturn(Map.of(11L, 9L));