use of io.realm.entities.PrimaryKeyAsBoxedShort in project realm-java by realm.
the class RealmTests method createObjectWithPrimaryKey_null.
@Test
public void createObjectWithPrimaryKey_null() {
// Byte
realm.beginTransaction();
PrimaryKeyAsBoxedByte primaryKeyAsBoxedByte = realm.createObject(PrimaryKeyAsBoxedByte.class, null);
realm.commitTransaction();
assertEquals(1, realm.where(PrimaryKeyAsBoxedByte.class).count());
assertNull(primaryKeyAsBoxedByte.getId());
// Short
realm.beginTransaction();
PrimaryKeyAsBoxedShort primaryKeyAsBoxedShort = realm.createObject(PrimaryKeyAsBoxedShort.class, null);
realm.commitTransaction();
assertEquals(1, realm.where(PrimaryKeyAsBoxedShort.class).count());
assertNull(primaryKeyAsBoxedShort.getId());
// Integer
realm.beginTransaction();
PrimaryKeyAsBoxedInteger primaryKeyAsBoxedInteger = realm.createObject(PrimaryKeyAsBoxedInteger.class, null);
realm.commitTransaction();
assertEquals(1, realm.where(PrimaryKeyAsBoxedInteger.class).count());
assertNull(primaryKeyAsBoxedInteger.getId());
// Long
realm.beginTransaction();
PrimaryKeyAsBoxedLong primaryKeyAsBoxedLong = realm.createObject(PrimaryKeyAsBoxedLong.class, null);
realm.commitTransaction();
assertEquals(1, realm.where(PrimaryKeyAsBoxedLong.class).count());
assertNull(primaryKeyAsBoxedLong.getId());
// String
realm.beginTransaction();
PrimaryKeyAsString primaryKeyAsString = realm.createObject(PrimaryKeyAsString.class, null);
realm.commitTransaction();
assertEquals(1, realm.where(PrimaryKeyAsString.class).count());
assertNull(primaryKeyAsString.getName());
}
Aggregations