// 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 java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class L2NetworkInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        L2NetworkInner model =
            BinaryData
                .fromString(
                    "{\"extendedLocation\":{\"name\":\"fn\",\"type\":\"ckw\"},\"properties\":{\"associatedResourceIds\":[\"qwhxxbuyqaxzfeqz\",\"ppriol\",\"or\",\"altol\"],\"clusterId\":\"cwsobqwcs\",\"detailedStatus\":\"Error\",\"detailedStatusMessage\":\"dcfhucqdpf\",\"hybridAksClustersAssociatedIds\":[\"lsbjjcanvxbv\",\"vudutncor\"],\"hybridAksPluginType\":\"DPDK\",\"interfaceName\":\"qtvcofudflvkgj\",\"l2IsolationDomainId\":\"bgdknnqv\",\"provisioningState\":\"Provisioning\",\"virtualMachinesAssociatedIds\":[\"n\",\"orudsgsa\",\"mkycgra\",\"wjue\"]},\"location\":\"eburu\",\"tags\":{\"l\":\"ovsm\",\"oefki\":\"wabm\",\"qujmqlgkf\":\"rvtp\",\"tujitcjedft\":\"tndoaongbjc\"},\"id\":\"waezkojvd\",\"name\":\"pzfoqoui\",\"type\":\"ybxarzgszu\"}")
                .toObject(L2NetworkInner.class);
        Assertions.assertEquals("eburu", model.location());
        Assertions.assertEquals("ovsm", model.tags().get("l"));
        Assertions.assertEquals("fn", model.extendedLocation().name());
        Assertions.assertEquals("ckw", model.extendedLocation().type());
        Assertions.assertEquals(HybridAksPluginType.DPDK, model.hybridAksPluginType());
        Assertions.assertEquals("qtvcofudflvkgj", model.interfaceName());
        Assertions.assertEquals("bgdknnqv", model.l2IsolationDomainId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        L2NetworkInner model =
            new L2NetworkInner()
                .withLocation("eburu")
                .withTags(mapOf("l", "ovsm", "oefki", "wabm", "qujmqlgkf", "rvtp", "tujitcjedft", "tndoaongbjc"))
                .withExtendedLocation(new ExtendedLocation().withName("fn").withType("ckw"))
                .withHybridAksPluginType(HybridAksPluginType.DPDK)
                .withInterfaceName("qtvcofudflvkgj")
                .withL2IsolationDomainId("bgdknnqv");
        model = BinaryData.fromObject(model).toObject(L2NetworkInner.class);
        Assertions.assertEquals("eburu", model.location());
        Assertions.assertEquals("ovsm", model.tags().get("l"));
        Assertions.assertEquals("fn", model.extendedLocation().name());
        Assertions.assertEquals("ckw", model.extendedLocation().type());
        Assertions.assertEquals(HybridAksPluginType.DPDK, model.hybridAksPluginType());
        Assertions.assertEquals("qtvcofudflvkgj", model.interfaceName());
        Assertions.assertEquals("bgdknnqv", model.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;
    }
}
