// 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.models.AutoScaleVCoreSku;
import com.azure.resourcemanager.powerbidedicated.models.AutoScaleVCoreUpdateParameters;
import com.azure.resourcemanager.powerbidedicated.models.VCoreSkuTier;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class AutoScaleVCoreUpdateParametersTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AutoScaleVCoreUpdateParameters model =
            BinaryData
                .fromString(
                    "{\"sku\":{\"name\":\"hzdobpxjmflbvvnc\",\"tier\":\"AutoScale\",\"capacity\":682758161},\"tags\":{\"rsa\":\"wzjuqk\",\"ghsauuimjmvxied\":\"iwkuofos\",\"byao\":\"ugidyjrr\",\"xc\":\"v\"},\"properties\":{\"capacityLimit\":771742090}}")
                .toObject(AutoScaleVCoreUpdateParameters.class);
        Assertions.assertEquals("hzdobpxjmflbvvnc", model.sku().name());
        Assertions.assertEquals(VCoreSkuTier.AUTO_SCALE, model.sku().tier());
        Assertions.assertEquals(682758161, model.sku().capacity());
        Assertions.assertEquals("wzjuqk", model.tags().get("rsa"));
        Assertions.assertEquals(771742090, model.capacityLimit());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AutoScaleVCoreUpdateParameters model =
            new AutoScaleVCoreUpdateParameters()
                .withSku(
                    new AutoScaleVCoreSku()
                        .withName("hzdobpxjmflbvvnc")
                        .withTier(VCoreSkuTier.AUTO_SCALE)
                        .withCapacity(682758161))
                .withTags(mapOf("rsa", "wzjuqk", "ghsauuimjmvxied", "iwkuofos", "byao", "ugidyjrr", "xc", "v"))
                .withCapacityLimit(771742090);
        model = BinaryData.fromObject(model).toObject(AutoScaleVCoreUpdateParameters.class);
        Assertions.assertEquals("hzdobpxjmflbvvnc", model.sku().name());
        Assertions.assertEquals(VCoreSkuTier.AUTO_SCALE, model.sku().tier());
        Assertions.assertEquals(682758161, model.sku().capacity());
        Assertions.assertEquals("wzjuqk", model.tags().get("rsa"));
        Assertions.assertEquals(771742090, 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;
    }
}
