1 package net.pterodactylus.sone.utils
3 import com.fasterxml.jackson.databind.node.ArrayNode
4 import com.fasterxml.jackson.databind.node.ObjectNode
5 import org.hamcrest.MatcherAssert.assertThat
6 import org.hamcrest.Matchers.equalTo
7 import org.hamcrest.Matchers.instanceOf
11 * Unit test for JSON utilities.
16 fun `object node is created correctly`() {
17 val objectNode = jsonObject {
20 assertThat(objectNode, instanceOf(ObjectNode::class.java))
21 assertThat(objectNode.toString(), equalTo("{\"foo\":\"bar\"}"))
25 fun `array node is created correctly`() {
26 val arrayNode = listOf(
27 jsonObject { put("foo", "bar") },
28 jsonObject { put("baz", "quo") }
30 assertThat(arrayNode, instanceOf(ArrayNode::class.java))
31 assertThat(arrayNode.toString(), equalTo("[{\"foo\":\"bar\"},{\"baz\":\"quo\"}]"))
35 fun `array is created correctly for strings`() {
36 val arrayNode = jsonArray("foo", "bar", "baz")
37 assertThat(arrayNode.toString(), equalTo("[\"foo\",\"bar\",\"baz\"]"))