use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmQueryTests method like_caseSensitiveWithNonLatinCharacters.
@Test
public void like_caseSensitiveWithNonLatinCharacters() {
populateTestRealm();
String flagEmoji = new StringBuilder().append(Character.toChars(0x1F1E9)).toString();
String emojis = "ABC" + flagEmoji + "DEF";
realm.beginTransaction();
realm.delete(AllTypes.class);
AllTypes at1 = realm.createObject(AllTypes.class);
at1.setColumnString("Αλφα");
AllTypes at2 = realm.createObject(AllTypes.class);
at2.setColumnString("βήτα");
AllTypes at3 = realm.createObject(AllTypes.class);
at3.setColumnString("δέλτα");
AllTypes at4 = realm.createObject(AllTypes.class);
at4.setColumnString(emojis);
realm.commitTransaction();
RealmResults<AllTypes> resultList = realm.where(AllTypes.class).like("columnString", "*Α*").findAll();
assertEquals(1, resultList.size());
resultList = realm.where(AllTypes.class).like("columnString", "*λ*").findAll();
assertEquals(2, resultList.size());
resultList = realm.where(AllTypes.class).like("columnString", "*Δ*").findAll();
assertEquals(0, resultList.size());
resultList = realm.where(AllTypes.class).like("columnString", "*Α*", Case.INSENSITIVE).findAll();
// without ASCII-only limitation A matches α
// assertEquals(3, resultList.size());
assertEquals(1, resultList.size());
resultList = realm.where(AllTypes.class).like("columnString", "*λ*", Case.INSENSITIVE).findAll();
assertEquals(2, resultList.size());
resultList = realm.where(AllTypes.class).like("columnString", "*Δ*", Case.INSENSITIVE).findAll();
// without ASCII-only limitation Δ matches δ
// assertEquals(1, resultList.size());
assertEquals(0, resultList.size());
resultList = realm.where(AllTypes.class).like("columnString", "?λ*").findAll();
assertEquals(1, resultList.size());
resultList = realm.where(AllTypes.class).like("columnString", "??λ*").findAll();
assertEquals(1, resultList.size());
resultList = realm.where(AllTypes.class).like("columnString", "?λ*").findAll();
assertEquals(1, resultList.size());
resultList = realm.where(AllTypes.class).like("columnString", "??λ*").findAll();
assertEquals(1, resultList.size());
resultList = realm.where(AllTypes.class).like("columnString", "ABC?DEF*").findAll();
assertEquals(1, resultList.size());
resultList = realm.where(AllTypes.class).like("columnString", "*" + flagEmoji + "*").findAll();
assertEquals(1, resultList.size());
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmQueryTests method notEqualTo_decimal128.
@Test
public void notEqualTo_decimal128() {
populateTestRealm(realm, 10);
RealmResults<AllTypes> resultList = realm.where(AllTypes.class).notEqualTo(AllTypes.FIELD_DECIMAL128, new Decimal128(new BigDecimal("0.23456789"))).sort(AllTypes.FIELD_UUID, Sort.ASCENDING).findAll();
assertEquals(9, resultList.size());
for (int i = 1; i < 10; i++) {
assertNotEquals(new Decimal128(new BigDecimal("0.23456789")), resultList.get(0).getColumnDecimal128());
}
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmQueryTests method equalTo_decimal128.
@Test
public void equalTo_decimal128() {
populateTestRealm(realm, 10);
for (int i = 0; i < 10; i++) {
RealmResults<AllTypes> resultList = realm.where(AllTypes.class).equalTo(AllTypes.FIELD_DECIMAL128, new Decimal128(new BigDecimal(i + ".23456789"))).sort(AllTypes.FIELD_DECIMAL128, Sort.ASCENDING).findAll();
assertEquals(1, resultList.size());
assertEquals(new Decimal128(new BigDecimal(i + ".23456789")), resultList.get(0).getColumnDecimal128());
}
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmQueryTests method between.
@Test
public void between() {
final int TEST_OBJECTS_COUNT = 200;
populateTestRealm(realm, TEST_OBJECTS_COUNT);
RealmResults<AllTypes> resultList = realm.where(AllTypes.class).between(AllTypes.FIELD_LONG, 0, 9).findAll();
assertEquals(10, resultList.size());
resultList = realm.where(AllTypes.class).beginsWith(AllTypes.FIELD_STRING, "test data ").findAll();
assertEquals(TEST_OBJECTS_COUNT, resultList.size());
resultList = realm.where(AllTypes.class).beginsWith(AllTypes.FIELD_STRING, "test data 1").between(AllTypes.FIELD_LONG, 2, 20).findAll();
assertEquals(10, resultList.size());
resultList = realm.where(AllTypes.class).between(AllTypes.FIELD_LONG, 2, 20).beginsWith(AllTypes.FIELD_STRING, "test data 1").findAll();
assertEquals(10, resultList.size());
assertEquals(51, realm.where(AllTypes.class).between(AllTypes.FIELD_DATE, new Date(0), new Date(DECADE_MILLIS * 50)).count());
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmQueryTests method lessThan_Date.
@Test
public void lessThan_Date() {
final int TEST_OBJECTS_COUNT = 200;
populateTestRealm(realm, TEST_OBJECTS_COUNT);
RealmResults<AllTypes> resultList;
resultList = realm.where(AllTypes.class).lessThan(AllTypes.FIELD_DATE, new Date(Long.MIN_VALUE)).findAll();
assertEquals(0, resultList.size());
resultList = realm.where(AllTypes.class).lessThan(AllTypes.FIELD_DATE, new Date(DECADE_MILLIS * -80)).findAll();
assertEquals(20, resultList.size());
resultList = realm.where(AllTypes.class).lessThan(AllTypes.FIELD_DATE, new Date(0)).findAll();
assertEquals(TEST_OBJECTS_COUNT / 2, resultList.size());
resultList = realm.where(AllTypes.class).lessThan(AllTypes.FIELD_DATE, new Date(DECADE_MILLIS * 80)).findAll();
assertEquals(180, resultList.size());
resultList = realm.where(AllTypes.class).lessThan(AllTypes.FIELD_DATE, new Date(Long.MAX_VALUE)).findAll();
assertEquals(TEST_OBJECTS_COUNT, resultList.size());
}
Aggregations