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

package com.azure.resourcemanager.storagecache.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.storagecache.models.AmlFilesystemEncryptionSettings;
import com.azure.resourcemanager.storagecache.models.AmlFilesystemUpdate;
import com.azure.resourcemanager.storagecache.models.AmlFilesystemUpdatePropertiesMaintenanceWindow;
import com.azure.resourcemanager.storagecache.models.MaintenanceDayOfWeekType;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class AmlFilesystemUpdateTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AmlFilesystemUpdate model =
            BinaryData
                .fromString(
                    "{\"tags\":{\"x\":\"a\",\"hr\":\"fizuckyf\"},\"properties\":{\"encryptionSettings\":{},\"maintenanceWindow\":{\"dayOfWeek\":\"Wednesday\",\"timeOfDayUTC\":\"zuhtymwisdkfthwx\"}}}")
                .toObject(AmlFilesystemUpdate.class);
        Assertions.assertEquals("a", model.tags().get("x"));
        Assertions.assertEquals(MaintenanceDayOfWeekType.WEDNESDAY, model.maintenanceWindow().dayOfWeek());
        Assertions.assertEquals("zuhtymwisdkfthwx", model.maintenanceWindow().timeOfDayUtc());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AmlFilesystemUpdate model =
            new AmlFilesystemUpdate()
                .withTags(mapOf("x", "a", "hr", "fizuckyf"))
                .withEncryptionSettings(new AmlFilesystemEncryptionSettings())
                .withMaintenanceWindow(
                    new AmlFilesystemUpdatePropertiesMaintenanceWindow()
                        .withDayOfWeek(MaintenanceDayOfWeekType.WEDNESDAY)
                        .withTimeOfDayUtc("zuhtymwisdkfthwx"));
        model = BinaryData.fromObject(model).toObject(AmlFilesystemUpdate.class);
        Assertions.assertEquals("a", model.tags().get("x"));
        Assertions.assertEquals(MaintenanceDayOfWeekType.WEDNESDAY, model.maintenanceWindow().dayOfWeek());
        Assertions.assertEquals("zuhtymwisdkfthwx", model.maintenanceWindow().timeOfDayUtc());
    }

    @SuppressWarnings("unchecked")
    private static <T> Map<String, T> mapOf(Object... inputs) {
        Map<String, T> map = new HashMap<>();
        for (int i = 0; i < inputs.length; i += 2) {
            String key = (String) inputs[i];
            T value = (T) inputs[i + 1];
            map.put(key, value);
        }
        return map;
    }
}
