@Test public void getValueReturnsNull(){ final Column column = new Column("NAME", "COLUMN_NAME", Column.Type.text); Cursor mockCursor = mock(Cursor.class); when(mockCursor.getCount()).thenReturn(1); when(mockCursor.getColumnIndex(anyString())).thenReturn(0); when(mockCursor.isNull(anyInt())).thenReturn(true); final Object value = column.getValue(mockCursor); assertThat(value).isNull(); }
public Object getValue(final Cursor cursor) { if (cursor.getCount() == 0) { return null; } final int columnIndex = cursor.getColumnIndex(mName); if (columnIndex == -1 || cursor.isNull(columnIndex)) { return null; } switch (mType) { case blob: return cursor.getBlob(columnIndex); case integer: return cursor.getLong(columnIndex); case real: return cursor.getFloat(columnIndex); case text: default: return cursor.getString(columnIndex); } }
Column { public Object getValue(final Cursor cursor) { if (cursor.getCount() == 0) { return null; } final int columnIndex = cursor.getColumnIndex(mName); if (columnIndex == -1 || cursor.isNull(columnIndex)) { return null; } switch (mType) { case blob: return cursor.getBlob(columnIndex); case integer: return cursor.getLong(columnIndex); case real: return cursor.getFloat(columnIndex); case text: default: return cursor.getString(columnIndex); } } }
Column { public Object getValue(final Cursor cursor) { if (cursor.getCount() == 0) { return null; } final int columnIndex = cursor.getColumnIndex(mName); if (columnIndex == -1 || cursor.isNull(columnIndex)) { return null; } switch (mType) { case blob: return cursor.getBlob(columnIndex); case integer: return cursor.getLong(columnIndex); case real: return cursor.getFloat(columnIndex); case text: default: return cursor.getString(columnIndex); } } Column(final String sqlName, final String name, final Type type, final String stringType);  Column(final String tableName, final String name, final Type type); }
Column { public Object getValue(final Cursor cursor) { if (cursor.getCount() == 0) { return null; } final int columnIndex = cursor.getColumnIndex(mName); if (columnIndex == -1 || cursor.isNull(columnIndex)) { return null; } switch (mType) { case blob: return cursor.getBlob(columnIndex); case integer: return cursor.getLong(columnIndex); case real: return cursor.getFloat(columnIndex); case text: default: return cursor.getString(columnIndex); } } Column(final String sqlName, final String name, final Type type, final String stringType);  Column(final String tableName, final String name, final Type type); String getName(); Type getType(); String getStringType(); String getColumnLine(); Object getValue(final Cursor cursor); String getSqlName(); @Override String toString(); }
Column { public Object getValue(final Cursor cursor) { if (cursor.getCount() == 0) { return null; } final int columnIndex = cursor.getColumnIndex(mName); if (columnIndex == -1 || cursor.isNull(columnIndex)) { return null; } switch (mType) { case blob: return cursor.getBlob(columnIndex); case integer: return cursor.getLong(columnIndex); case real: return cursor.getFloat(columnIndex); case text: default: return cursor.getString(columnIndex); } } Column(final String sqlName, final String name, final Type type, final String stringType);  Column(final String tableName, final String name, final Type type); String getName(); Type getType(); String getStringType(); String getColumnLine(); Object getValue(final Cursor cursor); String getSqlName(); @Override String toString();  }