// 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.fluent.models.CreatorInner;
import com.azure.resourcemanager.maps.fluent.models.CreatorProperties;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class CreatorInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        CreatorInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"provisioningState\":\"jn\",\"storageUnits\":746279797},\"location\":\"khsmtxpsiebt\",\"tags\":{\"htldwk\":\"pesapskrdqmhjj\",\"otogtwrupqs\":\"zxuutkncwscwsvl\",\"cykvceo\":\"vnm\",\"vnotyfjfcnj\":\"eil\"},\"id\":\"k\",\"name\":\"nxdhbt\",\"type\":\"kphywpnvjto\"}")
                .toObject(CreatorInner.class);
        Assertions.assertEquals("khsmtxpsiebt", model.location());
        Assertions.assertEquals("pesapskrdqmhjj", model.tags().get("htldwk"));
        Assertions.assertEquals(746279797, model.properties().storageUnits());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        CreatorInner model =
            new CreatorInner()
                .withLocation("khsmtxpsiebt")
                .withTags(
                    mapOf(
                        "htldwk",
                        "pesapskrdqmhjj",
                        "otogtwrupqs",
                        "zxuutkncwscwsvl",
                        "cykvceo",
                        "vnm",
                        "vnotyfjfcnj",
                        "eil"))
                .withProperties(new CreatorProperties().withStorageUnits(746279797));
        model = BinaryData.fromObject(model).toObject(CreatorInner.class);
        Assertions.assertEquals("khsmtxpsiebt", model.location());
        Assertions.assertEquals("pesapskrdqmhjj", model.tags().get("htldwk"));
        Assertions.assertEquals(746279797, model.properties().storageUnits());
    }

    // Use "Map.of" if available
    @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;
    }
}
