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

package com.azure.resourcemanager.hdinsight.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.hdinsight.models.AutoscaleRecurrence;
import com.azure.resourcemanager.hdinsight.models.AutoscaleSchedule;
import com.azure.resourcemanager.hdinsight.models.AutoscaleTimeAndCapacity;
import com.azure.resourcemanager.hdinsight.models.DaysOfWeek;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class AutoscaleRecurrenceTests {
    @Test
    public void testDeserialize() {
        AutoscaleRecurrence model =
            BinaryData
                .fromString(
                    "{\"timeZone\":\"uujitcjc\",\"schedule\":[{\"days\":[\"Thursday\",\"Monday\",\"Friday\"],\"timeAndCapacity\":{\"time\":\"wpdappdsbdkv\",\"minInstanceCount\":1134506891,\"maxInstanceCount\":1914162243}},{\"days\":[\"Thursday\",\"Thursday\"],\"timeAndCapacity\":{\"time\":\"tjelt\",\"minInstanceCount\":1403309762,\"maxInstanceCount\":1554551214}},{\"days\":[\"Monday\",\"Tuesday\",\"Tuesday\",\"Wednesday\"],\"timeAndCapacity\":{\"time\":\"qxhocdgeablgphut\",\"minInstanceCount\":732372528,\"maxInstanceCount\":1906017395}},{\"days\":[\"Monday\",\"Sunday\",\"Friday\",\"Friday\"],\"timeAndCapacity\":{\"time\":\"tyhxhurokft\",\"minInstanceCount\":900623903,\"maxInstanceCount\":214532343}}]}")
                .toObject(AutoscaleRecurrence.class);
        Assertions.assertEquals("uujitcjc", model.timeZone());
        Assertions.assertEquals(DaysOfWeek.THURSDAY, model.schedule().get(0).days().get(0));
        Assertions.assertEquals("wpdappdsbdkv", model.schedule().get(0).timeAndCapacity().time());
        Assertions.assertEquals(1134506891, model.schedule().get(0).timeAndCapacity().minInstanceCount());
        Assertions.assertEquals(1914162243, model.schedule().get(0).timeAndCapacity().maxInstanceCount());
    }

    @Test
    public void testSerialize() {
        AutoscaleRecurrence model =
            new AutoscaleRecurrence()
                .withTimeZone("uujitcjc")
                .withSchedule(
                    Arrays
                        .asList(
                            new AutoscaleSchedule()
                                .withDays(Arrays.asList(DaysOfWeek.THURSDAY, DaysOfWeek.MONDAY, DaysOfWeek.FRIDAY))
                                .withTimeAndCapacity(
                                    new AutoscaleTimeAndCapacity()
                                        .withTime("wpdappdsbdkv")
                                        .withMinInstanceCount(1134506891)
                                        .withMaxInstanceCount(1914162243)),
                            new AutoscaleSchedule()
                                .withDays(Arrays.asList(DaysOfWeek.THURSDAY, DaysOfWeek.THURSDAY))
                                .withTimeAndCapacity(
                                    new AutoscaleTimeAndCapacity()
                                        .withTime("tjelt")
                                        .withMinInstanceCount(1403309762)
                                        .withMaxInstanceCount(1554551214)),
                            new AutoscaleSchedule()
                                .withDays(
                                    Arrays
                                        .asList(
                                            DaysOfWeek.MONDAY,
                                            DaysOfWeek.TUESDAY,
                                            DaysOfWeek.TUESDAY,
                                            DaysOfWeek.WEDNESDAY))
                                .withTimeAndCapacity(
                                    new AutoscaleTimeAndCapacity()
                                        .withTime("qxhocdgeablgphut")
                                        .withMinInstanceCount(732372528)
                                        .withMaxInstanceCount(1906017395)),
                            new AutoscaleSchedule()
                                .withDays(
                                    Arrays
                                        .asList(
                                            DaysOfWeek.MONDAY, DaysOfWeek.SUNDAY, DaysOfWeek.FRIDAY, DaysOfWeek.FRIDAY))
                                .withTimeAndCapacity(
                                    new AutoscaleTimeAndCapacity()
                                        .withTime("tyhxhurokft")
                                        .withMinInstanceCount(900623903)
                                        .withMaxInstanceCount(214532343))));
        model = BinaryData.fromObject(model).toObject(AutoscaleRecurrence.class);
        Assertions.assertEquals("uujitcjc", model.timeZone());
        Assertions.assertEquals(DaysOfWeek.THURSDAY, model.schedule().get(0).days().get(0));
        Assertions.assertEquals("wpdappdsbdkv", model.schedule().get(0).timeAndCapacity().time());
        Assertions.assertEquals(1134506891, model.schedule().get(0).timeAndCapacity().minInstanceCount());
        Assertions.assertEquals(1914162243, model.schedule().get(0).timeAndCapacity().maxInstanceCount());
    }
}
