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

package com.azure.resourcemanager.maps.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.maps.models.Kind;
import com.azure.resourcemanager.maps.models.MapsAccountUpdateParameters;
import com.azure.resourcemanager.maps.models.Name;
import com.azure.resourcemanager.maps.models.Sku;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class MapsAccountUpdateParametersTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        MapsAccountUpdateParameters model =
            BinaryData
                .fromString(
                    "{\"tags\":{\"izntocipao\":\"zlhjxrifkwmrvkt\"},\"kind\":\"Gen1\",\"sku\":{\"name\":\"S0\",\"tier\":\"ucmpoyfd\"},\"properties\":{\"uniqueId\":\"gknygjofjddeqs\",\"disableLocalAuth\":true,\"provisioningState\":\"pewnw\"}}")
                .toObject(MapsAccountUpdateParameters.class);
        Assertions.assertEquals("zlhjxrifkwmrvkt", model.tags().get("izntocipao"));
        Assertions.assertEquals(Kind.GEN1, model.kind());
        Assertions.assertEquals(Name.S0, model.sku().name());
        Assertions.assertEquals(true, model.disableLocalAuth());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        MapsAccountUpdateParameters model =
            new MapsAccountUpdateParameters()
                .withTags(mapOf("izntocipao", "zlhjxrifkwmrvkt"))
                .withKind(Kind.GEN1)
                .withSku(new Sku().withName(Name.S0))
                .withDisableLocalAuth(true);
        model = BinaryData.fromObject(model).toObject(MapsAccountUpdateParameters.class);
        Assertions.assertEquals("zlhjxrifkwmrvkt", model.tags().get("izntocipao"));
        Assertions.assertEquals(Kind.GEN1, model.kind());
        Assertions.assertEquals(Name.S0, model.sku().name());
        Assertions.assertEquals(true, model.disableLocalAuth());
    }

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