// 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.fluent.models.AzureMonitorResponseInner;
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 AzureMonitorResponseInnerTests {
    @Test
    public void testDeserialize() {
        AzureMonitorResponseInner model =
            BinaryData
                .fromString(
                    "{\"clusterMonitoringEnabled\":true,\"workspaceId\":\"lg\",\"selectedConfigurations\":{\"configurationVersion\":\"vtvsexsowueluq\",\"globalConfigurations\":{\"wws\":\"hhxvrhmzkwpj\",\"qxujxukndxd\":\"ughftqsx\"},\"tableList\":[{\"name\":\"guufzd\"},{\"name\":\"yqtfihwh\"},{\"name\":\"tzingamvpph\"},{\"name\":\"zqzudph\"}]}}")
                .toObject(AzureMonitorResponseInner.class);
        Assertions.assertEquals(true, model.clusterMonitoringEnabled());
        Assertions.assertEquals("lg", model.workspaceId());
        Assertions.assertEquals("vtvsexsowueluq", model.selectedConfigurations().configurationVersion());
        Assertions.assertEquals("hhxvrhmzkwpj", model.selectedConfigurations().globalConfigurations().get("wws"));
        Assertions.assertEquals("guufzd", model.selectedConfigurations().tableList().get(0).name());
    }

    @Test
    public void testSerialize() {
        AzureMonitorResponseInner model =
            new AzureMonitorResponseInner()
                .withClusterMonitoringEnabled(true)
                .withWorkspaceId("lg")
                .withSelectedConfigurations(
                    new AzureMonitorSelectedConfigurations()
                        .withConfigurationVersion("vtvsexsowueluq")
                        .withGlobalConfigurations(mapOf("wws", "hhxvrhmzkwpj", "qxujxukndxd", "ughftqsx"))
                        .withTableList(
                            Arrays
                                .asList(
                                    new AzureMonitorTableConfiguration().withName("guufzd"),
                                    new AzureMonitorTableConfiguration().withName("yqtfihwh"),
                                    new AzureMonitorTableConfiguration().withName("tzingamvpph"),
                                    new AzureMonitorTableConfiguration().withName("zqzudph"))));
        model = BinaryData.fromObject(model).toObject(AzureMonitorResponseInner.class);
        Assertions.assertEquals(true, model.clusterMonitoringEnabled());
        Assertions.assertEquals("lg", model.workspaceId());
        Assertions.assertEquals("vtvsexsowueluq", model.selectedConfigurations().configurationVersion());
        Assertions.assertEquals("hhxvrhmzkwpj", model.selectedConfigurations().globalConfigurations().get("wws"));
        Assertions.assertEquals("guufzd", model.selectedConfigurations().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;
    }
}
