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

package com.azure.resourcemanager.mixedreality.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.mixedreality.fluent.models.RemoteRenderingAccountInner;
import com.azure.resourcemanager.mixedreality.models.Identity;
import com.azure.resourcemanager.mixedreality.models.ResourceIdentityType;
import com.azure.resourcemanager.mixedreality.models.Sku;
import com.azure.resourcemanager.mixedreality.models.SkuTier;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class RemoteRenderingAccountInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RemoteRenderingAccountInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"storageAccountName\":\"cqibycnojv\",\"accountId\":\"mefqsgzvahapjyzh\",\"accountDomain\":\"gqzcjr\"},\"identity\":{\"principalId\":\"jzlmw\",\"tenantId\":\"kvugfhzovawjvzun\",\"type\":\"SystemAssigned\"},\"plan\":{\"principalId\":\"n\",\"tenantId\":\"nxipeil\",\"type\":\"SystemAssigned\"},\"sku\":{\"name\":\"aejxd\",\"tier\":\"Premium\",\"size\":\"kzbbtd\",\"family\":\"mv\",\"capacity\":1487921664},\"kind\":{\"name\":\"pwo\",\"tier\":\"Basic\",\"size\":\"fpbsjyofdxl\",\"family\":\"sd\",\"capacity\":1422945070},\"location\":\"waboe\",\"tags\":{\"hhcaal\":\"kelnsmvbxwyjsf\"},\"id\":\"jixisxyawjoyaqcs\",\"name\":\"yjpkiidzyexz\",\"type\":\"eli\"}")
                .toObject(RemoteRenderingAccountInner.class);
        Assertions.assertEquals("waboe", model.location());
        Assertions.assertEquals("kelnsmvbxwyjsf", model.tags().get("hhcaal"));
        Assertions.assertEquals(ResourceIdentityType.SYSTEM_ASSIGNED, model.identity().type());
        Assertions.assertEquals(ResourceIdentityType.SYSTEM_ASSIGNED, model.plan().type());
        Assertions.assertEquals("aejxd", model.sku().name());
        Assertions.assertEquals(SkuTier.PREMIUM, model.sku().tier());
        Assertions.assertEquals("kzbbtd", model.sku().size());
        Assertions.assertEquals("mv", model.sku().family());
        Assertions.assertEquals(1487921664, model.sku().capacity());
        Assertions.assertEquals("pwo", model.kind().name());
        Assertions.assertEquals(SkuTier.BASIC, model.kind().tier());
        Assertions.assertEquals("fpbsjyofdxl", model.kind().size());
        Assertions.assertEquals("sd", model.kind().family());
        Assertions.assertEquals(1422945070, model.kind().capacity());
        Assertions.assertEquals("cqibycnojv", model.storageAccountName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RemoteRenderingAccountInner model =
            new RemoteRenderingAccountInner()
                .withLocation("waboe")
                .withTags(mapOf("hhcaal", "kelnsmvbxwyjsf"))
                .withIdentity(new Identity().withType(ResourceIdentityType.SYSTEM_ASSIGNED))
                .withPlan(new Identity().withType(ResourceIdentityType.SYSTEM_ASSIGNED))
                .withSku(
                    new Sku()
                        .withName("aejxd")
                        .withTier(SkuTier.PREMIUM)
                        .withSize("kzbbtd")
                        .withFamily("mv")
                        .withCapacity(1487921664))
                .withKind(
                    new Sku()
                        .withName("pwo")
                        .withTier(SkuTier.BASIC)
                        .withSize("fpbsjyofdxl")
                        .withFamily("sd")
                        .withCapacity(1422945070))
                .withStorageAccountName("cqibycnojv");
        model = BinaryData.fromObject(model).toObject(RemoteRenderingAccountInner.class);
        Assertions.assertEquals("waboe", model.location());
        Assertions.assertEquals("kelnsmvbxwyjsf", model.tags().get("hhcaal"));
        Assertions.assertEquals(ResourceIdentityType.SYSTEM_ASSIGNED, model.identity().type());
        Assertions.assertEquals(ResourceIdentityType.SYSTEM_ASSIGNED, model.plan().type());
        Assertions.assertEquals("aejxd", model.sku().name());
        Assertions.assertEquals(SkuTier.PREMIUM, model.sku().tier());
        Assertions.assertEquals("kzbbtd", model.sku().size());
        Assertions.assertEquals("mv", model.sku().family());
        Assertions.assertEquals(1487921664, model.sku().capacity());
        Assertions.assertEquals("pwo", model.kind().name());
        Assertions.assertEquals(SkuTier.BASIC, model.kind().tier());
        Assertions.assertEquals("fpbsjyofdxl", model.kind().size());
        Assertions.assertEquals("sd", model.kind().family());
        Assertions.assertEquals(1422945070, model.kind().capacity());
        Assertions.assertEquals("cqibycnojv", model.storageAccountName());
    }

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