// 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.SweepJobLimits;
import java.time.Duration;
import org.junit.jupiter.api.Assertions;

public final class SweepJobLimitsTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SweepJobLimits model =
            BinaryData
                .fromString(
                    "{\"jobLimitsType\":\"Sweep\",\"maxConcurrentTrials\":1289892692,\"maxTotalTrials\":1229317362,\"trialTimeout\":\"PT17H24M34S\",\"timeout\":\"PT94H24M1S\"}")
                .toObject(SweepJobLimits.class);
        Assertions.assertEquals(Duration.parse("PT94H24M1S"), model.timeout());
        Assertions.assertEquals(1289892692, model.maxConcurrentTrials());
        Assertions.assertEquals(1229317362, model.maxTotalTrials());
        Assertions.assertEquals(Duration.parse("PT17H24M34S"), model.trialTimeout());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SweepJobLimits model =
            new SweepJobLimits()
                .withTimeout(Duration.parse("PT94H24M1S"))
                .withMaxConcurrentTrials(1289892692)
                .withMaxTotalTrials(1229317362)
                .withTrialTimeout(Duration.parse("PT17H24M34S"));
        model = BinaryData.fromObject(model).toObject(SweepJobLimits.class);
        Assertions.assertEquals(Duration.parse("PT94H24M1S"), model.timeout());
        Assertions.assertEquals(1289892692, model.maxConcurrentTrials());
        Assertions.assertEquals(1229317362, model.maxTotalTrials());
        Assertions.assertEquals(Duration.parse("PT17H24M34S"), model.trialTimeout());
    }
}
