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

public final class AutoScaleVCoreListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AutoScaleVCoreListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"sku\":{\"name\":\"lhocohslkev\",\"tier\":\"AutoScale\",\"capacity\":1425243209},\"properties\":{\"capacityObjectId\":\"u\",\"provisioningState\":\"Succeeded\",\"capacityLimit\":53032115},\"location\":\"x\",\"tags\":{\"v\":\"eiithlvmez\",\"xwburvjxxjns\":\"hxmzsbbzoggig\",\"ou\":\"ydptkoen\"},\"id\":\"nvudwtiukb\",\"name\":\"dng\",\"type\":\"pocipazyxoegu\"},{\"sku\":{\"name\":\"g\",\"tier\":\"AutoScale\",\"capacity\":244069221},\"properties\":{\"capacityObjectId\":\"ygevqzntypmrbpiz\",\"provisioningState\":\"Succeeded\",\"capacityLimit\":53365345},\"location\":\"dpydn\",\"tags\":{\"ifsjttgzfbishcb\":\"xdeoejzic\",\"alpbuxwgipwhon\":\"hajdeyeamdpha\"},\"id\":\"wkgshwa\",\"name\":\"kix\",\"type\":\"bin\"},{\"sku\":{\"name\":\"eputtmrywnuzoqf\",\"tier\":\"AutoScale\",\"capacity\":827817441},\"properties\":{\"capacityObjectId\":\"kcqvyxl\",\"provisioningState\":\"Succeeded\",\"capacityLimit\":1368622267},\"location\":\"cohoq\",\"tags\":{\"gyxzk\":\"vlryavwhheunmmq\"},\"id\":\"noc\",\"name\":\"koklya\",\"type\":\"uconuqszfkbey\"}]}")
                .toObject(AutoScaleVCoreListResult.class);
        Assertions.assertEquals("x", model.value().get(0).location());
        Assertions.assertEquals("eiithlvmez", model.value().get(0).tags().get("v"));
        Assertions.assertEquals("lhocohslkev", model.value().get(0).sku().name());
        Assertions.assertEquals(VCoreSkuTier.AUTO_SCALE, model.value().get(0).sku().tier());
        Assertions.assertEquals(1425243209, model.value().get(0).sku().capacity());
        Assertions.assertEquals("u", model.value().get(0).capacityObjectId());
        Assertions.assertEquals(53032115, model.value().get(0).capacityLimit());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AutoScaleVCoreListResult model =
            new AutoScaleVCoreListResult()
                .withValue(
                    Arrays
                        .asList(
                            new AutoScaleVCoreInner()
                                .withLocation("x")
                                .withTags(mapOf("v", "eiithlvmez", "xwburvjxxjns", "hxmzsbbzoggig", "ou", "ydptkoen"))
                                .withSku(
                                    new AutoScaleVCoreSku()
                                        .withName("lhocohslkev")
                                        .withTier(VCoreSkuTier.AUTO_SCALE)
                                        .withCapacity(1425243209))
                                .withCapacityObjectId("u")
                                .withCapacityLimit(53032115),
                            new AutoScaleVCoreInner()
                                .withLocation("dpydn")
                                .withTags(mapOf("ifsjttgzfbishcb", "xdeoejzic", "alpbuxwgipwhon", "hajdeyeamdpha"))
                                .withSku(
                                    new AutoScaleVCoreSku()
                                        .withName("g")
                                        .withTier(VCoreSkuTier.AUTO_SCALE)
                                        .withCapacity(244069221))
                                .withCapacityObjectId("ygevqzntypmrbpiz")
                                .withCapacityLimit(53365345),
                            new AutoScaleVCoreInner()
                                .withLocation("cohoq")
                                .withTags(mapOf("gyxzk", "vlryavwhheunmmq"))
                                .withSku(
                                    new AutoScaleVCoreSku()
                                        .withName("eputtmrywnuzoqf")
                                        .withTier(VCoreSkuTier.AUTO_SCALE)
                                        .withCapacity(827817441))
                                .withCapacityObjectId("kcqvyxl")
                                .withCapacityLimit(1368622267)));
        model = BinaryData.fromObject(model).toObject(AutoScaleVCoreListResult.class);
        Assertions.assertEquals("x", model.value().get(0).location());
        Assertions.assertEquals("eiithlvmez", model.value().get(0).tags().get("v"));
        Assertions.assertEquals("lhocohslkev", model.value().get(0).sku().name());
        Assertions.assertEquals(VCoreSkuTier.AUTO_SCALE, model.value().get(0).sku().tier());
        Assertions.assertEquals(1425243209, model.value().get(0).sku().capacity());
        Assertions.assertEquals("u", model.value().get(0).capacityObjectId());
        Assertions.assertEquals(53032115, model.value().get(0).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;
    }
}
