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

package com.azure.resourcemanager.hybridcontainerservice.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.hybridcontainerservice.fluent.models.VirtualNetworksInner;
import com.azure.resourcemanager.hybridcontainerservice.models.VirtualNetworksExtendedLocation;
import com.azure.resourcemanager.hybridcontainerservice.models.VirtualNetworksListResult;
import com.azure.resourcemanager.hybridcontainerservice.models.VirtualNetworksProperties;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class VirtualNetworksListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        VirtualNetworksListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"vipPool\":[],\"vmipPool\":[],\"dhcpServers\":[],\"dnsServers\":[],\"gateway\":\"cstwity\",\"ipAddressPrefix\":\"evxccedcp\",\"vlanID\":\"dyodnwzxltj\",\"provisioningState\":\"Deleting\"},\"extendedLocation\":{\"type\":\"ugcxnavvwxq\",\"name\":\"y\"},\"location\":\"unyowxwl\",\"tags\":{\"acizsjqlhkrr\":\"rkvfgbvfvpdbo\",\"hvxndzwmkrefajpj\":\"bdeibqipqk\",\"yhgbijtjivfx\":\"rwkq\",\"stawfsdjpvkv\":\"sjabibs\"},\"id\":\"bjxbkzbzk\",\"name\":\"vncjabudurgk\",\"type\":\"kmokz\"}],\"nextLink\":\"jk\"}")
                .toObject(VirtualNetworksListResult.class);
        Assertions.assertEquals("unyowxwl", model.value().get(0).location());
        Assertions.assertEquals("rkvfgbvfvpdbo", model.value().get(0).tags().get("acizsjqlhkrr"));
        Assertions.assertEquals("cstwity", model.value().get(0).properties().gateway());
        Assertions.assertEquals("evxccedcp", model.value().get(0).properties().ipAddressPrefix());
        Assertions.assertEquals("ugcxnavvwxq", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals("y", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("jk", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        VirtualNetworksListResult model =
            new VirtualNetworksListResult()
                .withValue(
                    Arrays
                        .asList(
                            new VirtualNetworksInner()
                                .withLocation("unyowxwl")
                                .withTags(
                                    mapOf(
                                        "acizsjqlhkrr",
                                        "rkvfgbvfvpdbo",
                                        "hvxndzwmkrefajpj",
                                        "bdeibqipqk",
                                        "yhgbijtjivfx",
                                        "rwkq",
                                        "stawfsdjpvkv",
                                        "sjabibs"))
                                .withProperties(
                                    new VirtualNetworksProperties()
                                        .withVipPool(Arrays.asList())
                                        .withVmipPool(Arrays.asList())
                                        .withDnsServers(Arrays.asList())
                                        .withGateway("cstwity")
                                        .withIpAddressPrefix("evxccedcp"))
                                .withExtendedLocation(
                                    new VirtualNetworksExtendedLocation().withType("ugcxnavvwxq").withName("y"))))
                .withNextLink("jk");
        model = BinaryData.fromObject(model).toObject(VirtualNetworksListResult.class);
        Assertions.assertEquals("unyowxwl", model.value().get(0).location());
        Assertions.assertEquals("rkvfgbvfvpdbo", model.value().get(0).tags().get("acizsjqlhkrr"));
        Assertions.assertEquals("cstwity", model.value().get(0).properties().gateway());
        Assertions.assertEquals("evxccedcp", model.value().get(0).properties().ipAddressPrefix());
        Assertions.assertEquals("ugcxnavvwxq", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals("y", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("jk", model.nextLink());
    }

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