// 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 FineTuningJobTest {

    @Test
    fun createFineTuningJob() {
        val fineTuningJob =
            FineTuningJob.builder()
                .id("id")
                .createdAt(0L)
                .error(
                    FineTuningJob.Error.builder()
                        .code("code")
                        .message("message")
                        .param("param")
                        .build()
                )
                .fineTunedModel("fine_tuned_model")
                .finishedAt(0L)
                .hyperparameters(
                    FineTuningJob.Hyperparameters.builder()
                        .batchSize(FineTuningJob.Hyperparameters.BatchSize.Auto.AUTO)
                        .learningRateMultiplier(
                            FineTuningJob.Hyperparameters.LearningRateMultiplier.Auto.AUTO
                        )
                        .nEpochs(FineTuningJob.Hyperparameters.NEpochs.Behavior.AUTO)
                        .build()
                )
                .model("model")
                .object_(FineTuningJob.Object.FINE_TUNING_JOB)
                .organizationId("organization_id")
                .addResultFile("file-abc123")
                .seed(0L)
                .status(FineTuningJob.Status.VALIDATING_FILES)
                .trainedTokens(0L)
                .trainingFile("training_file")
                .validationFile("validation_file")
                .estimatedFinish(0L)
                .addIntegration(
                    FineTuningJobWandbIntegrationObject.builder()
                        .type(FineTuningJobWandbIntegrationObject.Type.WANDB)
                        .wandb(
                            FineTuningJobWandbIntegration.builder()
                                .project("my-wandb-project")
                                .entity("entity")
                                .name("name")
                                .addTag("custom-tag")
                                .build()
                        )
                        .build()
                )
                .method(
                    FineTuningJob.Method.builder()
                        .dpo(
                            FineTuningJob.Method.Dpo.builder()
                                .hyperparameters(
                                    FineTuningJob.Method.Dpo.Hyperparameters.builder()
                                        .batchSize(
                                            FineTuningJob.Method.Dpo.Hyperparameters.BatchSize.Auto
                                                .AUTO
                                        )
                                        .beta(
                                            FineTuningJob.Method.Dpo.Hyperparameters.Beta.Auto.AUTO
                                        )
                                        .learningRateMultiplier(
                                            FineTuningJob.Method.Dpo.Hyperparameters
                                                .LearningRateMultiplier
                                                .Auto
                                                .AUTO
                                        )
                                        .nEpochs(
                                            FineTuningJob.Method.Dpo.Hyperparameters.NEpochs.Auto
                                                .AUTO
                                        )
                                        .build()
                                )
                                .build()
                        )
                        .supervised(
                            FineTuningJob.Method.Supervised.builder()
                                .hyperparameters(
                                    FineTuningJob.Method.Supervised.Hyperparameters.builder()
                                        .batchSize(
                                            FineTuningJob.Method.Supervised.Hyperparameters
                                                .BatchSize
                                                .Auto
                                                .AUTO
                                        )
                                        .learningRateMultiplier(
                                            FineTuningJob.Method.Supervised.Hyperparameters
                                                .LearningRateMultiplier
                                                .Auto
                                                .AUTO
                                        )
                                        .nEpochs(
                                            FineTuningJob.Method.Supervised.Hyperparameters.NEpochs
                                                .Auto
                                                .AUTO
                                        )
                                        .build()
                                )
                                .build()
                        )
                        .type(FineTuningJob.Method.Type.SUPERVISED)
                        .build()
                )
                .build()
        assertThat(fineTuningJob).isNotNull
        assertThat(fineTuningJob.id()).isEqualTo("id")
        assertThat(fineTuningJob.createdAt()).isEqualTo(0L)
        assertThat(fineTuningJob.error())
            .contains(
                FineTuningJob.Error.builder().code("code").message("message").param("param").build()
            )
        assertThat(fineTuningJob.fineTunedModel()).contains("fine_tuned_model")
        assertThat(fineTuningJob.finishedAt()).contains(0L)
        assertThat(fineTuningJob.hyperparameters())
            .isEqualTo(
                FineTuningJob.Hyperparameters.builder()
                    .batchSize(FineTuningJob.Hyperparameters.BatchSize.Auto.AUTO)
                    .learningRateMultiplier(
                        FineTuningJob.Hyperparameters.LearningRateMultiplier.Auto.AUTO
                    )
                    .nEpochs(FineTuningJob.Hyperparameters.NEpochs.Behavior.AUTO)
                    .build()
            )
        assertThat(fineTuningJob.model()).isEqualTo("model")
        assertThat(fineTuningJob.object_()).isEqualTo(FineTuningJob.Object.FINE_TUNING_JOB)
        assertThat(fineTuningJob.organizationId()).isEqualTo("organization_id")
        assertThat(fineTuningJob.resultFiles()).containsExactly("file-abc123")
        assertThat(fineTuningJob.seed()).isEqualTo(0L)
        assertThat(fineTuningJob.status()).isEqualTo(FineTuningJob.Status.VALIDATING_FILES)
        assertThat(fineTuningJob.trainedTokens()).contains(0L)
        assertThat(fineTuningJob.trainingFile()).isEqualTo("training_file")
        assertThat(fineTuningJob.validationFile()).contains("validation_file")
        assertThat(fineTuningJob.estimatedFinish()).contains(0L)
        assertThat(fineTuningJob.integrations().get())
            .containsExactly(
                FineTuningJobWandbIntegrationObject.builder()
                    .type(FineTuningJobWandbIntegrationObject.Type.WANDB)
                    .wandb(
                        FineTuningJobWandbIntegration.builder()
                            .project("my-wandb-project")
                            .entity("entity")
                            .name("name")
                            .addTag("custom-tag")
                            .build()
                    )
                    .build()
            )
        assertThat(fineTuningJob.method())
            .contains(
                FineTuningJob.Method.builder()
                    .dpo(
                        FineTuningJob.Method.Dpo.builder()
                            .hyperparameters(
                                FineTuningJob.Method.Dpo.Hyperparameters.builder()
                                    .batchSize(
                                        FineTuningJob.Method.Dpo.Hyperparameters.BatchSize.Auto.AUTO
                                    )
                                    .beta(FineTuningJob.Method.Dpo.Hyperparameters.Beta.Auto.AUTO)
                                    .learningRateMultiplier(
                                        FineTuningJob.Method.Dpo.Hyperparameters
                                            .LearningRateMultiplier
                                            .Auto
                                            .AUTO
                                    )
                                    .nEpochs(
                                        FineTuningJob.Method.Dpo.Hyperparameters.NEpochs.Auto.AUTO
                                    )
                                    .build()
                            )
                            .build()
                    )
                    .supervised(
                        FineTuningJob.Method.Supervised.builder()
                            .hyperparameters(
                                FineTuningJob.Method.Supervised.Hyperparameters.builder()
                                    .batchSize(
                                        FineTuningJob.Method.Supervised.Hyperparameters.BatchSize
                                            .Auto
                                            .AUTO
                                    )
                                    .learningRateMultiplier(
                                        FineTuningJob.Method.Supervised.Hyperparameters
                                            .LearningRateMultiplier
                                            .Auto
                                            .AUTO
                                    )
                                    .nEpochs(
                                        FineTuningJob.Method.Supervised.Hyperparameters.NEpochs.Auto
                                            .AUTO
                                    )
                                    .build()
                            )
                            .build()
                    )
                    .type(FineTuningJob.Method.Type.SUPERVISED)
                    .build()
            )
    }
}
