// 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.MaintenanceConfigurationProperties;
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 MaintenanceConfigurationPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        MaintenanceConfigurationProperties model =
            BinaryData
                .fromString(
                    "{\"namespace\":\"dosyg\",\"extensionProperties\":{\"vdphlxaolthqtr\":\"aojakhmsbzjhcrz\",\"gvfcj\":\"qjbpfzfsin\",\"xjtfelluwfzit\":\"wzo\",\"qfpjk\":\"np\"},\"maintenanceScope\":\"SQLManagedInstance\",\"maintenanceWindow\":{\"startDateTime\":\"pdvhpfxxypin\",\"expirationDateTime\":\"mayhuybbkpodepoo\",\"duration\":\"nuvamiheogna\",\"timeZone\":\"zxtheotusivyevcc\",\"recurEvery\":\"ihnhun\"},\"visibility\":\"Public\"}")
                .toObject(MaintenanceConfigurationProperties.class);
        Assertions.assertEquals("dosyg", model.namespace());
        Assertions.assertEquals("aojakhmsbzjhcrz", model.extensionProperties().get("vdphlxaolthqtr"));
        Assertions.assertEquals(MaintenanceScope.SQLMANAGED_INSTANCE, model.maintenanceScope());
        Assertions.assertEquals(Visibility.PUBLIC, model.visibility());
        Assertions.assertEquals("pdvhpfxxypin", model.startDateTime());
        Assertions.assertEquals("mayhuybbkpodepoo", model.expirationDateTime());
        Assertions.assertEquals("nuvamiheogna", model.duration());
        Assertions.assertEquals("zxtheotusivyevcc", model.timeZone());
        Assertions.assertEquals("ihnhun", model.recurEvery());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        MaintenanceConfigurationProperties model =
            new MaintenanceConfigurationProperties()
                .withNamespace("dosyg")
                .withExtensionProperties(
                    mapOf(
                        "vdphlxaolthqtr",
                        "aojakhmsbzjhcrz",
                        "gvfcj",
                        "qjbpfzfsin",
                        "xjtfelluwfzit",
                        "wzo",
                        "qfpjk",
                        "np"))
                .withMaintenanceScope(MaintenanceScope.SQLMANAGED_INSTANCE)
                .withVisibility(Visibility.PUBLIC)
                .withStartDateTime("pdvhpfxxypin")
                .withExpirationDateTime("mayhuybbkpodepoo")
                .withDuration("nuvamiheogna")
                .withTimeZone("zxtheotusivyevcc")
                .withRecurEvery("ihnhun");
        model = BinaryData.fromObject(model).toObject(MaintenanceConfigurationProperties.class);
        Assertions.assertEquals("dosyg", model.namespace());
        Assertions.assertEquals("aojakhmsbzjhcrz", model.extensionProperties().get("vdphlxaolthqtr"));
        Assertions.assertEquals(MaintenanceScope.SQLMANAGED_INSTANCE, model.maintenanceScope());
        Assertions.assertEquals(Visibility.PUBLIC, model.visibility());
        Assertions.assertEquals("pdvhpfxxypin", model.startDateTime());
        Assertions.assertEquals("mayhuybbkpodepoo", model.expirationDateTime());
        Assertions.assertEquals("nuvamiheogna", model.duration());
        Assertions.assertEquals("zxtheotusivyevcc", model.timeZone());
        Assertions.assertEquals("ihnhun", 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;
    }
}
