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

package com.azure.resourcemanager.netapp.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.netapp.fluent.models.CapacityPoolInner;
import com.azure.resourcemanager.netapp.models.CapacityPoolList;
import com.azure.resourcemanager.netapp.models.EncryptionType;
import com.azure.resourcemanager.netapp.models.QosType;
import com.azure.resourcemanager.netapp.models.ServiceLevel;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class CapacityPoolListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        CapacityPoolList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"etag\":\"asxazjpqyegualhb\",\"properties\":{\"poolId\":\"hejjz\",\"size\":246259275856309822,\"serviceLevel\":\"Ultra\",\"provisioningState\":\"gwdslfhotwm\",\"totalThroughputMibps\":56.16594,\"utilizedThroughputMibps\":86.83051,\"qosType\":\"Auto\",\"coolAccess\":true,\"encryptionType\":\"Double\"},\"location\":\"cftadeh\",\"tags\":{\"wd\":\"tyfsoppusuesn\",\"hctbqvudwxdn\":\"jbavorxzdm\"},\"id\":\"nvowgujju\",\"name\":\"wdkcglhsl\",\"type\":\"zj\"},{\"etag\":\"ggd\",\"properties\":{\"poolId\":\"ixhbkuofqweykhm\",\"size\":134874479412475399,\"serviceLevel\":\"Premium\",\"provisioningState\":\"yexfwh\",\"totalThroughputMibps\":85.08707,\"utilizedThroughputMibps\":59.6065,\"qosType\":\"Manual\",\"coolAccess\":false,\"encryptionType\":\"Single\"},\"location\":\"tynnaamdectehfi\",\"tags\":{\"hezrkgq\":\"jeyp\"},\"id\":\"c\",\"name\":\"refovgmkqsleyyvx\",\"type\":\"qjpkcattpngjcrc\"},{\"etag\":\"sqpjhvmdajvn\",\"properties\":{\"poolId\":\"ounqecano\",\"size\":4529960801894599237,\"serviceLevel\":\"Premium\",\"provisioningState\":\"hy\",\"totalThroughputMibps\":25.772358,\"utilizedThroughputMibps\":40.584183,\"qosType\":\"Manual\",\"coolAccess\":true,\"encryptionType\":\"Single\"},\"location\":\"atuokthfuiu\",\"tags\":{\"zydagfuaxbezyiuo\":\"sfcpkvxodpuozm\",\"dxwzywqsmbsurexi\":\"ktwh\",\"yocf\":\"o\",\"uxh\":\"fksymddystki\"},\"id\":\"yudxorrqnbp\",\"name\":\"czvyifq\",\"type\":\"vkd\"}],\"nextLink\":\"sllr\"}")
                .toObject(CapacityPoolList.class);
        Assertions.assertEquals("cftadeh", model.value().get(0).location());
        Assertions.assertEquals("tyfsoppusuesn", model.value().get(0).tags().get("wd"));
        Assertions.assertEquals(246259275856309822L, model.value().get(0).size());
        Assertions.assertEquals(ServiceLevel.ULTRA, model.value().get(0).serviceLevel());
        Assertions.assertEquals(QosType.AUTO, model.value().get(0).qosType());
        Assertions.assertEquals(true, model.value().get(0).coolAccess());
        Assertions.assertEquals(EncryptionType.DOUBLE, model.value().get(0).encryptionType());
        Assertions.assertEquals("sllr", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        CapacityPoolList model =
            new CapacityPoolList()
                .withValue(
                    Arrays
                        .asList(
                            new CapacityPoolInner()
                                .withLocation("cftadeh")
                                .withTags(mapOf("wd", "tyfsoppusuesn", "hctbqvudwxdn", "jbavorxzdm"))
                                .withSize(246259275856309822L)
                                .withServiceLevel(ServiceLevel.ULTRA)
                                .withQosType(QosType.AUTO)
                                .withCoolAccess(true)
                                .withEncryptionType(EncryptionType.DOUBLE),
                            new CapacityPoolInner()
                                .withLocation("tynnaamdectehfi")
                                .withTags(mapOf("hezrkgq", "jeyp"))
                                .withSize(134874479412475399L)
                                .withServiceLevel(ServiceLevel.PREMIUM)
                                .withQosType(QosType.MANUAL)
                                .withCoolAccess(false)
                                .withEncryptionType(EncryptionType.SINGLE),
                            new CapacityPoolInner()
                                .withLocation("atuokthfuiu")
                                .withTags(
                                    mapOf(
                                        "zydagfuaxbezyiuo",
                                        "sfcpkvxodpuozm",
                                        "dxwzywqsmbsurexi",
                                        "ktwh",
                                        "yocf",
                                        "o",
                                        "uxh",
                                        "fksymddystki"))
                                .withSize(4529960801894599237L)
                                .withServiceLevel(ServiceLevel.PREMIUM)
                                .withQosType(QosType.MANUAL)
                                .withCoolAccess(true)
                                .withEncryptionType(EncryptionType.SINGLE)))
                .withNextLink("sllr");
        model = BinaryData.fromObject(model).toObject(CapacityPoolList.class);
        Assertions.assertEquals("cftadeh", model.value().get(0).location());
        Assertions.assertEquals("tyfsoppusuesn", model.value().get(0).tags().get("wd"));
        Assertions.assertEquals(246259275856309822L, model.value().get(0).size());
        Assertions.assertEquals(ServiceLevel.ULTRA, model.value().get(0).serviceLevel());
        Assertions.assertEquals(QosType.AUTO, model.value().get(0).qosType());
        Assertions.assertEquals(true, model.value().get(0).coolAccess());
        Assertions.assertEquals(EncryptionType.DOUBLE, model.value().get(0).encryptionType());
        Assertions.assertEquals("sllr", 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;
    }
}
