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

package com.azure.resourcemanager.networkcloud.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.networkcloud.fluent.models.ClusterManagerInner;
import com.azure.resourcemanager.networkcloud.models.ManagedResourceGroupConfiguration;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ClusterManagerInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ClusterManagerInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"analyticsWorkspaceId\":\"clhocohsl\",\"availabilityZones\":[\"leggzfbu\",\"fmvfaxkffeiit\",\"lvmezyvshxmzsbbz\",\"ggi\"],\"clusterVersions\":[{\"supportExpiryDate\":\"burvjxxjnspy\",\"targetClusterVersion\":\"tko\"},{\"supportExpiryDate\":\"kouknvudwtiu\",\"targetClusterVersion\":\"ldngkpoci\"},{\"supportExpiryDate\":\"z\",\"targetClusterVersion\":\"o\"}],\"detailedStatus\":\"Provisioning\",\"detailedStatusMessage\":\"g\",\"fabricControllerId\":\"npiucgygevqznty\",\"managedResourceGroupConfiguration\":{\"location\":\"bpizcdrqjsdpydn\",\"name\":\"hxdeoejz\"},\"managerExtendedLocation\":{\"name\":\"w\",\"type\":\"fsj\"},\"provisioningState\":\"Failed\",\"vmSize\":\"fbishcbkha\"},\"location\":\"eyeam\",\"tags\":{\"wkgshwa\":\"agalpbuxwgipwhon\",\"bin\":\"kix\",\"iyqzrnk\":\"eputtmrywnuzoqf\",\"qnwvlrya\":\"qvyxlwhzlsicoho\"},\"id\":\"w\",\"name\":\"heun\",\"type\":\"mqhgyxzkonocuk\"}")
                .toObject(ClusterManagerInner.class);
        Assertions.assertEquals("eyeam", model.location());
        Assertions.assertEquals("agalpbuxwgipwhon", model.tags().get("wkgshwa"));
        Assertions.assertEquals("clhocohsl", model.analyticsWorkspaceId());
        Assertions.assertEquals("leggzfbu", model.availabilityZones().get(0));
        Assertions.assertEquals("npiucgygevqznty", model.fabricControllerId());
        Assertions.assertEquals("bpizcdrqjsdpydn", model.managedResourceGroupConfiguration().location());
        Assertions.assertEquals("hxdeoejz", model.managedResourceGroupConfiguration().name());
        Assertions.assertEquals("fbishcbkha", model.vmSize());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ClusterManagerInner model =
            new ClusterManagerInner()
                .withLocation("eyeam")
                .withTags(
                    mapOf(
                        "wkgshwa",
                        "agalpbuxwgipwhon",
                        "bin",
                        "kix",
                        "iyqzrnk",
                        "eputtmrywnuzoqf",
                        "qnwvlrya",
                        "qvyxlwhzlsicoho"))
                .withAnalyticsWorkspaceId("clhocohsl")
                .withAvailabilityZones(Arrays.asList("leggzfbu", "fmvfaxkffeiit", "lvmezyvshxmzsbbz", "ggi"))
                .withFabricControllerId("npiucgygevqznty")
                .withManagedResourceGroupConfiguration(
                    new ManagedResourceGroupConfiguration().withLocation("bpizcdrqjsdpydn").withName("hxdeoejz"))
                .withVmSize("fbishcbkha");
        model = BinaryData.fromObject(model).toObject(ClusterManagerInner.class);
        Assertions.assertEquals("eyeam", model.location());
        Assertions.assertEquals("agalpbuxwgipwhon", model.tags().get("wkgshwa"));
        Assertions.assertEquals("clhocohsl", model.analyticsWorkspaceId());
        Assertions.assertEquals("leggzfbu", model.availabilityZones().get(0));
        Assertions.assertEquals("npiucgygevqznty", model.fabricControllerId());
        Assertions.assertEquals("bpizcdrqjsdpydn", model.managedResourceGroupConfiguration().location());
        Assertions.assertEquals("hxdeoejz", model.managedResourceGroupConfiguration().name());
        Assertions.assertEquals("fbishcbkha", model.vmSize());
    }

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