@Test public void insertSource() { source.insertSource(new Source()); verify(database).insert(eq("source"), eq((String) null), any(ContentValues.class)); }
public void insertSource(Source source) { if (!categoryExists(source.categoryName)) { source.categoryId = insertCategory(source.categoryName); } else if (source.categoryId == null) { source.categoryId = getCategoryId(source.categoryName); } ContentValues values = new ContentValues(4); values.put(SourceModel.COLUMN_NAME, source.name); values.put(SourceModel.COLUMN_IMAGE_URL, source.imageUrl); values.put(SourceModel.COLUMN_REMOTE_ID, source.remoteId); values.put(SourceModel.COLUMN_CATEGORY_ID, source.categoryId); database.insert(SourceModel.TABLE, null, values); }
DataSource { public void insertSource(Source source) { if (!categoryExists(source.categoryName)) { source.categoryId = insertCategory(source.categoryName); } else if (source.categoryId == null) { source.categoryId = getCategoryId(source.categoryName); } ContentValues values = new ContentValues(4); values.put(SourceModel.COLUMN_NAME, source.name); values.put(SourceModel.COLUMN_IMAGE_URL, source.imageUrl); values.put(SourceModel.COLUMN_REMOTE_ID, source.remoteId); values.put(SourceModel.COLUMN_CATEGORY_ID, source.categoryId); database.insert(SourceModel.TABLE, null, values); } }
DataSource { public void insertSource(Source source) { if (!categoryExists(source.categoryName)) { source.categoryId = insertCategory(source.categoryName); } else if (source.categoryId == null) { source.categoryId = getCategoryId(source.categoryName); } ContentValues values = new ContentValues(4); values.put(SourceModel.COLUMN_NAME, source.name); values.put(SourceModel.COLUMN_IMAGE_URL, source.imageUrl); values.put(SourceModel.COLUMN_REMOTE_ID, source.remoteId); values.put(SourceModel.COLUMN_CATEGORY_ID, source.categoryId); database.insert(SourceModel.TABLE, null, values); } private  DataSource(Context context); @VisibleForTesting  DataSource(DatabaseSQLiteHelper helper); @VisibleForTesting  DataSource(SQLiteDatabase database); }
DataSource { public void insertSource(Source source) { if (!categoryExists(source.categoryName)) { source.categoryId = insertCategory(source.categoryName); } else if (source.categoryId == null) { source.categoryId = getCategoryId(source.categoryName); } ContentValues values = new ContentValues(4); values.put(SourceModel.COLUMN_NAME, source.name); values.put(SourceModel.COLUMN_IMAGE_URL, source.imageUrl); values.put(SourceModel.COLUMN_REMOTE_ID, source.remoteId); values.put(SourceModel.COLUMN_CATEGORY_ID, source.categoryId); database.insert(SourceModel.TABLE, null, values); } private  DataSource(Context context); @VisibleForTesting  DataSource(DatabaseSQLiteHelper helper); @VisibleForTesting  DataSource(SQLiteDatabase database); static DataSource get(Context context); synchronized void open(); boolean isOpen(); synchronized void close(); @VisibleForTesting SQLiteDatabase getDatabase(); void clearTables(); void beginTransaction(); void execSql(String sql); Cursor rawQuery(String sql); void setTransactionSuccessful(); void endTransaction(); long insertArticle(Article article); int updateSavedArticleState(Article article); int updateArticleInsertedAtTimestamp(Article article); void updateArticleContent(Article article); Article getArticle(String url); Cursor getAllArticles(); Cursor getSavedArticles(); Cursor getArticlesForSource(long remoteSourceId); void deleteArticle(Article article); void deleteArticle(long articleId); long insertCategory(String categoryName); void insertSource(Source source); void deleteSource(String name); List<Source> getSources(); Source getSource(long remoteId); CategoryCounts getCategoryCounts(long timestamp); }
DataSource { public void insertSource(Source source) { if (!categoryExists(source.categoryName)) { source.categoryId = insertCategory(source.categoryName); } else if (source.categoryId == null) { source.categoryId = getCategoryId(source.categoryName); } ContentValues values = new ContentValues(4); values.put(SourceModel.COLUMN_NAME, source.name); values.put(SourceModel.COLUMN_IMAGE_URL, source.imageUrl); values.put(SourceModel.COLUMN_REMOTE_ID, source.remoteId); values.put(SourceModel.COLUMN_CATEGORY_ID, source.categoryId); database.insert(SourceModel.TABLE, null, values); } private  DataSource(Context context); @VisibleForTesting  DataSource(DatabaseSQLiteHelper helper); @VisibleForTesting  DataSource(SQLiteDatabase database); static DataSource get(Context context); synchronized void open(); boolean isOpen(); synchronized void close(); @VisibleForTesting SQLiteDatabase getDatabase(); void clearTables(); void beginTransaction(); void execSql(String sql); Cursor rawQuery(String sql); void setTransactionSuccessful(); void endTransaction(); long insertArticle(Article article); int updateSavedArticleState(Article article); int updateArticleInsertedAtTimestamp(Article article); void updateArticleContent(Article article); Article getArticle(String url); Cursor getAllArticles(); Cursor getSavedArticles(); Cursor getArticlesForSource(long remoteSourceId); void deleteArticle(Article article); void deleteArticle(long articleId); long insertCategory(String categoryName); void insertSource(Source source); void deleteSource(String name); List<Source> getSources(); Source getSource(long remoteId); CategoryCounts getCategoryCounts(long timestamp);  }