// 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.EarlyTerminationPolicy;
import com.azure.resourcemanager.machinelearning.models.ImageLimitSettings;
import com.azure.resourcemanager.machinelearning.models.ImageSweepSettings;
import com.azure.resourcemanager.machinelearning.models.ImageVertical;
import com.azure.resourcemanager.machinelearning.models.InputDeliveryMode;
import com.azure.resourcemanager.machinelearning.models.MLTableJobInput;
import com.azure.resourcemanager.machinelearning.models.SamplingAlgorithmType;
import java.time.Duration;
import org.junit.jupiter.api.Assertions;

public final class ImageVerticalTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ImageVertical model =
            BinaryData
                .fromString(
                    "{\"limitSettings\":{\"maxConcurrentTrials\":4557833,\"maxTrials\":267543853,\"timeout\":\"PT33H18M38S\"},\"sweepSettings\":{\"earlyTermination\":{\"policyType\":\"EarlyTerminationPolicy\",\"delayEvaluation\":1370366721,\"evaluationInterval\":1583622668},\"samplingAlgorithm\":\"Grid\"},\"validationData\":{\"jobInputType\":\"mltable\",\"mode\":\"ReadOnlyMount\",\"uri\":\"lbcnndt\",\"description\":\"xawqy\"},\"validationDataSize\":69.16610610373561}")
                .toObject(ImageVertical.class);
        Assertions.assertEquals(4557833, model.limitSettings().maxConcurrentTrials());
        Assertions.assertEquals(267543853, model.limitSettings().maxTrials());
        Assertions.assertEquals(Duration.parse("PT33H18M38S"), model.limitSettings().timeout());
        Assertions.assertEquals(1370366721, model.sweepSettings().earlyTermination().delayEvaluation());
        Assertions.assertEquals(1583622668, model.sweepSettings().earlyTermination().evaluationInterval());
        Assertions.assertEquals(SamplingAlgorithmType.GRID, model.sweepSettings().samplingAlgorithm());
        Assertions.assertEquals("xawqy", model.validationData().description());
        Assertions.assertEquals(InputDeliveryMode.READ_ONLY_MOUNT, model.validationData().mode());
        Assertions.assertEquals("lbcnndt", model.validationData().uri());
        Assertions.assertEquals(69.16610610373561D, model.validationDataSize());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ImageVertical model =
            new ImageVertical()
                .withLimitSettings(
                    new ImageLimitSettings()
                        .withMaxConcurrentTrials(4557833)
                        .withMaxTrials(267543853)
                        .withTimeout(Duration.parse("PT33H18M38S")))
                .withSweepSettings(
                    new ImageSweepSettings()
                        .withEarlyTermination(
                            new EarlyTerminationPolicy()
                                .withDelayEvaluation(1370366721)
                                .withEvaluationInterval(1583622668))
                        .withSamplingAlgorithm(SamplingAlgorithmType.GRID))
                .withValidationData(
                    new MLTableJobInput()
                        .withDescription("xawqy")
                        .withMode(InputDeliveryMode.READ_ONLY_MOUNT)
                        .withUri("lbcnndt"))
                .withValidationDataSize(69.16610610373561D);
        model = BinaryData.fromObject(model).toObject(ImageVertical.class);
        Assertions.assertEquals(4557833, model.limitSettings().maxConcurrentTrials());
        Assertions.assertEquals(267543853, model.limitSettings().maxTrials());
        Assertions.assertEquals(Duration.parse("PT33H18M38S"), model.limitSettings().timeout());
        Assertions.assertEquals(1370366721, model.sweepSettings().earlyTermination().delayEvaluation());
        Assertions.assertEquals(1583622668, model.sweepSettings().earlyTermination().evaluationInterval());
        Assertions.assertEquals(SamplingAlgorithmType.GRID, model.sweepSettings().samplingAlgorithm());
        Assertions.assertEquals("xawqy", model.validationData().description());
        Assertions.assertEquals(InputDeliveryMode.READ_ONLY_MOUNT, model.validationData().mode());
        Assertions.assertEquals("lbcnndt", model.validationData().uri());
        Assertions.assertEquals(69.16610610373561D, model.validationDataSize());
    }
}
