// 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;
import org.junit.jupiter.api.Test;

public final class ScaleSettingsTests {
    @Test
    public void testDeserialize() {
        ScaleSettings model =
            BinaryData
                .fromString(
                    "{\"fixedScale\":{\"resizeTimeout\":\"PT206H14M3S\",\"targetDedicatedNodes\":1448354996,\"targetLowPriorityNodes\":54809998,\"nodeDeallocationOption\":\"TaskCompletion\"},\"autoScale\":{\"formula\":\"weriofzpyqsem\",\"evaluationInterval\":\"PT128H24M12S\"}}")
                .toObject(ScaleSettings.class);
        Assertions.assertEquals(Duration.parse("PT206H14M3S"), model.fixedScale().resizeTimeout());
        Assertions.assertEquals(1448354996, model.fixedScale().targetDedicatedNodes());
        Assertions.assertEquals(54809998, model.fixedScale().targetLowPriorityNodes());
        Assertions
            .assertEquals(ComputeNodeDeallocationOption.TASK_COMPLETION, model.fixedScale().nodeDeallocationOption());
        Assertions.assertEquals("weriofzpyqsem", model.autoScale().formula());
        Assertions.assertEquals(Duration.parse("PT128H24M12S"), model.autoScale().evaluationInterval());
    }

    @Test
    public void testSerialize() {
        ScaleSettings model =
            new ScaleSettings()
                .withFixedScale(
                    new FixedScaleSettings()
                        .withResizeTimeout(Duration.parse("PT206H14M3S"))
                        .withTargetDedicatedNodes(1448354996)
                        .withTargetLowPriorityNodes(54809998)
                        .withNodeDeallocationOption(ComputeNodeDeallocationOption.TASK_COMPLETION))
                .withAutoScale(
                    new AutoScaleSettings()
                        .withFormula("weriofzpyqsem")
                        .withEvaluationInterval(Duration.parse("PT128H24M12S")));
        model = BinaryData.fromObject(model).toObject(ScaleSettings.class);
        Assertions.assertEquals(Duration.parse("PT206H14M3S"), model.fixedScale().resizeTimeout());
        Assertions.assertEquals(1448354996, model.fixedScale().targetDedicatedNodes());
        Assertions.assertEquals(54809998, model.fixedScale().targetLowPriorityNodes());
        Assertions
            .assertEquals(ComputeNodeDeallocationOption.TASK_COMPLETION, model.fixedScale().nodeDeallocationOption());
        Assertions.assertEquals("weriofzpyqsem", model.autoScale().formula());
        Assertions.assertEquals(Duration.parse("PT128H24M12S"), model.autoScale().evaluationInterval());
    }
}
