fix Jackson deserialization for empty Filters and add regression test
This commit is contained in:
+7
-7
@@ -52,15 +52,15 @@ class ManualFilterDeserializer {
|
||||
}
|
||||
|
||||
return Filter(
|
||||
ids = jsonObject.get("ids").mapNotNull { it.asTextOrNull() },
|
||||
authors = jsonObject.get("authors").mapNotNull { it.asTextOrNull() },
|
||||
kinds = jsonObject.get("kinds").mapNotNull { it.asIntOrNull() },
|
||||
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() } },
|
||||
since = jsonObject.get("since").asLongOrNull(),
|
||||
until = jsonObject.get("until").asLongOrNull(),
|
||||
limit = jsonObject.get("limit").asIntOrNull(),
|
||||
search = jsonObject.get("search").asTextOrNull(),
|
||||
since = jsonObject.get("since")?.asLongOrNull(),
|
||||
until = jsonObject.get("until")?.asLongOrNull(),
|
||||
limit = jsonObject.get("limit")?.asIntOrNull(),
|
||||
search = jsonObject.get("search")?.asTextOrNull(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -21,6 +21,7 @@
|
||||
package com.vitorpamplona.quartz.nip01Core.jackson
|
||||
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
|
||||
import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
|
||||
import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.rumors.Rumor
|
||||
@@ -152,4 +153,12 @@ class JacksonMapperTest {
|
||||
assertContentEquals(tag, deserialized.tags[index])
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldNotThrowExceptionWhenDeserializingEmptyFilter() {
|
||||
val json = Filter().toJson()
|
||||
val deserialized = JacksonMapper.fromJsonTo<Filter>(json)
|
||||
|
||||
assertEquals(deserialized.ids, null)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user