CommentTable { public String loadComments(int photoId) { Cursor cursor = database.query( TABLE_NAME, new String[]{COLUMN_COMMENTS}, String.format("%s = ?", COLUMN_PHOTO_ID), new String[]{String.valueOf(photoId)}, null,null,null ); String comments = null; if (cursor.moveToFirst()){ comments = cursor.getString(cursor.getColumnIndex(COLUMN_COMMENTS)); } cursor.close(); return comments; } 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 loadComments(){ internalInsertComments(); assertEquals(DUMMY_COMMENT_STRING, commentTable.loadComments(1)); }
@Test public void loadCommentsShouldReturnNull(){ assertNull(commentTable.loadComments(PHOTO_ID)); }