// 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.StorageApplianceInner;
import com.azure.resourcemanager.networkcloud.models.ExtendedLocation;
import com.azure.resourcemanager.networkcloud.models.StorageApplianceList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class StorageApplianceListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        StorageApplianceList model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"cizjxvydfceacvl\",\"value\":[{\"extendedLocation\":{\"name\":\"gdyftumrtwna\",\"type\":\"jslb\"},\"properties\":{\"capacity\":738500562819787288,\"capacityUsed\":5263273195459135313,\"clusterId\":\"ztsfmznbaeqp\",\"detailedStatus\":\"Available\",\"detailedStatusMessage\":\"nrnrp\",\"managementIpv4Address\":\"huwrykqgaifm\",\"provisioningState\":\"Provisioning\",\"rackId\":\"lb\",\"rackSlot\":3020386945325813203,\"remoteVendorManagementFeature\":\"Unsupported\",\"remoteVendorManagementStatus\":\"Enabled\",\"serialNumber\":\"jdz\",\"storageApplianceSkuId\":\"xcv\"},\"location\":\"rhnj\",\"tags\":{\"qfzgemjdftul\":\"lvtno\",\"tmczuomejwcwwqi\":\"ltducea\",\"vpkjpr\":\"knssxmojm\"},\"id\":\"kwcf\",\"name\":\"ql\",\"type\":\"yxgtczh\"},{\"extendedLocation\":{\"name\":\"ydbsd\",\"type\":\"hmkxmaehvbb\"},\"properties\":{\"capacity\":6488427573342094358,\"capacityUsed\":3755202150997171578,\"clusterId\":\"n\",\"detailedStatus\":\"Error\",\"detailedStatusMessage\":\"x\",\"managementIpv4Address\":\"xywr\",\"provisioningState\":\"Succeeded\",\"rackId\":\"yklyhpluodpvruud\",\"rackSlot\":7713015855877945152,\"remoteVendorManagementFeature\":\"Supported\",\"remoteVendorManagementStatus\":\"Disabled\",\"serialNumber\":\"ostgkts\",\"storageApplianceSkuId\":\"vdxec\"},\"location\":\"edqbc\",\"tags\":{\"dqkdlwwqfbu\":\"lhpl\"},\"id\":\"lkxt\",\"name\":\"qjfsmlmbtxhw\",\"type\":\"fwsrtawcoezbrhu\"},{\"extendedLocation\":{\"name\":\"skh\",\"type\":\"dyg\"},\"properties\":{\"capacity\":3757334132859952072,\"capacityUsed\":4463320086185749721,\"clusterId\":\"jb\",\"detailedStatus\":\"Available\",\"detailedStatusMessage\":\"rfmluiqtq\",\"managementIpv4Address\":\"avyvnqqyba\",\"provisioningState\":\"Canceled\",\"rackId\":\"uayjkqa\",\"rackSlot\":7781909264743877977,\"remoteVendorManagementFeature\":\"Unsupported\",\"remoteVendorManagementStatus\":\"Enabled\",\"serialNumber\":\"sjc\",\"storageApplianceSkuId\":\"hernntiewdjc\"},\"location\":\"quwrbehwag\",\"tags\":{\"xtdr\":\"uffkmrqemvvh\",\"znmwcp\":\"futacoebjvewzc\",\"v\":\"guaadraufactkahz\",\"eekulfgslqubkwd\":\"jjziuxxpsh\"},\"id\":\"enr\",\"name\":\"sutujba\",\"type\":\"pjuohminyfl\"}]}")
                .toObject(StorageApplianceList.class);
        Assertions.assertEquals("cizjxvydfceacvl", model.nextLink());
        Assertions.assertEquals("rhnj", model.value().get(0).location());
        Assertions.assertEquals("lvtno", model.value().get(0).tags().get("qfzgemjdftul"));
        Assertions.assertEquals("gdyftumrtwna", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("jslb", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals("lb", model.value().get(0).rackId());
        Assertions.assertEquals(3020386945325813203L, model.value().get(0).rackSlot());
        Assertions.assertEquals("jdz", model.value().get(0).serialNumber());
        Assertions.assertEquals("xcv", model.value().get(0).storageApplianceSkuId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        StorageApplianceList model =
            new StorageApplianceList()
                .withNextLink("cizjxvydfceacvl")
                .withValue(
                    Arrays
                        .asList(
                            new StorageApplianceInner()
                                .withLocation("rhnj")
                                .withTags(
                                    mapOf("qfzgemjdftul", "lvtno", "tmczuomejwcwwqi", "ltducea", "vpkjpr", "knssxmojm"))
                                .withExtendedLocation(new ExtendedLocation().withName("gdyftumrtwna").withType("jslb"))
                                .withRackId("lb")
                                .withRackSlot(3020386945325813203L)
                                .withSerialNumber("jdz")
                                .withStorageApplianceSkuId("xcv"),
                            new StorageApplianceInner()
                                .withLocation("edqbc")
                                .withTags(mapOf("dqkdlwwqfbu", "lhpl"))
                                .withExtendedLocation(new ExtendedLocation().withName("ydbsd").withType("hmkxmaehvbb"))
                                .withRackId("yklyhpluodpvruud")
                                .withRackSlot(7713015855877945152L)
                                .withSerialNumber("ostgkts")
                                .withStorageApplianceSkuId("vdxec"),
                            new StorageApplianceInner()
                                .withLocation("quwrbehwag")
                                .withTags(
                                    mapOf(
                                        "xtdr",
                                        "uffkmrqemvvh",
                                        "znmwcp",
                                        "futacoebjvewzc",
                                        "v",
                                        "guaadraufactkahz",
                                        "eekulfgslqubkwd",
                                        "jjziuxxpsh"))
                                .withExtendedLocation(new ExtendedLocation().withName("skh").withType("dyg"))
                                .withRackId("uayjkqa")
                                .withRackSlot(7781909264743877977L)
                                .withSerialNumber("sjc")
                                .withStorageApplianceSkuId("hernntiewdjc")));
        model = BinaryData.fromObject(model).toObject(StorageApplianceList.class);
        Assertions.assertEquals("cizjxvydfceacvl", model.nextLink());
        Assertions.assertEquals("rhnj", model.value().get(0).location());
        Assertions.assertEquals("lvtno", model.value().get(0).tags().get("qfzgemjdftul"));
        Assertions.assertEquals("gdyftumrtwna", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("jslb", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals("lb", model.value().get(0).rackId());
        Assertions.assertEquals(3020386945325813203L, model.value().get(0).rackSlot());
        Assertions.assertEquals("jdz", model.value().get(0).serialNumber());
        Assertions.assertEquals("xcv", model.value().get(0).storageApplianceSkuId());
    }

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