// File generated from our OpenAPI spec by Stainless.

package com.openai.models

import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

class ChatCompletionTest {

    @Test
    fun createChatCompletion() {
        val chatCompletion =
            ChatCompletion.builder()
                .id("id")
                .choices(
                    listOf(
                        ChatCompletion.Choice.builder()
                            .finishReason(ChatCompletion.Choice.FinishReason.STOP)
                            .index(0L)
                            .logprobs(
                                ChatCompletion.Choice.Logprobs.builder()
                                    .content(
                                        listOf(
                                            ChatCompletionTokenLogprob.builder()
                                                .token("token")
                                                .bytes(listOf(0L))
                                                .logprob(0.0)
                                                .topLogprobs(
                                                    listOf(
                                                        ChatCompletionTokenLogprob.TopLogprob
                                                            .builder()
                                                            .token("token")
                                                            .bytes(listOf(0L))
                                                            .logprob(0.0)
                                                            .build()
                                                    )
                                                )
                                                .build()
                                        )
                                    )
                                    .refusal(
                                        listOf(
                                            ChatCompletionTokenLogprob.builder()
                                                .token("token")
                                                .bytes(listOf(0L))
                                                .logprob(0.0)
                                                .topLogprobs(
                                                    listOf(
                                                        ChatCompletionTokenLogprob.TopLogprob
                                                            .builder()
                                                            .token("token")
                                                            .bytes(listOf(0L))
                                                            .logprob(0.0)
                                                            .build()
                                                    )
                                                )
                                                .build()
                                        )
                                    )
                                    .build()
                            )
                            .message(
                                ChatCompletionMessage.builder()
                                    .content("content")
                                    .refusal("refusal")
                                    .role(ChatCompletionMessage.Role.ASSISTANT)
                                    .audio(
                                        ChatCompletionAudio.builder()
                                            .id("id")
                                            .data("data")
                                            .expiresAt(0L)
                                            .transcript("transcript")
                                            .build()
                                    )
                                    .functionCall(
                                        ChatCompletionMessage.FunctionCall.builder()
                                            .arguments("arguments")
                                            .name("name")
                                            .build()
                                    )
                                    .toolCalls(
                                        listOf(
                                            ChatCompletionMessageToolCall.builder()
                                                .id("id")
                                                .function(
                                                    ChatCompletionMessageToolCall.Function.builder()
                                                        .arguments("arguments")
                                                        .name("name")
                                                        .build()
                                                )
                                                .type(ChatCompletionMessageToolCall.Type.FUNCTION)
                                                .build()
                                        )
                                    )
                                    .build()
                            )
                            .build()
                    )
                )
                .created(0L)
                .model("model")
                .object_(ChatCompletion.Object.CHAT_COMPLETION)
                .serviceTier(ChatCompletion.ServiceTier.SCALE)
                .systemFingerprint("system_fingerprint")
                .usage(
                    CompletionUsage.builder()
                        .completionTokens(0L)
                        .promptTokens(0L)
                        .totalTokens(0L)
                        .completionTokensDetails(
                            CompletionUsage.CompletionTokensDetails.builder()
                                .acceptedPredictionTokens(0L)
                                .audioTokens(0L)
                                .reasoningTokens(0L)
                                .rejectedPredictionTokens(0L)
                                .build()
                        )
                        .promptTokensDetails(
                            CompletionUsage.PromptTokensDetails.builder()
                                .audioTokens(0L)
                                .cachedTokens(0L)
                                .build()
                        )
                        .build()
                )
                .build()
        assertThat(chatCompletion).isNotNull
        assertThat(chatCompletion.id()).isEqualTo("id")
        assertThat(chatCompletion.choices())
            .containsExactly(
                ChatCompletion.Choice.builder()
                    .finishReason(ChatCompletion.Choice.FinishReason.STOP)
                    .index(0L)
                    .logprobs(
                        ChatCompletion.Choice.Logprobs.builder()
                            .content(
                                listOf(
                                    ChatCompletionTokenLogprob.builder()
                                        .token("token")
                                        .bytes(listOf(0L))
                                        .logprob(0.0)
                                        .topLogprobs(
                                            listOf(
                                                ChatCompletionTokenLogprob.TopLogprob.builder()
                                                    .token("token")
                                                    .bytes(listOf(0L))
                                                    .logprob(0.0)
                                                    .build()
                                            )
                                        )
                                        .build()
                                )
                            )
                            .refusal(
                                listOf(
                                    ChatCompletionTokenLogprob.builder()
                                        .token("token")
                                        .bytes(listOf(0L))
                                        .logprob(0.0)
                                        .topLogprobs(
                                            listOf(
                                                ChatCompletionTokenLogprob.TopLogprob.builder()
                                                    .token("token")
                                                    .bytes(listOf(0L))
                                                    .logprob(0.0)
                                                    .build()
                                            )
                                        )
                                        .build()
                                )
                            )
                            .build()
                    )
                    .message(
                        ChatCompletionMessage.builder()
                            .content("content")
                            .refusal("refusal")
                            .role(ChatCompletionMessage.Role.ASSISTANT)
                            .audio(
                                ChatCompletionAudio.builder()
                                    .id("id")
                                    .data("data")
                                    .expiresAt(0L)
                                    .transcript("transcript")
                                    .build()
                            )
                            .functionCall(
                                ChatCompletionMessage.FunctionCall.builder()
                                    .arguments("arguments")
                                    .name("name")
                                    .build()
                            )
                            .toolCalls(
                                listOf(
                                    ChatCompletionMessageToolCall.builder()
                                        .id("id")
                                        .function(
                                            ChatCompletionMessageToolCall.Function.builder()
                                                .arguments("arguments")
                                                .name("name")
                                                .build()
                                        )
                                        .type(ChatCompletionMessageToolCall.Type.FUNCTION)
                                        .build()
                                )
                            )
                            .build()
                    )
                    .build()
            )
        assertThat(chatCompletion.created()).isEqualTo(0L)
        assertThat(chatCompletion.model()).isEqualTo("model")
        assertThat(chatCompletion.object_()).isEqualTo(ChatCompletion.Object.CHAT_COMPLETION)
        assertThat(chatCompletion.serviceTier()).contains(ChatCompletion.ServiceTier.SCALE)
        assertThat(chatCompletion.systemFingerprint()).contains("system_fingerprint")
        assertThat(chatCompletion.usage())
            .contains(
                CompletionUsage.builder()
                    .completionTokens(0L)
                    .promptTokens(0L)
                    .totalTokens(0L)
                    .completionTokensDetails(
                        CompletionUsage.CompletionTokensDetails.builder()
                            .acceptedPredictionTokens(0L)
                            .audioTokens(0L)
                            .reasoningTokens(0L)
                            .rejectedPredictionTokens(0L)
                            .build()
                    )
                    .promptTokensDetails(
                        CompletionUsage.PromptTokensDetails.builder()
                            .audioTokens(0L)
                            .cachedTokens(0L)
                            .build()
                    )
                    .build()
            )
    }
}
