// 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.ClusterManagerList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ClusterManagerListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ClusterManagerList model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"xim\",\"value\":[{\"properties\":{\"analyticsWorkspaceId\":\"cfsf\",\"availabilityZones\":[],\"clusterVersions\":[],\"detailedStatus\":\"Error\",\"detailedStatusMessage\":\"ys\",\"fabricControllerId\":\"kiiuxhqyudxor\",\"provisioningState\":\"Provisioning\",\"vmSize\":\"czvyifq\"},\"location\":\"kdvjsll\",\"tags\":{\"ulexxbczwtr\":\"vdfwatkpn\",\"acspkwl\":\"wiqzbqjvsovmyo\",\"kcciwwzjuqkhr\":\"zdobpxjmflbvvnch\",\"oskg\":\"ajiwkuo\"},\"id\":\"sauuimj\",\"name\":\"vxieduugidyj\",\"type\":\"rfbyaosvexcso\"}]}")
                .toObject(ClusterManagerList.class);
        Assertions.assertEquals("xim", model.nextLink());
        Assertions.assertEquals("kdvjsll", model.value().get(0).location());
        Assertions.assertEquals("vdfwatkpn", model.value().get(0).tags().get("ulexxbczwtr"));
        Assertions.assertEquals("cfsf", model.value().get(0).analyticsWorkspaceId());
        Assertions.assertEquals("kiiuxhqyudxor", model.value().get(0).fabricControllerId());
        Assertions.assertEquals("czvyifq", model.value().get(0).vmSize());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ClusterManagerList model =
            new ClusterManagerList()
                .withNextLink("xim")
                .withValue(
                    Arrays
                        .asList(
                            new ClusterManagerInner()
                                .withLocation("kdvjsll")
                                .withTags(
                                    mapOf(
                                        "ulexxbczwtr",
                                        "vdfwatkpn",
                                        "acspkwl",
                                        "wiqzbqjvsovmyo",
                                        "kcciwwzjuqkhr",
                                        "zdobpxjmflbvvnch",
                                        "oskg",
                                        "ajiwkuo"))
                                .withAnalyticsWorkspaceId("cfsf")
                                .withAvailabilityZones(Arrays.asList())
                                .withFabricControllerId("kiiuxhqyudxor")
                                .withVmSize("czvyifq")));
        model = BinaryData.fromObject(model).toObject(ClusterManagerList.class);
        Assertions.assertEquals("xim", model.nextLink());
        Assertions.assertEquals("kdvjsll", model.value().get(0).location());
        Assertions.assertEquals("vdfwatkpn", model.value().get(0).tags().get("ulexxbczwtr"));
        Assertions.assertEquals("cfsf", model.value().get(0).analyticsWorkspaceId());
        Assertions.assertEquals("kiiuxhqyudxor", model.value().get(0).fabricControllerId());
        Assertions.assertEquals("czvyifq", model.value().get(0).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;
    }
}
