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

package azure.resourcemanager.methodsubscriptionid.generated;

import azure.resourcemanager.methodsubscriptionid.fluent.models.ResourceGroupResourceInner;
import azure.resourcemanager.methodsubscriptionid.models.ResourceGroupResourceProperties;
import com.azure.core.util.BinaryData;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ResourceGroupResourceInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ResourceGroupResourceInner model = BinaryData.fromString(
            "{\"properties\":{\"provisioningState\":\"Failed\",\"resourceGroupSetting\":\"wmrvktsizntocipa\"},\"location\":\"ajpsquc\",\"tags\":{\"kfo\":\"yf\"},\"id\":\"knygjofjddeq\",\"name\":\"rd\",\"type\":\"upewnwreitjzy\"}")
            .toObject(ResourceGroupResourceInner.class);
        Assertions.assertEquals("ajpsquc", model.location());
        Assertions.assertEquals("yf", model.tags().get("kfo"));
        Assertions.assertEquals("wmrvktsizntocipa", model.properties().resourceGroupSetting());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ResourceGroupResourceInner model = new ResourceGroupResourceInner().withLocation("ajpsquc")
            .withTags(mapOf("kfo", "yf"))
            .withProperties(new ResourceGroupResourceProperties().withResourceGroupSetting("wmrvktsizntocipa"));
        model = BinaryData.fromObject(model).toObject(ResourceGroupResourceInner.class);
        Assertions.assertEquals("ajpsquc", model.location());
        Assertions.assertEquals("yf", model.tags().get("kfo"));
        Assertions.assertEquals("wmrvktsizntocipa", model.properties().resourceGroupSetting());
    }

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