// 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.containers.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.hdinsight.containers.models.Schedule;
import com.azure.resourcemanager.hdinsight.containers.models.ScheduleBasedConfig;
import com.azure.resourcemanager.hdinsight.containers.models.ScheduleDay;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ScheduleBasedConfigTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ScheduleBasedConfig model =
            BinaryData
                .fromString(
                    "{\"timeZone\":\"vt\",\"defaultCount\":1243858380,\"schedules\":[{\"startTime\":\"mqkrhahvljuahaqu\",\"endTime\":\"c\",\"count\":1312333731,\"days\":[\"Thursday\"]},{\"startTime\":\"ualaexqpvfadmw\",\"endTime\":\"rcrgvx\",\"count\":1281697798,\"days\":[\"Sunday\"]},{\"startTime\":\"mzlfmisgwb\",\"endTime\":\"b\",\"count\":85144126,\"days\":[\"Friday\",\"Monday\",\"Tuesday\",\"Tuesday\"]}]}")
                .toObject(ScheduleBasedConfig.class);
        Assertions.assertEquals("vt", model.timeZone());
        Assertions.assertEquals(1243858380, model.defaultCount());
        Assertions.assertEquals("mqkrhahvljuahaqu", model.schedules().get(0).startTime());
        Assertions.assertEquals("c", model.schedules().get(0).endTime());
        Assertions.assertEquals(1312333731, model.schedules().get(0).count());
        Assertions.assertEquals(ScheduleDay.THURSDAY, model.schedules().get(0).days().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ScheduleBasedConfig model =
            new ScheduleBasedConfig()
                .withTimeZone("vt")
                .withDefaultCount(1243858380)
                .withSchedules(
                    Arrays
                        .asList(
                            new Schedule()
                                .withStartTime("mqkrhahvljuahaqu")
                                .withEndTime("c")
                                .withCount(1312333731)
                                .withDays(Arrays.asList(ScheduleDay.THURSDAY)),
                            new Schedule()
                                .withStartTime("ualaexqpvfadmw")
                                .withEndTime("rcrgvx")
                                .withCount(1281697798)
                                .withDays(Arrays.asList(ScheduleDay.SUNDAY)),
                            new Schedule()
                                .withStartTime("mzlfmisgwb")
                                .withEndTime("b")
                                .withCount(85144126)
                                .withDays(
                                    Arrays
                                        .asList(
                                            ScheduleDay.FRIDAY,
                                            ScheduleDay.MONDAY,
                                            ScheduleDay.TUESDAY,
                                            ScheduleDay.TUESDAY))));
        model = BinaryData.fromObject(model).toObject(ScheduleBasedConfig.class);
        Assertions.assertEquals("vt", model.timeZone());
        Assertions.assertEquals(1243858380, model.defaultCount());
        Assertions.assertEquals("mqkrhahvljuahaqu", model.schedules().get(0).startTime());
        Assertions.assertEquals("c", model.schedules().get(0).endTime());
        Assertions.assertEquals(1312333731, model.schedules().get(0).count());
        Assertions.assertEquals(ScheduleDay.THURSDAY, model.schedules().get(0).days().get(0));
    }
}
