use of io.realm.RealmFieldType in project realm-java by realm.
the class SortDescriptorTests method getInstanceForSort.
@Test
public void getInstanceForSort() {
for (RealmFieldType type : SortDescriptor.validFieldTypesForSort) {
table.addColumn(type, type.name());
}
long i = 0;
for (RealmFieldType type : SortDescriptor.validFieldTypesForSort) {
SortDescriptor sortDescriptor = SortDescriptor.getInstanceForSort(table, type.name(), Sort.DESCENDING);
assertEquals(1, sortDescriptor.getColumnIndices()[0].length);
assertEquals(i, sortDescriptor.getColumnIndices()[0][0]);
assertFalse(sortDescriptor.getAscendings()[0]);
i++;
}
}
use of io.realm.RealmFieldType in project realm-java by realm.
the class SortDescriptorTests method getInstanceForDistinct.
@Test
public void getInstanceForDistinct() {
for (RealmFieldType type : SortDescriptor.validFieldTypesForDistinct) {
long column = table.addColumn(type, type.name());
table.addSearchIndex(column);
}
long i = 0;
for (RealmFieldType type : SortDescriptor.validFieldTypesForDistinct) {
SortDescriptor sortDescriptor = SortDescriptor.getInstanceForDistinct(table, type.name());
assertEquals(1, sortDescriptor.getColumnIndices()[0].length);
assertEquals(i, sortDescriptor.getColumnIndices()[0][0]);
assertNull(sortDescriptor.getAscendings());
i++;
}
}
use of io.realm.RealmFieldType in project realm-java by realm.
the class SortDescriptorTests method getInstanceForSort_shouldThrowOnLinkListField.
@Test
public void getInstanceForSort_shouldThrowOnLinkListField() {
RealmFieldType type = RealmFieldType.STRING;
RealmFieldType listType = RealmFieldType.LIST;
table.addColumn(type, type.name());
table.addColumnLink(listType, listType.name(), table);
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("is not a supported link field");
SortDescriptor.getInstanceForSort(table, String.format("%s.%s", listType.name(), type.name()), Sort.ASCENDING);
}
Aggregations