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

package com.azure.resourcemanager.storagepool.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.storagepool.fluent.models.DiskPoolInner;
import com.azure.resourcemanager.storagepool.models.DiskPoolListResult;
import com.azure.resourcemanager.storagepool.models.OperationalStatus;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DiskPoolListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DiskPoolListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"sku\":{\"name\":\"kohdbiha\",\"tier\":\"fhfcb\"},\"properties\":{\"provisioningState\":\"Invalid\",\"availabilityZones\":[],\"status\":\"Invalid\",\"disks\":[],\"subnetId\":\"git\",\"additionalCapabilities\":[]},\"managedBy\":\"hab\",\"managedByExtended\":[\"ikxwc\",\"byscnp\",\"x\",\"hiv\"],\"systemData\":{\"createdBy\":\"iwbybrkxvdumjg\",\"createdByType\":\"Application\",\"createdAt\":\"2021-08-06T06:25:16Z\",\"lastModifiedBy\":\"k\",\"lastModifiedByType\":\"ManagedIdentity\",\"lastModifiedAt\":\"2021-02-24T15:23:22Z\"},\"location\":\"ccsnhsjc\",\"tags\":{\"kryhtnapczwlokj\":\"j\",\"jnchgej\":\"emkkvnipjox\"},\"id\":\"podmailzydehojwy\",\"name\":\"huxinpmqnj\",\"type\":\"qwixjspro\"},{\"sku\":{\"name\":\"cputegjvwmfdats\",\"tier\":\"dvpjhulsuuvmk\"},\"properties\":{\"provisioningState\":\"Deleting\",\"availabilityZones\":[],\"status\":\"Healthy\",\"disks\":[],\"subnetId\":\"rwfndiod\",\"additionalCapabilities\":[]},\"managedBy\":\"lwejdpv\",\"managedByExtended\":[\"oqpsoa\",\"ctazakljlahbcryf\",\"dfdosygexp\"],\"systemData\":{\"createdBy\":\"akhmsbzjhcrz\",\"createdByType\":\"ManagedIdentity\",\"createdAt\":\"2021-07-17T05:53:15Z\",\"lastModifiedBy\":\"xaolth\",\"lastModifiedByType\":\"Key\",\"lastModifiedAt\":\"2021-11-21T18:08:48Z\"},\"location\":\"jbp\",\"tags\":{\"n\":\"s\",\"wzo\":\"gvfcj\",\"np\":\"xjtfelluwfzit\",\"lxofpdvhpfxxypin\":\"qfpjk\"},\"id\":\"nmayhuybb\",\"name\":\"podepoo\",\"type\":\"inuvamiheogn\"},{\"sku\":{\"name\":\"xzxtheo\",\"tier\":\"si\"},\"properties\":{\"provisioningState\":\"Succeeded\",\"availabilityZones\":[],\"status\":\"Running\",\"disks\":[],\"subnetId\":\"cciqihnhungbwjz\",\"additionalCapabilities\":[]},\"managedBy\":\"ygxgispemvtz\",\"managedByExtended\":[\"fublj\",\"fxqeof\"],\"systemData\":{\"createdBy\":\"qjhqjbas\",\"createdByType\":\"Key\",\"createdAt\":\"2021-01-21T06:57:24Z\",\"lastModifiedBy\":\"ulngsntn\",\"lastModifiedByType\":\"ManagedIdentity\",\"lastModifiedAt\":\"2021-04-13T14:53:58Z\"},\"location\":\"gc\",\"tags\":{\"skcqvkocrcjd\":\"clxxwrljdo\",\"lssai\":\"wtnhxbnjbiksqr\"},\"id\":\"qpjwnzlljfm\",\"name\":\"pee\",\"type\":\"vmgxsab\"},{\"sku\":{\"name\":\"qduujitcjczdz\",\"tier\":\"ndhkrw\"},\"properties\":{\"provisioningState\":\"Invalid\",\"availabilityZones\":[],\"status\":\"Unknown\",\"disks\":[],\"subnetId\":\"p\",\"additionalCapabilities\":[]},\"managedBy\":\"dkvwrwjfe\",\"managedByExtended\":[\"hutje\",\"tmrldhugjzzdatq\",\"hocdgeab\",\"gphuticndvka\"],\"systemData\":{\"createdBy\":\"yiftyhxhuro\",\"createdByType\":\"ManagedIdentity\",\"createdAt\":\"2021-02-18T21:26:44Z\",\"lastModifiedBy\":\"lniwpwcukjfkgiaw\",\"lastModifiedByType\":\"Key\",\"lastModifiedAt\":\"2021-05-21T20:11:19Z\"},\"location\":\"plwckbas\",\"tags\":{\"jkot\":\"nddhsgcbacph\",\"wyqkgfgibm\":\"nqgoulzndli\",\"qsrxybzqqed\":\"dgak\",\"iqfouflmmnkz\":\"ytb\"},\"id\":\"modmglougpb\",\"name\":\"wtmutduq\",\"type\":\"ta\"}],\"nextLink\":\"pwgcuertu\"}")
                .toObject(DiskPoolListResult.class);
        Assertions.assertEquals("ccsnhsjc", model.value().get(0).location());
        Assertions.assertEquals("j", model.value().get(0).tags().get("kryhtnapczwlokj"));
        Assertions.assertEquals("kohdbiha", model.value().get(0).nameSkuName());
        Assertions.assertEquals("fhfcb", model.value().get(0).tier());
        Assertions.assertEquals(OperationalStatus.INVALID, model.value().get(0).status());
        Assertions.assertEquals("git", model.value().get(0).subnetId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DiskPoolListResult model =
            new DiskPoolListResult()
                .withValue(
                    Arrays
                        .asList(
                            new DiskPoolInner()
                                .withLocation("ccsnhsjc")
                                .withTags(mapOf("kryhtnapczwlokj", "j", "jnchgej", "emkkvnipjox"))
                                .withNameSkuName("kohdbiha")
                                .withTier("fhfcb")
                                .withAvailabilityZones(Arrays.asList())
                                .withStatus(OperationalStatus.INVALID)
                                .withDisks(Arrays.asList())
                                .withSubnetId("git")
                                .withAdditionalCapabilities(Arrays.asList()),
                            new DiskPoolInner()
                                .withLocation("jbp")
                                .withTags(
                                    mapOf("n", "s", "wzo", "gvfcj", "np", "xjtfelluwfzit", "lxofpdvhpfxxypin", "qfpjk"))
                                .withNameSkuName("cputegjvwmfdats")
                                .withTier("dvpjhulsuuvmk")
                                .withAvailabilityZones(Arrays.asList())
                                .withStatus(OperationalStatus.HEALTHY)
                                .withDisks(Arrays.asList())
                                .withSubnetId("rwfndiod")
                                .withAdditionalCapabilities(Arrays.asList()),
                            new DiskPoolInner()
                                .withLocation("gc")
                                .withTags(mapOf("skcqvkocrcjd", "clxxwrljdo", "lssai", "wtnhxbnjbiksqr"))
                                .withNameSkuName("xzxtheo")
                                .withTier("si")
                                .withAvailabilityZones(Arrays.asList())
                                .withStatus(OperationalStatus.RUNNING)
                                .withDisks(Arrays.asList())
                                .withSubnetId("cciqihnhungbwjz")
                                .withAdditionalCapabilities(Arrays.asList()),
                            new DiskPoolInner()
                                .withLocation("plwckbas")
                                .withTags(
                                    mapOf(
                                        "jkot",
                                        "nddhsgcbacph",
                                        "wyqkgfgibm",
                                        "nqgoulzndli",
                                        "qsrxybzqqed",
                                        "dgak",
                                        "iqfouflmmnkz",
                                        "ytb"))
                                .withNameSkuName("qduujitcjczdz")
                                .withTier("ndhkrw")
                                .withAvailabilityZones(Arrays.asList())
                                .withStatus(OperationalStatus.UNKNOWN)
                                .withDisks(Arrays.asList())
                                .withSubnetId("p")
                                .withAdditionalCapabilities(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(DiskPoolListResult.class);
        Assertions.assertEquals("ccsnhsjc", model.value().get(0).location());
        Assertions.assertEquals("j", model.value().get(0).tags().get("kryhtnapczwlokj"));
        Assertions.assertEquals("kohdbiha", model.value().get(0).nameSkuName());
        Assertions.assertEquals("fhfcb", model.value().get(0).tier());
        Assertions.assertEquals(OperationalStatus.INVALID, model.value().get(0).status());
        Assertions.assertEquals("git", model.value().get(0).subnetId());
    }

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