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

package com.azure.resourcemanager.batch.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.batch.models.AutoScaleSettings;
import com.azure.resourcemanager.batch.models.ComputeNodeDeallocationOption;
import com.azure.resourcemanager.batch.models.FixedScaleSettings;
import com.azure.resourcemanager.batch.models.ScaleSettings;
import java.time.Duration;
import org.junit.jupiter.api.Assertions;

public final class ScaleSettingsTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ScaleSettings model =
            BinaryData
                .fromString(
                    "{\"fixedScale\":{\"resizeTimeout\":\"PT22H6M27S\",\"targetDedicatedNodes\":277100703,\"targetLowPriorityNodes\":850153698,\"nodeDeallocationOption\":\"Terminate\"},\"autoScale\":{\"formula\":\"rfbjf\",\"evaluationInterval\":\"PT229H20M17S\"}}")
                .toObject(ScaleSettings.class);
        Assertions.assertEquals(Duration.parse("PT22H6M27S"), model.fixedScale().resizeTimeout());
        Assertions.assertEquals(277100703, model.fixedScale().targetDedicatedNodes());
        Assertions.assertEquals(850153698, model.fixedScale().targetLowPriorityNodes());
        Assertions.assertEquals(ComputeNodeDeallocationOption.TERMINATE, model.fixedScale().nodeDeallocationOption());
        Assertions.assertEquals("rfbjf", model.autoScale().formula());
        Assertions.assertEquals(Duration.parse("PT229H20M17S"), model.autoScale().evaluationInterval());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ScaleSettings model =
            new ScaleSettings()
                .withFixedScale(
                    new FixedScaleSettings()
                        .withResizeTimeout(Duration.parse("PT22H6M27S"))
                        .withTargetDedicatedNodes(277100703)
                        .withTargetLowPriorityNodes(850153698)
                        .withNodeDeallocationOption(ComputeNodeDeallocationOption.TERMINATE))
                .withAutoScale(
                    new AutoScaleSettings()
                        .withFormula("rfbjf")
                        .withEvaluationInterval(Duration.parse("PT229H20M17S")));
        model = BinaryData.fromObject(model).toObject(ScaleSettings.class);
        Assertions.assertEquals(Duration.parse("PT22H6M27S"), model.fixedScale().resizeTimeout());
        Assertions.assertEquals(277100703, model.fixedScale().targetDedicatedNodes());
        Assertions.assertEquals(850153698, model.fixedScale().targetLowPriorityNodes());
        Assertions.assertEquals(ComputeNodeDeallocationOption.TERMINATE, model.fixedScale().nodeDeallocationOption());
        Assertions.assertEquals("rfbjf", model.autoScale().formula());
        Assertions.assertEquals(Duration.parse("PT229H20M17S"), model.autoScale().evaluationInterval());
    }
}
