Skip to content

Commit

Permalink
Merge branch 'main' into feature/github-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Melchior committed Nov 21, 2023
2 parents c4eaee6 + a88bb46 commit 94a8347
Show file tree
Hide file tree
Showing 24 changed files with 428 additions and 135 deletions.
2 changes: 1 addition & 1 deletion DEPRECATED-Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pipeline {
ANDROID_NDK_HOME="${NDK_HOME}"
REALM_DISABLE_ANALYTICS=true
REALM_PRINT_ANALYTICS=true
REALM_FAIL_ON_ANALYTICS_ERRORS=false
REALM_FAIL_ON_ANALYTICS_ERRORS=true
JAVA_8='/Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home'
JAVA_11='/Library/Java/JavaVirtualMachines/jdk-11.0.12.jdk/Contents/Home'
JAVA_17='/Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home'
Expand Down
4 changes: 2 additions & 2 deletions examples/min-android-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.3")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20")
classpath("com.android.tools.build:gradle:4.2.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0")
classpath("io.realm.kotlin:gradle-plugin:${rootProject.extra["realmVersion"]}")
}
}
Expand Down
2 changes: 2 additions & 0 deletions examples/min-android-sample/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ kotlin.code.style=official
android.useAndroidX=true

org.gradle.configuration-cache=true

kotlin.mpp.androidSourceSetLayoutVersion=1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Double> = 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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<Double> = 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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class AsymmetricSyncTests {
}
config = SyncConfiguration.Builder(
user,
schema = FLX_SYNC_SCHEMA
schema = FLEXIBLE_SYNC_SCHEMA
).initialSubscriptions {
it.query<DeviceParent>().subscribe()
}.build()
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<FlexParentObject>("section = $0", randomSection))
Expand All @@ -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<FlexParentObject>(
Expand All @@ -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 ->
Expand All @@ -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<FlexParentObject>()
Expand All @@ -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<FlexParentObject>("section = $0", it))
Expand All @@ -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<FlexParentObject>("section = $0", randomSection))
Expand All @@ -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<FlexParentObject>(
Expand Down Expand Up @@ -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<FlexParentObject>("section = $0", randomSection))
Expand Down Expand Up @@ -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<FlexParentObject>(
Expand Down Expand Up @@ -303,7 +303,7 @@ class FlexibleSyncIntegrationTests {

val channel = Channel<CompensatingWriteException>(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)
Expand Down
Loading

0 comments on commit 94a8347

Please sign in to comment.