@Override protected void setUp() throws InterruptedException { RealmConfiguration realmConfig = new RealmConfiguration.Builder(getContext()).build(); Realm.deleteRealm(realmConfig); testRealm = Realm.getInstance(realmConfig); populateTestRealm(); }
public void testContainsDoesNotContainAnItem() { RealmConfiguration realmConfig = TestHelper.createConfiguration(getContext(), "contains_test.realm"); Realm.deleteRealm(realmConfig); Realm testRealmTwo = Realm.getInstance(realmConfig); try { testRealmTwo.beginTransaction(); testRealmTwo.allObjects(AllTypes.class).clear(); testRealmTwo.allObjects(NonLatinFieldNames.class).clear(); for (int i = 0; i < TEST_DATA_SIZE; ++i) { AllTypes allTypes = testRealmTwo.createObject(AllTypes.class); allTypes.setColumnBoolean((i % 2) == 0); allTypes.setColumnBinary(new byte[] {1, 2, 3}); allTypes.setColumnDate(new Date(YEAR_MILLIS * (i - TEST_DATA_SIZE / 2))); allTypes.setColumnDouble(3.1415 + i); allTypes.setColumnFloat(1.234567f + i); allTypes.setColumnString("test data " + i); allTypes.setColumnLong(i); Dog d = testRealmTwo.createObject(Dog.class); d.setName("Foo " + i); allTypes.setColumnRealmObject(d); allTypes.getColumnRealmList().add(d); NonLatinFieldNames nonLatinFieldNames = testRealmTwo.createObject(NonLatinFieldNames.class); nonLatinFieldNames.set델타(i); nonLatinFieldNames.setΔέλτα(i); } testRealmTwo.commitTransaction(); final AllTypes item = testRealmTwo.where(AllTypes.class).findFirst(); assertFalse( "Should not be able to find one object in another Realm via RealmResults#contains", testRealm.where(AllTypes.class).findAll().contains(item)); } finally { if (testRealmTwo != null && !testRealmTwo.isClosed()) { testRealmTwo.close(); } } }