// 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.CloudServicesNetworkInner;
import com.azure.resourcemanager.networkcloud.models.CloudServicesNetworkEnableDefaultEgressEndpoints;
import com.azure.resourcemanager.networkcloud.models.CloudServicesNetworkList;
import com.azure.resourcemanager.networkcloud.models.ExtendedLocation;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class CloudServicesNetworkListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        CloudServicesNetworkList model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"xtbzsgfyccsne\",\"value\":[{\"extendedLocation\":{\"name\":\"wzjeiach\",\"type\":\"oosflnr\"},\"properties\":{\"additionalEgressEndpoints\":[],\"associatedResourceIds\":[],\"clusterId\":\"t\",\"detailedStatus\":\"Available\",\"detailedStatusMessage\":\"zvypyqrimzinp\",\"enableDefaultEgressEndpoints\":\"True\",\"enabledEgressEndpoints\":[],\"hybridAksClustersAssociatedIds\":[],\"interfaceName\":\"irsoodqxhcrmnohj\",\"provisioningState\":\"Canceled\",\"virtualMachinesAssociatedIds\":[]},\"location\":\"dsoifiyipj\",\"tags\":{\"cjxvsnbyxqab\":\"wpgrjbzno\",\"shurzafbljjgpbto\":\"mocpc\",\"mkljavb\":\"c\"},\"id\":\"idtqajzyu\",\"name\":\"pku\",\"type\":\"jkrlkhbzhfepg\"},{\"extendedLocation\":{\"name\":\"gqexzlocxs\",\"type\":\"paierh\"},\"properties\":{\"additionalEgressEndpoints\":[],\"associatedResourceIds\":[],\"clusterId\":\"l\",\"detailedStatus\":\"Provisioning\",\"detailedStatusMessage\":\"jtjaodxobnbdxkq\",\"enableDefaultEgressEndpoints\":\"True\",\"enabledEgressEndpoints\":[],\"hybridAksClustersAssociatedIds\":[],\"interfaceName\":\"ionpimexg\",\"provisioningState\":\"Provisioning\",\"virtualMachinesAssociatedIds\":[]},\"location\":\"po\",\"tags\":{\"djwzrlov\":\"aajrm\",\"qsqsy\":\"clwhijcoejctbz\",\"ppofmxaxcfjpgdd\":\"bkbfkgukdkex\",\"zxibqeoj\":\"ocjjxhvpmouexh\"},\"id\":\"xqbzvddntwnd\",\"name\":\"icbtwnpzao\",\"type\":\"vuhrhcffcyddgl\"},{\"extendedLocation\":{\"name\":\"jthjqkwpyei\",\"type\":\"xmqci\"},\"properties\":{\"additionalEgressEndpoints\":[],\"associatedResourceIds\":[],\"clusterId\":\"hix\",\"detailedStatus\":\"Provisioning\",\"detailedStatusMessage\":\"topbobjogh\",\"enableDefaultEgressEndpoints\":\"True\",\"enabledEgressEndpoints\":[],\"hybridAksClustersAssociatedIds\":[],\"interfaceName\":\"a\",\"provisioningState\":\"Provisioning\",\"virtualMachinesAssociatedIds\":[]},\"location\":\"yvvtpgvdfgio\",\"tags\":{\"xkrxdqmi\":\"tutqxlngxlefgug\",\"abhjybi\":\"tthzrvqd\",\"ktzlcuiywg\":\"ehoqfbowskan\",\"nhzgpphrcgyn\":\"ywgndrv\"},\"id\":\"ocpecfvmmco\",\"name\":\"fsxlzevgbmqjqa\",\"type\":\"c\"}]}")
                .toObject(CloudServicesNetworkList.class);
        Assertions.assertEquals("xtbzsgfyccsne", model.nextLink());
        Assertions.assertEquals("dsoifiyipj", model.value().get(0).location());
        Assertions.assertEquals("wpgrjbzno", model.value().get(0).tags().get("cjxvsnbyxqab"));
        Assertions.assertEquals("wzjeiach", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("oosflnr", model.value().get(0).extendedLocation().type());
        Assertions
            .assertEquals(
                CloudServicesNetworkEnableDefaultEgressEndpoints.TRUE,
                model.value().get(0).enableDefaultEgressEndpoints());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        CloudServicesNetworkList model =
            new CloudServicesNetworkList()
                .withNextLink("xtbzsgfyccsne")
                .withValue(
                    Arrays
                        .asList(
                            new CloudServicesNetworkInner()
                                .withLocation("dsoifiyipj")
                                .withTags(
                                    mapOf("cjxvsnbyxqab", "wpgrjbzno", "shurzafbljjgpbto", "mocpc", "mkljavb", "c"))
                                .withExtendedLocation(new ExtendedLocation().withName("wzjeiach").withType("oosflnr"))
                                .withAdditionalEgressEndpoints(Arrays.asList())
                                .withEnableDefaultEgressEndpoints(
                                    CloudServicesNetworkEnableDefaultEgressEndpoints.TRUE),
                            new CloudServicesNetworkInner()
                                .withLocation("po")
                                .withTags(
                                    mapOf(
                                        "djwzrlov",
                                        "aajrm",
                                        "qsqsy",
                                        "clwhijcoejctbz",
                                        "ppofmxaxcfjpgdd",
                                        "bkbfkgukdkex",
                                        "zxibqeoj",
                                        "ocjjxhvpmouexh"))
                                .withExtendedLocation(new ExtendedLocation().withName("gqexzlocxs").withType("paierh"))
                                .withAdditionalEgressEndpoints(Arrays.asList())
                                .withEnableDefaultEgressEndpoints(
                                    CloudServicesNetworkEnableDefaultEgressEndpoints.TRUE),
                            new CloudServicesNetworkInner()
                                .withLocation("yvvtpgvdfgio")
                                .withTags(
                                    mapOf(
                                        "xkrxdqmi",
                                        "tutqxlngxlefgug",
                                        "abhjybi",
                                        "tthzrvqd",
                                        "ktzlcuiywg",
                                        "ehoqfbowskan",
                                        "nhzgpphrcgyn",
                                        "ywgndrv"))
                                .withExtendedLocation(new ExtendedLocation().withName("jthjqkwpyei").withType("xmqci"))
                                .withAdditionalEgressEndpoints(Arrays.asList())
                                .withEnableDefaultEgressEndpoints(
                                    CloudServicesNetworkEnableDefaultEgressEndpoints.TRUE)));
        model = BinaryData.fromObject(model).toObject(CloudServicesNetworkList.class);
        Assertions.assertEquals("xtbzsgfyccsne", model.nextLink());
        Assertions.assertEquals("dsoifiyipj", model.value().get(0).location());
        Assertions.assertEquals("wpgrjbzno", model.value().get(0).tags().get("cjxvsnbyxqab"));
        Assertions.assertEquals("wzjeiach", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("oosflnr", model.value().get(0).extendedLocation().type());
        Assertions
            .assertEquals(
                CloudServicesNetworkEnableDefaultEgressEndpoints.TRUE,
                model.value().get(0).enableDefaultEgressEndpoints());
    }

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