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

public final class L2NetworkListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        L2NetworkList model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"ggxkallatmelwuip\",\"value\":[{\"extendedLocation\":{\"name\":\"jzkzi\",\"type\":\"gvvcnayrhyr\"},\"properties\":{\"associatedResourceIds\":[],\"clusterId\":\"mueedndrdvstk\",\"detailedStatus\":\"Available\",\"detailedStatusMessage\":\"chea\",\"hybridAksClustersAssociatedIds\":[],\"hybridAksPluginType\":\"OSDevice\",\"interfaceName\":\"d\",\"l2IsolationDomainId\":\"aygdvwvgpioh\",\"provisioningState\":\"Accepted\",\"virtualMachinesAssociatedIds\":[]},\"location\":\"fudxepxgyqagvrv\",\"tags\":{\"kghimdblxgwimfnj\":\"k\",\"kfoqreyfkzikfj\":\"fjxwmsz\"},\"id\":\"wneaiv\",\"name\":\"wczelpci\",\"type\":\"elsfeaen\"},{\"extendedLocation\":{\"name\":\"abfatkl\",\"type\":\"dxbjhwuaanozj\"},\"properties\":{\"associatedResourceIds\":[],\"clusterId\":\"hyoulpjr\",\"detailedStatus\":\"Error\",\"detailedStatusMessage\":\"l\",\"hybridAksClustersAssociatedIds\":[],\"hybridAksPluginType\":\"OSDevice\",\"interfaceName\":\"wosytxitcskf\",\"l2IsolationDomainId\":\"k\",\"provisioningState\":\"Provisioning\",\"virtualMachinesAssociatedIds\":[]},\"location\":\"ekkezzikhlyfjh\",\"tags\":{\"dunyg\":\"gge\"},\"id\":\"eqidbqfatpx\",\"name\":\"lr\",\"type\":\"cyjmoadsuvarmy\"},{\"extendedLocation\":{\"name\":\"dmjsjqb\",\"type\":\"hhyxxrw\"},\"properties\":{\"associatedResourceIds\":[],\"clusterId\":\"oduhp\",\"detailedStatus\":\"Available\",\"detailedStatusMessage\":\"ymareqnajxqugj\",\"hybridAksClustersAssociatedIds\":[],\"hybridAksPluginType\":\"OSDevice\",\"interfaceName\":\"beddgssofw\",\"l2IsolationDomainId\":\"mzqa\",\"provisioningState\":\"Accepted\",\"virtualMachinesAssociatedIds\":[]},\"location\":\"jijpxac\",\"tags\":{\"yffimrzrtuzqogs\":\"dfnbyxbaaabjyv\",\"mewzsyyc\":\"xnevfdnwn\",\"judpfrxt\":\"uzsoi\"},\"id\":\"thzvaytdwkqbrqu\",\"name\":\"paxh\",\"type\":\"xiilivpdtiirqt\"},{\"extendedLocation\":{\"name\":\"qoaxoruzfgs\",\"type\":\"uyfxrxxleptramxj\"},\"properties\":{\"associatedResourceIds\":[],\"clusterId\":\"lwnwxuqlcvydyp\",\"detailedStatus\":\"Available\",\"detailedStatusMessage\":\"oa\",\"hybridAksClustersAssociatedIds\":[],\"hybridAksPluginType\":\"DPDK\",\"interfaceName\":\"odko\",\"l2IsolationDomainId\":\"ebwnujhe\",\"provisioningState\":\"Canceled\",\"virtualMachinesAssociatedIds\":[]},\"location\":\"dkcrodt\",\"tags\":{\"lfltka\":\"fw\",\"gaowpulpqblylsyx\":\"jvefkdlfoakggkfp\",\"xsdszuempsb\":\"qjnsjervtia\",\"v\":\"kfzbeyvpnqicvi\"},\"id\":\"jjxd\",\"name\":\"rbuukzclewyhmlwp\",\"type\":\"ztzp\"}]}")
                .toObject(L2NetworkList.class);
        Assertions.assertEquals("ggxkallatmelwuip", model.nextLink());
        Assertions.assertEquals("fudxepxgyqagvrv", model.value().get(0).location());
        Assertions.assertEquals("k", model.value().get(0).tags().get("kghimdblxgwimfnj"));
        Assertions.assertEquals("jzkzi", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("gvvcnayrhyr", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals(HybridAksPluginType.OSDEVICE, model.value().get(0).hybridAksPluginType());
        Assertions.assertEquals("d", model.value().get(0).interfaceName());
        Assertions.assertEquals("aygdvwvgpioh", model.value().get(0).l2IsolationDomainId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        L2NetworkList model =
            new L2NetworkList()
                .withNextLink("ggxkallatmelwuip")
                .withValue(
                    Arrays
                        .asList(
                            new L2NetworkInner()
                                .withLocation("fudxepxgyqagvrv")
                                .withTags(mapOf("kghimdblxgwimfnj", "k", "kfoqreyfkzikfj", "fjxwmsz"))
                                .withExtendedLocation(new ExtendedLocation().withName("jzkzi").withType("gvvcnayrhyr"))
                                .withHybridAksPluginType(HybridAksPluginType.OSDEVICE)
                                .withInterfaceName("d")
                                .withL2IsolationDomainId("aygdvwvgpioh"),
                            new L2NetworkInner()
                                .withLocation("ekkezzikhlyfjh")
                                .withTags(mapOf("dunyg", "gge"))
                                .withExtendedLocation(
                                    new ExtendedLocation().withName("abfatkl").withType("dxbjhwuaanozj"))
                                .withHybridAksPluginType(HybridAksPluginType.OSDEVICE)
                                .withInterfaceName("wosytxitcskf")
                                .withL2IsolationDomainId("k"),
                            new L2NetworkInner()
                                .withLocation("jijpxac")
                                .withTags(
                                    mapOf(
                                        "yffimrzrtuzqogs",
                                        "dfnbyxbaaabjyv",
                                        "mewzsyyc",
                                        "xnevfdnwn",
                                        "judpfrxt",
                                        "uzsoi"))
                                .withExtendedLocation(new ExtendedLocation().withName("dmjsjqb").withType("hhyxxrw"))
                                .withHybridAksPluginType(HybridAksPluginType.OSDEVICE)
                                .withInterfaceName("beddgssofw")
                                .withL2IsolationDomainId("mzqa"),
                            new L2NetworkInner()
                                .withLocation("dkcrodt")
                                .withTags(
                                    mapOf(
                                        "lfltka",
                                        "fw",
                                        "gaowpulpqblylsyx",
                                        "jvefkdlfoakggkfp",
                                        "xsdszuempsb",
                                        "qjnsjervtia",
                                        "v",
                                        "kfzbeyvpnqicvi"))
                                .withExtendedLocation(
                                    new ExtendedLocation().withName("qoaxoruzfgs").withType("uyfxrxxleptramxj"))
                                .withHybridAksPluginType(HybridAksPluginType.DPDK)
                                .withInterfaceName("odko")
                                .withL2IsolationDomainId("ebwnujhe")));
        model = BinaryData.fromObject(model).toObject(L2NetworkList.class);
        Assertions.assertEquals("ggxkallatmelwuip", model.nextLink());
        Assertions.assertEquals("fudxepxgyqagvrv", model.value().get(0).location());
        Assertions.assertEquals("k", model.value().get(0).tags().get("kghimdblxgwimfnj"));
        Assertions.assertEquals("jzkzi", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("gvvcnayrhyr", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals(HybridAksPluginType.OSDEVICE, model.value().get(0).hybridAksPluginType());
        Assertions.assertEquals("d", model.value().get(0).interfaceName());
        Assertions.assertEquals("aygdvwvgpioh", model.value().get(0).l2IsolationDomainId());
    }

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