@Override public void readEntity(Cursor cursor, SimpleEntityNotNull entity, int offset) { entity.setId(cursor.getLong(offset + 0)); entity.setSimpleBoolean(cursor.getShort(offset + 1) != 0); entity.setSimpleByte((byte) cursor.getShort(offset + 2)); entity.setSimpleShort(cursor.getShort(offset + 3)); entity.setSimpleInt(cursor.getInt(offset + 4)); entity.setSimpleLong(cursor.getLong(offset + 5)); entity.setSimpleFloat(cursor.getFloat(offset + 6)); entity.setSimpleDouble(cursor.getDouble(offset + 7)); entity.setSimpleString(cursor.getString(offset + 8)); entity.setSimpleByteArray(cursor.getBlob(offset + 9)); }
public static SimpleEntityNotNull createEntity(Long key) { if (key == null) { return null; } SimpleEntityNotNull entity = new SimpleEntityNotNull(); entity.setId(key); entity.setSimpleBoolean(true); entity.setSimpleByte(Byte.MAX_VALUE); entity.setSimpleShort(Short.MAX_VALUE); entity.setSimpleInt(Integer.MAX_VALUE); entity.setSimpleLong(Long.MAX_VALUE); entity.setSimpleFloat(Float.MAX_VALUE); entity.setSimpleDouble(Double.MAX_VALUE); entity.setSimpleString("greenrobot greenDAO"); byte[] bytes = { 42, -17, 23, 0, 127, -128 }; entity.setSimpleByteArray(bytes); return entity; } }
public void testUpdateValues() { SimpleEntityNotNull entity = createEntity(1l); dao.insert(entity); entity = dao.load(1l); entity.setSimpleBoolean(false); entity.setSimpleByte(Byte.MIN_VALUE); entity.setSimpleShort(Short.MIN_VALUE); entity.setSimpleInt(Integer.MIN_VALUE); entity.setSimpleLong(Long.MIN_VALUE); entity.setSimpleFloat(Float.MIN_VALUE); entity.setSimpleDouble(Double.MIN_VALUE); entity.setSimpleString("greenDAO"); byte[] bytes = { -1, 0, 1 }; entity.setSimpleByteArray(bytes); dao.update(entity); SimpleEntityNotNull reloaded = dao.load(1l); assertEqualProperties(entity, reloaded); }