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

public final class TrunkedNetworkListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        TrunkedNetworkList model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"jcrxgibbdaxcon\",\"value\":[{\"extendedLocation\":{\"name\":\"auorsukokw\",\"type\":\"qplhlvnu\"},\"properties\":{\"associatedResourceIds\":[],\"clusterId\":\"zlrphwzs\",\"detailedStatus\":\"Error\",\"detailedStatusMessage\":\"eyuqdunvmnnrwr\",\"hybridAksClustersAssociatedIds\":[],\"hybridAksPluginType\":\"SRIOV\",\"interfaceName\":\"talywjhhgdnhxms\",\"isolationDomainIds\":[],\"provisioningState\":\"Canceled\",\"virtualMachinesAssociatedIds\":[],\"vlans\":[]},\"location\":\"iloxggdufiq\",\"tags\":{\"chvcyyysfgdo\":\"euzaof\",\"qonmacj\":\"cubiipuipw\",\"izsh\":\"k\",\"gmblrri\":\"vcimpev\"},\"id\":\"bywdxsmicc\",\"name\":\"rwfscjfnynszquj\",\"type\":\"zdvoqytibyowbb\"},{\"extendedLocation\":{\"name\":\"gyavu\",\"type\":\"pthjoxo\"},\"properties\":{\"associatedResourceIds\":[],\"clusterId\":\"sks\",\"detailedStatus\":\"Error\",\"detailedStatusMessage\":\"lqol\",\"hybridAksClustersAssociatedIds\":[],\"hybridAksPluginType\":\"OSDevice\",\"interfaceName\":\"xxlxsffgcvizq\",\"isolationDomainIds\":[],\"provisioningState\":\"Provisioning\",\"virtualMachinesAssociatedIds\":[],\"vlans\":[]},\"location\":\"w\",\"tags\":{\"ubdyhgk\":\"upfgfbk\",\"tsttktlahbq\":\"minsgowzf\"},\"id\":\"ctxtgzukxi\",\"name\":\"mmqtgqqqxhr\",\"type\":\"xrxc\"}]}")
                .toObject(TrunkedNetworkList.class);
        Assertions.assertEquals("jcrxgibbdaxcon", model.nextLink());
        Assertions.assertEquals("iloxggdufiq", model.value().get(0).location());
        Assertions.assertEquals("euzaof", model.value().get(0).tags().get("chvcyyysfgdo"));
        Assertions.assertEquals("auorsukokw", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("qplhlvnu", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals(HybridAksPluginType.SRIOV, model.value().get(0).hybridAksPluginType());
        Assertions.assertEquals("talywjhhgdnhxms", model.value().get(0).interfaceName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        TrunkedNetworkList model =
            new TrunkedNetworkList()
                .withNextLink("jcrxgibbdaxcon")
                .withValue(
                    Arrays
                        .asList(
                            new TrunkedNetworkInner()
                                .withLocation("iloxggdufiq")
                                .withTags(
                                    mapOf(
                                        "chvcyyysfgdo",
                                        "euzaof",
                                        "qonmacj",
                                        "cubiipuipw",
                                        "izsh",
                                        "k",
                                        "gmblrri",
                                        "vcimpev"))
                                .withExtendedLocation(
                                    new ExtendedLocation().withName("auorsukokw").withType("qplhlvnu"))
                                .withHybridAksPluginType(HybridAksPluginType.SRIOV)
                                .withInterfaceName("talywjhhgdnhxms")
                                .withIsolationDomainIds(Arrays.asList())
                                .withVlans(Arrays.asList()),
                            new TrunkedNetworkInner()
                                .withLocation("w")
                                .withTags(mapOf("ubdyhgk", "upfgfbk", "tsttktlahbq", "minsgowzf"))
                                .withExtendedLocation(new ExtendedLocation().withName("gyavu").withType("pthjoxo"))
                                .withHybridAksPluginType(HybridAksPluginType.OSDEVICE)
                                .withInterfaceName("xxlxsffgcvizq")
                                .withIsolationDomainIds(Arrays.asList())
                                .withVlans(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(TrunkedNetworkList.class);
        Assertions.assertEquals("jcrxgibbdaxcon", model.nextLink());
        Assertions.assertEquals("iloxggdufiq", model.value().get(0).location());
        Assertions.assertEquals("euzaof", model.value().get(0).tags().get("chvcyyysfgdo"));
        Assertions.assertEquals("auorsukokw", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("qplhlvnu", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals(HybridAksPluginType.SRIOV, model.value().get(0).hybridAksPluginType());
        Assertions.assertEquals("talywjhhgdnhxms", model.value().get(0).interfaceName());
    }

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