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

package com.azure.resourcemanager.databoxedge.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.databoxedge.fluent.models.DataBoxEdgeDeviceInner;
import com.azure.resourcemanager.databoxedge.models.DataBoxEdgeDeviceStatus;
import com.azure.resourcemanager.databoxedge.models.Sku;
import com.azure.resourcemanager.databoxedge.models.SkuName;
import com.azure.resourcemanager.databoxedge.models.SkuTier;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DataBoxEdgeDeviceInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DataBoxEdgeDeviceInner model =
            BinaryData
                .fromString(
                    "{\"location\":\"sycbkbfk\",\"tags\":{\"axcfjpgddtocjjx\":\"dkexxppofm\",\"eojnxqbzvddn\":\"vpmouexhdzxib\"},\"sku\":{\"name\":\"TEA_1Node_UPS_Heater\",\"tier\":\"Standard\"},\"etag\":\"btwnpzaoqvuhrhcf\",\"properties\":{\"dataBoxEdgeDeviceStatus\":\"NeedsAttention\",\"serialNumber\":\"glmjth\",\"description\":\"kw\",\"modelDescription\":\"eicxmqciwqvhkhi\",\"deviceType\":\"DataBoxEdgeDevice\",\"friendlyName\":\"dtopbob\",\"culture\":\"ghmewuam\",\"deviceModel\":\"hrzayvvtpgvdf\",\"deviceSoftwareVersion\":\"otkftutqxlngx\",\"deviceLocalCapacity\":6623521547442247310,\"timeZone\":\"gnxkrxdqmidtth\",\"deviceHcsVersion\":\"vqdra\",\"configuredRoleTypes\":[\"IOT\",\"IOT\"],\"nodeCount\":1370032032},\"id\":\"ehoqfbowskan\",\"name\":\"ktzlcuiywg\",\"type\":\"ywgndrv\"}")
                .toObject(DataBoxEdgeDeviceInner.class);
        Assertions.assertEquals("sycbkbfk", model.location());
        Assertions.assertEquals("dkexxppofm", model.tags().get("axcfjpgddtocjjx"));
        Assertions.assertEquals(SkuName.TEA_1NODE_UPS_HEATER, model.sku().name());
        Assertions.assertEquals(SkuTier.STANDARD, model.sku().tier());
        Assertions.assertEquals("btwnpzaoqvuhrhcf", model.etag());
        Assertions.assertEquals(DataBoxEdgeDeviceStatus.NEEDS_ATTENTION, model.dataBoxEdgeDeviceStatus());
        Assertions.assertEquals("kw", model.description());
        Assertions.assertEquals("eicxmqciwqvhkhi", model.modelDescription());
        Assertions.assertEquals("dtopbob", model.friendlyName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DataBoxEdgeDeviceInner model =
            new DataBoxEdgeDeviceInner()
                .withLocation("sycbkbfk")
                .withTags(mapOf("axcfjpgddtocjjx", "dkexxppofm", "eojnxqbzvddn", "vpmouexhdzxib"))
                .withSku(new Sku().withName(SkuName.TEA_1NODE_UPS_HEATER).withTier(SkuTier.STANDARD))
                .withEtag("btwnpzaoqvuhrhcf")
                .withDataBoxEdgeDeviceStatus(DataBoxEdgeDeviceStatus.NEEDS_ATTENTION)
                .withDescription("kw")
                .withModelDescription("eicxmqciwqvhkhi")
                .withFriendlyName("dtopbob");
        model = BinaryData.fromObject(model).toObject(DataBoxEdgeDeviceInner.class);
        Assertions.assertEquals("sycbkbfk", model.location());
        Assertions.assertEquals("dkexxppofm", model.tags().get("axcfjpgddtocjjx"));
        Assertions.assertEquals(SkuName.TEA_1NODE_UPS_HEATER, model.sku().name());
        Assertions.assertEquals(SkuTier.STANDARD, model.sku().tier());
        Assertions.assertEquals("btwnpzaoqvuhrhcf", model.etag());
        Assertions.assertEquals(DataBoxEdgeDeviceStatus.NEEDS_ATTENTION, model.dataBoxEdgeDeviceStatus());
        Assertions.assertEquals("kw", model.description());
        Assertions.assertEquals("eicxmqciwqvhkhi", model.modelDescription());
        Assertions.assertEquals("dtopbob", model.friendlyName());
    }

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