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

package com.azure.resourcemanager.managednetworkfabric.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.managednetworkfabric.fluent.models.L2IsolationDomainInner;
import com.azure.resourcemanager.managednetworkfabric.models.L2IsolationDomainsListResult;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class L2IsolationDomainsListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        L2IsolationDomainsListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"networkFabricId\":\"j\",\"vlanId\":1640197955,\"mtu\":9347197,\"disabledOnResources\":[],\"administrativeState\":\"Enabled\",\"provisioningState\":\"Succeeded\",\"annotation\":\"gjljyoxgvc\"},\"location\":\"bgsncghkjeszzhb\",\"tags\":{\"fsm\":\"txfvgx\",\"odebfqkkrbmpu\":\"nehmpvecx\",\"wflzlfbxzpuzy\":\"gr\",\"y\":\"ispnqzahmgkbrp\"},\"id\":\"hibnuqqkpika\",\"name\":\"rgvtqag\",\"type\":\"buynhijggm\"}],\"nextLink\":\"fsiarbutr\"}")
                .toObject(L2IsolationDomainsListResult.class);
        Assertions.assertEquals("bgsncghkjeszzhb", model.value().get(0).location());
        Assertions.assertEquals("txfvgx", model.value().get(0).tags().get("fsm"));
        Assertions.assertEquals("j", model.value().get(0).networkFabricId());
        Assertions.assertEquals(1640197955, model.value().get(0).vlanId());
        Assertions.assertEquals(9347197, model.value().get(0).mtu());
        Assertions.assertEquals("gjljyoxgvc", model.value().get(0).annotation());
        Assertions.assertEquals("fsiarbutr", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        L2IsolationDomainsListResult model =
            new L2IsolationDomainsListResult()
                .withValue(
                    Arrays
                        .asList(
                            new L2IsolationDomainInner()
                                .withLocation("bgsncghkjeszzhb")
                                .withTags(
                                    mapOf(
                                        "fsm",
                                        "txfvgx",
                                        "odebfqkkrbmpu",
                                        "nehmpvecx",
                                        "wflzlfbxzpuzy",
                                        "gr",
                                        "y",
                                        "ispnqzahmgkbrp"))
                                .withNetworkFabricId("j")
                                .withVlanId(1640197955)
                                .withMtu(9347197)
                                .withAnnotation("gjljyoxgvc")))
                .withNextLink("fsiarbutr");
        model = BinaryData.fromObject(model).toObject(L2IsolationDomainsListResult.class);
        Assertions.assertEquals("bgsncghkjeszzhb", model.value().get(0).location());
        Assertions.assertEquals("txfvgx", model.value().get(0).tags().get("fsm"));
        Assertions.assertEquals("j", model.value().get(0).networkFabricId());
        Assertions.assertEquals(1640197955, model.value().get(0).vlanId());
        Assertions.assertEquals(9347197, model.value().get(0).mtu());
        Assertions.assertEquals("gjljyoxgvc", model.value().get(0).annotation());
        Assertions.assertEquals("fsiarbutr", 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;
    }
}
