// 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.SpatialAnchorsAccountInner;
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 SpatialAnchorsAccountInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SpatialAnchorsAccountInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"storageAccountName\":\"burvjxxjnspy\",\"accountId\":\"tko\",\"accountDomain\":\"kouknvudwtiu\"},\"identity\":{\"principalId\":\"dng\",\"tenantId\":\"ocipazyxoeg\",\"type\":\"SystemAssigned\"},\"plan\":{\"principalId\":\"piu\",\"tenantId\":\"ygevqzntypmrbpiz\",\"type\":\"SystemAssigned\"},\"sku\":{\"name\":\"j\",\"tier\":\"Free\",\"size\":\"dnfyhxdeoejzicwi\",\"family\":\"jttgzf\",\"capacity\":2101457273},\"kind\":{\"name\":\"cbkhajdeyeamdph\",\"tier\":\"Premium\",\"size\":\"pbuxwgipwhon\",\"family\":\"kgshwa\",\"capacity\":2111638773},\"location\":\"zbinjeputtm\",\"tags\":{\"ftiyqzrnkcq\":\"nuzo\",\"whzlsicohoq\":\"yx\",\"hgyxzkonoc\":\"nwvlryavwhheunmm\",\"uconuqszfkbey\":\"koklya\"},\"id\":\"ewrmjmwvvjektc\",\"name\":\"senhwlrs\",\"type\":\"frzpwvlqdqgb\"}")
                .toObject(SpatialAnchorsAccountInner.class);
        Assertions.assertEquals("zbinjeputtm", model.location());
        Assertions.assertEquals("nuzo", model.tags().get("ftiyqzrnkcq"));
        Assertions.assertEquals(ResourceIdentityType.SYSTEM_ASSIGNED, model.identity().type());
        Assertions.assertEquals(ResourceIdentityType.SYSTEM_ASSIGNED, model.plan().type());
        Assertions.assertEquals("j", model.sku().name());
        Assertions.assertEquals(SkuTier.FREE, model.sku().tier());
        Assertions.assertEquals("dnfyhxdeoejzicwi", model.sku().size());
        Assertions.assertEquals("jttgzf", model.sku().family());
        Assertions.assertEquals(2101457273, model.sku().capacity());
        Assertions.assertEquals("cbkhajdeyeamdph", model.kind().name());
        Assertions.assertEquals(SkuTier.PREMIUM, model.kind().tier());
        Assertions.assertEquals("pbuxwgipwhon", model.kind().size());
        Assertions.assertEquals("kgshwa", model.kind().family());
        Assertions.assertEquals(2111638773, model.kind().capacity());
        Assertions.assertEquals("burvjxxjnspy", model.storageAccountName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SpatialAnchorsAccountInner model =
            new SpatialAnchorsAccountInner()
                .withLocation("zbinjeputtm")
                .withTags(
                    mapOf(
                        "ftiyqzrnkcq",
                        "nuzo",
                        "whzlsicohoq",
                        "yx",
                        "hgyxzkonoc",
                        "nwvlryavwhheunmm",
                        "uconuqszfkbey",
                        "koklya"))
                .withIdentity(new Identity().withType(ResourceIdentityType.SYSTEM_ASSIGNED))
                .withPlan(new Identity().withType(ResourceIdentityType.SYSTEM_ASSIGNED))
                .withSku(
                    new Sku()
                        .withName("j")
                        .withTier(SkuTier.FREE)
                        .withSize("dnfyhxdeoejzicwi")
                        .withFamily("jttgzf")
                        .withCapacity(2101457273))
                .withKind(
                    new Sku()
                        .withName("cbkhajdeyeamdph")
                        .withTier(SkuTier.PREMIUM)
                        .withSize("pbuxwgipwhon")
                        .withFamily("kgshwa")
                        .withCapacity(2111638773))
                .withStorageAccountName("burvjxxjnspy");
        model = BinaryData.fromObject(model).toObject(SpatialAnchorsAccountInner.class);
        Assertions.assertEquals("zbinjeputtm", model.location());
        Assertions.assertEquals("nuzo", model.tags().get("ftiyqzrnkcq"));
        Assertions.assertEquals(ResourceIdentityType.SYSTEM_ASSIGNED, model.identity().type());
        Assertions.assertEquals(ResourceIdentityType.SYSTEM_ASSIGNED, model.plan().type());
        Assertions.assertEquals("j", model.sku().name());
        Assertions.assertEquals(SkuTier.FREE, model.sku().tier());
        Assertions.assertEquals("dnfyhxdeoejzicwi", model.sku().size());
        Assertions.assertEquals("jttgzf", model.sku().family());
        Assertions.assertEquals(2101457273, model.sku().capacity());
        Assertions.assertEquals("cbkhajdeyeamdph", model.kind().name());
        Assertions.assertEquals(SkuTier.PREMIUM, model.kind().tier());
        Assertions.assertEquals("pbuxwgipwhon", model.kind().size());
        Assertions.assertEquals("kgshwa", model.kind().family());
        Assertions.assertEquals(2111638773, model.kind().capacity());
        Assertions.assertEquals("burvjxxjnspy", 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;
    }
}
