diff --git a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/UserImpl.kt b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/UserImpl.kt index ec96b5d864..14be010962 100644 --- a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/UserImpl.kt +++ b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/UserImpl.kt @@ -48,6 +48,7 @@ public class UserImpl( get() = RealmInterop.realm_user_get_identity(nativePointer) override val loggedIn: Boolean get() = RealmInterop.realm_user_is_logged_in(nativePointer) + @Deprecated("Property not stable, users might have multiple providers.", ReplaceWith("User.identities")) override val provider: AuthenticationProvider get() = identities.first().provider override val accessToken: String diff --git a/packages/test-base/src/commonMain/kotlin/io/realm/kotlin/entities/GeoEntities.kt b/packages/test-base/src/commonMain/kotlin/io/realm/kotlin/entities/GeoEntities.kt new file mode 100644 index 0000000000..6b0e826e33 --- /dev/null +++ b/packages/test-base/src/commonMain/kotlin/io/realm/kotlin/entities/GeoEntities.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2023 Realm Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.realm.kotlin.entities + +import io.realm.kotlin.ext.realmListOf +import io.realm.kotlin.types.EmbeddedRealmObject +import io.realm.kotlin.types.RealmList +import io.realm.kotlin.types.RealmObject +import io.realm.kotlin.types.annotations.Ignore + +class Restaurant : RealmObject { + var location: Location? = null +} + +// Custom embedded model class for storing GeoPoints in Realm. +class Location : EmbeddedRealmObject { + constructor(latitude: Double, longitude: Double) { + coordinates.apply { + add(longitude) + add(latitude) + } + } + constructor() : this(0.0, 0.0) // Empty constructor required by Realm. Should not be used. + + // Name and type required by Realm + var coordinates: RealmList = realmListOf() + + // Name and type by Realm + @Suppress("UnusedPrivateMember") + private var type: String = "Point" + + @Ignore + var latitude: Double + get() = coordinates[1] + set(value) { + coordinates[1] = value + } + + @Ignore + var longitude: Double + get() = coordinates[0] + set(value) { + coordinates[0] = value + } +} diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/GeoSpatialTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/GeoSpatialTests.kt index fec02fddd5..e4ea4cab38 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/GeoSpatialTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/GeoSpatialTests.kt @@ -20,18 +20,15 @@ package io.realm.kotlin.test.common import io.realm.kotlin.Realm import io.realm.kotlin.RealmConfiguration import io.realm.kotlin.annotations.ExperimentalGeoSpatialApi +import io.realm.kotlin.entities.Location +import io.realm.kotlin.entities.Restaurant import io.realm.kotlin.ext.degrees import io.realm.kotlin.ext.km import io.realm.kotlin.ext.miles import io.realm.kotlin.ext.query import io.realm.kotlin.ext.radians -import io.realm.kotlin.ext.realmListOf import io.realm.kotlin.test.common.utils.assertFailsWithMessage import io.realm.kotlin.test.platform.PlatformUtils -import io.realm.kotlin.types.EmbeddedRealmObject -import io.realm.kotlin.types.RealmList -import io.realm.kotlin.types.RealmObject -import io.realm.kotlin.types.annotations.Ignore import io.realm.kotlin.types.geo.Distance import io.realm.kotlin.types.geo.GeoBox import io.realm.kotlin.types.geo.GeoCircle @@ -44,41 +41,6 @@ import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.fail -class Restaurant : RealmObject { - var location: Location? = null -} - -// Custom embedded model class for storing GeoPoints in Realm. -class Location : EmbeddedRealmObject { - constructor(latitude: Double, longitude: Double) { - coordinates.apply { - add(longitude) - add(latitude) - } - } - constructor() : this(0.0, 0.0) // Empty constructor required by Realm. Should not be used. - - // Name and type required by Realm - var coordinates: RealmList = realmListOf() - - // Name and type by Realm - private var type: String = "Point" - - @Ignore - var latitude: Double - get() = coordinates[1] - set(value) { - coordinates[1] = value - } - - @Ignore - var longitude: Double - get() = coordinates[0] - set(value) { - coordinates[0] = value - } -} - @OptIn(ExperimentalGeoSpatialApi::class) class GeoSpatialTests { diff --git a/packages/test-sync/src/commonMain/kotlin/io/realm/kotlin/entities/sync/SyncRestaurant.kt b/packages/test-sync/src/commonMain/kotlin/io/realm/kotlin/entities/sync/SyncRestaurant.kt new file mode 100644 index 0000000000..2cbbf89418 --- /dev/null +++ b/packages/test-sync/src/commonMain/kotlin/io/realm/kotlin/entities/sync/SyncRestaurant.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2023 Realm Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.realm.kotlin.entities.sync + +import io.realm.kotlin.entities.Location +import io.realm.kotlin.types.RealmObject +import io.realm.kotlin.types.annotations.PrimaryKey +import org.mongodb.kbson.ObjectId + +class SyncRestaurant : RealmObject { + @PrimaryKey + @Suppress("VariableNaming") + var _id = ObjectId() + var section: ObjectId? = null + var location: Location? = null +} diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt index 8bb6a4df18..cd351d80b4 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt @@ -386,7 +386,7 @@ class AppTests { // Create Realm in order to create the sync metadata Realm val user = app.asTestApp.createUserAndLogin() val syncConfig = SyncConfiguration - .Builder(user, setOf(ParentPk::class, ChildPk::class)) + .Builder(user, FLEXIBLE_SYNC_SCHEMA) .build() Realm.open(syncConfig).close() @@ -423,7 +423,7 @@ class AppTests { // Create Realm in order to create the sync metadata Realm val user = app.asTestApp.createUserAndLogin() val syncConfig = SyncConfiguration - .Builder(user, setOf(ParentPk::class, ChildPk::class)) + .Builder(user, FLEXIBLE_SYNC_SCHEMA) .build() Realm.open(syncConfig).close() diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AsymmetricSyncTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AsymmetricSyncTests.kt index 642278458c..261a5b7845 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AsymmetricSyncTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AsymmetricSyncTests.kt @@ -104,7 +104,7 @@ class AsymmetricSyncTests { } config = SyncConfiguration.Builder( user, - schema = FLX_SYNC_SCHEMA + schema = FLEXIBLE_SYNC_SCHEMA ).initialSubscriptions { it.query().subscribe() }.build() @@ -294,7 +294,7 @@ class AsymmetricSyncTests { fun asymmetricSchema() = runBlocking { config = SyncConfiguration.Builder( app.login(Credentials.anonymous()), - schema = FLX_SYNC_SCHEMA + schema = FLEXIBLE_SYNC_SCHEMA ).build() Realm.open(config).use { it.write { diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FlexibleSyncIntegrationTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FlexibleSyncIntegrationTests.kt index 3160fd094d..6be5a27180 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FlexibleSyncIntegrationTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FlexibleSyncIntegrationTests.kt @@ -82,7 +82,7 @@ class FlexibleSyncIntegrationTests { // Upload data from user 1 val user1 = app.createUserAndLogIn(TestHelper.randomEmail(), "123456") - val config1 = SyncConfiguration.create(user1, FLX_SYNC_SCHEMA) + val config1 = SyncConfiguration.create(user1, FLEXIBLE_SYNC_SCHEMA) Realm.open(config1).use { realm1 -> val subs = realm1.subscriptions.update { add(realm1.query("section = $0", randomSection)) @@ -97,7 +97,7 @@ class FlexibleSyncIntegrationTests { // Download data from user 2 val user2 = app.createUserAndLogIn(TestHelper.randomEmail(), "123456") - val config2 = SyncConfiguration.Builder(user2, FLX_SYNC_SCHEMA) + val config2 = SyncConfiguration.Builder(user2, FLEXIBLE_SYNC_SCHEMA) .initialSubscriptions { realm -> add( realm.query( @@ -118,7 +118,7 @@ class FlexibleSyncIntegrationTests { @Test fun writeFailsIfNoSubscription() = runBlocking { val user = app.createUserAndLogIn(TestHelper.randomEmail(), "123456") - val config = SyncConfiguration.Builder(user, FLX_SYNC_SCHEMA) + val config = SyncConfiguration.Builder(user, FLEXIBLE_SYNC_SCHEMA) .build() Realm.open(config).use { realm -> @@ -136,7 +136,7 @@ class FlexibleSyncIntegrationTests { val randomSection = Random.nextInt() // Generate random section to allow replays of unit tests val user = app.createUserAndLogIn(TestHelper.randomEmail(), "123456") - val config = SyncConfiguration.Builder(user, FLX_SYNC_SCHEMA).build() + val config = SyncConfiguration.Builder(user, FLEXIBLE_SYNC_SCHEMA).build() Realm.open(config).use { realm -> realm.subscriptions.update { val query = realm.query() @@ -161,7 +161,7 @@ class FlexibleSyncIntegrationTests { @Test fun initialSubscriptions_timeOut() { - val config = SyncConfiguration.Builder(app.currentUser!!, FLX_SYNC_SCHEMA) + val config = SyncConfiguration.Builder(app.currentUser!!, FLEXIBLE_SYNC_SCHEMA) .initialSubscriptions { realm -> repeat(10) { add(realm.query("section = $0", it)) @@ -184,7 +184,7 @@ class FlexibleSyncIntegrationTests { // Prepare some user data val user1 = app.createUserAndLogin() - val config1 = SyncConfiguration.create(user1, FLX_SYNC_SCHEMA) + val config1 = SyncConfiguration.create(user1, FLEXIBLE_SYNC_SCHEMA) Realm.open(config1).use { realm -> realm.subscriptions.update { add(realm.query("section = $0", randomSection)) @@ -206,7 +206,7 @@ class FlexibleSyncIntegrationTests { // User 2 opens a Realm twice val counter = atomic(0) val user2 = app.createUserAndLogin() - val config2 = SyncConfiguration.Builder(user2, FLX_SYNC_SCHEMA) + val config2 = SyncConfiguration.Builder(user2, FLEXIBLE_SYNC_SCHEMA) .initialSubscriptions(rerunOnOpen = true) { realm -> add( realm.query( @@ -234,7 +234,7 @@ class FlexibleSyncIntegrationTests { // Upload data from user 1 val user1 = app.createUserAndLogIn(TestHelper.randomEmail(), "123456") - val config1 = SyncConfiguration.create(user1, FLX_SYNC_SCHEMA) + val config1 = SyncConfiguration.create(user1, FLEXIBLE_SYNC_SCHEMA) Realm.open(config1).use { realm1 -> val subs = realm1.subscriptions.update { add(realm1.query("section = $0", randomSection)) @@ -272,7 +272,7 @@ class FlexibleSyncIntegrationTests { // Download data from user 2 val user2 = app.createUserAndLogIn(TestHelper.randomEmail(), "123456") - val config2 = SyncConfiguration.Builder(user2, FLX_SYNC_SCHEMA) + val config2 = SyncConfiguration.Builder(user2, FLEXIBLE_SYNC_SCHEMA) .initialSubscriptions { realm -> add( realm.query( @@ -303,7 +303,7 @@ class FlexibleSyncIntegrationTests { val channel = Channel(1) - val config1 = SyncConfiguration.Builder(user1, FLX_SYNC_SCHEMA) + val config1 = SyncConfiguration.Builder(user1, FLEXIBLE_SYNC_SCHEMA) .errorHandler { _: SyncSession, syncException: SyncException -> runBlocking { channel.send(syncException as CompensatingWriteException) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/GeoSpatialTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/GeoSpatialTests.kt new file mode 100644 index 0000000000..1cdbe71ff3 --- /dev/null +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/GeoSpatialTests.kt @@ -0,0 +1,251 @@ +/* + * Copyright 2023 Realm Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.realm.kotlin.test.mongodb.common + +import io.realm.kotlin.Realm +import io.realm.kotlin.annotations.ExperimentalGeoSpatialApi +import io.realm.kotlin.entities.Location +import io.realm.kotlin.entities.sync.SyncRestaurant +import io.realm.kotlin.ext.query +import io.realm.kotlin.internal.platform.runBlocking +import io.realm.kotlin.mongodb.User +import io.realm.kotlin.mongodb.sync.SyncConfiguration +import io.realm.kotlin.mongodb.syncSession +import io.realm.kotlin.test.mongodb.TEST_APP_FLEX +import io.realm.kotlin.test.mongodb.TestApp +import io.realm.kotlin.test.mongodb.createUserAndLogIn +import io.realm.kotlin.test.util.TestHelper +import io.realm.kotlin.test.util.use +import io.realm.kotlin.types.geo.Distance +import io.realm.kotlin.types.geo.GeoBox +import io.realm.kotlin.types.geo.GeoCircle +import io.realm.kotlin.types.geo.GeoPoint +import io.realm.kotlin.types.geo.GeoPolygon +import org.mongodb.kbson.ObjectId +import kotlin.test.AfterTest +import kotlin.test.BeforeTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.time.Duration.Companion.seconds + +@OptIn(ExperimentalGeoSpatialApi::class) +class GeoSpatialTests { + private lateinit var app: TestApp + + @BeforeTest + fun setup() { + app = TestApp(this::class.simpleName, appName = TEST_APP_FLEX) + } + + @AfterTest + fun tearDown() { + if (this::app.isInitialized) { + app.close() + } + } + + private suspend fun createRandomUser(): User = + app.createUserAndLogIn( + email = TestHelper.randomEmail(), + password = "password1234" + ) + + @Test + fun write() { + runBlocking { + val user = createRandomUser() + + val config = + SyncConfiguration.Builder( + user = user, + schema = FLEXIBLE_SYNC_SCHEMA + ).initialSubscriptions { + add(it.query()) + }.build() + + Realm.open(config).use { realm -> + realm.write { + copyToRealm(SyncRestaurant()) + } + } + } + } + + @Test + fun write_outsideSubscriptionsFail() { + runBlocking { + val user = createRandomUser() + + val config = + SyncConfiguration.Builder( + user = user, + schema = FLEXIBLE_SYNC_SCHEMA + ).build() + + Realm.open(config).use { realm -> + realm.write { + assertFailsWith( + message = "[RLM_ERR_NO_SUBSCRIPTION_FOR_WRITE]: Cannot write to class SyncRestaurant when no flexible sync subscription has been created." + ) { + copyToRealm(SyncRestaurant()) + } + } + } + } + } + + @Test + fun geoBox_tests() { + runBlocking { + generic_geo_test( + bounds = GeoBox.create( + top = 1.0, left = 1.0, + bottom = -1.0, right = -1.0, + ), + validLocation = Location(0.0, 0.0), + invalidLocation = Location(40.0, 40.0), + ) + } + } + + @Test + fun geoCircle_tests() { + runBlocking { + generic_geo_test( + bounds = GeoCircle.create( + GeoPoint.create(0.0, 0.0), Distance.fromKilometers(.01) + ), + validLocation = Location(0.0, 0.0), + invalidLocation = Location(40.0, 40.0), + ) + } + } + + @Test + fun geoPolygon_tests() { + runBlocking { + generic_geo_test( + bounds = GeoPolygon.create( + outerRing = listOf( + GeoPoint.create(-5.0, -5.0), + GeoPoint.create(5.0, -5.0), + GeoPoint.create(5.0, 5.0), + GeoPoint.create(-5.0, 5.0), + GeoPoint.create(-5.0, -5.0) + ), + holes = arrayOf( + listOf( + GeoPoint.create(-4.0, -4.0), + GeoPoint.create(4.0, -4.0), + GeoPoint.create(4.0, 4.0), + GeoPoint.create(-4.0, 4.0), + GeoPoint.create(-4.0, -4.0) + ) + ) + ), + validLocation = Location(4.5, 4.5), // Outside the hole and withing the ring + invalidLocation = Location(0.0, 0.0), // Inside the hole + ) + } + } + + private suspend fun generic_geo_test( + bounds: Any, + validLocation: Location, + invalidLocation: Location, + ) { + val section = ObjectId() + + // User #1 will try to write some data and assert some failure conditions. + val user1 = createRandomUser() + val config = + SyncConfiguration.Builder( + user = user1, + schema = FLEXIBLE_SYNC_SCHEMA + ).initialSubscriptions { + add( + it.query( + "section = $0 AND location GEOWITHIN $1", + section, + bounds + ) + ) + }.waitForInitialRemoteData().build() + + Realm.open(config).use { realm -> + val restaurant = realm.write { + // Fail: write outside subscription bounds, compensating write + copyToRealm( + SyncRestaurant().apply { + this.section = section + this.location = invalidLocation + } + ) + + // Ok: Write within subscription bounds + copyToRealm( + SyncRestaurant().apply { + this.section = section + this.location = validLocation + } + ) + + // Ok: Write within subscription bounds, this one will be moved outside of bounds in the next step. + copyToRealm( + SyncRestaurant().apply { + this.section = section + this.location = validLocation + } + ) + } + + realm.syncSession.uploadAllLocalChanges(timeout = 30.seconds) + + realm.write { + // Ok. The object will be updated and moved outside of its view. + // It is a valid operation, it would be removed from the local Realm but still be + // accessible at the mongo instance. + findLatest(restaurant)!!.location = invalidLocation + } + + realm.syncSession.uploadAllLocalChanges(timeout = 30.seconds) + } + + // Download data on user #2 + val user2 = createRandomUser() + val config2 = + SyncConfiguration.Builder( + user = user2, + schema = FLEXIBLE_SYNC_SCHEMA + ).initialSubscriptions { + add( + it.query( + "section = $0 AND location GEOWITHIN $1", + section, + bounds + ) + ) + }.waitForInitialRemoteData( + timeout = 30.seconds + ).build() + + Realm.open(config2).use { realm -> + assertEquals(1, realm.query().count().find()) + } + } +} diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/MutableSubscriptionSetTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/MutableSubscriptionSetTests.kt index 56ef66dc9a..623a9e9508 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/MutableSubscriptionSetTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/MutableSubscriptionSetTests.kt @@ -18,7 +18,6 @@ package io.realm.kotlin.test.mongodb.common import io.realm.kotlin.Realm import io.realm.kotlin.entities.sync.flx.FlexChildObject -import io.realm.kotlin.entities.sync.flx.FlexEmbeddedObject import io.realm.kotlin.entities.sync.flx.FlexParentObject import io.realm.kotlin.ext.query import io.realm.kotlin.internal.platform.runBlocking @@ -64,7 +63,7 @@ class MutableSubscriptionSetTests { } config = SyncConfiguration.Builder( user, - schema = FLX_SYNC_SCHEMA + schema = FLEXIBLE_SYNC_SCHEMA ) .build() realm = Realm.open(config) @@ -369,7 +368,7 @@ class MutableSubscriptionSetTests { private suspend fun uploadServerData(sectionId: Int, noOfObjects: Int) { val user = app.createUserAndLogin() - val config = SyncConfiguration.Builder(user, setOf(FlexParentObject::class, FlexChildObject::class, FlexEmbeddedObject::class)) + val config = SyncConfiguration.Builder(user, FLEXIBLE_SYNC_SCHEMA) .initialSubscriptions { it.query().subscribe() } diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/ProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/ProgressListenerTests.kt index a3310c5494..502c4d6b60 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/ProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/ProgressListenerTests.kt @@ -240,7 +240,7 @@ class ProgressListenerTests { fun throwsOnFlexibleSync() = runBlocking { TestApp("throwsOnFlexibleSync", TEST_APP_FLEX).use { val user = app.createUserAndLogIn() - val configuration: SyncConfiguration = SyncConfiguration.create(user, FLX_SYNC_SCHEMA) + val configuration: SyncConfiguration = SyncConfiguration.create(user, FLEXIBLE_SYNC_SCHEMA) Realm.open(configuration).use { realm -> assertFailsWithMessage( "Progress listeners are not supported for Flexible Sync" @@ -304,7 +304,7 @@ class ProgressListenerTests { user: User, partitionValue: String = getTestPartitionValue() ): SyncConfiguration { - return SyncConfiguration.Builder(user, partitionValue, io.realm.kotlin.test.mongodb.common.PARTITION_SYNC_SCHEMA) + return SyncConfiguration.Builder(user, partitionValue, PARTITION_BASED_SCHEMA) .build() } diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/Schema.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/Schema.kt index 13591ef636..e9eb4265ad 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/Schema.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/Schema.kt @@ -13,26 +13,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package io.realm.kotlin.test.mongodb.common +import io.realm.kotlin.entities.Location +import io.realm.kotlin.entities.sync.BinaryObject import io.realm.kotlin.entities.sync.ChildPk import io.realm.kotlin.entities.sync.ObjectIdPk import io.realm.kotlin.entities.sync.ParentPk import io.realm.kotlin.entities.sync.SyncObjectWithAllTypes import io.realm.kotlin.entities.sync.SyncPerson +import io.realm.kotlin.entities.sync.SyncRestaurant import io.realm.kotlin.entities.sync.flx.FlexChildObject import io.realm.kotlin.entities.sync.flx.FlexEmbeddedObject import io.realm.kotlin.entities.sync.flx.FlexParentObject -private val ASYMMETRIC_CLASSES = setOf( +private val ASYMMETRIC_SCHEMAS = setOf( AsymmetricSyncTests.AsymmetricA::class, AsymmetricSyncTests.EmbeddedB::class, AsymmetricSyncTests.StandardC::class, Measurement::class, ) - -private val DEFAULT_CLASSES = setOf( +private val DEFAULT_SCHEMAS = setOf( BackupDevice::class, + BinaryObject::class, ChildPk::class, Device::class, DeviceParent::class, @@ -42,8 +46,10 @@ private val DEFAULT_CLASSES = setOf( ObjectIdPk::class, ParentPk::class, SyncObjectWithAllTypes::class, - SyncPerson::class + SyncPerson::class, + SyncRestaurant::class, + Location::class, ) -val FLX_SYNC_SCHEMA = DEFAULT_CLASSES + ASYMMETRIC_CLASSES -val PARTITION_SYNC_SCHEMA = DEFAULT_CLASSES +val PARTITION_BASED_SCHEMA = DEFAULT_SCHEMAS +val FLEXIBLE_SYNC_SCHEMA = DEFAULT_SCHEMAS + ASYMMETRIC_SCHEMAS diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SubscriptionExtensionsTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SubscriptionExtensionsTests.kt index bce3f8697a..83c7333b83 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SubscriptionExtensionsTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SubscriptionExtensionsTests.kt @@ -64,7 +64,7 @@ class SubscriptionExtensionsTests { } val config = SyncConfiguration.Builder( user, - schema = FLX_SYNC_SCHEMA + schema = FLEXIBLE_SYNC_SCHEMA ) .build() realm = Realm.open(config) @@ -133,7 +133,7 @@ class SubscriptionExtensionsTests { val user1 = app.createUserAndLogIn(email, password) val config = SyncConfiguration.Builder( user1, - schema = FLX_SYNC_SCHEMA + schema = FLEXIBLE_SYNC_SCHEMA ).initialSubscriptions { realm: Realm -> realm.query("section = $0", section).subscribe() }.build() @@ -391,7 +391,7 @@ class SubscriptionExtensionsTests { private suspend fun uploadServerData(sectionId: Int, noOfObjects: Int) { val user = app.createUserAndLogin() - val config = SyncConfiguration.Builder(user, FLX_SYNC_SCHEMA) + val config = SyncConfiguration.Builder(user, FLEXIBLE_SYNC_SCHEMA) .initialSubscriptions { it.query().subscribe() } diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SubscriptionSetTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SubscriptionSetTests.kt index 73487856bb..4264d3329a 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SubscriptionSetTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SubscriptionSetTests.kt @@ -16,8 +16,6 @@ package io.realm.kotlin.test.mongodb.common import io.realm.kotlin.Realm -import io.realm.kotlin.entities.sync.flx.FlexChildObject -import io.realm.kotlin.entities.sync.flx.FlexEmbeddedObject import io.realm.kotlin.entities.sync.flx.FlexParentObject import io.realm.kotlin.ext.query import io.realm.kotlin.internal.platform.runBlocking @@ -64,7 +62,7 @@ class SubscriptionSetTests { } val config = SyncConfiguration.Builder( user, - schema = FLX_SYNC_SCHEMA + schema = FLEXIBLE_SYNC_SCHEMA ) .build() realm = Realm.open(config) @@ -98,7 +96,7 @@ class SubscriptionSetTests { val config = SyncConfiguration.create( user, TestHelper.randomPartitionValue(), - setOf(FlexParentObject::class, FlexChildObject::class, FlexEmbeddedObject::class) + PARTITION_BASED_SCHEMA ) Realm.open(config).use { partionBasedRealm -> assertFailsWith { partionBasedRealm.subscriptions } @@ -192,10 +190,7 @@ class SubscriptionSetTests { assertFailsWith { subscriptions.waitForSynchronization() } - assertTrue( - subscriptions.errorMessage!!.contains("Invalid query: invalid RQL for table \"FlexParentObject\": syntax error: unexpected Limit, expecting Or or RightParenthesis"), - subscriptions.errorMessage - ) + assertTrue(subscriptions.errorMessage!!.contains("Invalid query: invalid RQL for table \"FlexParentObject\": syntax error: unexpected Limit, expecting Or or RightParenthesis")) subscriptions.update { removeAll() } @@ -261,10 +256,7 @@ class SubscriptionSetTests { updatedSubs.waitForSynchronization() } assertEquals(SubscriptionSetState.ERROR, updatedSubs.state) - assertTrue( - updatedSubs.errorMessage!!.contains("Invalid query: invalid RQL for table \"FlexParentObject\": syntax error: unexpected Limit, expecting Or or RightParenthesis"), - updatedSubs.errorMessage - ) + assertTrue(updatedSubs.errorMessage!!.contains("Invalid query: invalid RQL for table \"FlexParentObject\": syntax error: unexpected Limit, expecting Or or RightParenthesis")) } // Test case for https://github.com/realm/realm-core/issues/5504 @@ -278,10 +270,7 @@ class SubscriptionSetTests { } assertEquals(SubscriptionSetState.ERROR, updatedSubs.state) assertEquals("TRUEPREDICATE and TRUEPREDICATE LIMIT(1)", updatedSubs.first().queryDescription) - assertTrue( - updatedSubs.errorMessage!!.contains("Invalid query: invalid RQL for table \"FlexParentObject\": syntax error: unexpected Limit, expecting Or or RightParenthesis"), - updatedSubs.errorMessage - ) + assertTrue(updatedSubs.errorMessage!!.contains("Invalid query: invalid RQL for table \"FlexParentObject\": syntax error: unexpected Limit, expecting Or or RightParenthesis")) } @Test diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SubscriptionTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SubscriptionTests.kt index 1bc7105f75..ffe94723a1 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SubscriptionTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SubscriptionTests.kt @@ -62,7 +62,7 @@ class SubscriptionTests { } val config = SyncConfiguration.Builder( user, - schema = FLX_SYNC_SCHEMA + schema = FLEXIBLE_SYNC_SCHEMA ) .build() realm = Realm.open(config) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientResetIntegrationTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientResetIntegrationTests.kt index 06f9940072..01fd16cb75 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientResetIntegrationTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientResetIntegrationTests.kt @@ -160,7 +160,7 @@ class SyncClientResetIntegrationTests { configBuilderGenerator = { user -> return@TestEnvironment SyncConfiguration.Builder( user, - FLX_SYNC_SCHEMA + FLEXIBLE_SYNC_SCHEMA ).initialSubscriptions { realm -> realm.query( "section = $0 AND name = $1", @@ -215,7 +215,7 @@ class SyncClientResetIntegrationTests { return@TestEnvironment SyncConfiguration.Builder( user, TestHelper.randomPartitionValue(), - schema = PARTITION_SYNC_SCHEMA + schema = PARTITION_BASED_SCHEMA ) }, insertElement = { realm: Realm -> diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientTests.kt index 5cdd58e678..52fe439bea 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientTests.kt @@ -56,7 +56,7 @@ class SyncClientTests { // There is no way to test reconnect automatically, so just verify that code path does not crash. @Test fun reconnect() { - val config = SyncConfiguration.create(user, schema = FLX_SYNC_SCHEMA) + val config = SyncConfiguration.create(user, schema = FLEXIBLE_SYNC_SCHEMA) Realm.open(config).use { app.sync.reconnect() } @@ -69,7 +69,7 @@ class SyncClientTests { @Test fun hasSyncSessions() { - val config = SyncConfiguration.create(user, schema = FLX_SYNC_SCHEMA) + val config = SyncConfiguration.create(user, schema = FLEXIBLE_SYNC_SCHEMA) Realm.open(config).use { assertTrue(app.sync.hasSyncSessions) } @@ -82,8 +82,8 @@ class SyncClientTests { @Test fun waitForSessionsToTerminate() { - val config1 = SyncConfiguration.Builder(user, schema = FLX_SYNC_SCHEMA).build() - val config2 = SyncConfiguration.Builder(user, schema = FLX_SYNC_SCHEMA).name("other.realm").build() + val config1 = SyncConfiguration.Builder(user, schema = FLEXIBLE_SYNC_SCHEMA).build() + val config2 = SyncConfiguration.Builder(user, schema = FLEXIBLE_SYNC_SCHEMA).name("other.realm").build() Realm.open(config1).use { assertTrue(app.sync.hasSyncSessions) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncConfigTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncConfigTests.kt index 2635dc277d..a51453089c 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncConfigTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncConfigTests.kt @@ -105,7 +105,7 @@ class SyncConfigTests { val logger = createDefaultSystemLogger("TEST", LogLevel.DEBUG) val customLoggers = listOf(logger) val config = SyncConfiguration.Builder( - schema = FLX_SYNC_SCHEMA, + schema = PARTITION_BASED_SCHEMA, user = user, partitionValue = partitionValue ).also { builder -> @@ -124,7 +124,7 @@ class SyncConfigTests { } val user = createTestUser() val config = SyncConfiguration.Builder( - schema = FLX_SYNC_SCHEMA, + schema = PARTITION_BASED_SCHEMA, user = user, partitionValue = partitionValue ).also { builder -> @@ -137,7 +137,7 @@ class SyncConfigTests { fun errorHandler_default() { val user = createTestUser() val config = SyncConfiguration.Builder( - schema = FLX_SYNC_SCHEMA, + schema = PARTITION_BASED_SCHEMA, user = user, partitionValue = partitionValue ).build() @@ -150,7 +150,7 @@ class SyncConfigTests { fun compactOnLaunch_default() { val user = createTestUser() val config = SyncConfiguration.Builder( - schema = FLX_SYNC_SCHEMA, + schema = PARTITION_BASED_SCHEMA, user = user, partitionValue = partitionValue ).build() @@ -164,7 +164,7 @@ class SyncConfigTests { val user = createTestUser() val callback = CompactOnLaunchCallback { _, _ -> false } val config = SyncConfiguration.Builder( - schema = FLX_SYNC_SCHEMA, + schema = PARTITION_BASED_SCHEMA, user = user, partitionValue = partitionValue ) @@ -186,7 +186,7 @@ class SyncConfigTests { ) } val config = SyncConfiguration.Builder( - schema = PARTITION_SYNC_SCHEMA, + schema = PARTITION_BASED_SCHEMA, user = user, partitionValue = partitionValue ) @@ -249,7 +249,7 @@ class SyncConfigTests { } } val config = SyncConfiguration.Builder( - schema = FLX_SYNC_SCHEMA, + schema = PARTITION_BASED_SCHEMA, user = user, partitionValue = partitionValue ).syncClientResetStrategy(strategy) @@ -277,7 +277,7 @@ class SyncConfigTests { } } val config = SyncConfiguration.Builder( - schema = FLX_SYNC_SCHEMA, + schema = PARTITION_BASED_SCHEMA, user = user, partitionValue = partitionValue ).syncClientResetStrategy(strategy) @@ -309,7 +309,7 @@ class SyncConfigTests { } } val config = SyncConfiguration.Builder( - schema = FLX_SYNC_SCHEMA, + schema = PARTITION_BASED_SCHEMA, user = user, partitionValue = partitionValue ).syncClientResetStrategy(strategy) @@ -321,7 +321,7 @@ class SyncConfigTests { fun equals_sameObject() { val user = createTestUser() val config = SyncConfiguration.Builder( - schema = FLX_SYNC_SCHEMA, + schema = PARTITION_BASED_SCHEMA, user = user, partitionValue = partitionValue ).build() @@ -374,7 +374,7 @@ class SyncConfigTests { fun equals_syncSpecificFields() { val user = createTestUser() val config = SyncConfiguration.Builder( - schema = FLX_SYNC_SCHEMA, + schema = PARTITION_BASED_SCHEMA, user = user, partitionValue = partitionValue ).build() @@ -532,7 +532,7 @@ class SyncConfigTests { fun encryption() { val user = createTestUser() val config = SyncConfiguration.Builder( - schema = FLX_SYNC_SCHEMA, + schema = PARTITION_BASED_SCHEMA, user = user, partitionValue = partitionValue ).also { builder -> @@ -647,7 +647,7 @@ class SyncConfigTests { @Test fun getInitialRemoteDataTimeout() { val user = createTestUser() - val config = SyncConfiguration.Builder(user, TestHelper.randomPartitionValue(), setOf()) + val config = SyncConfiguration.Builder(user, TestHelper.randomPartitionValue(), PARTITION_BASED_SCHEMA) .waitForInitialRemoteData(timeout = 10.seconds) .build() assertNotNull(config.initialRemoteData) @@ -759,7 +759,7 @@ class SyncConfigTests { fun getPartitionValue() { val user = createTestUser() val config = SyncConfiguration.Builder( - schema = FLX_SYNC_SCHEMA, + schema = FLEXIBLE_SYNC_SCHEMA, user = user, partitionValue = partitionValue ).build() @@ -1243,7 +1243,7 @@ class SyncConfigTests { } SyncConfiguration.Builder( - schema = FLX_SYNC_SCHEMA, + schema = FLEXIBLE_SYNC_SCHEMA, user = user, partitionValue = partitionValue ).build() diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncSessionTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncSessionTests.kt index 827832ed2f..c32a396a2a 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncSessionTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncSessionTests.kt @@ -258,13 +258,13 @@ class SyncSessionTests { val config1 = SyncConfiguration.Builder( user1, partitionValue, - schema = FLX_SYNC_SCHEMA + schema = PARTITION_BASED_SCHEMA ).name("user1.realm") .build() val config2 = SyncConfiguration.Builder( user2, partitionValue, - schema = FLX_SYNC_SCHEMA + schema = PARTITION_BASED_SCHEMA ).name("user2.realm") .build() @@ -320,7 +320,7 @@ class SyncSessionTests { val user = app.createUserAndLogIn(email, password) val channel = Channel(1) val config = SyncConfiguration.Builder( - schema = PARTITION_SYNC_SCHEMA, + schema = PARTITION_BASED_SCHEMA, user = user, partitionValue = partitionValue ).errorHandler { session, _ -> @@ -382,7 +382,7 @@ class SyncSessionTests { @Test fun syncingObjectIdFromMongoDB() = runBlocking { val adminApi = app.asTestApp - val config = SyncConfiguration.Builder(user, partitionValue, schema = PARTITION_SYNC_SCHEMA).build() + val config = SyncConfiguration.Builder(user, partitionValue, schema = PARTITION_BASED_SCHEMA).build() Realm.open(config).use { realm -> val json: JsonObject = adminApi.insertDocument( ObjectIdPk::class.simpleName!!, @@ -427,7 +427,7 @@ class SyncSessionTests { val config = SyncConfiguration.Builder( user, partitionValue, - schema = PARTITION_SYNC_SCHEMA + schema = PARTITION_BASED_SCHEMA ) .build() Realm.open(config).use { realm -> @@ -481,7 +481,7 @@ class SyncSessionTests { val (email, password) = TestHelper.randomEmail() to "password1234" val user = app.createUserAndLogIn(email, password) val config1 = SyncConfiguration.Builder( - schema = FLX_SYNC_SCHEMA, + schema = FLEXIBLE_SYNC_SCHEMA, user = user, partitionValue = partitionValue ).name("test1.realm").build() diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt index d79f7f157a..23d4b05a31 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt @@ -404,7 +404,7 @@ class SyncedRealmTests { @Ignore fun waitForInitialRemoteData_mainThreadThrows() = runBlocking(Dispatchers.Main) { val user = app.asTestApp.createUserAndLogin() - val config = SyncConfiguration.Builder(user, TestHelper.randomPartitionValue(), setOf()) + val config = SyncConfiguration.Builder(user, TestHelper.randomPartitionValue(), PARTITION_BASED_SCHEMA) .waitForInitialRemoteData() .build() assertFailsWith { @@ -429,11 +429,10 @@ class SyncedRealmTests { @Test fun waitForInitialRemoteData() = runBlocking { val partitionValue = TestHelper.randomPartitionValue() - val schema = setOf(ParentPk::class, ChildPk::class) // 1. Copy a valid Realm to the server val user1 = app.asTestApp.createUserAndLogin() - val config1: SyncConfiguration = SyncConfiguration.create(user1, partitionValue, schema) + val config1: SyncConfiguration = SyncConfiguration.create(user1, partitionValue, PARTITION_BASED_SCHEMA) Realm.open(config1).use { realm -> realm.write { for (index in 0..9) { @@ -450,7 +449,7 @@ class SyncedRealmTests { // 2. Sometimes it can take a little while for the data to be available to other users, // so make sure data has reached server. val user2 = app.asTestApp.createUserAndLogin() - val config2: SyncConfiguration = SyncConfiguration.create(user2, partitionValue, schema) + val config2: SyncConfiguration = SyncConfiguration.create(user2, partitionValue, PARTITION_BASED_SCHEMA) assertNotEquals(config1.path, config2.path) Realm.open(config2).use { realm -> val count = realm.query() @@ -462,7 +461,7 @@ class SyncedRealmTests { // 3. Finally verify `waitForInitialData` is working val user3 = app.asTestApp.createUserAndLogin() - val config3: SyncConfiguration = SyncConfiguration.Builder(user3, partitionValue, schema) + val config3: SyncConfiguration = SyncConfiguration.Builder(user3, partitionValue, PARTITION_BASED_SCHEMA) .waitForInitialRemoteData() .build() assertNotEquals(config1.path, config3.path) @@ -474,7 +473,6 @@ class SyncedRealmTests { @Test fun waitForInitialData_timeOut() = runBlocking { val partitionValue = TestHelper.randomPartitionValue() - val schema = setOf(BinaryObject::class) // High enough to introduce latency when download Realm initial data // but not too high so that we reach Atlas' transmission limit @@ -482,7 +480,7 @@ class SyncedRealmTests { // 1. Copy a valid Realm to the server val user1 = app.asTestApp.createUserAndLogin() - val config1: SyncConfiguration = SyncConfiguration.create(user1, partitionValue, schema) + val config1: SyncConfiguration = SyncConfiguration.create(user1, partitionValue, PARTITION_BASED_SCHEMA) Realm.open(config1).use { realm -> realm.write { for (index in 0 until objectCount) { @@ -499,7 +497,7 @@ class SyncedRealmTests { // 2. Sometimes it can take a little while for the data to be available to other users, // so make sure data has reached server. val user2 = app.asTestApp.createUserAndLogin() - val config2: SyncConfiguration = SyncConfiguration.create(user2, partitionValue, schema) + val config2: SyncConfiguration = SyncConfiguration.create(user2, partitionValue, PARTITION_BASED_SCHEMA) assertNotEquals(config1.path, config2.path) Realm.open(config2).use { realm -> val count = realm.query() @@ -512,7 +510,7 @@ class SyncedRealmTests { // 3. Finally verify `waitForInitialData` is working val user3 = app.asTestApp.createUserAndLogin() - val config3: SyncConfiguration = SyncConfiguration.Builder(user3, partitionValue, schema) + val config3: SyncConfiguration = SyncConfiguration.Builder(user3, partitionValue, PARTITION_BASED_SCHEMA) .waitForInitialRemoteData(1.nanoseconds) .build() assertNotEquals(config1.path, config3.path) @@ -531,9 +529,8 @@ class SyncedRealmTests { @Ignore // See https://github.com/realm/realm-kotlin/issues/851 fun waitForInitialData_resilientInCaseOfRetries() = runBlocking { val user = app.asTestApp.createUserAndLogin() - val schema = setOf(ParentPk::class, ChildPk::class) val partitionValue = TestHelper.randomPartitionValue() - val config: SyncConfiguration = SyncConfiguration.Builder(user, partitionValue, schema) + val config: SyncConfiguration = SyncConfiguration.Builder(user, partitionValue, PARTITION_BASED_SCHEMA) .waitForInitialRemoteData(1.nanoseconds) .build() @@ -1416,7 +1413,7 @@ class SyncedRealmTests { name = "asset-fs.realm", errorHandler = { _, error -> fail(error.toString()) - } + }, ) Realm.open(syncConfig1).use { flexRealm1: Realm -> @@ -1458,7 +1455,7 @@ class SyncedRealmTests { name = "sync1.realm", errorHandler = { _, error -> fail(error.toString()) - } + }, ) { initialRealmFile("asset-fs.realm") initialData { @@ -1856,7 +1853,7 @@ class SyncedRealmTests { errorHandler: ErrorHandler? = null, block: SyncConfiguration.Builder.() -> Unit = {} ): SyncConfiguration = SyncConfiguration.Builder( - schema = PARTITION_SYNC_SCHEMA, + schema = PARTITION_BASED_SCHEMA, user = user, partitionValue = partitionValue ).name(name).also { builder -> @@ -1877,7 +1874,7 @@ class SyncedRealmTests { block: SyncConfiguration.Builder.() -> Unit = {}, ): SyncConfiguration = SyncConfiguration.Builder( user = user, - schema = FLX_SYNC_SCHEMA + schema = FLEXIBLE_SYNC_SCHEMA ).name(name).also { builder -> if (encryptionKey != null) builder.encryptionKey(encryptionKey) if (errorHandler != null) builder.errorHandler(errorHandler) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/UserTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/UserTests.kt index eb622cf8c0..417c4c5516 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/UserTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/UserTests.kt @@ -20,7 +20,6 @@ package io.realm.kotlin.test.mongodb.common import io.realm.kotlin.Realm import io.realm.kotlin.annotations.ExperimentalRealmSerializerApi -import io.realm.kotlin.entities.sync.SyncObjectWithAllTypes import io.realm.kotlin.internal.platform.fileExists import io.realm.kotlin.internal.platform.runBlocking import io.realm.kotlin.mongodb.AuthenticationProvider @@ -388,7 +387,7 @@ class UserTests { val config = SyncConfiguration.create( user1, TestHelper.randomPartitionValue(), - setOf(SyncObjectWithAllTypes::class) + PARTITION_BASED_SCHEMA ) Realm.open(config).close() assertTrue(fileExists(config.path)) @@ -409,7 +408,7 @@ class UserTests { val config = SyncConfiguration.create( user1, TestHelper.randomPartitionValue(), - setOf(SyncObjectWithAllTypes::class) + PARTITION_BASED_SCHEMA ) Realm.open(config).close() user1.logOut() diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/nonlatin/NonLatinTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/nonlatin/NonLatinTests.kt index effa1d2db0..eb1d23f579 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/nonlatin/NonLatinTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/nonlatin/NonLatinTests.kt @@ -8,7 +8,7 @@ import io.realm.kotlin.mongodb.User import io.realm.kotlin.mongodb.sync.SyncConfiguration import io.realm.kotlin.test.mongodb.TestApp import io.realm.kotlin.test.mongodb.asTestApp -import io.realm.kotlin.test.mongodb.common.PARTITION_SYNC_SCHEMA +import io.realm.kotlin.test.mongodb.common.PARTITION_BASED_SCHEMA import io.realm.kotlin.test.mongodb.createUserAndLogIn import io.realm.kotlin.test.util.TestHelper import io.realm.kotlin.test.util.receiveOrFail @@ -55,7 +55,7 @@ class NonLatinTests { @Test fun readNullCharacterFromMongoDB() = runBlocking { val adminApi = app.asTestApp - val config = SyncConfiguration.Builder(user, partitionValue, schema = PARTITION_SYNC_SCHEMA).build() + val config = SyncConfiguration.Builder(user, partitionValue, schema = PARTITION_BASED_SCHEMA).build() Realm.open(config).use { realm -> val json: JsonObject = adminApi.insertDocument( ObjectIdPk::class.simpleName!!,