From 3c7a7dad021db1dec4af665eba30bc8ab7358f73 Mon Sep 17 00:00:00 2001 From: Neal Date: Wed, 31 Jan 2024 11:17:00 -0600 Subject: [PATCH] naming updates --- ...ageTest.kt => TbdexTestVectorsProtocol.kt} | 49 ++++++++++++++----- .../protocol/TbdexTestVectorsResourceTest.kt | 29 ----------- 2 files changed, 37 insertions(+), 41 deletions(-) rename protocol/src/test/kotlin/tbdex/sdk/protocol/{TbdexTestVectorsMessageTest.kt => TbdexTestVectorsProtocol.kt} (55%) delete mode 100644 protocol/src/test/kotlin/tbdex/sdk/protocol/TbdexTestVectorsResourceTest.kt diff --git a/protocol/src/test/kotlin/tbdex/sdk/protocol/TbdexTestVectorsMessageTest.kt b/protocol/src/test/kotlin/tbdex/sdk/protocol/TbdexTestVectorsProtocol.kt similarity index 55% rename from protocol/src/test/kotlin/tbdex/sdk/protocol/TbdexTestVectorsMessageTest.kt rename to protocol/src/test/kotlin/tbdex/sdk/protocol/TbdexTestVectorsProtocol.kt index 9144418d..c6ff4080 100644 --- a/protocol/src/test/kotlin/tbdex/sdk/protocol/TbdexTestVectorsMessageTest.kt +++ b/protocol/src/test/kotlin/tbdex/sdk/protocol/TbdexTestVectorsProtocol.kt @@ -4,53 +4,68 @@ import com.fasterxml.jackson.databind.JsonNode import org.junit.jupiter.api.Test import tbdex.sdk.protocol.models.Close import tbdex.sdk.protocol.models.Message +import tbdex.sdk.protocol.models.Offering import tbdex.sdk.protocol.models.Order import tbdex.sdk.protocol.models.OrderStatus import tbdex.sdk.protocol.models.Quote +import tbdex.sdk.protocol.models.Resource import tbdex.sdk.protocol.models.Rfq import tbdex.sdk.protocol.serialization.Json import kotlin.test.assertEquals import kotlin.test.assertIs import kotlin.test.assertNotNull -class TbdexTestVectorsMessageTest { +class TbdexTestVectorsProtocol { + /** + * Tbdex Test Vectors Message Tests + */ @Test - fun `parse-close json`() { + fun parse_close() { val vector = TestVectors.getVector("parse-close.json") assertNotNull(vector) - testNonErrorTestVector(vector) + testNonErrorMessageTestVector(vector) } @Test - fun `parse-order json`() { + fun parse_order() { val vector = TestVectors.getVector("parse-order.json") assertNotNull(vector) - testNonErrorTestVector(vector) + testNonErrorMessageTestVector(vector) } @Test - fun `parse-orderstatus json`() { + fun parse_orderstatus() { val vector = TestVectors.getVector("parse-orderstatus.json") assertNotNull(vector) - testNonErrorTestVector(vector) + testNonErrorMessageTestVector(vector) } @Test - fun `parse-quote json`() { + fun parse_quote() { val vector = TestVectors.getVector("parse-quote.json") assertNotNull(vector) - testNonErrorTestVector(vector) + testNonErrorMessageTestVector(vector) } @Test - fun `parse-rfq json`() { + fun parse_rfq() { val vector = TestVectors.getVector("parse-rfq.json") assertNotNull(vector) - testNonErrorTestVector(vector) + testNonErrorMessageTestVector(vector) } - private inline fun testNonErrorTestVector(vector: JsonNode) { + /** + * Tbdex Test Vectors Resource Tests + */ + @Test + fun parse_offering() { + val vector = TestVectors.getVector("parse-offering.json") + assertNotNull(vector) + testNonErrorResourceTestVector(vector) + } + + private inline fun testNonErrorMessageTestVector(vector: JsonNode) { val input = vector["input"].textValue() assertNotNull(input) @@ -60,6 +75,16 @@ class TbdexTestVectorsMessageTest { assertEquals(vector["output"], Json.jsonMapper.readTree(tbDEXMessage.toString())) } + private inline fun testNonErrorResourceTestVector(vector: JsonNode) { + val input = vector["input"].textValue() + assertNotNull(input) + + val tbDEXMessage = Resource.parse(input) + assertIs(tbDEXMessage) + + assertEquals(vector["output"], Json.jsonMapper.readTree(tbDEXMessage.toString())) + } + // When we create test vectors with `error: true` // private fun testErrorTestVector(vector: JsonNode) { // val input = vector["input"].textValue() diff --git a/protocol/src/test/kotlin/tbdex/sdk/protocol/TbdexTestVectorsResourceTest.kt b/protocol/src/test/kotlin/tbdex/sdk/protocol/TbdexTestVectorsResourceTest.kt deleted file mode 100644 index 4b7ce389..00000000 --- a/protocol/src/test/kotlin/tbdex/sdk/protocol/TbdexTestVectorsResourceTest.kt +++ /dev/null @@ -1,29 +0,0 @@ -package tbdex.sdk.protocol - -import com.fasterxml.jackson.databind.JsonNode -import tbdex.sdk.protocol.models.Offering -import tbdex.sdk.protocol.models.Resource -import tbdex.sdk.protocol.serialization.Json -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertIs -import kotlin.test.assertNotNull - -class TbdexTestVectorsResourceTest { - @Test - fun `parse-offering json`() { - val vector = TestVectors.getVector("parse-offering.json") - assertNotNull(vector) - testNonErrorTestVector(vector) - } - - private inline fun testNonErrorTestVector(vector: JsonNode) { - val input = vector["input"].textValue() - assertNotNull(input) - - val tbDEXMessage = Resource.parse(input) - assertIs(tbDEXMessage) - - assertEquals(vector["output"], Json.jsonMapper.readTree(tbDEXMessage.toString())) - } -} \ No newline at end of file