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

package com.azure.resourcemanager.desktopvirtualization.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.desktopvirtualization.models.AgentUpdatePatchProperties;
import com.azure.resourcemanager.desktopvirtualization.models.DayOfWeek;
import com.azure.resourcemanager.desktopvirtualization.models.MaintenanceWindowPatchProperties;
import com.azure.resourcemanager.desktopvirtualization.models.SessionHostComponentUpdateType;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AgentUpdatePatchPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AgentUpdatePatchProperties model =
            BinaryData
                .fromString(
                    "{\"type\":\"Default\",\"useSessionHostLocalTime\":false,\"maintenanceWindowTimeZone\":\"ocmbqfqvmkcxoza\",\"maintenanceWindows\":[{\"hour\":2066979028,\"dayOfWeek\":\"Thursday\"},{\"hour\":1663002651,\"dayOfWeek\":\"Friday\"},{\"hour\":1689859600,\"dayOfWeek\":\"Tuesday\"}]}")
                .toObject(AgentUpdatePatchProperties.class);
        Assertions.assertEquals(SessionHostComponentUpdateType.DEFAULT, model.type());
        Assertions.assertEquals(false, model.useSessionHostLocalTime());
        Assertions.assertEquals("ocmbqfqvmkcxoza", model.maintenanceWindowTimeZone());
        Assertions.assertEquals(2066979028, model.maintenanceWindows().get(0).hour());
        Assertions.assertEquals(DayOfWeek.THURSDAY, model.maintenanceWindows().get(0).dayOfWeek());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AgentUpdatePatchProperties model =
            new AgentUpdatePatchProperties()
                .withType(SessionHostComponentUpdateType.DEFAULT)
                .withUseSessionHostLocalTime(false)
                .withMaintenanceWindowTimeZone("ocmbqfqvmkcxoza")
                .withMaintenanceWindows(
                    Arrays
                        .asList(
                            new MaintenanceWindowPatchProperties()
                                .withHour(2066979028)
                                .withDayOfWeek(DayOfWeek.THURSDAY),
                            new MaintenanceWindowPatchProperties().withHour(1663002651).withDayOfWeek(DayOfWeek.FRIDAY),
                            new MaintenanceWindowPatchProperties()
                                .withHour(1689859600)
                                .withDayOfWeek(DayOfWeek.TUESDAY)));
        model = BinaryData.fromObject(model).toObject(AgentUpdatePatchProperties.class);
        Assertions.assertEquals(SessionHostComponentUpdateType.DEFAULT, model.type());
        Assertions.assertEquals(false, model.useSessionHostLocalTime());
        Assertions.assertEquals("ocmbqfqvmkcxoza", model.maintenanceWindowTimeZone());
        Assertions.assertEquals(2066979028, model.maintenanceWindows().get(0).hour());
        Assertions.assertEquals(DayOfWeek.THURSDAY, model.maintenanceWindows().get(0).dayOfWeek());
    }
}
