// 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.CapabilitiesResultInner;
import com.azure.resourcemanager.hdinsight.models.RegionsCapability;
import com.azure.resourcemanager.hdinsight.models.VersionsCapability;
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 CapabilitiesResultInnerTests {
    @Test
    public void testDeserialize() {
        CapabilitiesResultInner model =
            BinaryData
                .fromString(
                    "{\"versions\":{\"rhzo\":{\"available\":[]},\"bmrqyibahwfl\":{\"available\":[]},\"dtmhrkwofyyvoqa\":{\"available\":[]},\"expbtg\":{\"available\":[]}},\"regions\":{\"xwbpokulpiuj\":{\"available\":[\"enwash\",\"tdtkcn\"]},\"wcciuqgbdbu\":{\"available\":[\"sipqii\",\"byuqerpqlp\"]},\"kkpwdreqnovvq\":{\"available\":[\"vfbtkuwh\",\"mhykojoxafnndl\",\"ichkoymkcdyhb\"]}},\"features\":[\"ljxywsu\",\"syrsndsytgadgvra\"],\"quota\":{\"coresUsed\":3800115719889326698,\"maxCoresAllowed\":4293634280481383135,\"regionalQuotas\":[{\"regionName\":\"wlquuijfqkace\",\"coresUsed\":9040428680411345053,\"coresAvailable\":7317687022147254934},{\"regionName\":\"ji\",\"coresUsed\":4782165638110518920,\"coresAvailable\":4706346504350614547},{\"regionName\":\"qkvpuvksgplsakn\",\"coresUsed\":3402828126111711911,\"coresAvailable\":44531628104673471},{\"regionName\":\"ph\",\"coresUsed\":7200001329577551370,\"coresAvailable\":4359673283515658098}]}}")
                .toObject(CapabilitiesResultInner.class);
        Assertions.assertEquals("enwash", model.regions().get("xwbpokulpiuj").available().get(0));
        Assertions.assertEquals("ljxywsu", model.features().get(0));
    }

    @Test
    public void testSerialize() {
        CapabilitiesResultInner model =
            new CapabilitiesResultInner()
                .withVersions(
                    mapOf(
                        "rhzo",
                        new VersionsCapability().withAvailable(Arrays.asList()),
                        "bmrqyibahwfl",
                        new VersionsCapability().withAvailable(Arrays.asList()),
                        "dtmhrkwofyyvoqa",
                        new VersionsCapability().withAvailable(Arrays.asList()),
                        "expbtg",
                        new VersionsCapability().withAvailable(Arrays.asList())))
                .withRegions(
                    mapOf(
                        "xwbpokulpiuj",
                        new RegionsCapability().withAvailable(Arrays.asList("enwash", "tdtkcn")),
                        "wcciuqgbdbu",
                        new RegionsCapability().withAvailable(Arrays.asList("sipqii", "byuqerpqlp")),
                        "kkpwdreqnovvq",
                        new RegionsCapability()
                            .withAvailable(Arrays.asList("vfbtkuwh", "mhykojoxafnndl", "ichkoymkcdyhb"))))
                .withFeatures(Arrays.asList("ljxywsu", "syrsndsytgadgvra"));
        model = BinaryData.fromObject(model).toObject(CapabilitiesResultInner.class);
        Assertions.assertEquals("enwash", model.regions().get("xwbpokulpiuj").available().get(0));
        Assertions.assertEquals("ljxywsu", model.features().get(0));
    }

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