|
|
|
@ -22,12 +22,11 @@ class CustomFieldFilterInstrumentedUnitTest : BaseFilterInstrumentedUnitTest() { |
|
|
|
val realm = this.mockRealm |
|
|
|
val realm = this.mockRealm |
|
|
|
realm.beginTransaction() |
|
|
|
realm.beginTransaction() |
|
|
|
|
|
|
|
|
|
|
|
val cf1 = CustomField() |
|
|
|
val cf1 = realm.createObject(CustomField::class.java, "1") |
|
|
|
cf1.id = "1" |
|
|
|
|
|
|
|
cf1.type = CustomField.Type.LIST.ordinal |
|
|
|
cf1.type = CustomField.Type.LIST.ordinal |
|
|
|
|
|
|
|
|
|
|
|
val cfe1 = CustomFieldEntry() |
|
|
|
val cfe1 = realm.createObject(CustomFieldEntry::class.java, "9") |
|
|
|
val cfe2 = CustomFieldEntry() |
|
|
|
val cfe2 = realm.createObject(CustomFieldEntry::class.java, "8") |
|
|
|
cfe1.value = "super" |
|
|
|
cfe1.value = "super" |
|
|
|
cfe2.value = "nul" |
|
|
|
cfe2.value = "nul" |
|
|
|
|
|
|
|
|
|
|
|
@ -51,24 +50,21 @@ class CustomFieldFilterInstrumentedUnitTest : BaseFilterInstrumentedUnitTest() { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
fun testCustomFieldAmountFilter() { |
|
|
|
fun testCustomFieldAmountFilter() { |
|
|
|
|
|
|
|
|
|
|
|
val cf1Id = "1234" |
|
|
|
val cfId = "1234" |
|
|
|
var s2Id = "" |
|
|
|
var s2Id = "" |
|
|
|
|
|
|
|
|
|
|
|
val realm = this.mockRealm |
|
|
|
val realm = this.mockRealm |
|
|
|
realm.executeTransaction { |
|
|
|
realm.executeTransaction { |
|
|
|
|
|
|
|
|
|
|
|
val cf1 = CustomField() |
|
|
|
val cf = realm.createObject(CustomField::class.java, cfId) |
|
|
|
cf1.id = cf1Id |
|
|
|
cf.type = CustomField.Type.AMOUNT.ordinal |
|
|
|
cf1.type = CustomField.Type.AMOUNT.ordinal |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val cfe1 = CustomFieldEntry() |
|
|
|
val cfe1 = realm.createObject(CustomFieldEntry::class.java, "999") |
|
|
|
cfe1.id = "999" |
|
|
|
cf.entries.add(cfe1) |
|
|
|
cf1.entries.add(cfe1) |
|
|
|
|
|
|
|
cfe1.numericValue = 30.0 |
|
|
|
cfe1.numericValue = 30.0 |
|
|
|
|
|
|
|
|
|
|
|
val cfe2 = CustomFieldEntry() |
|
|
|
val cfe2 = realm.createObject(CustomFieldEntry::class.java, "888") |
|
|
|
cfe2.id = "888" |
|
|
|
cf.entries.add(cfe2) |
|
|
|
cf1.entries.add(cfe2) |
|
|
|
|
|
|
|
cfe2.numericValue = 100.0 |
|
|
|
cfe2.numericValue = 100.0 |
|
|
|
|
|
|
|
|
|
|
|
val s1 = Session.testInstance(100.0, false, Date(), 1) |
|
|
|
val s1 = Session.testInstance(100.0, false, Date(), 1) |
|
|
|
@ -78,7 +74,7 @@ class CustomFieldFilterInstrumentedUnitTest : BaseFilterInstrumentedUnitTest() { |
|
|
|
s2Id = s2.id |
|
|
|
s2Id = s2.id |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val condition = QueryCondition.CustomFieldNumberQuery(cf1Id, 100.0) |
|
|
|
val condition = QueryCondition.CustomFieldNumberQuery(cfId, 100.0) |
|
|
|
val sessions = Filter.queryOn<Session>(realm, Query(condition)) |
|
|
|
val sessions = Filter.queryOn<Session>(realm, Query(condition)) |
|
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(1, sessions.size) |
|
|
|
Assert.assertEquals(1, sessions.size) |
|
|
|
|