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

package azure.resourcemanager.multiservice.combined.generated;

import azure.resourcemanager.multiservice.combined.fluent.models.DiskInner;
import azure.resourcemanager.multiservice.combined.models.DiskProperties;
import com.azure.core.util.BinaryData;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DiskInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DiskInner model = BinaryData.fromString(
            "{\"properties\":{\"provisioningState\":\"Succeeded\"},\"location\":\"zhwlrxy\",\"tags\":{\"obcu\":\"oqijgkdmbpaz\",\"qgn\":\"pdznrbtcqqjnqgl\"},\"id\":\"foooj\",\"name\":\"wifsq\",\"type\":\"saagdf\"}")
            .toObject(DiskInner.class);
        Assertions.assertEquals("zhwlrxy", model.location());
        Assertions.assertEquals("oqijgkdmbpaz", model.tags().get("obcu"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DiskInner model = new DiskInner().withLocation("zhwlrxy")
            .withTags(mapOf("obcu", "oqijgkdmbpaz", "qgn", "pdznrbtcqqjnqgl"))
            .withProperties(new DiskProperties());
        model = BinaryData.fromObject(model).toObject(DiskInner.class);
        Assertions.assertEquals("zhwlrxy", model.location());
        Assertions.assertEquals("oqijgkdmbpaz", model.tags().get("obcu"));
    }

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