diff --git a/openai-gateway/openai-gateway-core/src/jvmTest/kotlin/com/tddworks/anthropic/api/messages/api/ContentMessageTest.kt b/openai-gateway/openai-gateway-core/src/jvmTest/kotlin/com/tddworks/anthropic/api/messages/api/ContentMessageTest.kt new file mode 100644 index 0000000..d3e4a2b --- /dev/null +++ b/openai-gateway/openai-gateway-core/src/jvmTest/kotlin/com/tddworks/anthropic/api/messages/api/ContentMessageTest.kt @@ -0,0 +1,15 @@ +package com.tddworks.anthropic.api.messages.api + +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test + +class ContentMessageTest { + + @Test + fun `should create a ContentMessage`() { + val dummyMessage = ContentMessage("Hi! My name is Claude.", "text") + + assertEquals("Hi! My name is Claude.", dummyMessage.text) + assertEquals("text", dummyMessage.type) + } +} \ No newline at end of file diff --git a/openai-gateway/openai-gateway-core/src/jvmTest/kotlin/com/tddworks/anthropic/api/messages/api/CreateMessageResponseTest.kt b/openai-gateway/openai-gateway-core/src/jvmTest/kotlin/com/tddworks/anthropic/api/messages/api/CreateMessageResponseTest.kt new file mode 100644 index 0000000..55bb815 --- /dev/null +++ b/openai-gateway/openai-gateway-core/src/jvmTest/kotlin/com/tddworks/anthropic/api/messages/api/CreateMessageResponseTest.kt @@ -0,0 +1,24 @@ +package com.tddworks.anthropic.api.messages.api + +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test + + +internal class CreateMessageResponseTest { + + @Test + fun `should create a dummy CreateMessageResponse`() { + + val dummyResponse = CreateMessageResponse.dummy() + + assertEquals("msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY", dummyResponse.id) + assertEquals("claude-3-opus-20240229", dummyResponse.model) + assertEquals("assistant", dummyResponse.role) + assertNull(dummyResponse.stopReason) + assertNull(dummyResponse.stopSequence) + assertEquals("message", dummyResponse.type) + assertEquals(Usage(25, 1), dummyResponse.usage) + assertEquals(listOf(ContentMessage("Hi! My name is Claude.", "text")), dummyResponse.content) + } + +} \ No newline at end of file diff --git a/openai-gateway/openai-gateway-core/src/jvmTest/kotlin/com/tddworks/anthropic/api/messages/api/DeltaTest.kt b/openai-gateway/openai-gateway-core/src/jvmTest/kotlin/com/tddworks/anthropic/api/messages/api/DeltaTest.kt new file mode 100644 index 0000000..758d1f0 --- /dev/null +++ b/openai-gateway/openai-gateway-core/src/jvmTest/kotlin/com/tddworks/anthropic/api/messages/api/DeltaTest.kt @@ -0,0 +1,19 @@ +package com.tddworks.anthropic.api.messages.api + +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test + + +class DeltaTest { + + @Test + fun `should create dummy Delta`() { + val delta = Delta.dummy() + assertEquals("text_delta", delta.type) + assertEquals("Hello", delta.text) + assertEquals("end_turn", delta.stopReason) + assertEquals(null, delta.stopSequence) + assertEquals(Usage(outputTokens = 15), delta.usage) + } + +} \ No newline at end of file diff --git a/openai-gateway/openai-gateway-core/src/jvmTest/kotlin/com/tddworks/anthropic/api/messages/api/UsageTest.kt b/openai-gateway/openai-gateway-core/src/jvmTest/kotlin/com/tddworks/anthropic/api/messages/api/UsageTest.kt new file mode 100644 index 0000000..3ffe821 --- /dev/null +++ b/openai-gateway/openai-gateway-core/src/jvmTest/kotlin/com/tddworks/anthropic/api/messages/api/UsageTest.kt @@ -0,0 +1,35 @@ +package com.tddworks.anthropic.api.messages.api + +import kotlinx.serialization.encodeToString +import kotlinx.serialization.json.Json +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test + +class UsageTest { + @Test + fun `should create a empty Usage`() { + val usage = Usage() + val json = Json.encodeToString(usage) + + val expectedJson = "{}" + assertEquals(expectedJson, json) + } + + @Test + fun `should create a dummy Usage`() { + val usage = Usage(inputTokens = 10, outputTokens = 20) + val json = Json.encodeToString(usage) + + val expectedJson = "{\"input_tokens\":10,\"output_tokens\":20}" + assertEquals(expectedJson, json) + } + + @Test + fun `should parse a Usage from json`() { + val json = "{\"input_tokens\":5,\"output_tokens\":15}" + val usage = Json.decodeFromString(json) + + assertEquals(5, usage.inputTokens) + assertEquals(15, usage.outputTokens) + } +} \ No newline at end of file