// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.machinelearning.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.machinelearning.models.StackEnsembleSettings;
import com.azure.resourcemanager.machinelearning.models.StackMetaLearnerType;
import com.azure.resourcemanager.machinelearning.models.TrainingSettings;
import java.time.Duration;
import org.junit.jupiter.api.Assertions;

public final class TrainingSettingsTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        TrainingSettings model =
            BinaryData
                .fromString(
                    "{\"enableDnnTraining\":false,\"enableModelExplainability\":false,\"enableOnnxCompatibleModels\":true,\"enableStackEnsemble\":false,\"enableVoteEnsemble\":false,\"ensembleModelDownloadTimeout\":\"PT109H29M10S\",\"stackEnsembleSettings\":{\"stackMetaLearnerKWargs\":\"datajtasbvwispk\",\"stackMetaLearnerTrainPercentage\":99.23936213293845,\"stackMetaLearnerType\":\"LogisticRegressionCV\"}}")
                .toObject(TrainingSettings.class);
        Assertions.assertEquals(false, model.enableDnnTraining());
        Assertions.assertEquals(false, model.enableModelExplainability());
        Assertions.assertEquals(true, model.enableOnnxCompatibleModels());
        Assertions.assertEquals(false, model.enableStackEnsemble());
        Assertions.assertEquals(false, model.enableVoteEnsemble());
        Assertions.assertEquals(Duration.parse("PT109H29M10S"), model.ensembleModelDownloadTimeout());
        Assertions.assertEquals(99.23936213293845D, model.stackEnsembleSettings().stackMetaLearnerTrainPercentage());
        Assertions
            .assertEquals(
                StackMetaLearnerType.LOGISTIC_REGRESSION_CV, model.stackEnsembleSettings().stackMetaLearnerType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        TrainingSettings model =
            new TrainingSettings()
                .withEnableDnnTraining(false)
                .withEnableModelExplainability(false)
                .withEnableOnnxCompatibleModels(true)
                .withEnableStackEnsemble(false)
                .withEnableVoteEnsemble(false)
                .withEnsembleModelDownloadTimeout(Duration.parse("PT109H29M10S"))
                .withStackEnsembleSettings(
                    new StackEnsembleSettings()
                        .withStackMetaLearnerKWargs("datajtasbvwispk")
                        .withStackMetaLearnerTrainPercentage(99.23936213293845D)
                        .withStackMetaLearnerType(StackMetaLearnerType.LOGISTIC_REGRESSION_CV));
        model = BinaryData.fromObject(model).toObject(TrainingSettings.class);
        Assertions.assertEquals(false, model.enableDnnTraining());
        Assertions.assertEquals(false, model.enableModelExplainability());
        Assertions.assertEquals(true, model.enableOnnxCompatibleModels());
        Assertions.assertEquals(false, model.enableStackEnsemble());
        Assertions.assertEquals(false, model.enableVoteEnsemble());
        Assertions.assertEquals(Duration.parse("PT109H29M10S"), model.ensembleModelDownloadTimeout());
        Assertions.assertEquals(99.23936213293845D, model.stackEnsembleSettings().stackMetaLearnerTrainPercentage());
        Assertions
            .assertEquals(
                StackMetaLearnerType.LOGISTIC_REGRESSION_CV, model.stackEnsembleSettings().stackMetaLearnerType());
    }
}
