CommentTable { public String loadEtag(int photoId) { Cursor cursor = database.query( TABLE_NAME, new String[]{COLUMN_ETAG}, String.format("%s = ?", COLUMN_PHOTO_ID), new String[]{String.valueOf(photoId)}, null,null,null ); String storedEtag = null; if (cursor.moveToFirst()){ storedEtag = cursor.getString(cursor.getColumnIndex(COLUMN_ETAG)); } cursor.close(); return storedEtag; } CommentTable(DbConnection dbHelper); void openDatabase(); void closeDatabase(); boolean areNewComments(int photoId, String etag); long insertOrReplaceComments(int photoId, String comments, String etag); String loadEtag(int photoId); String loadComments(int photoId); static final String TABLE_NAME; static final String COLUMN_PHOTO_ID; static final String COLUMN_COMMENTS; static final String COLUMN_ETAG; static final String TABLE_CREATE; static final String TABLE_DROP; }
@Test public void loadEtagShouldReturnNull(){ assertNull(commentTable.loadEtag(PHOTO_ID)); }
@Test public void loadEtag(){ internalInsertComments(); assertEquals(SOME_ETAG_VALUE, commentTable.loadEtag(1)); }