use of io.realm.internal.RealmProxyMediator in project realm-java by realm.
the class RealmProxyMediatorTests method validateTable_noDuplicateIndexInIndexFields.
@Test
public void validateTable_noDuplicateIndexInIndexFields() {
RealmProxyMediator mediator = realm.getConfiguration().getSchemaMediator();
CatRealmProxy.CatColumnInfo columnInfo;
columnInfo = (CatRealmProxy.CatColumnInfo) mediator.validateTable(Cat.class, realm.sharedRealm, false);
final Set<Long> indexSet = new HashSet<Long>();
int indexCount = 0;
indexSet.add(columnInfo.nameIndex);
indexCount++;
indexSet.add(columnInfo.ageIndex);
indexCount++;
indexSet.add(columnInfo.heightIndex);
indexCount++;
indexSet.add(columnInfo.weightIndex);
indexCount++;
indexSet.add(columnInfo.hasTailIndex);
indexCount++;
indexSet.add(columnInfo.birthdayIndex);
indexCount++;
indexSet.add(columnInfo.ownerIndex);
indexCount++;
indexSet.add(columnInfo.scaredOfDogIndex);
indexCount++;
assertEquals(indexCount, indexSet.size());
}
use of io.realm.internal.RealmProxyMediator in project realm-java by realm.
the class ColumnInfoTests method clone_hasSameValue.
@Test
public void clone_hasSameValue() {
final RealmProxyMediator mediator = realm.getConfiguration().getSchemaMediator();
final CatRealmProxy.CatColumnInfo columnInfo;
columnInfo = (CatRealmProxy.CatColumnInfo) mediator.validateTable(Cat.class, realm.sharedRealm, false);
columnInfo.nameIndex = 1;
columnInfo.ageIndex = 2;
columnInfo.heightIndex = 3;
columnInfo.weightIndex = 4;
columnInfo.hasTailIndex = 5;
columnInfo.birthdayIndex = 6;
columnInfo.ownerIndex = 7;
columnInfo.scaredOfDogIndex = 8;
CatRealmProxy.CatColumnInfo copy = columnInfo.clone();
// Modifies original object.
columnInfo.nameIndex = 0;
columnInfo.ageIndex = 0;
columnInfo.heightIndex = 0;
columnInfo.weightIndex = 0;
columnInfo.hasTailIndex = 0;
columnInfo.birthdayIndex = 0;
columnInfo.ownerIndex = 0;
columnInfo.scaredOfDogIndex = 0;
assertNotSame(columnInfo, copy);
assertEquals(1, copy.nameIndex);
assertEquals(2, copy.ageIndex);
assertEquals(3, copy.heightIndex);
assertEquals(4, copy.weightIndex);
assertEquals(5, copy.hasTailIndex);
assertEquals(6, copy.birthdayIndex);
assertEquals(7, copy.ownerIndex);
assertEquals(8, copy.scaredOfDogIndex);
// Current implementation shares the indices map between copies.
assertSame(columnInfo.getIndicesMap(), copy.getIndicesMap());
}
Aggregations