mirror of https://github.com/usbharu/Hideout.git
test: JsonLDのシリアライズのテストを追加
This commit is contained in:
parent
4ee71416d9
commit
822c57c02b
|
@ -176,4 +176,74 @@ class JsonLdSerializeTest {
|
|||
|
||||
assertEquals("""{"@context":["https://example.com","https://www.w3.org/ns/activitystreams"]}""", actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun contextがオブジェクトのときシリアライズできる() {
|
||||
val jsonLd = JsonLd(
|
||||
listOf(
|
||||
StringOrObject(mapOf("hoge" to "fuga"))
|
||||
)
|
||||
)
|
||||
|
||||
val objectMapper = ActivityPubConfig().objectMapper()
|
||||
|
||||
val actual = objectMapper.writeValueAsString(jsonLd)
|
||||
|
||||
assertEquals("""{"@context":{"hoge":"fuga"}}""", actual)
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun contextが複数のオブジェクトのときシリアライズできる() {
|
||||
val jsonLd = JsonLd(
|
||||
listOf(
|
||||
StringOrObject(mapOf("hoge" to "fuga")),
|
||||
StringOrObject(mapOf("foo" to "bar"))
|
||||
)
|
||||
)
|
||||
|
||||
val objectMapper = ActivityPubConfig().objectMapper()
|
||||
|
||||
val actual = objectMapper.writeValueAsString(jsonLd)
|
||||
|
||||
assertEquals("""{"@context":[{"hoge":"fuga"},{"foo":"bar"}]}""", actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun contextが複数のオブジェクトのときデシリアライズできる() {
|
||||
//language=JSON
|
||||
val json = """{"@context":["https://example.com",{"hoge": "fuga"},{"foo": "bar"}]}"""
|
||||
|
||||
val objectMapper = ActivityPubConfig().objectMapper()
|
||||
|
||||
val readValue = objectMapper.readValue<JsonLd>(json)
|
||||
|
||||
assertEquals(
|
||||
JsonLd(
|
||||
listOf(
|
||||
StringOrObject("https://example.com"),
|
||||
StringOrObject(mapOf("hoge" to "fuga")),
|
||||
StringOrObject(mapOf("foo" to "bar"))
|
||||
)
|
||||
), readValue
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun contextがオブジェクトのときデシリアライズできる() {
|
||||
//language=JSON
|
||||
val json = """{"@context":{"hoge": "fuga"}}"""
|
||||
|
||||
val objectMapper = ActivityPubConfig().objectMapper()
|
||||
|
||||
val readValue = objectMapper.readValue<JsonLd>(json)
|
||||
|
||||
assertEquals(
|
||||
JsonLd(
|
||||
listOf(
|
||||
StringOrObject(mapOf("hoge" to "fuga"))
|
||||
)
|
||||
), readValue
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue