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

package com.azure.resourcemanager.storagecache.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.storagecache.fluent.models.AmlFilesystemInner;
import com.azure.resourcemanager.storagecache.models.AmlFilesystemIdentity;
import com.azure.resourcemanager.storagecache.models.AmlFilesystemIdentityType;
import com.azure.resourcemanager.storagecache.models.AmlFilesystemsListResult;
import com.azure.resourcemanager.storagecache.models.SkuName;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class AmlFilesystemsListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AmlFilesystemsListResult model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"mhquvgjxp\",\"value\":[{\"identity\":{\"principalId\":\"ehmtzop\",\"tenantId\":\"phrupidgsybbejhp\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{}},\"sku\":{\"name\":\"xaobhdxbmtqioqjz\"},\"zones\":[\"bmufpown\",\"izhwlrxy\"],\"properties\":{\"storageCapacityTiB\":33.52534,\"provisioningState\":\"Creating\",\"filesystemSubnet\":\"jgkdmbpazlobcu\",\"throughputProvisionedMBps\":1053599723},\"location\":\"t\",\"tags\":{\"ooojywifsqe\":\"jnqglhqgnu\",\"zlhjxrifkwmrvkt\":\"aagdfmg\",\"ajpsquc\":\"izntocipao\",\"gjofjd\":\"poyfdkfogkn\"},\"id\":\"eqsrdeupewnwreit\",\"name\":\"zyf\",\"type\":\"usarhmofc\"},{\"identity\":{\"principalId\":\"my\",\"tenantId\":\"kdtmlxhekuk\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{}},\"sku\":{\"name\":\"cdm\"},\"zones\":[\"cryuan\",\"w\",\"xzdxtayrlhmwh\",\"pmrqobm\"],\"properties\":{\"storageCapacityTiB\":59.327854,\"provisioningState\":\"Failed\",\"filesystemSubnet\":\"yrtih\",\"throughputProvisionedMBps\":1773018691},\"location\":\"zvgnwzs\",\"tags\":{\"anufhfcbjysag\":\"lzufcyzkohdbi\",\"qhabifpikxwcz\":\"th\"},\"id\":\"yscnpqxu\",\"name\":\"ivyqniwbybrkxvd\",\"type\":\"mjgr\"},{\"identity\":{\"principalId\":\"vukxgau\",\"tenantId\":\"cs\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{}},\"sku\":{\"name\":\"yejhk\"},\"zones\":[\"tnapczwlokjyemkk\",\"ni\",\"joxzjnchgejspodm\",\"ilzyd\"],\"properties\":{\"storageCapacityTiB\":1.213932,\"provisioningState\":\"Updating\",\"filesystemSubnet\":\"ahuxinpm\",\"throughputProvisionedMBps\":972887206},\"location\":\"xj\",\"tags\":{\"gjvw\":\"ozvcput\"},\"id\":\"fdatsc\",\"name\":\"dvpjhulsuuvmk\",\"type\":\"ozkrwfndiodjpslw\"},{\"identity\":{\"principalId\":\"pvwryoqpsoacc\",\"tenantId\":\"zakljlahbc\",\"type\":\"None\",\"userAssignedIdentities\":{}},\"sku\":{\"name\":\"dosyg\"},\"zones\":[\"aojakhmsbzjhcrz\",\"vdphlxaolthqtr\",\"qjbpfzfsin\",\"gvfcj\"],\"properties\":{\"storageCapacityTiB\":42.41827,\"provisioningState\":\"Deleting\",\"filesystemSubnet\":\"j\",\"throughputProvisionedMBps\":1190609144},\"location\":\"fziton\",\"tags\":{\"vhpfxxypininmay\":\"fpjkjlxofp\",\"oginuvamiheognar\":\"uybbkpodep\"},\"id\":\"zxtheotusivyevcc\",\"name\":\"qi\",\"type\":\"nhungbw\"}]}")
                .toObject(AmlFilesystemsListResult.class);
        Assertions.assertEquals("mhquvgjxp", model.nextLink());
        Assertions.assertEquals("t", model.value().get(0).location());
        Assertions.assertEquals("jnqglhqgnu", model.value().get(0).tags().get("ooojywifsqe"));
        Assertions.assertEquals(AmlFilesystemIdentityType.USER_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("xaobhdxbmtqioqjz", model.value().get(0).sku().name());
        Assertions.assertEquals("bmufpown", model.value().get(0).zones().get(0));
        Assertions.assertEquals(33.52534f, model.value().get(0).storageCapacityTiB());
        Assertions.assertEquals("jgkdmbpazlobcu", model.value().get(0).filesystemSubnet());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AmlFilesystemsListResult model =
            new AmlFilesystemsListResult()
                .withNextLink("mhquvgjxp")
                .withValue(
                    Arrays
                        .asList(
                            new AmlFilesystemInner()
                                .withLocation("t")
                                .withTags(
                                    mapOf(
                                        "ooojywifsqe",
                                        "jnqglhqgnu",
                                        "zlhjxrifkwmrvkt",
                                        "aagdfmg",
                                        "ajpsquc",
                                        "izntocipao",
                                        "gjofjd",
                                        "poyfdkfogkn"))
                                .withIdentity(
                                    new AmlFilesystemIdentity()
                                        .withType(AmlFilesystemIdentityType.USER_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withSku(new SkuName().withName("xaobhdxbmtqioqjz"))
                                .withZones(Arrays.asList("bmufpown", "izhwlrxy"))
                                .withStorageCapacityTiB(33.52534f)
                                .withFilesystemSubnet("jgkdmbpazlobcu"),
                            new AmlFilesystemInner()
                                .withLocation("zvgnwzs")
                                .withTags(mapOf("anufhfcbjysag", "lzufcyzkohdbi", "qhabifpikxwcz", "th"))
                                .withIdentity(
                                    new AmlFilesystemIdentity()
                                        .withType(AmlFilesystemIdentityType.USER_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withSku(new SkuName().withName("cdm"))
                                .withZones(Arrays.asList("cryuan", "w", "xzdxtayrlhmwh", "pmrqobm"))
                                .withStorageCapacityTiB(59.327854f)
                                .withFilesystemSubnet("yrtih"),
                            new AmlFilesystemInner()
                                .withLocation("xj")
                                .withTags(mapOf("gjvw", "ozvcput"))
                                .withIdentity(
                                    new AmlFilesystemIdentity()
                                        .withType(AmlFilesystemIdentityType.USER_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withSku(new SkuName().withName("yejhk"))
                                .withZones(Arrays.asList("tnapczwlokjyemkk", "ni", "joxzjnchgejspodm", "ilzyd"))
                                .withStorageCapacityTiB(1.213932f)
                                .withFilesystemSubnet("ahuxinpm"),
                            new AmlFilesystemInner()
                                .withLocation("fziton")
                                .withTags(mapOf("vhpfxxypininmay", "fpjkjlxofp", "oginuvamiheognar", "uybbkpodep"))
                                .withIdentity(
                                    new AmlFilesystemIdentity()
                                        .withType(AmlFilesystemIdentityType.NONE)
                                        .withUserAssignedIdentities(mapOf()))
                                .withSku(new SkuName().withName("dosyg"))
                                .withZones(Arrays.asList("aojakhmsbzjhcrz", "vdphlxaolthqtr", "qjbpfzfsin", "gvfcj"))
                                .withStorageCapacityTiB(42.41827f)
                                .withFilesystemSubnet("j")));
        model = BinaryData.fromObject(model).toObject(AmlFilesystemsListResult.class);
        Assertions.assertEquals("mhquvgjxp", model.nextLink());
        Assertions.assertEquals("t", model.value().get(0).location());
        Assertions.assertEquals("jnqglhqgnu", model.value().get(0).tags().get("ooojywifsqe"));
        Assertions.assertEquals(AmlFilesystemIdentityType.USER_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("xaobhdxbmtqioqjz", model.value().get(0).sku().name());
        Assertions.assertEquals("bmufpown", model.value().get(0).zones().get(0));
        Assertions.assertEquals(33.52534f, model.value().get(0).storageCapacityTiB());
        Assertions.assertEquals("jgkdmbpazlobcu", model.value().get(0).filesystemSubnet());
    }

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