use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmQueryTests method populateTestRealm.
private void populateTestRealm(Realm testRealm, int dataSize) {
testRealm.beginTransaction();
testRealm.deleteAll();
for (int i = 0; i < dataSize; ++i) {
AllTypes allTypes = testRealm.createObject(AllTypes.class);
allTypes.setColumnBoolean((i % 3) == 0);
allTypes.setColumnBinary(new byte[] { 1, 2, 3 });
allTypes.setColumnDate(new Date(DECADE_MILLIS * (i - (dataSize / 2))));
allTypes.setColumnDouble(3.1415);
allTypes.setColumnFloat(1.234567f + i);
allTypes.setColumnString("test data " + i);
allTypes.setColumnLong(i);
NonLatinFieldNames nonLatinFieldNames = testRealm.createObject(NonLatinFieldNames.class);
nonLatinFieldNames.set델타(i);
nonLatinFieldNames.setΔέλτα(i);
nonLatinFieldNames.set베타(1.234567f + i);
nonLatinFieldNames.setΒήτα(1.234567f + i);
Dog dog = testRealm.createObject(Dog.class);
dog.setAge(i);
dog.setName("test data " + i);
allTypes.setColumnRealmObject(dog);
}
testRealm.commitTransaction();
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmQueryTests method lessThanOrEqualTo_date.
@Test
public void lessThanOrEqualTo_date() {
final int TEST_OBJECTS_COUNT = 200;
populateTestRealm(realm, TEST_OBJECTS_COUNT);
RealmResults<AllTypes> resultList;
resultList = realm.where(AllTypes.class).lessThanOrEqualTo(AllTypes.FIELD_DATE, new Date(Long.MIN_VALUE)).findAll();
assertEquals(0, resultList.size());
resultList = realm.where(AllTypes.class).lessThanOrEqualTo(AllTypes.FIELD_DATE, new Date(DECADE_MILLIS * -80)).findAll();
assertEquals(21, resultList.size());
resultList = realm.where(AllTypes.class).lessThanOrEqualTo(AllTypes.FIELD_DATE, new Date(0)).findAll();
assertEquals(TEST_OBJECTS_COUNT / 2 + 1, resultList.size());
resultList = realm.where(AllTypes.class).lessThanOrEqualTo(AllTypes.FIELD_DATE, new Date(DECADE_MILLIS * 80)).findAll();
assertEquals(181, resultList.size());
resultList = realm.where(AllTypes.class).lessThanOrEqualTo(AllTypes.FIELD_DATE, new Date(Long.MAX_VALUE)).findAll();
assertEquals(TEST_OBJECTS_COUNT, resultList.size());
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmTests method copyFromRealm_list_invalidListThrows.
@Test
public void copyFromRealm_list_invalidListThrows() {
realm.beginTransaction();
AllTypes object = realm.createObject(AllTypes.class);
List<AllTypes> list = new RealmList<AllTypes>(object);
object.deleteFromRealm();
realm.commitTransaction();
thrown.expect(IllegalArgumentException.class);
realm.copyFromRealm(list);
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmTests method copyFromRealm_dynamicRealmObjectThrows.
@Test
public void copyFromRealm_dynamicRealmObjectThrows() {
realm.beginTransaction();
AllTypes obj = realm.createObject(AllTypes.class);
realm.commitTransaction();
DynamicRealmObject dObj = new DynamicRealmObject(obj);
try {
realm.copyFromRealm(dObj);
fail();
} catch (IllegalArgumentException ignored) {
}
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmTests method copyToRealmOrUpdate_noPrimaryKeyField.
@Test
public void copyToRealmOrUpdate_noPrimaryKeyField() {
realm.beginTransaction();
thrown.expect(IllegalArgumentException.class);
realm.copyToRealmOrUpdate(new AllTypes());
}
Aggregations