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(
|
return Filter(
|
||||||
ids = jsonObject.get("ids").mapNotNull { it.asTextOrNull() },
|
ids = jsonObject.get("ids")?.mapNotNull { it.asTextOrNull() },
|
||||||
authors = jsonObject.get("authors").mapNotNull { it.asTextOrNull() },
|
authors = jsonObject.get("authors")?.mapNotNull { it.asTextOrNull() },
|
||||||
kinds = jsonObject.get("kinds").mapNotNull { it.asIntOrNull() },
|
kinds = jsonObject.get("kinds")?.mapNotNull { it.asIntOrNull() },
|
||||||
tags = tagsIn.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() } },
|
tagsAll = tagsAll.associateWith { jsonObject.get(it).mapNotNull { it.asTextOrNull() } },
|
||||||
since = jsonObject.get("since").asLongOrNull(),
|
since = jsonObject.get("since")?.asLongOrNull(),
|
||||||
until = jsonObject.get("until").asLongOrNull(),
|
until = jsonObject.get("until")?.asLongOrNull(),
|
||||||
limit = jsonObject.get("limit").asIntOrNull(),
|
limit = jsonObject.get("limit")?.asIntOrNull(),
|
||||||
search = jsonObject.get("search").asTextOrNull(),
|
search = jsonObject.get("search")?.asTextOrNull(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
@@ -21,6 +21,7 @@
|
|||||||
package com.vitorpamplona.quartz.nip01Core.jackson
|
package com.vitorpamplona.quartz.nip01Core.jackson
|
||||||
|
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
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.nip01Core.signers.EventTemplate
|
||||||
import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent
|
import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent
|
||||||
import com.vitorpamplona.quartz.nip59Giftwrap.rumors.Rumor
|
import com.vitorpamplona.quartz.nip59Giftwrap.rumors.Rumor
|
||||||
@@ -152,4 +153,12 @@ class JacksonMapperTest {
|
|||||||
assertContentEquals(tag, deserialized.tags[index])
|
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