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

package com.azure.resourcemanager.devtestlabs.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.devtestlabs.fluent.models.DiskInner;
import com.azure.resourcemanager.devtestlabs.models.DiskList;
import com.azure.resourcemanager.devtestlabs.models.StorageType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DiskListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DiskList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"diskType\":\"Premium\",\"diskSizeGiB\":1919581142,\"leasedByLabVmId\":\"u\",\"diskBlobName\":\"bgo\",\"diskUri\":\"bteoybf\",\"storageAccountId\":\"xakvvjgslor\",\"createdDate\":\"2021-01-13T10:59:26Z\",\"hostCaching\":\"yw\",\"managedDiskId\":\"kgkxn\",\"provisioningState\":\"dabg\",\"uniqueIdentifier\":\"udtjuewbc\"},\"location\":\"hxuuwhcjyxccybvp\",\"tags\":{\"gwjplmag\":\"kkudzp\",\"bdgiogsjk\":\"tcyohpfkyrk\"},\"id\":\"nwqjnoba\",\"name\":\"yhddvia\",\"type\":\"egfnmntfpmvmemfn\"},{\"properties\":{\"diskType\":\"Standard\",\"diskSizeGiB\":1426712657,\"leasedByLabVmId\":\"b\",\"diskBlobName\":\"xlllchp\",\"diskUri\":\"bzevwrd\",\"storageAccountId\":\"fukuvsjcswsmystu\",\"createdDate\":\"2021-02-12T04:05:52Z\",\"hostCaching\":\"pfcvlerchpqbmfp\",\"managedDiskId\":\"abwidfcxsspuun\",\"provisioningState\":\"xyh\",\"uniqueIdentifier\":\"g\"},\"location\":\"ddrihpf\",\"tags\":{\"djvlpj\":\"caaewdao\",\"msgeivsiykzk\":\"xkzb\",\"xonbzoggculapz\":\"ncj\",\"pgogtqxepny\":\"y\"},\"id\":\"b\",\"name\":\"uajlyj\",\"type\":\"lvofqzhvfcibyfmo\"},{\"properties\":{\"diskType\":\"Standard\",\"diskSizeGiB\":2073572107,\"leasedByLabVmId\":\"pvdwxf\",\"diskBlobName\":\"iivwzjbhyzsxjrka\",\"diskUri\":\"trnegvmnvuqeqvld\",\"storageAccountId\":\"astjbkkdmflvestm\",\"createdDate\":\"2021-03-05T16:19:09Z\",\"hostCaching\":\"ril\",\"managedDiskId\":\"apeewchpxlkt\",\"provisioningState\":\"uziycsl\",\"uniqueIdentifier\":\"ufuztcktyhjtq\"},\"location\":\"dcgzul\",\"tags\":{\"rjvpglydzgkrvqee\":\"rqzz\",\"nwy\":\"toepryu\",\"vzvfvaawzqadfl\":\"pzdm\"},\"id\":\"z\",\"name\":\"riglaec\",\"type\":\"ndtic\"},{\"properties\":{\"diskType\":\"Standard\",\"diskSizeGiB\":684499938,\"leasedByLabVmId\":\"lqtmldgxob\",\"diskBlobName\":\"rclnpkc\",\"diskUri\":\"yzriykhy\",\"storageAccountId\":\"fvjlboxqvkjlmx\",\"createdDate\":\"2021-07-31T05:45:52Z\",\"hostCaching\":\"ynhdwdigum\",\"managedDiskId\":\"raauzzpt\",\"provisioningState\":\"zysdzh\",\"uniqueIdentifier\":\"wwvaiqyuvvfonk\"},\"location\":\"hhqyi\",\"tags\":{\"uwmncs\":\"lauyav\"},\"id\":\"tijfybvp\",\"name\":\"ekrsgs\",\"type\":\"b\"}],\"nextLink\":\"uzqgnjdgkynsc\"}")
                .toObject(DiskList.class);
        Assertions.assertEquals("hxuuwhcjyxccybvp", model.value().get(0).location());
        Assertions.assertEquals("kkudzp", model.value().get(0).tags().get("gwjplmag"));
        Assertions.assertEquals(StorageType.PREMIUM, model.value().get(0).diskType());
        Assertions.assertEquals(1919581142, model.value().get(0).diskSizeGiB());
        Assertions.assertEquals("u", model.value().get(0).leasedByLabVmId());
        Assertions.assertEquals("bgo", model.value().get(0).diskBlobName());
        Assertions.assertEquals("bteoybf", model.value().get(0).diskUri());
        Assertions.assertEquals("xakvvjgslor", model.value().get(0).storageAccountId());
        Assertions.assertEquals("yw", model.value().get(0).hostCaching());
        Assertions.assertEquals("kgkxn", model.value().get(0).managedDiskId());
        Assertions.assertEquals("uzqgnjdgkynsc", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DiskList model =
            new DiskList()
                .withValue(
                    Arrays
                        .asList(
                            new DiskInner()
                                .withLocation("hxuuwhcjyxccybvp")
                                .withTags(mapOf("gwjplmag", "kkudzp", "bdgiogsjk", "tcyohpfkyrk"))
                                .withDiskType(StorageType.PREMIUM)
                                .withDiskSizeGiB(1919581142)
                                .withLeasedByLabVmId("u")
                                .withDiskBlobName("bgo")
                                .withDiskUri("bteoybf")
                                .withStorageAccountId("xakvvjgslor")
                                .withHostCaching("yw")
                                .withManagedDiskId("kgkxn"),
                            new DiskInner()
                                .withLocation("ddrihpf")
                                .withTags(
                                    mapOf(
                                        "djvlpj",
                                        "caaewdao",
                                        "msgeivsiykzk",
                                        "xkzb",
                                        "xonbzoggculapz",
                                        "ncj",
                                        "pgogtqxepny",
                                        "y"))
                                .withDiskType(StorageType.STANDARD)
                                .withDiskSizeGiB(1426712657)
                                .withLeasedByLabVmId("b")
                                .withDiskBlobName("xlllchp")
                                .withDiskUri("bzevwrd")
                                .withStorageAccountId("fukuvsjcswsmystu")
                                .withHostCaching("pfcvlerchpqbmfp")
                                .withManagedDiskId("abwidfcxsspuun"),
                            new DiskInner()
                                .withLocation("dcgzul")
                                .withTags(mapOf("rjvpglydzgkrvqee", "rqzz", "nwy", "toepryu", "vzvfvaawzqadfl", "pzdm"))
                                .withDiskType(StorageType.STANDARD)
                                .withDiskSizeGiB(2073572107)
                                .withLeasedByLabVmId("pvdwxf")
                                .withDiskBlobName("iivwzjbhyzsxjrka")
                                .withDiskUri("trnegvmnvuqeqvld")
                                .withStorageAccountId("astjbkkdmflvestm")
                                .withHostCaching("ril")
                                .withManagedDiskId("apeewchpxlkt"),
                            new DiskInner()
                                .withLocation("hhqyi")
                                .withTags(mapOf("uwmncs", "lauyav"))
                                .withDiskType(StorageType.STANDARD)
                                .withDiskSizeGiB(684499938)
                                .withLeasedByLabVmId("lqtmldgxob")
                                .withDiskBlobName("rclnpkc")
                                .withDiskUri("yzriykhy")
                                .withStorageAccountId("fvjlboxqvkjlmx")
                                .withHostCaching("ynhdwdigum")
                                .withManagedDiskId("raauzzpt")))
                .withNextLink("uzqgnjdgkynsc");
        model = BinaryData.fromObject(model).toObject(DiskList.class);
        Assertions.assertEquals("hxuuwhcjyxccybvp", model.value().get(0).location());
        Assertions.assertEquals("kkudzp", model.value().get(0).tags().get("gwjplmag"));
        Assertions.assertEquals(StorageType.PREMIUM, model.value().get(0).diskType());
        Assertions.assertEquals(1919581142, model.value().get(0).diskSizeGiB());
        Assertions.assertEquals("u", model.value().get(0).leasedByLabVmId());
        Assertions.assertEquals("bgo", model.value().get(0).diskBlobName());
        Assertions.assertEquals("bteoybf", model.value().get(0).diskUri());
        Assertions.assertEquals("xakvvjgslor", model.value().get(0).storageAccountId());
        Assertions.assertEquals("yw", model.value().get(0).hostCaching());
        Assertions.assertEquals("kgkxn", model.value().get(0).managedDiskId());
        Assertions.assertEquals("uzqgnjdgkynsc", 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;
    }
}
