app/src/androidTest/java/com/example/android/popularmoviesapp/data/TestDb.java
private long insertMovieEntry() {

        // GIVEN
        final SQLiteDatabase db = new MovieDbHelper(mContext).getWritableDatabase();

        final ContentValues contentValues = TestUtilities.createMovieValues();

        // WHEN
        final long movieRowId = db.insert(MovieEntry.TABLE_NAME, null, contentValues);
        assertTrue(movieRowId != -1);

        final Cursor cursor = db.query(
                MovieEntry.TABLE_NAME, // table
                null, // all columns
                null, // columns for the "where" clause
                null, // values for the "where" clause
                null, // columns to group by
                null, // columns ot filter by row groups
                null // sort order
        );

        // THEN
        assertTrue("Error: No Records returned from movie query", cursor.moveToFirst());

        TestUtilities.validateCurrentRecord("Error: Movie Query Validation Failed", cursor, contentValues);

        assertFalse("Error: More than one record returned from movie query",
                cursor.moveToNext());

        cursor.close();
        db.close();

        return movieRowId;
    }
/**
     * Ensures a movie entry can be inserted and queried.
     * @return movieRowId
     */
Ensures a movie entry can be inserted and queried.
Ensures a movie entry can be inserted and queried .
private long insertMovieEntry() {
        final SQLiteDatabase db = new MovieDbHelper(mContext).getWritableDatabase();
        final ContentValues contentValues = TestUtilities.createMovieValues();
        final long movieRowId = db.insert(MovieEntry.TABLE_NAME, null, contentValues);
        assertTrue(movieRowId != -1);
        final Cursor cursor = db.query(
                MovieEntry.TABLE_NAME, 
                null, 
                null, 
                null, 
                null, 
                null, 
                null 
        );
        assertTrue("Error: No Records returned from movie query", cursor.moveToFirst());
        TestUtilities.validateCurrentRecord("Error: Movie Query Validation Failed", cursor, contentValues);
        assertFalse("Error: More than one record returned from movie query",
                cursor.moveToNext());
        cursor.close();
        db.close();
        return movieRowId;
    }
private long insertMovieEntry ( ) { final SQLiteDatabase db = new MovieDbHelper ( mContext ) . getWritableDatabase ( ) ; final ContentValues contentValues = TestUtilities . createMovieValues ( ) ; final long movieRowId = db . insert ( MovieEntry . TABLE_NAME , null , contentValues ) ; assertTrue ( movieRowId != - 1 ) ; final Cursor cursor = db . query ( MovieEntry . TABLE_NAME , null , null , null , null , null , null ) ; assertTrue ( "Error: No Records returned from movie query" , cursor . moveToFirst ( ) ) ; TestUtilities . validateCurrentRecord ( "Error: Movie Query Validation Failed" , cursor , contentValues ) ; assertFalse ( "Error: More than one record returned from movie query" , cursor . moveToNext ( ) ) ; cursor . close ( ) ; db . close ( ) ; return movieRowId ; }
Ensures a movie entry can be inserted and queried.
Ensures a movie entry can be inserted and queried .
// GIVEN // WHEN // table // all columns // columns for the "where" clause // values for the "where" clause // columns to group by // columns ot filter by row groups // sort order // THEN