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

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.hdinsight.models.AzureMonitorSelectedConfigurations;
import com.azure.resourcemanager.hdinsight.models.AzureMonitorTableConfiguration;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class AzureMonitorSelectedConfigurationsTests {
    @Test
    public void testDeserialize() {
        AzureMonitorSelectedConfigurations model =
            BinaryData
                .fromString(
                    "{\"configurationVersion\":\"kixrj\",\"globalConfigurations\":{\"frl\":\"rgz\",\"jylwbtlhflsj\":\"zszrnwoiindfpw\"},\"tableList\":[{\"name\":\"zfjvfbgofe\"},{\"name\":\"a\"}]}")
                .toObject(AzureMonitorSelectedConfigurations.class);
        Assertions.assertEquals("kixrj", model.configurationVersion());
        Assertions.assertEquals("rgz", model.globalConfigurations().get("frl"));
        Assertions.assertEquals("zfjvfbgofe", model.tableList().get(0).name());
    }

    @Test
    public void testSerialize() {
        AzureMonitorSelectedConfigurations model =
            new AzureMonitorSelectedConfigurations()
                .withConfigurationVersion("kixrj")
                .withGlobalConfigurations(mapOf("frl", "rgz", "jylwbtlhflsj", "zszrnwoiindfpw"))
                .withTableList(
                    Arrays
                        .asList(
                            new AzureMonitorTableConfiguration().withName("zfjvfbgofe"),
                            new AzureMonitorTableConfiguration().withName("a")));
        model = BinaryData.fromObject(model).toObject(AzureMonitorSelectedConfigurations.class);
        Assertions.assertEquals("kixrj", model.configurationVersion());
        Assertions.assertEquals("rgz", model.globalConfigurations().get("frl"));
        Assertions.assertEquals("zfjvfbgofe", model.tableList().get(0).name());
    }

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