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

package com.azure.resourcemanager.networkcloud.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.networkcloud.fluent.models.VolumeInner;
import com.azure.resourcemanager.networkcloud.models.ExtendedLocation;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class VolumeInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        VolumeInner model =
            BinaryData
                .fromString(
                    "{\"extendedLocation\":{\"name\":\"l\",\"type\":\"xgncxyk\"},\"properties\":{\"attachedTo\":[\"jhlimmbcxfhbcpo\",\"xvxcjzhq\"],\"detailedStatus\":\"Provisioning\",\"detailedStatusMessage\":\"pxtgqscjav\",\"provisioningState\":\"Succeeded\",\"serialNumber\":\"hdqazkmtgguwp\",\"sizeMiB\":8179047474835825750},\"location\":\"jcivmmg\",\"tags\":{\"uvyinzqodfvpgs\":\"fiwrxgkn\"},\"id\":\"oxgsgbpfgzdjtx\",\"name\":\"zflbqvg\",\"type\":\"qvlgafcqusrdvetn\"}")
                .toObject(VolumeInner.class);
        Assertions.assertEquals("jcivmmg", model.location());
        Assertions.assertEquals("fiwrxgkn", model.tags().get("uvyinzqodfvpgs"));
        Assertions.assertEquals("l", model.extendedLocation().name());
        Assertions.assertEquals("xgncxyk", model.extendedLocation().type());
        Assertions.assertEquals(8179047474835825750L, model.sizeMiB());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        VolumeInner model =
            new VolumeInner()
                .withLocation("jcivmmg")
                .withTags(mapOf("uvyinzqodfvpgs", "fiwrxgkn"))
                .withExtendedLocation(new ExtendedLocation().withName("l").withType("xgncxyk"))
                .withSizeMiB(8179047474835825750L);
        model = BinaryData.fromObject(model).toObject(VolumeInner.class);
        Assertions.assertEquals("jcivmmg", model.location());
        Assertions.assertEquals("fiwrxgkn", model.tags().get("uvyinzqodfvpgs"));
        Assertions.assertEquals("l", model.extendedLocation().name());
        Assertions.assertEquals("xgncxyk", model.extendedLocation().type());
        Assertions.assertEquals(8179047474835825750L, model.sizeMiB());
    }

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