// 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\":\"cvpnazzmhjrunmpx\",\"properties\":{\"poolId\":\"dbhrbnlankxm\",\"size\":7709872707867102281,\"serviceLevel\":\"Standard\",\"provisioningState\":\"henbtkcxywnytn\",\"totalThroughputMibps\":7.4236927,\"utilizedThroughputMibps\":38.21055,\"qosType\":\"Manual\",\"coolAccess\":false,\"encryptionType\":\"Single\"},\"location\":\"czfc\",\"tags\":{\"wrqlfktsthsuco\":\"axdbabph\",\"bt\":\"mnyyazt\",\"ckzywbiexzfeyue\":\"wrqpue\",\"zyoxaepdkzjan\":\"xibxujwbhqwalm\"},\"id\":\"ux\",\"name\":\"hdwbavxbniwdjs\",\"type\":\"zt\"},{\"etag\":\"bpg\",\"properties\":{\"poolId\":\"ytxhp\",\"size\":8724476376904230855,\"serviceLevel\":\"Ultra\",\"provisioningState\":\"fzab\",\"totalThroughputMibps\":16.014355,\"utilizedThroughputMibps\":15.152192,\"qosType\":\"Auto\",\"coolAccess\":false,\"encryptionType\":\"Double\"},\"location\":\"iklbbovpl\",\"tags\":{\"ss\":\"hvgyuguosvmk\",\"gmgsxnkjzkde\":\"qukkfp\"},\"id\":\"lpvlopw\",\"name\":\"yighxpk\",\"type\":\"wzbaiue\"},{\"etag\":\"a\",\"properties\":{\"poolId\":\"nyqupedeojnabck\",\"size\":225728868050420204,\"serviceLevel\":\"Standard\",\"provisioningState\":\"psiebtfhvpes\",\"totalThroughputMibps\":52.521877,\"utilizedThroughputMibps\":98.02466,\"qosType\":\"Manual\",\"coolAccess\":true,\"encryptionType\":\"Double\"},\"location\":\"htldwk\",\"tags\":{\"cwsvlxotog\":\"uutkncw\",\"o\":\"wrupqsxvnmicykvc\",\"vnotyfjfcnj\":\"eil\",\"nxdhbt\":\"k\"},\"id\":\"kphywpnvjto\",\"name\":\"nermcl\",\"type\":\"plpho\"}],\"nextLink\":\"scrpabgyepsbjt\"}")
                .toObject(CapacityPoolList.class);
        Assertions.assertEquals("czfc", model.value().get(0).location());
        Assertions.assertEquals("axdbabph", model.value().get(0).tags().get("wrqlfktsthsuco"));
        Assertions.assertEquals(7709872707867102281L, model.value().get(0).size());
        Assertions.assertEquals(ServiceLevel.STANDARD, model.value().get(0).serviceLevel());
        Assertions.assertEquals(QosType.MANUAL, model.value().get(0).qosType());
        Assertions.assertEquals(false, model.value().get(0).coolAccess());
        Assertions.assertEquals(EncryptionType.SINGLE, model.value().get(0).encryptionType());
        Assertions.assertEquals("scrpabgyepsbjt", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        CapacityPoolList model =
            new CapacityPoolList()
                .withValue(
                    Arrays
                        .asList(
                            new CapacityPoolInner()
                                .withLocation("czfc")
                                .withTags(
                                    mapOf(
                                        "wrqlfktsthsuco",
                                        "axdbabph",
                                        "bt",
                                        "mnyyazt",
                                        "ckzywbiexzfeyue",
                                        "wrqpue",
                                        "zyoxaepdkzjan",
                                        "xibxujwbhqwalm"))
                                .withSize(7709872707867102281L)
                                .withServiceLevel(ServiceLevel.STANDARD)
                                .withQosType(QosType.MANUAL)
                                .withCoolAccess(false)
                                .withEncryptionType(EncryptionType.SINGLE),
                            new CapacityPoolInner()
                                .withLocation("iklbbovpl")
                                .withTags(mapOf("ss", "hvgyuguosvmk", "gmgsxnkjzkde", "qukkfp"))
                                .withSize(8724476376904230855L)
                                .withServiceLevel(ServiceLevel.ULTRA)
                                .withQosType(QosType.AUTO)
                                .withCoolAccess(false)
                                .withEncryptionType(EncryptionType.DOUBLE),
                            new CapacityPoolInner()
                                .withLocation("htldwk")
                                .withTags(
                                    mapOf(
                                        "cwsvlxotog",
                                        "uutkncw",
                                        "o",
                                        "wrupqsxvnmicykvc",
                                        "vnotyfjfcnj",
                                        "eil",
                                        "nxdhbt",
                                        "k"))
                                .withSize(225728868050420204L)
                                .withServiceLevel(ServiceLevel.STANDARD)
                                .withQosType(QosType.MANUAL)
                                .withCoolAccess(true)
                                .withEncryptionType(EncryptionType.DOUBLE)))
                .withNextLink("scrpabgyepsbjt");
        model = BinaryData.fromObject(model).toObject(CapacityPoolList.class);
        Assertions.assertEquals("czfc", model.value().get(0).location());
        Assertions.assertEquals("axdbabph", model.value().get(0).tags().get("wrqlfktsthsuco"));
        Assertions.assertEquals(7709872707867102281L, model.value().get(0).size());
        Assertions.assertEquals(ServiceLevel.STANDARD, model.value().get(0).serviceLevel());
        Assertions.assertEquals(QosType.MANUAL, model.value().get(0).qosType());
        Assertions.assertEquals(false, model.value().get(0).coolAccess());
        Assertions.assertEquals(EncryptionType.SINGLE, model.value().get(0).encryptionType());
        Assertions.assertEquals("scrpabgyepsbjt", 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;
    }
}
