use of com.battlelancer.seriesguide.ui.movies.MovieDetails 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));
}
use of com.battlelancer.seriesguide.ui.movies.MovieDetails in project SeriesGuide by UweTrottmann.
the class TmdbSyncTest method insertMovie.
private void insertMovie(int tmdbId, long releaseDateMs, Long lastUpdatedMs) {
Movie movie = new Movie();
movie.id = tmdbId;
movie.release_date = new Date(releaseDateMs);
MovieDetails details = new MovieDetails();
details.setInCollection(true);
details.setInWatchlist(true);
details.tmdbMovie(movie);
ContentValues values = details.toContentValuesInsert();
if (lastUpdatedMs == null) {
values.remove(Movies.LAST_UPDATED);
} else {
values.put(Movies.LAST_UPDATED, lastUpdatedMs);
}
resolver.insert(Movies.CONTENT_URI, values);
}
use of com.battlelancer.seriesguide.ui.movies.MovieDetails in project SeriesGuide by UweTrottmann.
the class MigrationTest method getTestMovieDetails.
private static MovieDetails getTestMovieDetails(@Nullable Integer tmdbId) {
MovieDetails movieDetails = new MovieDetails();
Movie tmdbMovie = new Movie();
if (tmdbId != null) {
tmdbMovie.id = tmdbId;
} else {
tmdbMovie.id = 12;
}
movieDetails.tmdbMovie(tmdbMovie);
return movieDetails;
}
Aggregations