-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrating and enabling sync session integration test #6884
Changes from all commits
f6c4d3a
1a254cf
b25841a
914fa1a
8e3a5b9
5b7b4c1
de03563
6d434c0
fbcef54
e501096
661b2fc
8c1aa7f
ec7162d
ecf4751
bdb01a3
fee820b
72af903
1760905
c88ffd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Copyright 2020 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.entities | ||
|
||
import io.realm.MutableRealmInteger | ||
import io.realm.RealmList | ||
import io.realm.RealmObject | ||
import io.realm.TestHelper | ||
import io.realm.annotations.PrimaryKey | ||
import io.realm.annotations.RealmField | ||
import io.realm.annotations.Required | ||
import org.bson.types.Decimal128 | ||
import org.bson.types.ObjectId | ||
import java.math.BigDecimal | ||
import java.util.* | ||
|
||
open class SyncAllTypes : RealmObject() { | ||
|
||
companion object { | ||
const val CLASS_NAME = "AllTypes" | ||
const val FIELD_STRING = "columnString" | ||
const val FIELD_LONG = "columnLong" | ||
const val FIELD_FLOAT = "columnFloat" | ||
const val FIELD_DOUBLE = "columnDouble" | ||
const val FIELD_BOOLEAN = "columnBoolean" | ||
const val FIELD_DATE = "columnDate" | ||
const val FIELD_BINARY = "columnBinary" | ||
const val FIELD_MUTABLEREALMINTEGER = "columnMutableRealmInteger" | ||
const val FIELD_DECIMAL128 = "columnDecimal128" | ||
const val FIELD_OBJECT_ID = "columnObjectId" | ||
const val FIELD_REALMOBJECT = "columnRealmObject" | ||
const val FIELD_REALMLIST = "columnRealmList" | ||
const val FIELD_STRING_LIST = "columnStringList" | ||
const val FIELD_BINARY_LIST = "columnBinaryList" | ||
const val FIELD_BOOLEAN_LIST = "columnBooleanList" | ||
const val FIELD_LONG_LIST = "columnLongList" | ||
const val FIELD_DOUBLE_LIST = "columnDoubleList" | ||
const val FIELD_FLOAT_LIST = "columnFloatList" | ||
const val FIELD_DATE_LIST = "columnDateList" | ||
val INVALID_TYPES_FIELDS_FOR_DISTINCT = arrayOf(FIELD_REALMOBJECT, FIELD_REALMLIST, FIELD_DOUBLE, FIELD_FLOAT, | ||
FIELD_STRING_LIST, FIELD_BINARY_LIST, FIELD_BOOLEAN_LIST, FIELD_LONG_LIST, | ||
FIELD_DOUBLE_LIST, FIELD_FLOAT_LIST, FIELD_DATE_LIST) | ||
} | ||
|
||
@PrimaryKey | ||
@RealmField(name = "_id") | ||
var id = ObjectId() | ||
|
||
@Required | ||
var columnString = "" | ||
var columnLong: Long = 0 | ||
var columnFloat = 0f | ||
var columnDouble = 0.0 | ||
var isColumnBoolean = false | ||
|
||
@Required | ||
var columnDate = Date(0) | ||
|
||
@Required | ||
var columnBinary = ByteArray(0) | ||
|
||
@Required | ||
var columnDecimal128 = Decimal128(BigDecimal.ZERO) | ||
|
||
@Required | ||
var columnObjectId = ObjectId(TestHelper.randomObjectIdHexString()) | ||
val columnRealmInteger = MutableRealmInteger.ofNull() | ||
var columnRealmObject: SyncDog? = null | ||
var columnRealmList: RealmList<SyncDog>? = null | ||
var columnStringList: RealmList<String>? = null | ||
var columnBinaryList: RealmList<ByteArray>? = null | ||
var columnBooleanList: RealmList<Boolean>? = null | ||
var columnLongList: RealmList<Long>? = null | ||
var columnDoubleList: RealmList<Double>? = null | ||
var columnFloatList: RealmList<Float>? = null | ||
var columnDateList: RealmList<Date>? = null | ||
var columnDecimal128List: RealmList<Decimal128>? = null | ||
|
||
var columnObjectIdList: RealmList<ObjectId>? = null | ||
|
||
fun setColumnMutableRealmInteger(value: Int) { | ||
columnRealmInteger.set(value.toLong()) | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2020 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. | ||
*/ | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. License is duplicated There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will fix in another PR along with the other |
||
* Copyright 2020 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.entities | ||
|
||
import io.realm.annotations.RealmModule | ||
|
||
/** | ||
* The set of classes initially supported by MongoDB Realm. | ||
*/ | ||
@RealmModule(classes = [SyncDog::class, SyncPerson::class, SyncAllTypes::class]) | ||
class SyncAllTypesSchema { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2020 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.entities | ||
|
||
import io.realm.RealmObject | ||
import io.realm.annotations.PrimaryKey | ||
import io.realm.annotations.RealmField | ||
import org.bson.types.ObjectId | ||
|
||
open class SyncStringOnly : RealmObject() { | ||
|
||
companion object { | ||
const val CLASS_NAME = "StringOnly" | ||
const val FIELD_CHARS = "chars" | ||
} | ||
|
||
@PrimaryKey | ||
@RealmField(name = "_id") | ||
var id = ObjectId() | ||
|
||
var chars: String? = null | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2020 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.entities | ||
|
||
import io.realm.annotations.RealmModule | ||
|
||
@RealmModule(classes = [SyncStringOnly::class]) | ||
class SyncStringOnlyModule |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright 2020 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.entities | ||
|
||
import io.realm.MutableRealmInteger | ||
import io.realm.RealmList | ||
import io.realm.RealmObject | ||
import io.realm.TestHelper | ||
import io.realm.annotations.PrimaryKey | ||
import io.realm.annotations.RealmField | ||
import io.realm.annotations.Required | ||
import org.bson.types.Decimal128 | ||
import org.bson.types.ObjectId | ||
import java.math.BigDecimal | ||
import java.util.* | ||
|
||
open class SyncSupportedTypes : RealmObject() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I get having both this class and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I introduced this one to enable successful testing while keeping the |
||
|
||
companion object { | ||
const val CLASS_NAME = "AllTypes" | ||
const val FIELD_STRING = "columnString" | ||
const val FIELD_LONG = "columnLong" | ||
const val FIELD_FLOAT = "columnFloat" | ||
const val FIELD_DOUBLE = "columnDouble" | ||
const val FIELD_BOOLEAN = "columnBoolean" | ||
const val FIELD_DATE = "columnDate" | ||
const val FIELD_BINARY = "columnBinary" | ||
const val FIELD_MUTABLEREALMINTEGER = "columnMutableRealmInteger" | ||
const val FIELD_DECIMAL128 = "columnDecimal128" | ||
const val FIELD_OBJECT_ID = "columnObjectId" | ||
const val FIELD_REALMOBJECT = "columnRealmObject" | ||
const val FIELD_REALMLIST = "columnRealmList" | ||
const val FIELD_STRING_LIST = "columnStringList" | ||
const val FIELD_BINARY_LIST = "columnBinaryList" | ||
const val FIELD_BOOLEAN_LIST = "columnBooleanList" | ||
const val FIELD_LONG_LIST = "columnLongList" | ||
const val FIELD_DOUBLE_LIST = "columnDoubleList" | ||
const val FIELD_FLOAT_LIST = "columnFloatList" | ||
const val FIELD_DATE_LIST = "columnDateList" | ||
val INVALID_TYPES_FIELDS_FOR_DISTINCT = arrayOf(FIELD_REALMOBJECT, FIELD_REALMLIST, FIELD_DOUBLE, FIELD_FLOAT, | ||
FIELD_STRING_LIST, FIELD_BINARY_LIST, FIELD_BOOLEAN_LIST, FIELD_LONG_LIST, | ||
FIELD_DOUBLE_LIST, FIELD_FLOAT_LIST, FIELD_DATE_LIST) | ||
} | ||
|
||
@PrimaryKey | ||
@RealmField(name = "_id") | ||
var id = ObjectId() | ||
|
||
@Required | ||
var columnString = "" | ||
var columnLong: Long = 0 | ||
var columnFloat = 0f | ||
var isColumnBoolean = false | ||
|
||
@Required | ||
var columnDate = Date(0) | ||
|
||
@Required | ||
var columnBinary = ByteArray(0) | ||
|
||
@Required | ||
var columnDecimal128 = Decimal128(BigDecimal.ZERO) | ||
|
||
@Required | ||
var columnObjectId = ObjectId(TestHelper.randomObjectIdHexString()) | ||
val columnRealmInteger = MutableRealmInteger.ofNull() | ||
var columnRealmObject: SyncDog? = null | ||
var columnRealmList: RealmList<SyncDog>? = null | ||
|
||
// FIXME These are the fields needed to be removed from SyncAllTypes for sync to work when | ||
// updating the partitionValue | ||
// var columnDouble = 0.0 | ||
// var columnStringList: RealmList<String>? = null | ||
// var columnBinaryList: RealmList<ByteArray>? = null | ||
// var columnBooleanList: RealmList<Boolean>? = null | ||
// var columnLongList: RealmList<Long>? = null | ||
// var columnDoubleList: RealmList<Double>? = null | ||
// var columnFloatList: RealmList<Float> = RealmList() | ||
// var columnDateList: RealmList<Date>? = null | ||
// var columnDecimal128List: RealmList<Decimal128>? = null | ||
|
||
// var columnObjectIdList: RealmList<ObjectId>? = null | ||
|
||
fun setColumnMutableRealmInteger(value: Int) { | ||
columnRealmInteger.set(value.toLong()) | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2020 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.mongodb.sync | ||
|
||
// Helper to expose package protected methods for testing purpose | ||
fun SyncSession.testClose() { | ||
this.close() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of these will fail unless made @required, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Tests using this are currently all ignore. It took me some time to realise that lists with null elements where not supported on the server. The initial upload worked and the subsequent sync failed because of mismatched schema as the server just "truncated" the
nullable
parameter on the initial upload. Issue is raised on the server. Will fix in another PR when the issue is also fixed on the server.