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

package com.azure.resourcemanager.powerbidedicated.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.powerbidedicated.fluent.models.AutoScaleVCoreInner;
import com.azure.resourcemanager.powerbidedicated.models.AutoScaleVCoreSku;
import com.azure.resourcemanager.powerbidedicated.models.VCoreSkuTier;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class AutoScaleVCoreInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AutoScaleVCoreInner model =
            BinaryData
                .fromString(
                    "{\"sku\":{\"name\":\"pfhyhl\",\"tier\":\"AutoScale\",\"capacity\":1911186108},\"properties\":{\"capacityObjectId\":\"mcmatuokthfuiu\",\"provisioningState\":\"Succeeded\",\"capacityLimit\":680550088},\"location\":\"pk\",\"tags\":{\"dagfuaxbezyiuok\":\"dpuozmyz\",\"surex\":\"twhrdxwzywqsm\",\"dystkiiuxhqyud\":\"moryocfsfksym\",\"rq\":\"o\"},\"id\":\"b\",\"name\":\"oczvy\",\"type\":\"fqrvkdvjsllrmvvd\"}")
                .toObject(AutoScaleVCoreInner.class);
        Assertions.assertEquals("pk", model.location());
        Assertions.assertEquals("dpuozmyz", model.tags().get("dagfuaxbezyiuok"));
        Assertions.assertEquals("pfhyhl", model.sku().name());
        Assertions.assertEquals(VCoreSkuTier.AUTO_SCALE, model.sku().tier());
        Assertions.assertEquals(1911186108, model.sku().capacity());
        Assertions.assertEquals("mcmatuokthfuiu", model.capacityObjectId());
        Assertions.assertEquals(680550088, model.capacityLimit());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AutoScaleVCoreInner model =
            new AutoScaleVCoreInner()
                .withLocation("pk")
                .withTags(
                    mapOf(
                        "dagfuaxbezyiuok",
                        "dpuozmyz",
                        "surex",
                        "twhrdxwzywqsm",
                        "dystkiiuxhqyud",
                        "moryocfsfksym",
                        "rq",
                        "o"))
                .withSku(
                    new AutoScaleVCoreSku()
                        .withName("pfhyhl")
                        .withTier(VCoreSkuTier.AUTO_SCALE)
                        .withCapacity(1911186108))
                .withCapacityObjectId("mcmatuokthfuiu")
                .withCapacityLimit(680550088);
        model = BinaryData.fromObject(model).toObject(AutoScaleVCoreInner.class);
        Assertions.assertEquals("pk", model.location());
        Assertions.assertEquals("dpuozmyz", model.tags().get("dagfuaxbezyiuok"));
        Assertions.assertEquals("pfhyhl", model.sku().name());
        Assertions.assertEquals(VCoreSkuTier.AUTO_SCALE, model.sku().tier());
        Assertions.assertEquals(1911186108, model.sku().capacity());
        Assertions.assertEquals("mcmatuokthfuiu", model.capacityObjectId());
        Assertions.assertEquals(680550088, model.capacityLimit());
    }

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