// File generated from our OpenAPI spec by Stainless.

package com.openai.models.responses

import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import com.openai.core.jsonMapper
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

internal class ResponseFunctionToolCallOutputItemTest {

    @Test
    fun create() {
        val responseFunctionToolCallOutputItem =
            ResponseFunctionToolCallOutputItem.builder()
                .id("id")
                .callId("call_id")
                .output("string")
                .status(ResponseFunctionToolCallOutputItem.Status.IN_PROGRESS)
                .createdBy("created_by")
                .build()

        assertThat(responseFunctionToolCallOutputItem.id()).isEqualTo("id")
        assertThat(responseFunctionToolCallOutputItem.callId()).isEqualTo("call_id")
        assertThat(responseFunctionToolCallOutputItem.output())
            .isEqualTo(ResponseFunctionToolCallOutputItem.Output.ofString("string"))
        assertThat(responseFunctionToolCallOutputItem.status())
            .isEqualTo(ResponseFunctionToolCallOutputItem.Status.IN_PROGRESS)
        assertThat(responseFunctionToolCallOutputItem.createdBy()).contains("created_by")
    }

    @Test
    fun roundtrip() {
        val jsonMapper = jsonMapper()
        val responseFunctionToolCallOutputItem =
            ResponseFunctionToolCallOutputItem.builder()
                .id("id")
                .callId("call_id")
                .output("string")
                .status(ResponseFunctionToolCallOutputItem.Status.IN_PROGRESS)
                .createdBy("created_by")
                .build()

        val roundtrippedResponseFunctionToolCallOutputItem =
            jsonMapper.readValue(
                jsonMapper.writeValueAsString(responseFunctionToolCallOutputItem),
                jacksonTypeRef<ResponseFunctionToolCallOutputItem>(),
            )

        assertThat(roundtrippedResponseFunctionToolCallOutputItem)
            .isEqualTo(responseFunctionToolCallOutputItem)
    }
}
