Search in sources :

Example 1 with MovieDetails

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));
}
Also used : SupportSQLiteDatabase(androidx.sqlite.db.SupportSQLiteDatabase) TestEpisode(com.battlelancer.seriesguide.provider.RoomDatabaseTestHelper.TestEpisode) MovieDetails(com.battlelancer.seriesguide.ui.movies.MovieDetails) Test(org.junit.Test)

Example 2 with MovieDetails

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);
}
Also used : ContentValues(android.content.ContentValues) Movie(com.uwetrottmann.tmdb2.entities.Movie) SgMovie(com.battlelancer.seriesguide.model.SgMovie) Date(java.util.Date) MovieDetails(com.battlelancer.seriesguide.ui.movies.MovieDetails)

Example 3 with MovieDetails

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;
}
Also used : Movie(com.uwetrottmann.tmdb2.entities.Movie) MovieDetails(com.battlelancer.seriesguide.ui.movies.MovieDetails)

Aggregations

MovieDetails (com.battlelancer.seriesguide.ui.movies.MovieDetails)3 Movie (com.uwetrottmann.tmdb2.entities.Movie)2 ContentValues (android.content.ContentValues)1 SupportSQLiteDatabase (androidx.sqlite.db.SupportSQLiteDatabase)1 SgMovie (com.battlelancer.seriesguide.model.SgMovie)1 TestEpisode (com.battlelancer.seriesguide.provider.RoomDatabaseTestHelper.TestEpisode)1 Date (java.util.Date)1 Test (org.junit.Test)1