Fixed NullPointerException when filter contain tags
This commit is contained in:
+2
-2
@@ -55,8 +55,8 @@ class ManualFilterDeserializer {
|
||||
ids = jsonObject.get("ids")?.mapNotNull { it.asTextOrNull() },
|
||||
authors = jsonObject.get("authors")?.mapNotNull { it.asTextOrNull() },
|
||||
kinds = jsonObject.get("kinds")?.mapNotNull { it.asIntOrNull() },
|
||||
tags = tagsIn.associateWith { jsonObject.get(it).mapNotNull { it.asTextOrNull() } },
|
||||
tagsAll = tagsAll.associateWith { jsonObject.get(it).mapNotNull { it.asTextOrNull() } },
|
||||
tags = tagsIn.associateWith { jsonObject.get("#$it").mapNotNull { it.asTextOrNull() } },
|
||||
tagsAll = tagsAll.associateWith { jsonObject.get("&$it").mapNotNull { it.asTextOrNull() } },
|
||||
since = jsonObject.get("since")?.asLongOrNull(),
|
||||
until = jsonObject.get("until")?.asLongOrNull(),
|
||||
limit = jsonObject.get("limit")?.asIntOrNull(),
|
||||
|
||||
+13
@@ -161,4 +161,17 @@ class JacksonMapperTest {
|
||||
|
||||
assertEquals(null, deserialized.ids)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldNotThrowExceptionWhenDeserializingFilterTags() {
|
||||
val json =
|
||||
Filter(
|
||||
tags = mapOf("p" to listOf("123")),
|
||||
tagsAll = mapOf("p" to listOf("123")),
|
||||
).toJson()
|
||||
val deserialized = JacksonMapper.fromJsonTo<Filter>(json)
|
||||
|
||||
assertEquals(true, deserialized.tags?.keys?.contains("p"))
|
||||
assertEquals(true, deserialized.tagsAll?.keys?.contains("p"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user