// 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.RegressionModels;
import com.azure.resourcemanager.machinelearning.models.RegressionTrainingSettings;
import com.azure.resourcemanager.machinelearning.models.StackEnsembleSettings;
import com.azure.resourcemanager.machinelearning.models.StackMetaLearnerType;
import java.time.Duration;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class RegressionTrainingSettingsTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RegressionTrainingSettings model =
            BinaryData
                .fromString(
                    "{\"allowedTrainingAlgorithms\":[\"LightGBM\"],\"blockedTrainingAlgorithms\":[\"DecisionTree\"],\"enableDnnTraining\":true,\"enableModelExplainability\":false,\"enableOnnxCompatibleModels\":true,\"enableStackEnsemble\":true,\"enableVoteEnsemble\":true,\"ensembleModelDownloadTimeout\":\"PT173H34M23S\",\"stackEnsembleSettings\":{\"stackMetaLearnerKWargs\":\"datakiceevsaaxwsp\",\"stackMetaLearnerTrainPercentage\":33.77569584333657,\"stackMetaLearnerType\":\"LightGBMRegressor\"}}")
                .toObject(RegressionTrainingSettings.class);
        Assertions.assertEquals(true, model.enableDnnTraining());
        Assertions.assertEquals(false, model.enableModelExplainability());
        Assertions.assertEquals(true, model.enableOnnxCompatibleModels());
        Assertions.assertEquals(true, model.enableStackEnsemble());
        Assertions.assertEquals(true, model.enableVoteEnsemble());
        Assertions.assertEquals(Duration.parse("PT173H34M23S"), model.ensembleModelDownloadTimeout());
        Assertions.assertEquals(33.77569584333657D, model.stackEnsembleSettings().stackMetaLearnerTrainPercentage());
        Assertions
            .assertEquals(
                StackMetaLearnerType.LIGHT_GBMREGRESSOR, model.stackEnsembleSettings().stackMetaLearnerType());
        Assertions.assertEquals(RegressionModels.LIGHT_GBM, model.allowedTrainingAlgorithms().get(0));
        Assertions.assertEquals(RegressionModels.DECISION_TREE, model.blockedTrainingAlgorithms().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RegressionTrainingSettings model =
            new RegressionTrainingSettings()
                .withEnableDnnTraining(true)
                .withEnableModelExplainability(false)
                .withEnableOnnxCompatibleModels(true)
                .withEnableStackEnsemble(true)
                .withEnableVoteEnsemble(true)
                .withEnsembleModelDownloadTimeout(Duration.parse("PT173H34M23S"))
                .withStackEnsembleSettings(
                    new StackEnsembleSettings()
                        .withStackMetaLearnerKWargs("datakiceevsaaxwsp")
                        .withStackMetaLearnerTrainPercentage(33.77569584333657D)
                        .withStackMetaLearnerType(StackMetaLearnerType.LIGHT_GBMREGRESSOR))
                .withAllowedTrainingAlgorithms(Arrays.asList(RegressionModels.LIGHT_GBM))
                .withBlockedTrainingAlgorithms(Arrays.asList(RegressionModels.DECISION_TREE));
        model = BinaryData.fromObject(model).toObject(RegressionTrainingSettings.class);
        Assertions.assertEquals(true, model.enableDnnTraining());
        Assertions.assertEquals(false, model.enableModelExplainability());
        Assertions.assertEquals(true, model.enableOnnxCompatibleModels());
        Assertions.assertEquals(true, model.enableStackEnsemble());
        Assertions.assertEquals(true, model.enableVoteEnsemble());
        Assertions.assertEquals(Duration.parse("PT173H34M23S"), model.ensembleModelDownloadTimeout());
        Assertions.assertEquals(33.77569584333657D, model.stackEnsembleSettings().stackMetaLearnerTrainPercentage());
        Assertions
            .assertEquals(
                StackMetaLearnerType.LIGHT_GBMREGRESSOR, model.stackEnsembleSettings().stackMetaLearnerType());
        Assertions.assertEquals(RegressionModels.LIGHT_GBM, model.allowedTrainingAlgorithms().get(0));
        Assertions.assertEquals(RegressionModels.DECISION_TREE, model.blockedTrainingAlgorithms().get(0));
    }
}
