-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1884 from /issues/1874-deserialize-tag-with-ident…
…ical-method-name Update PropertiesModel's deserialization of tags to not use `Model.initializeFromJson`
- Loading branch information
Showing
3 changed files
with
42 additions
and
1 deletion.
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
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
38 changes: 38 additions & 0 deletions
38
...esignal/core/src/test/java/com/onesignal/user/internal/properties/PropertiesModelTests.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,38 @@ | ||
package com.onesignal.user.internal.properties | ||
|
||
import com.onesignal.common.putJSONObject | ||
import io.kotest.core.spec.style.FunSpec | ||
import io.kotest.matchers.shouldBe | ||
import io.kotest.runner.junit4.KotestTestRunner | ||
import org.json.JSONObject | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(KotestTestRunner::class) | ||
class PropertiesModelTests : FunSpec({ | ||
|
||
test("successfully initializes varying tag names") { | ||
/* Given */ | ||
val varyingTags = JSONObject() | ||
.putJSONObject(PropertiesModel::tags.name) { | ||
it.put("value", "data1") | ||
.put("isEmpty", "data2") | ||
.put("object", "data3") | ||
.put("1", "data4") | ||
.put("false", "data5") | ||
.put("15.7", "data6") | ||
} | ||
val propertiesModel = PropertiesModel() | ||
|
||
/* When */ | ||
propertiesModel.initializeFromJson(varyingTags) | ||
val tagsModel = propertiesModel.tags | ||
|
||
/* Then */ | ||
tagsModel["value"] shouldBe "data1" | ||
tagsModel["isEmpty"] shouldBe "data2" | ||
tagsModel["object"] shouldBe "data3" | ||
tagsModel["1"] shouldBe "data4" | ||
tagsModel["false"] shouldBe "data5" | ||
tagsModel["15.7"] shouldBe "data6" | ||
} | ||
}) |