// 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.ClassificationPrimaryMetrics;
import com.azure.resourcemanager.machinelearning.models.InputDeliveryMode;
import com.azure.resourcemanager.machinelearning.models.LogVerbosity;
import com.azure.resourcemanager.machinelearning.models.MLTableJobInput;
import com.azure.resourcemanager.machinelearning.models.NlpVerticalFeaturizationSettings;
import com.azure.resourcemanager.machinelearning.models.NlpVerticalLimitSettings;
import com.azure.resourcemanager.machinelearning.models.TextClassification;
import java.time.Duration;
import org.junit.jupiter.api.Assertions;

public final class TextClassificationTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        TextClassification model =
            BinaryData
                .fromString(
                    "{\"taskType\":\"TextClassification\",\"primaryMetric\":\"AveragePrecisionScoreWeighted\",\"featurizationSettings\":{\"datasetLanguage\":\"tsffo\"},\"limitSettings\":{\"maxConcurrentTrials\":650758189,\"maxTrials\":560959800,\"timeout\":\"PT174H2M54S\"},\"validationData\":{\"jobInputType\":\"mltable\",\"mode\":\"ReadOnlyMount\",\"uri\":\"w\",\"description\":\"cgwdfriwgybjp\"},\"logVerbosity\":\"Warning\",\"targetColumnName\":\"scvgl\",\"trainingData\":{\"jobInputType\":\"mltable\",\"mode\":\"EvalMount\",\"uri\":\"dgbyfgwewqkjvxp\",\"description\":\"pxsoohu\"}}")
                .toObject(TextClassification.class);
        Assertions.assertEquals(LogVerbosity.WARNING, model.logVerbosity());
        Assertions.assertEquals("scvgl", model.targetColumnName());
        Assertions.assertEquals("pxsoohu", model.trainingData().description());
        Assertions.assertEquals(InputDeliveryMode.EVAL_MOUNT, model.trainingData().mode());
        Assertions.assertEquals("dgbyfgwewqkjvxp", model.trainingData().uri());
        Assertions.assertEquals(ClassificationPrimaryMetrics.AVERAGE_PRECISION_SCORE_WEIGHTED, model.primaryMetric());
        Assertions.assertEquals("tsffo", model.featurizationSettings().datasetLanguage());
        Assertions.assertEquals(650758189, model.limitSettings().maxConcurrentTrials());
        Assertions.assertEquals(560959800, model.limitSettings().maxTrials());
        Assertions.assertEquals(Duration.parse("PT174H2M54S"), model.limitSettings().timeout());
        Assertions.assertEquals("cgwdfriwgybjp", model.validationData().description());
        Assertions.assertEquals(InputDeliveryMode.READ_ONLY_MOUNT, model.validationData().mode());
        Assertions.assertEquals("w", model.validationData().uri());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        TextClassification model =
            new TextClassification()
                .withLogVerbosity(LogVerbosity.WARNING)
                .withTargetColumnName("scvgl")
                .withTrainingData(
                    new MLTableJobInput()
                        .withDescription("pxsoohu")
                        .withMode(InputDeliveryMode.EVAL_MOUNT)
                        .withUri("dgbyfgwewqkjvxp"))
                .withPrimaryMetric(ClassificationPrimaryMetrics.AVERAGE_PRECISION_SCORE_WEIGHTED)
                .withFeaturizationSettings(new NlpVerticalFeaturizationSettings().withDatasetLanguage("tsffo"))
                .withLimitSettings(
                    new NlpVerticalLimitSettings()
                        .withMaxConcurrentTrials(650758189)
                        .withMaxTrials(560959800)
                        .withTimeout(Duration.parse("PT174H2M54S")))
                .withValidationData(
                    new MLTableJobInput()
                        .withDescription("cgwdfriwgybjp")
                        .withMode(InputDeliveryMode.READ_ONLY_MOUNT)
                        .withUri("w"));
        model = BinaryData.fromObject(model).toObject(TextClassification.class);
        Assertions.assertEquals(LogVerbosity.WARNING, model.logVerbosity());
        Assertions.assertEquals("scvgl", model.targetColumnName());
        Assertions.assertEquals("pxsoohu", model.trainingData().description());
        Assertions.assertEquals(InputDeliveryMode.EVAL_MOUNT, model.trainingData().mode());
        Assertions.assertEquals("dgbyfgwewqkjvxp", model.trainingData().uri());
        Assertions.assertEquals(ClassificationPrimaryMetrics.AVERAGE_PRECISION_SCORE_WEIGHTED, model.primaryMetric());
        Assertions.assertEquals("tsffo", model.featurizationSettings().datasetLanguage());
        Assertions.assertEquals(650758189, model.limitSettings().maxConcurrentTrials());
        Assertions.assertEquals(560959800, model.limitSettings().maxTrials());
        Assertions.assertEquals(Duration.parse("PT174H2M54S"), model.limitSettings().timeout());
        Assertions.assertEquals("cgwdfriwgybjp", model.validationData().description());
        Assertions.assertEquals(InputDeliveryMode.READ_ONLY_MOUNT, model.validationData().mode());
        Assertions.assertEquals("w", model.validationData().uri());
    }
}
