fix(playback): 恢复已删除的观看进度
This commit is contained in:
1 parent
5a80e6693f
commit
9c25b1b397
4 files changed
+111
-20
No files matched your search
+26
@@ -15,6 +15,7 @@ import com.fruitshorts.playback.dal.entity.WatchProgress;
|
||||
import com.fruitshorts.playback.dal.mapper.WatchHistoryMapper;
|
||||
import com.fruitshorts.playback.dal.mapper.WatchProgressMapper;
|
||||
import com.fruitshorts.playback.vo.ProgressRespVO;
|
||||
import com.fruitshorts.playback.vo.ProgressSaveReqVO;
|
||||
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -28,6 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@@ -108,6 +110,30 @@ class WatchProgressServiceTest {
|
||||
return progress;
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_revive_deleted_progress_when_same_drama_is_reported_again() {
|
||||
DramaEpisode episode = episode(88L, 1);
|
||||
episode.setDramaId(5L);
|
||||
given(episodeService.getPublished(88L)).willReturn(episode);
|
||||
given(dramaService.getPublished(5L)).willReturn(drama(5L, "剧名", 10));
|
||||
WatchProgress hidden = progress(5L, 88L);
|
||||
hidden.setId(9L);
|
||||
hidden.setUserId(7L);
|
||||
hidden.setDeleted(1);
|
||||
given(progressMapper.selectAny(7L, 5L)).willReturn(hidden);
|
||||
given(progressMapper.selectById(9L)).willReturn(hidden);
|
||||
ProgressSaveReqVO req = new ProgressSaveReqVO();
|
||||
req.setEpisodeId(88L);
|
||||
req.setPositionMs(1_000L);
|
||||
req.setDurationMs(2_000L);
|
||||
|
||||
progressService.save(7L, req);
|
||||
|
||||
verify(progressMapper, never()).insert(any(WatchProgress.class));
|
||||
verify(progressMapper).updateAny(hidden);
|
||||
assertThat(hidden.getDeleted()).isZero();
|
||||
}
|
||||
|
||||
private Drama drama(Long id, String title, int totalEpisodes) {
|
||||
Drama drama = new Drama();
|
||||
drama.setId(id);
|
||||
|
||||
Reference in new issue
Block a user