@Test public void fillFromCursor() { MatrixCursor cursor = new MatrixCursor(new String[] { "s_id", "sremote_id", "sname", "simage_url", "cname", "c_id" }); cursor.addRow(new Object[] { 1L, 2L, "test name", "test url", "test category", 3L }); cursor.moveToFirst(); Source source = new Source(cursor); assertEquals(1L, source.id); assertEquals(2L, source.remoteId); assertEquals(3L, (long) source.categoryId); assertEquals("test name", source.name); assertEquals("test url", source.imageUrl); assertEquals("test category", source.categoryName); }
@Override public void fillFromCursor(Cursor cursor) { for (int i = 0; i < cursor.getColumnCount(); i++) { String column = cursor.getColumnName(i); if (column.equals("s" + SourceModel.COLUMN_ID)) { this.id = cursor.getLong(i); } else if (column.equals("s" + SourceModel.COLUMN_NAME)) { this.name = cursor.getString(i); } else if (column.equals("s" + SourceModel.COLUMN_IMAGE_URL)) { this.imageUrl = cursor.getString(i); } else if (column.equals("s" + SourceModel.COLUMN_REMOTE_ID)) { this.remoteId = cursor.getLong(i); } else if (column.equals("c" + CategoryModel.COLUMN_ID)) { this.categoryId = cursor.getLong(i); } else if (column.equals("c" + CategoryModel.COLUMN_NAME)) { this.categoryName = cursor.getString(i); } } }
Source implements DatabaseModel { @Override public void fillFromCursor(Cursor cursor) { for (int i = 0; i < cursor.getColumnCount(); i++) { String column = cursor.getColumnName(i); if (column.equals("s" + SourceModel.COLUMN_ID)) { this.id = cursor.getLong(i); } else if (column.equals("s" + SourceModel.COLUMN_NAME)) { this.name = cursor.getString(i); } else if (column.equals("s" + SourceModel.COLUMN_IMAGE_URL)) { this.imageUrl = cursor.getString(i); } else if (column.equals("s" + SourceModel.COLUMN_REMOTE_ID)) { this.remoteId = cursor.getLong(i); } else if (column.equals("c" + CategoryModel.COLUMN_ID)) { this.categoryId = cursor.getLong(i); } else if (column.equals("c" + CategoryModel.COLUMN_NAME)) { this.categoryName = cursor.getString(i); } } } }
Source implements DatabaseModel { @Override public void fillFromCursor(Cursor cursor) { for (int i = 0; i < cursor.getColumnCount(); i++) { String column = cursor.getColumnName(i); if (column.equals("s" + SourceModel.COLUMN_ID)) { this.id = cursor.getLong(i); } else if (column.equals("s" + SourceModel.COLUMN_NAME)) { this.name = cursor.getString(i); } else if (column.equals("s" + SourceModel.COLUMN_IMAGE_URL)) { this.imageUrl = cursor.getString(i); } else if (column.equals("s" + SourceModel.COLUMN_REMOTE_ID)) { this.remoteId = cursor.getLong(i); } else if (column.equals("c" + CategoryModel.COLUMN_ID)) { this.categoryId = cursor.getLong(i); } else if (column.equals("c" + CategoryModel.COLUMN_NAME)) { this.categoryName = cursor.getString(i); } } } Source();  Source(Cursor cursor); }
Source implements DatabaseModel { @Override public void fillFromCursor(Cursor cursor) { for (int i = 0; i < cursor.getColumnCount(); i++) { String column = cursor.getColumnName(i); if (column.equals("s" + SourceModel.COLUMN_ID)) { this.id = cursor.getLong(i); } else if (column.equals("s" + SourceModel.COLUMN_NAME)) { this.name = cursor.getString(i); } else if (column.equals("s" + SourceModel.COLUMN_IMAGE_URL)) { this.imageUrl = cursor.getString(i); } else if (column.equals("s" + SourceModel.COLUMN_REMOTE_ID)) { this.remoteId = cursor.getLong(i); } else if (column.equals("c" + CategoryModel.COLUMN_ID)) { this.categoryId = cursor.getLong(i); } else if (column.equals("c" + CategoryModel.COLUMN_NAME)) { this.categoryName = cursor.getString(i); } } } Source();  Source(Cursor cursor); @Override void fillFromCursor(Cursor cursor); @Override boolean equals(Object object); @Override int hashCode(); }
Source implements DatabaseModel { @Override public void fillFromCursor(Cursor cursor) { for (int i = 0; i < cursor.getColumnCount(); i++) { String column = cursor.getColumnName(i); if (column.equals("s" + SourceModel.COLUMN_ID)) { this.id = cursor.getLong(i); } else if (column.equals("s" + SourceModel.COLUMN_NAME)) { this.name = cursor.getString(i); } else if (column.equals("s" + SourceModel.COLUMN_IMAGE_URL)) { this.imageUrl = cursor.getString(i); } else if (column.equals("s" + SourceModel.COLUMN_REMOTE_ID)) { this.remoteId = cursor.getLong(i); } else if (column.equals("c" + CategoryModel.COLUMN_ID)) { this.categoryId = cursor.getLong(i); } else if (column.equals("c" + CategoryModel.COLUMN_NAME)) { this.categoryName = cursor.getString(i); } } } Source();  Source(Cursor cursor); @Override void fillFromCursor(Cursor cursor); @Override boolean equals(Object object); @Override int hashCode(); public long id; public String name; public String imageUrl; public String categoryName; public Long categoryId; public long remoteId; }