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

package com.azure.resourcemanager.devcenter.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.devcenter.models.DevBoxDefinitionUpdate;
import com.azure.resourcemanager.devcenter.models.HibernateSupport;
import com.azure.resourcemanager.devcenter.models.ImageReference;
import com.azure.resourcemanager.devcenter.models.Sku;
import com.azure.resourcemanager.devcenter.models.SkuTier;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DevBoxDefinitionUpdateTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DevBoxDefinitionUpdate model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"imageReference\":{\"id\":\"tmgrcfbun\",\"exactVersion\":\"fqjhhkxbpvjymj\"},\"sku\":{\"name\":\"xjyngudivk\",\"tier\":\"Basic\",\"size\":\"bxqz\",\"family\":\"zjf\",\"capacity\":1306170568},\"osStorageType\":\"fdxxivetvtcqaqtd\",\"hibernateSupport\":\"Enabled\"},\"tags\":{\"vxysl\":\"xv\",\"ytkblmpew\":\"bhsfxob\"},\"location\":\"fbkrvrnsvs\"}")
                .toObject(DevBoxDefinitionUpdate.class);
        Assertions.assertEquals("xv", model.tags().get("vxysl"));
        Assertions.assertEquals("fbkrvrnsvs", model.location());
        Assertions.assertEquals("tmgrcfbun", model.imageReference().id());
        Assertions.assertEquals("xjyngudivk", model.sku().name());
        Assertions.assertEquals(SkuTier.BASIC, model.sku().tier());
        Assertions.assertEquals("bxqz", model.sku().size());
        Assertions.assertEquals("zjf", model.sku().family());
        Assertions.assertEquals(1306170568, model.sku().capacity());
        Assertions.assertEquals("fdxxivetvtcqaqtd", model.osStorageType());
        Assertions.assertEquals(HibernateSupport.ENABLED, model.hibernateSupport());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DevBoxDefinitionUpdate model =
            new DevBoxDefinitionUpdate()
                .withTags(mapOf("vxysl", "xv", "ytkblmpew", "bhsfxob"))
                .withLocation("fbkrvrnsvs")
                .withImageReference(new ImageReference().withId("tmgrcfbun"))
                .withSku(
                    new Sku()
                        .withName("xjyngudivk")
                        .withTier(SkuTier.BASIC)
                        .withSize("bxqz")
                        .withFamily("zjf")
                        .withCapacity(1306170568))
                .withOsStorageType("fdxxivetvtcqaqtd")
                .withHibernateSupport(HibernateSupport.ENABLED);
        model = BinaryData.fromObject(model).toObject(DevBoxDefinitionUpdate.class);
        Assertions.assertEquals("xv", model.tags().get("vxysl"));
        Assertions.assertEquals("fbkrvrnsvs", model.location());
        Assertions.assertEquals("tmgrcfbun", model.imageReference().id());
        Assertions.assertEquals("xjyngudivk", model.sku().name());
        Assertions.assertEquals(SkuTier.BASIC, model.sku().tier());
        Assertions.assertEquals("bxqz", model.sku().size());
        Assertions.assertEquals("zjf", model.sku().family());
        Assertions.assertEquals(1306170568, model.sku().capacity());
        Assertions.assertEquals("fdxxivetvtcqaqtd", model.osStorageType());
        Assertions.assertEquals(HibernateSupport.ENABLED, model.hibernateSupport());
    }

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