use of io.realm.entities.NoPrimaryKeyNullTypes in project realm-java by realm.
the class RealmQueryTests method doTestForInDate.
private void doTestForInDate(String targetField) {
populateNoPrimaryKeyNullTypesRows();
RealmResults<NoPrimaryKeyNullTypes> resultList = realm.where(NoPrimaryKeyNullTypes.class).in(targetField, new Date[] { new Date(DECADE_MILLIS * -80) }).findAll();
assertEquals(1, resultList.size());
resultList = realm.where(NoPrimaryKeyNullTypes.class).in(targetField, new Date[] { new Date(0) }).findAll();
assertEquals(1, resultList.size());
resultList = realm.where(NoPrimaryKeyNullTypes.class).in(targetField, new Date[] { new Date(DECADE_MILLIS * -80), new Date(0) }).findAll();
assertEquals(2, resultList.size());
resultList = realm.where(NoPrimaryKeyNullTypes.class).not().in(targetField, new Date[] { new Date(DECADE_MILLIS * -80), new Date(0) }).findAll();
assertEquals(198, resultList.size());
// Empty input always produces zero results
resultList = realm.where(NoPrimaryKeyNullTypes.class).in(targetField, (Date[]) null).findAll();
assertTrue(resultList.isEmpty());
resultList = realm.where(NoPrimaryKeyNullTypes.class).in(targetField, new Date[] {}).findAll();
assertTrue(resultList.isEmpty());
}
use of io.realm.entities.NoPrimaryKeyNullTypes in project realm-java by realm.
the class RealmQueryTests method populateNoPrimaryKeyNullTypesRows.
private void populateNoPrimaryKeyNullTypesRows(Realm testRealm, int dataSize) {
testRealm.beginTransaction();
testRealm.deleteAll();
for (int i = 0; i < dataSize; ++i) {
NoPrimaryKeyNullTypes noPrimaryKeyNullTypes = testRealm.createObject(NoPrimaryKeyNullTypes.class);
noPrimaryKeyNullTypes.setFieldStringNull((i % 3) == 0 ? null : "test data " + i);
noPrimaryKeyNullTypes.setFieldStringNotNull("test data " + i);
noPrimaryKeyNullTypes.setFieldBooleanNull((i % 3) == 0 ? null : (i % 3) == 1);
noPrimaryKeyNullTypes.setFieldBooleanNotNull((i % 3) == 0);
noPrimaryKeyNullTypes.setFieldByteNull((i % 3) == 0 ? null : (byte) i);
noPrimaryKeyNullTypes.setFieldByteNotNull((byte) i);
noPrimaryKeyNullTypes.setFieldShortNull((i % 3) == 0 ? null : (short) i);
noPrimaryKeyNullTypes.setFieldShortNotNull((short) i);
noPrimaryKeyNullTypes.setFieldIntegerNull((i % 3) == 0 ? null : i);
noPrimaryKeyNullTypes.setFieldIntegerNotNull(i);
noPrimaryKeyNullTypes.setFieldLongNull((i % 3) == 0 ? null : (long) i);
noPrimaryKeyNullTypes.setFieldLongNotNull((long) i);
noPrimaryKeyNullTypes.setFieldFloatNull((i % 3) == 0 ? null : 1.2345f + i);
noPrimaryKeyNullTypes.setFieldFloatNotNull(1.2345f + i);
noPrimaryKeyNullTypes.setFieldDoubleNull((i % 3) == 0 ? null : Math.PI + i);
noPrimaryKeyNullTypes.setFieldDoubleNotNull(Math.PI + i);
noPrimaryKeyNullTypes.setFieldDateNull((i % 3) == 0 ? null : new Date(DECADE_MILLIS * (i - (dataSize / 2))));
noPrimaryKeyNullTypes.setFieldDateNotNull(new Date(DECADE_MILLIS * (i - (dataSize / 2))));
}
testRealm.commitTransaction();
}
Aggregations