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

package com.azure.resourcemanager.networkcloud.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.networkcloud.fluent.models.RackInner;
import com.azure.resourcemanager.networkcloud.models.ExtendedLocation;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class RackInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RackInner model =
            BinaryData
                .fromString(
                    "{\"extendedLocation\":{\"name\":\"fsbtkad\",\"type\":\"ysownbtgkbug\"},\"properties\":{\"availabilityZone\":\"jqctojcmisofie\",\"clusterId\":\"efojyqdhcupl\",\"detailedStatus\":\"Available\",\"detailedStatusMessage\":\"wkhihihlhzdsqt\",\"provisioningState\":\"Accepted\",\"rackLocation\":\"rgnowcjhfgm\",\"rackSerialNumber\":\"ecactx\",\"rackSkuId\":\"wotey\"},\"location\":\"cluqovekqvgqo\",\"tags\":{\"kfxcvhrfs\":\"fzmpjwyivq\",\"kvyklxubyjaffmm\":\"huagrttikteusqc\",\"qcuubgqibrta\":\"bl\"},\"id\":\"metttwgd\",\"name\":\"lqxihhrmooiz\",\"type\":\"seypxiutcxapz\"}")
                .toObject(RackInner.class);
        Assertions.assertEquals("cluqovekqvgqo", model.location());
        Assertions.assertEquals("fzmpjwyivq", model.tags().get("kfxcvhrfs"));
        Assertions.assertEquals("fsbtkad", model.extendedLocation().name());
        Assertions.assertEquals("ysownbtgkbug", model.extendedLocation().type());
        Assertions.assertEquals("jqctojcmisofie", model.availabilityZone());
        Assertions.assertEquals("rgnowcjhfgm", model.rackLocation());
        Assertions.assertEquals("ecactx", model.rackSerialNumber());
        Assertions.assertEquals("wotey", model.rackSkuId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RackInner model =
            new RackInner()
                .withLocation("cluqovekqvgqo")
                .withTags(mapOf("kfxcvhrfs", "fzmpjwyivq", "kvyklxubyjaffmm", "huagrttikteusqc", "qcuubgqibrta", "bl"))
                .withExtendedLocation(new ExtendedLocation().withName("fsbtkad").withType("ysownbtgkbug"))
                .withAvailabilityZone("jqctojcmisofie")
                .withRackLocation("rgnowcjhfgm")
                .withRackSerialNumber("ecactx")
                .withRackSkuId("wotey");
        model = BinaryData.fromObject(model).toObject(RackInner.class);
        Assertions.assertEquals("cluqovekqvgqo", model.location());
        Assertions.assertEquals("fzmpjwyivq", model.tags().get("kfxcvhrfs"));
        Assertions.assertEquals("fsbtkad", model.extendedLocation().name());
        Assertions.assertEquals("ysownbtgkbug", model.extendedLocation().type());
        Assertions.assertEquals("jqctojcmisofie", model.availabilityZone());
        Assertions.assertEquals("rgnowcjhfgm", model.rackLocation());
        Assertions.assertEquals("ecactx", model.rackSerialNumber());
        Assertions.assertEquals("wotey", model.rackSkuId());
    }

    // Use "Map.of" if available
    @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;
    }
}
