-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add geo types sync integration tests. (#1533)
- Loading branch information
1 parent
ce34cf2
commit a88bb46
Showing
21 changed files
with
423 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
packages/test-base/src/commonMain/kotlin/io/realm/kotlin/entities/GeoEntities.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/test-sync/src/commonMain/kotlin/io/realm/kotlin/entities/sync/SyncRestaurant.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.