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

public final class L2IsolationDomainInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        L2IsolationDomainInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"networkFabricId\":\"h\",\"vlanId\":1761587011,\"mtu\":765927655,\"configurationState\":\"Rejected\",\"provisioningState\":\"Accepted\",\"administrativeState\":\"RMA\",\"annotation\":\"exlfciatxtjrrl\"},\"location\":\"dskjhhxdlaj\",\"tags\":{\"a\":\"cxscvslxlh\",\"slojfkqidnqt\":\"krmukmyjmkxett\",\"rngl\":\"qxjhqxcsqhtkbtnq\"},\"id\":\"mbiipsnawwlqk\",\"name\":\"nxhhl\",\"type\":\"xricctkwmuqq\"}")
                .toObject(L2IsolationDomainInner.class);
        Assertions.assertEquals("dskjhhxdlaj", model.location());
        Assertions.assertEquals("cxscvslxlh", model.tags().get("a"));
        Assertions.assertEquals("h", model.networkFabricId());
        Assertions.assertEquals(1761587011, model.vlanId());
        Assertions.assertEquals(765927655, model.mtu());
        Assertions.assertEquals("exlfciatxtjrrl", model.annotation());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        L2IsolationDomainInner model =
            new L2IsolationDomainInner()
                .withLocation("dskjhhxdlaj")
                .withTags(mapOf("a", "cxscvslxlh", "slojfkqidnqt", "krmukmyjmkxett", "rngl", "qxjhqxcsqhtkbtnq"))
                .withNetworkFabricId("h")
                .withVlanId(1761587011)
                .withMtu(765927655)
                .withAnnotation("exlfciatxtjrrl");
        model = BinaryData.fromObject(model).toObject(L2IsolationDomainInner.class);
        Assertions.assertEquals("dskjhhxdlaj", model.location());
        Assertions.assertEquals("cxscvslxlh", model.tags().get("a"));
        Assertions.assertEquals("h", model.networkFabricId());
        Assertions.assertEquals(1761587011, model.vlanId());
        Assertions.assertEquals(765927655, model.mtu());
        Assertions.assertEquals("exlfciatxtjrrl", model.annotation());
    }

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