// 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.NetworkDeviceInner;
import com.azure.resourcemanager.managednetworkfabric.models.NetworkDeviceRoleTypes;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class NetworkDeviceInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        NetworkDeviceInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"version\":\"onasxifto\",\"networkDeviceSku\":\"qyzhf\",\"networkDeviceRole\":\"ToR\",\"provisioningState\":\"Updating\",\"networkRackId\":\"ogczhonnxkrlg\",\"hostName\":\"hmossxkkgth\",\"serialNumber\":\"gh\",\"annotation\":\"bdhqxvcxgf\"},\"location\":\"dsofbshrns\",\"tags\":{\"jsrtk\":\"swdvzyybycnun\",\"uxzejntpsew\":\"awnopqgikyzirtxd\"},\"id\":\"ioilqukrydxtq\",\"name\":\"ieoxorggufhyaomt\",\"type\":\"ghhavgrvkffo\"}")
                .toObject(NetworkDeviceInner.class);
        Assertions.assertEquals("dsofbshrns", model.location());
        Assertions.assertEquals("swdvzyybycnun", model.tags().get("jsrtk"));
        Assertions.assertEquals("qyzhf", model.networkDeviceSku());
        Assertions.assertEquals(NetworkDeviceRoleTypes.TOR, model.networkDeviceRole());
        Assertions.assertEquals("hmossxkkgth", model.hostname());
        Assertions.assertEquals("gh", model.serialNumber());
        Assertions.assertEquals("bdhqxvcxgf", model.annotation());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        NetworkDeviceInner model =
            new NetworkDeviceInner()
                .withLocation("dsofbshrns")
                .withTags(mapOf("jsrtk", "swdvzyybycnun", "uxzejntpsew", "awnopqgikyzirtxd"))
                .withNetworkDeviceSku("qyzhf")
                .withNetworkDeviceRole(NetworkDeviceRoleTypes.TOR)
                .withHostname("hmossxkkgth")
                .withSerialNumber("gh")
                .withAnnotation("bdhqxvcxgf");
        model = BinaryData.fromObject(model).toObject(NetworkDeviceInner.class);
        Assertions.assertEquals("dsofbshrns", model.location());
        Assertions.assertEquals("swdvzyybycnun", model.tags().get("jsrtk"));
        Assertions.assertEquals("qyzhf", model.networkDeviceSku());
        Assertions.assertEquals(NetworkDeviceRoleTypes.TOR, model.networkDeviceRole());
        Assertions.assertEquals("hmossxkkgth", model.hostname());
        Assertions.assertEquals("gh", model.serialNumber());
        Assertions.assertEquals("bdhqxvcxgf", 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;
    }
}
