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

package com.azure.resourcemanager.elasticsan.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.elasticsan.fluent.models.VolumeInner;
import com.azure.resourcemanager.elasticsan.models.VolumeList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class VolumeListTests {
    @Test
    public void testDeserialize() {
        VolumeList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"volumeId\":\"wdslfhotwmcy\",\"sizeGiB\":7443640931865034302},\"tags\":{\"ehxnltyfsop\":\"acfta\",\"nzwdejba\":\"usue\",\"xdn\":\"orxzdmohctbqvud\"},\"id\":\"nvowgujju\",\"name\":\"wdkcglhsl\",\"type\":\"zj\"},{\"properties\":{\"volumeId\":\"gdtjixhbkuofqwey\",\"sizeGiB\":7762769610748668832},\"tags\":{\"cibvyvdcsitynn\":\"exfwhy\",\"f\":\"amdecte\"},\"id\":\"qsc\",\"name\":\"eypvhezrkg\",\"type\":\"hcjrefovgmk\"},{\"properties\":{\"volumeId\":\"eyyvxyqjpkcat\",\"sizeGiB\":6006698533954960409},\"tags\":{\"ounqecano\":\"zsqpjhvmdajvny\",\"pjmcmatuokthfuiu\":\"eupfhyhltrpm\",\"zydagfuaxbezyiuo\":\"odsfcpkvxodpuozm\"},\"id\":\"ktwh\",\"name\":\"dxwzywqsmbsurexi\",\"type\":\"o\"}],\"nextLink\":\"ocfs\"}")
                .toObject(VolumeList.class);
        Assertions.assertEquals("acfta", model.value().get(0).tags().get("ehxnltyfsop"));
        Assertions.assertEquals(7443640931865034302L, model.value().get(0).sizeGiB());
    }

    @Test
    public void testSerialize() {
        VolumeList model =
            new VolumeList()
                .withValue(
                    Arrays
                        .asList(
                            new VolumeInner()
                                .withTags(mapOf("ehxnltyfsop", "acfta", "nzwdejba", "usue", "xdn", "orxzdmohctbqvud"))
                                .withSizeGiB(7443640931865034302L),
                            new VolumeInner()
                                .withTags(mapOf("cibvyvdcsitynn", "exfwhy", "f", "amdecte"))
                                .withSizeGiB(7762769610748668832L),
                            new VolumeInner()
                                .withTags(
                                    mapOf(
                                        "ounqecano",
                                        "zsqpjhvmdajvny",
                                        "pjmcmatuokthfuiu",
                                        "eupfhyhltrpm",
                                        "zydagfuaxbezyiuo",
                                        "odsfcpkvxodpuozm"))
                                .withSizeGiB(6006698533954960409L)));
        model = BinaryData.fromObject(model).toObject(VolumeList.class);
        Assertions.assertEquals("acfta", model.value().get(0).tags().get("ehxnltyfsop"));
        Assertions.assertEquals(7443640931865034302L, model.value().get(0).sizeGiB());
    }

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