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

package com.azure.resourcemanager.cognitiveservices.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.cognitiveservices.models.PatchResourceTagsAndSku;
import com.azure.resourcemanager.cognitiveservices.models.Sku;
import com.azure.resourcemanager.cognitiveservices.models.SkuTier;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class PatchResourceTagsAndSkuTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        PatchResourceTagsAndSku model =
            BinaryData
                .fromString(
                    "{\"sku\":{\"name\":\"lt\",\"tier\":\"Enterprise\",\"size\":\"cwsobqwcs\",\"family\":\"nwdcfhu\",\"capacity\":1491398356},\"tags\":{\"vtvudutncormr\":\"uvglsbjjcanvx\",\"f\":\"xqtvcofu\",\"u\":\"vkg\"}}")
                .toObject(PatchResourceTagsAndSku.class);
        Assertions.assertEquals("uvglsbjjcanvx", model.tags().get("vtvudutncormr"));
        Assertions.assertEquals("lt", model.sku().name());
        Assertions.assertEquals(SkuTier.ENTERPRISE, model.sku().tier());
        Assertions.assertEquals("cwsobqwcs", model.sku().size());
        Assertions.assertEquals("nwdcfhu", model.sku().family());
        Assertions.assertEquals(1491398356, model.sku().capacity());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        PatchResourceTagsAndSku model =
            new PatchResourceTagsAndSku()
                .withTags(mapOf("vtvudutncormr", "uvglsbjjcanvx", "f", "xqtvcofu", "u", "vkg"))
                .withSku(
                    new Sku()
                        .withName("lt")
                        .withTier(SkuTier.ENTERPRISE)
                        .withSize("cwsobqwcs")
                        .withFamily("nwdcfhu")
                        .withCapacity(1491398356));
        model = BinaryData.fromObject(model).toObject(PatchResourceTagsAndSku.class);
        Assertions.assertEquals("uvglsbjjcanvx", model.tags().get("vtvudutncormr"));
        Assertions.assertEquals("lt", model.sku().name());
        Assertions.assertEquals(SkuTier.ENTERPRISE, model.sku().tier());
        Assertions.assertEquals("cwsobqwcs", model.sku().size());
        Assertions.assertEquals("nwdcfhu", model.sku().family());
        Assertions.assertEquals(1491398356, model.sku().capacity());
    }

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