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

public final class NetworkRackInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        NetworkRackInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"networkRackSku\":\"mjqfrddgamquhio\",\"networkFabricId\":\"rsjuivfcdisyir\",\"networkDevices\":[\"hcz\",\"xrxzbujrtr\",\"qvwre\",\"khgn\"],\"provisioningState\":\"Updating\",\"annotation\":\"nzlrpiqywncvjt\"},\"location\":\"cof\",\"tags\":{\"gbjkvreljeamur\":\"htd\"},\"id\":\"zmlovuanash\",\"name\":\"xlpm\",\"type\":\"erbdk\"}")
                .toObject(NetworkRackInner.class);
        Assertions.assertEquals("cof", model.location());
        Assertions.assertEquals("htd", model.tags().get("gbjkvreljeamur"));
        Assertions.assertEquals("mjqfrddgamquhio", model.networkRackSku());
        Assertions.assertEquals("rsjuivfcdisyir", model.networkFabricId());
        Assertions.assertEquals("nzlrpiqywncvjt", model.annotation());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        NetworkRackInner model =
            new NetworkRackInner()
                .withLocation("cof")
                .withTags(mapOf("gbjkvreljeamur", "htd"))
                .withNetworkRackSku("mjqfrddgamquhio")
                .withNetworkFabricId("rsjuivfcdisyir")
                .withAnnotation("nzlrpiqywncvjt");
        model = BinaryData.fromObject(model).toObject(NetworkRackInner.class);
        Assertions.assertEquals("cof", model.location());
        Assertions.assertEquals("htd", model.tags().get("gbjkvreljeamur"));
        Assertions.assertEquals("mjqfrddgamquhio", model.networkRackSku());
        Assertions.assertEquals("rsjuivfcdisyir", model.networkFabricId());
        Assertions.assertEquals("nzlrpiqywncvjt", 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;
    }
}
