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

public final class L3NetworkListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        L3NetworkList model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"skdsnfdsdoakg\",\"value\":[{\"extendedLocation\":{\"name\":\"mkkzevdlhe\",\"type\":\"pusdstt\"},\"properties\":{\"associatedResourceIds\":[],\"clusterId\":\"gvbbejdcng\",\"detailedStatus\":\"Available\",\"detailedStatusMessage\":\"akufgmjz\",\"hybridAksClustersAssociatedIds\":[],\"hybridAksIpamEnabled\":\"False\",\"hybridAksPluginType\":\"DPDK\",\"interfaceName\":\"wae\",\"ipAllocationType\":\"DualStack\",\"ipv4ConnectedPrefix\":\"kopbminrf\",\"ipv6ConnectedPrefix\":\"oyuhhziui\",\"l3IsolationDomainId\":\"fozbhdmsmlmzqhof\",\"provisioningState\":\"Failed\",\"virtualMachinesAssociatedIds\":[],\"vlan\":4473608850473810276},\"location\":\"iahxicsl\",\"tags\":{\"alnswhccsphk\":\"qzpiyyl\",\"oluhczbwemh\":\"ivwitqscywugg\",\"sbrgz\":\"i\"},\"id\":\"wmsweypqwd\",\"name\":\"ggicccnxqhue\",\"type\":\"mkttlstvlzywem\"}]}")
                .toObject(L3NetworkList.class);
        Assertions.assertEquals("skdsnfdsdoakg", model.nextLink());
        Assertions.assertEquals("iahxicsl", model.value().get(0).location());
        Assertions.assertEquals("qzpiyyl", model.value().get(0).tags().get("alnswhccsphk"));
        Assertions.assertEquals("mkkzevdlhe", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("pusdstt", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals(HybridAksIpamEnabled.FALSE, model.value().get(0).hybridAksIpamEnabled());
        Assertions.assertEquals(HybridAksPluginType.DPDK, model.value().get(0).hybridAksPluginType());
        Assertions.assertEquals("wae", model.value().get(0).interfaceName());
        Assertions.assertEquals(IpAllocationType.DUAL_STACK, model.value().get(0).ipAllocationType());
        Assertions.assertEquals("kopbminrf", model.value().get(0).ipv4ConnectedPrefix());
        Assertions.assertEquals("oyuhhziui", model.value().get(0).ipv6ConnectedPrefix());
        Assertions.assertEquals("fozbhdmsmlmzqhof", model.value().get(0).l3IsolationDomainId());
        Assertions.assertEquals(4473608850473810276L, model.value().get(0).vlan());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        L3NetworkList model =
            new L3NetworkList()
                .withNextLink("skdsnfdsdoakg")
                .withValue(
                    Arrays
                        .asList(
                            new L3NetworkInner()
                                .withLocation("iahxicsl")
                                .withTags(
                                    mapOf("alnswhccsphk", "qzpiyyl", "oluhczbwemh", "ivwitqscywugg", "sbrgz", "i"))
                                .withExtendedLocation(new ExtendedLocation().withName("mkkzevdlhe").withType("pusdstt"))
                                .withHybridAksIpamEnabled(HybridAksIpamEnabled.FALSE)
                                .withHybridAksPluginType(HybridAksPluginType.DPDK)
                                .withInterfaceName("wae")
                                .withIpAllocationType(IpAllocationType.DUAL_STACK)
                                .withIpv4ConnectedPrefix("kopbminrf")
                                .withIpv6ConnectedPrefix("oyuhhziui")
                                .withL3IsolationDomainId("fozbhdmsmlmzqhof")
                                .withVlan(4473608850473810276L)));
        model = BinaryData.fromObject(model).toObject(L3NetworkList.class);
        Assertions.assertEquals("skdsnfdsdoakg", model.nextLink());
        Assertions.assertEquals("iahxicsl", model.value().get(0).location());
        Assertions.assertEquals("qzpiyyl", model.value().get(0).tags().get("alnswhccsphk"));
        Assertions.assertEquals("mkkzevdlhe", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("pusdstt", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals(HybridAksIpamEnabled.FALSE, model.value().get(0).hybridAksIpamEnabled());
        Assertions.assertEquals(HybridAksPluginType.DPDK, model.value().get(0).hybridAksPluginType());
        Assertions.assertEquals("wae", model.value().get(0).interfaceName());
        Assertions.assertEquals(IpAllocationType.DUAL_STACK, model.value().get(0).ipAllocationType());
        Assertions.assertEquals("kopbminrf", model.value().get(0).ipv4ConnectedPrefix());
        Assertions.assertEquals("oyuhhziui", model.value().get(0).ipv6ConnectedPrefix());
        Assertions.assertEquals("fozbhdmsmlmzqhof", model.value().get(0).l3IsolationDomainId());
        Assertions.assertEquals(4473608850473810276L, model.value().get(0).vlan());
    }

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