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

package com.azure.resourcemanager.maintenance.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.maintenance.fluent.models.MaintenanceConfigurationInner;
import com.azure.resourcemanager.maintenance.models.MaintenanceScope;
import com.azure.resourcemanager.maintenance.models.Visibility;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class MaintenanceConfigurationInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        MaintenanceConfigurationInner model =
            BinaryData
                .fromString(
                    "{\"location\":\"hab\",\"tags\":{\"byscnp\":\"ikxwc\",\"hiv\":\"x\",\"rtfw\":\"qniwbybrkxvdumj\",\"cs\":\"ukxgaud\"},\"properties\":{\"namespace\":\"jcny\",\"extensionProperties\":{\"emkkvnipjox\":\"kryhtnapczwlokj\",\"podmailzydehojwy\":\"jnchgej\"},\"maintenanceScope\":\"OSImage\",\"maintenanceWindow\":{\"startDateTime\":\"npmqnjaqwixjspro\",\"expirationDateTime\":\"cputegjvwmfdats\",\"duration\":\"dvpjhulsuuvmk\",\"timeZone\":\"zkrwfn\",\"recurEvery\":\"odjpslwejd\"},\"visibility\":\"Public\"},\"id\":\"yoqpsoaccta\",\"name\":\"akl\",\"type\":\"lahbcryff\"}")
                .toObject(MaintenanceConfigurationInner.class);
        Assertions.assertEquals("hab", model.location());
        Assertions.assertEquals("ikxwc", model.tags().get("byscnp"));
        Assertions.assertEquals("jcny", model.namespace());
        Assertions.assertEquals("kryhtnapczwlokj", model.extensionProperties().get("emkkvnipjox"));
        Assertions.assertEquals(MaintenanceScope.OSIMAGE, model.maintenanceScope());
        Assertions.assertEquals(Visibility.PUBLIC, model.visibility());
        Assertions.assertEquals("npmqnjaqwixjspro", model.startDateTime());
        Assertions.assertEquals("cputegjvwmfdats", model.expirationDateTime());
        Assertions.assertEquals("dvpjhulsuuvmk", model.duration());
        Assertions.assertEquals("zkrwfn", model.timeZone());
        Assertions.assertEquals("odjpslwejd", model.recurEvery());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        MaintenanceConfigurationInner model =
            new MaintenanceConfigurationInner()
                .withLocation("hab")
                .withTags(mapOf("byscnp", "ikxwc", "hiv", "x", "rtfw", "qniwbybrkxvdumj", "cs", "ukxgaud"))
                .withNamespace("jcny")
                .withExtensionProperties(mapOf("emkkvnipjox", "kryhtnapczwlokj", "podmailzydehojwy", "jnchgej"))
                .withMaintenanceScope(MaintenanceScope.OSIMAGE)
                .withVisibility(Visibility.PUBLIC)
                .withStartDateTime("npmqnjaqwixjspro")
                .withExpirationDateTime("cputegjvwmfdats")
                .withDuration("dvpjhulsuuvmk")
                .withTimeZone("zkrwfn")
                .withRecurEvery("odjpslwejd");
        model = BinaryData.fromObject(model).toObject(MaintenanceConfigurationInner.class);
        Assertions.assertEquals("hab", model.location());
        Assertions.assertEquals("ikxwc", model.tags().get("byscnp"));
        Assertions.assertEquals("jcny", model.namespace());
        Assertions.assertEquals("kryhtnapczwlokj", model.extensionProperties().get("emkkvnipjox"));
        Assertions.assertEquals(MaintenanceScope.OSIMAGE, model.maintenanceScope());
        Assertions.assertEquals(Visibility.PUBLIC, model.visibility());
        Assertions.assertEquals("npmqnjaqwixjspro", model.startDateTime());
        Assertions.assertEquals("cputegjvwmfdats", model.expirationDateTime());
        Assertions.assertEquals("dvpjhulsuuvmk", model.duration());
        Assertions.assertEquals("zkrwfn", model.timeZone());
        Assertions.assertEquals("odjpslwejd", model.recurEvery());
    }

    @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;
    }
}
