diff --git a/realm/realm-library/src/androidTest/java/io/realm/RealmTests.java b/realm/realm-library/src/androidTest/java/io/realm/RealmTests.java index 24ab17764f..1866297373 100644 --- a/realm/realm-library/src/androidTest/java/io/realm/RealmTests.java +++ b/realm/realm-library/src/androidTest/java/io/realm/RealmTests.java @@ -3710,6 +3710,27 @@ public void copyFromRealm_dynamicRealmListThrows() { } } + // Test for https://github.com/realm/realm-java/issues/7586 + @Test + public void copyFromRealm_list_realmAny() { + List list = new ArrayList(0); + for (int i = 0; i < 100; i++) { + AllTypes obj = new AllTypes(); + obj.setColumnRealmAnyList(new RealmList()); + for (int j = 0; j < 10; j++) { + obj.getColumnRealmAnyList().add(RealmAny.valueOf(123L)); + } + list.add(obj); + } + realm.executeTransaction((bgRealm) -> { + bgRealm.insertOrUpdate(list); + }); + + RealmResults res = realm.where(AllTypes.class).findAll(); + List copiedData = realm.copyFromRealm(res); + assertEquals(100, copiedData.size()); + } + // Tests if close can be called from Realm change listener when there is no other listeners. @Test public void closeRealmInChangeListener() {