use of com.battlelancer.seriesguide.provider.RoomDatabaseTestHelper.TestEpisode in project SeriesGuide by UweTrottmann.
the class MigrationTest method migrationFrom47To48_containsCorrectData.
@Test
public void migrationFrom47To48_containsCorrectData() throws IOException {
int v47 = SgRoomDatabase.VERSION_47_SERIES_POSTER_THUMB;
SupportSQLiteDatabase db = migrationTestHelper.createDatabase(TEST_DB_NAME, v47);
RoomDatabaseTestHelper.insertShow(SHOW, db);
RoomDatabaseTestHelper.insertSeason(SEASON, db);
TestEpisode testEpisode = getTestEpisode(21);
RoomDatabaseTestHelper.insertEpisode(db, testEpisode, SHOW.getTvdbId(), SEASON.getTvdbId(), SEASON.getNumber(), true);
testEpisode = getTestEpisode(22);
RoomDatabaseTestHelper.insertEpisode(db, testEpisode, SHOW.getTvdbId(), SEASON.getTvdbId(), SEASON.getNumber(), false);
MovieDetails testMovieDetails = getTestMovieDetails(12);
testMovieDetails.setWatched(true);
RoomDatabaseTestHelper.insertMovie(db, testMovieDetails);
testMovieDetails = getTestMovieDetails(13);
testMovieDetails.setWatched(false);
RoomDatabaseTestHelper.insertMovie(db, testMovieDetails);
db.close();
db = getMigratedDatabase(SgRoomDatabase.VERSION_48_EPISODE_PLAYS);
assertTestData_series_seasons_episodes(db);
// Watched episode should have 1 play.
queryAndAssert(db, "SELECT plays FROM episodes WHERE _id=21", episodeWatched -> assertThat(episodeWatched.getInt(0)).isEqualTo(1));
queryAndAssert(db, "SELECT plays FROM episodes WHERE _id=22", episodeNotWatched -> assertThat(episodeNotWatched.getInt(0)).isEqualTo(0));
// Watched movie should have 1 play.
queryAndAssert(db, "SELECT movies_plays FROM movies WHERE movies_tmdbid=12", movieWatched -> assertThat(movieWatched.getInt(0)).isEqualTo(1));
queryAndAssert(db, "SELECT movies_plays FROM movies WHERE movies_tmdbid=13", movieNotWatched -> assertThat(movieNotWatched.getInt(0)).isEqualTo(0));
}
Aggregations