// 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.DedicatedCapacityInner;
import com.azure.resourcemanager.powerbidedicated.models.CapacitySku;
import com.azure.resourcemanager.powerbidedicated.models.CapacitySkuTier;
import com.azure.resourcemanager.powerbidedicated.models.DedicatedCapacities;
import com.azure.resourcemanager.powerbidedicated.models.Mode;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DedicatedCapacitiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DedicatedCapacities model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"sku\":{\"name\":\"pmqnja\",\"tier\":\"AutoPremiumHost\",\"capacity\":1052966015},\"properties\":{\"state\":\"Scaling\",\"provisioningState\":\"Suspended\",\"mode\":\"Gen2\",\"tenantId\":\"tegjvwmf\",\"friendlyName\":\"t\"},\"location\":\"mdvpjhulsu\",\"tags\":{\"odjpslwejd\":\"kjozkrwfnd\",\"cctazakljlahbc\":\"vwryoqpso\",\"gexpaojakhmsbz\":\"yffdfdos\"},\"id\":\"hcrzevd\",\"name\":\"hlxaolthqtr\",\"type\":\"qjbpfzfsin\"},{\"sku\":{\"name\":\"gvfcj\",\"tier\":\"PBIE_Azure\",\"capacity\":1543108452},\"properties\":{\"state\":\"Provisioning\",\"provisioningState\":\"Resuming\",\"mode\":\"Gen2\",\"tenantId\":\"fziton\",\"friendlyName\":\"qfpjk\"},\"location\":\"xofpdvhpfxxypi\",\"tags\":{\"inuvamiheogn\":\"mayhuybbkpodepoo\",\"usivye\":\"rxzxtheo\",\"nfygxgispemvtz\":\"cciqihnhungbwjz\"},\"id\":\"kufubljo\",\"name\":\"xqeofjaeqjhqjba\",\"type\":\"v\"},{\"sku\":{\"name\":\"smjqulngsntnbyb\",\"tier\":\"PBIE_Azure\",\"capacity\":823404328},\"properties\":{\"state\":\"Failed\",\"provisioningState\":\"Succeeded\",\"mode\":\"Gen2\",\"tenantId\":\"jdous\",\"friendlyName\":\"qvkoc\"},\"location\":\"jdkwtnhxbnjb\",\"tags\":{\"lljfmppeeb\":\"qrglssainqpjwn\",\"yqduujit\":\"mgxsab\",\"rwpdappdsbdkvwrw\":\"jczdzevndh\"},\"id\":\"feusnhut\",\"name\":\"eltmrldhugjzzdat\",\"type\":\"xhocdgeablgphuti\"},{\"sku\":{\"name\":\"ndv\",\"tier\":\"PBIE_Azure\",\"capacity\":563001635},\"properties\":{\"state\":\"Suspended\",\"provisioningState\":\"Succeeded\",\"mode\":\"Gen2\",\"tenantId\":\"rokft\",\"friendlyName\":\"olniwpwcukjf\"},\"location\":\"iawxklry\",\"tags\":{\"sgcbac\":\"ckbasyypndd\",\"zndlikwy\":\"hejkotynqgou\",\"bmadgak\":\"kgfg\"},\"id\":\"qsrxybzqqed\",\"name\":\"ytb\",\"type\":\"iqfouflmmnkz\"}]}")
                .toObject(DedicatedCapacities.class);
        Assertions.assertEquals("mdvpjhulsu", model.value().get(0).location());
        Assertions.assertEquals("kjozkrwfnd", model.value().get(0).tags().get("odjpslwejd"));
        Assertions.assertEquals("pmqnja", model.value().get(0).sku().name());
        Assertions.assertEquals(CapacitySkuTier.AUTO_PREMIUM_HOST, model.value().get(0).sku().tier());
        Assertions.assertEquals(1052966015, model.value().get(0).sku().capacity());
        Assertions.assertEquals(Mode.GEN2, model.value().get(0).mode());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DedicatedCapacities model =
            new DedicatedCapacities()
                .withValue(
                    Arrays
                        .asList(
                            new DedicatedCapacityInner()
                                .withLocation("mdvpjhulsu")
                                .withTags(
                                    mapOf(
                                        "odjpslwejd",
                                        "kjozkrwfnd",
                                        "cctazakljlahbc",
                                        "vwryoqpso",
                                        "gexpaojakhmsbz",
                                        "yffdfdos"))
                                .withSku(
                                    new CapacitySku()
                                        .withName("pmqnja")
                                        .withTier(CapacitySkuTier.AUTO_PREMIUM_HOST)
                                        .withCapacity(1052966015))
                                .withMode(Mode.GEN2),
                            new DedicatedCapacityInner()
                                .withLocation("xofpdvhpfxxypi")
                                .withTags(
                                    mapOf(
                                        "inuvamiheogn",
                                        "mayhuybbkpodepoo",
                                        "usivye",
                                        "rxzxtheo",
                                        "nfygxgispemvtz",
                                        "cciqihnhungbwjz"))
                                .withSku(
                                    new CapacitySku()
                                        .withName("gvfcj")
                                        .withTier(CapacitySkuTier.PBIE_AZURE)
                                        .withCapacity(1543108452))
                                .withMode(Mode.GEN2),
                            new DedicatedCapacityInner()
                                .withLocation("jdkwtnhxbnjb")
                                .withTags(
                                    mapOf(
                                        "lljfmppeeb",
                                        "qrglssainqpjwn",
                                        "yqduujit",
                                        "mgxsab",
                                        "rwpdappdsbdkvwrw",
                                        "jczdzevndh"))
                                .withSku(
                                    new CapacitySku()
                                        .withName("smjqulngsntnbyb")
                                        .withTier(CapacitySkuTier.PBIE_AZURE)
                                        .withCapacity(823404328))
                                .withMode(Mode.GEN2),
                            new DedicatedCapacityInner()
                                .withLocation("iawxklry")
                                .withTags(mapOf("sgcbac", "ckbasyypndd", "zndlikwy", "hejkotynqgou", "bmadgak", "kgfg"))
                                .withSku(
                                    new CapacitySku()
                                        .withName("ndv")
                                        .withTier(CapacitySkuTier.PBIE_AZURE)
                                        .withCapacity(563001635))
                                .withMode(Mode.GEN2)));
        model = BinaryData.fromObject(model).toObject(DedicatedCapacities.class);
        Assertions.assertEquals("mdvpjhulsu", model.value().get(0).location());
        Assertions.assertEquals("kjozkrwfnd", model.value().get(0).tags().get("odjpslwejd"));
        Assertions.assertEquals("pmqnja", model.value().get(0).sku().name());
        Assertions.assertEquals(CapacitySkuTier.AUTO_PREMIUM_HOST, model.value().get(0).sku().tier());
        Assertions.assertEquals(1052966015, model.value().get(0).sku().capacity());
        Assertions.assertEquals(Mode.GEN2, model.value().get(0).mode());
    }

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