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

package com.azure.resourcemanager.machinelearning.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.machinelearning.models.PartialMinimalTrackedResourceWithSku;
import com.azure.resourcemanager.machinelearning.models.PartialSku;
import com.azure.resourcemanager.machinelearning.models.SkuTier;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class PartialMinimalTrackedResourceWithSkuTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        PartialMinimalTrackedResourceWithSku model =
            BinaryData
                .fromString(
                    "{\"sku\":{\"capacity\":1978421071,\"family\":\"noamldsehaohdj\",\"name\":\"flzokxco\",\"size\":\"e\",\"tier\":\"Premium\"},\"tags\":{\"ftgz\":\"agltsxoa\"}}")
                .toObject(PartialMinimalTrackedResourceWithSku.class);
        Assertions.assertEquals("agltsxoa", model.tags().get("ftgz"));
        Assertions.assertEquals(1978421071, model.sku().capacity());
        Assertions.assertEquals("noamldsehaohdj", model.sku().family());
        Assertions.assertEquals("flzokxco", model.sku().name());
        Assertions.assertEquals("e", model.sku().size());
        Assertions.assertEquals(SkuTier.PREMIUM, model.sku().tier());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        PartialMinimalTrackedResourceWithSku model =
            new PartialMinimalTrackedResourceWithSku()
                .withTags(mapOf("ftgz", "agltsxoa"))
                .withSku(
                    new PartialSku()
                        .withCapacity(1978421071)
                        .withFamily("noamldsehaohdj")
                        .withName("flzokxco")
                        .withSize("e")
                        .withTier(SkuTier.PREMIUM));
        model = BinaryData.fromObject(model).toObject(PartialMinimalTrackedResourceWithSku.class);
        Assertions.assertEquals("agltsxoa", model.tags().get("ftgz"));
        Assertions.assertEquals(1978421071, model.sku().capacity());
        Assertions.assertEquals("noamldsehaohdj", model.sku().family());
        Assertions.assertEquals("flzokxco", model.sku().name());
        Assertions.assertEquals("e", model.sku().size());
        Assertions.assertEquals(SkuTier.PREMIUM, model.sku().tier());
    }

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