// 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.DedicatedCapacityAdministrators;
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 DedicatedCapacityInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DedicatedCapacityInner model =
            BinaryData
                .fromString(
                    "{\"sku\":{\"name\":\"mmhquvgjxpyb\",\"tier\":\"PBIE_Azure\",\"capacity\":1336465504},\"properties\":{\"state\":\"Suspending\",\"provisioningState\":\"Deleting\",\"administration\":{\"members\":[\"h\",\"upi\",\"gsybbejhp\",\"oycmsxaobhdxbmt\"]},\"mode\":\"Gen2\",\"tenantId\":\"jzehtb\",\"friendlyName\":\"fpownoizhwlr\"},\"location\":\"bqsoqijg\",\"tags\":{\"btcqq\":\"bpazlobcufpdzn\",\"lhqgnufooojy\":\"nq\",\"zlhjxrifkwmrvkt\":\"ifsqesaagdfmg\",\"ajpsquc\":\"izntocipao\"},\"id\":\"poyfdkfogkn\",\"name\":\"gjofjd\",\"type\":\"eqsrdeupewnwreit\"}")
                .toObject(DedicatedCapacityInner.class);
        Assertions.assertEquals("bqsoqijg", model.location());
        Assertions.assertEquals("bpazlobcufpdzn", model.tags().get("btcqq"));
        Assertions.assertEquals("mmhquvgjxpyb", model.sku().name());
        Assertions.assertEquals(CapacitySkuTier.PBIE_AZURE, model.sku().tier());
        Assertions.assertEquals(1336465504, model.sku().capacity());
        Assertions.assertEquals("h", model.administration().members().get(0));
        Assertions.assertEquals(Mode.GEN2, model.mode());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DedicatedCapacityInner model =
            new DedicatedCapacityInner()
                .withLocation("bqsoqijg")
                .withTags(
                    mapOf(
                        "btcqq",
                        "bpazlobcufpdzn",
                        "lhqgnufooojy",
                        "nq",
                        "zlhjxrifkwmrvkt",
                        "ifsqesaagdfmg",
                        "ajpsquc",
                        "izntocipao"))
                .withSku(
                    new CapacitySku()
                        .withName("mmhquvgjxpyb")
                        .withTier(CapacitySkuTier.PBIE_AZURE)
                        .withCapacity(1336465504))
                .withAdministration(
                    new DedicatedCapacityAdministrators()
                        .withMembers(Arrays.asList("h", "upi", "gsybbejhp", "oycmsxaobhdxbmt")))
                .withMode(Mode.GEN2);
        model = BinaryData.fromObject(model).toObject(DedicatedCapacityInner.class);
        Assertions.assertEquals("bqsoqijg", model.location());
        Assertions.assertEquals("bpazlobcufpdzn", model.tags().get("btcqq"));
        Assertions.assertEquals("mmhquvgjxpyb", model.sku().name());
        Assertions.assertEquals(CapacitySkuTier.PBIE_AZURE, model.sku().tier());
        Assertions.assertEquals(1336465504, model.sku().capacity());
        Assertions.assertEquals("h", model.administration().members().get(0));
        Assertions.assertEquals(Mode.GEN2, model.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;
    }
}
