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

package com.azure.resourcemanager.hybridcontainerservice.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.hybridcontainerservice.fluent.models.StorageSpacesInner;
import com.azure.resourcemanager.hybridcontainerservice.models.StorageSpacesExtendedLocation;
import com.azure.resourcemanager.hybridcontainerservice.models.StorageSpacesListResult;
import com.azure.resourcemanager.hybridcontainerservice.models.StorageSpacesProperties;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class StorageSpacesListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        StorageSpacesListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"provisioningState\":\"Succeeded\"},\"extendedLocation\":{\"type\":\"dvwvgpio\",\"name\":\"wxrt\"},\"location\":\"udxepxgyqagv\",\"tags\":{\"wi\":\"npkukghimdblx\",\"rey\":\"fnjhfjxwmszkkfo\",\"elpcirelsfeaenwa\":\"kzikfjawneaivxwc\",\"xbjhwuaanozjosph\":\"fatkld\"},\"id\":\"oulpjrv\",\"name\":\"ag\",\"type\":\"rvimjwosytxitcsk\"},{\"properties\":{\"provisioningState\":\"Deleting\"},\"extendedLocation\":{\"type\":\"ke\",\"name\":\"ikh\"},\"location\":\"yf\",\"tags\":{\"idb\":\"gqggebdunygae\",\"su\":\"fatpxllrxcyjmoa\",\"wdmjsjqbjhhyx\":\"arm\"},\"id\":\"rw\",\"name\":\"yc\",\"type\":\"duhpk\"},{\"properties\":{\"provisioningState\":\"Canceled\"},\"extendedLocation\":{\"type\":\"ajxq\",\"name\":\"jhkycub\"},\"location\":\"ddg\",\"tags\":{\"i\":\"fwqmzqalkrmn\"},\"id\":\"pxacqqudfn\",\"name\":\"yxbaaabjyvayf\",\"type\":\"imrzrtuzqog\"}],\"nextLink\":\"xnevfdnwn\"}")
                .toObject(StorageSpacesListResult.class);
        Assertions.assertEquals("udxepxgyqagv", model.value().get(0).location());
        Assertions.assertEquals("npkukghimdblx", model.value().get(0).tags().get("wi"));
        Assertions.assertEquals("dvwvgpio", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals("wxrt", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("xnevfdnwn", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        StorageSpacesListResult model =
            new StorageSpacesListResult()
                .withValue(
                    Arrays
                        .asList(
                            new StorageSpacesInner()
                                .withLocation("udxepxgyqagv")
                                .withTags(
                                    mapOf(
                                        "wi",
                                        "npkukghimdblx",
                                        "rey",
                                        "fnjhfjxwmszkkfo",
                                        "elpcirelsfeaenwa",
                                        "kzikfjawneaivxwc",
                                        "xbjhwuaanozjosph",
                                        "fatkld"))
                                .withProperties(new StorageSpacesProperties())
                                .withExtendedLocation(
                                    new StorageSpacesExtendedLocation().withType("dvwvgpio").withName("wxrt")),
                            new StorageSpacesInner()
                                .withLocation("yf")
                                .withTags(
                                    mapOf("idb", "gqggebdunygae", "su", "fatpxllrxcyjmoa", "wdmjsjqbjhhyx", "arm"))
                                .withProperties(new StorageSpacesProperties())
                                .withExtendedLocation(
                                    new StorageSpacesExtendedLocation().withType("ke").withName("ikh")),
                            new StorageSpacesInner()
                                .withLocation("ddg")
                                .withTags(mapOf("i", "fwqmzqalkrmn"))
                                .withProperties(new StorageSpacesProperties())
                                .withExtendedLocation(
                                    new StorageSpacesExtendedLocation().withType("ajxq").withName("jhkycub"))))
                .withNextLink("xnevfdnwn");
        model = BinaryData.fromObject(model).toObject(StorageSpacesListResult.class);
        Assertions.assertEquals("udxepxgyqagv", model.value().get(0).location());
        Assertions.assertEquals("npkukghimdblx", model.value().get(0).tags().get("wi"));
        Assertions.assertEquals("dvwvgpio", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals("wxrt", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("xnevfdnwn", model.nextLink());
    }

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