// 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.LabInner;
import com.azure.resourcemanager.devtestlabs.models.EnvironmentPermission;
import com.azure.resourcemanager.devtestlabs.models.LabList;
import com.azure.resourcemanager.devtestlabs.models.PremiumDataDisk;
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 LabListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        LabList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"defaultStorageAccount\":\"ryrtihfxtijbpzv\",\"defaultPremiumStorageAccount\":\"wzsymglzufcy\",\"artifactsStorageAccount\":\"ohdbihanufh\",\"premiumDataDiskStorageAccount\":\"bj\",\"vaultName\":\"a\",\"labStorageType\":\"StandardSSD\",\"mandatoryArtifactsResourceIdsLinux\":[],\"mandatoryArtifactsResourceIdsWindows\":[],\"createdDate\":\"2021-11-04T10:26:32Z\",\"premiumDataDisks\":\"Enabled\",\"environmentPermission\":\"Contributor\",\"vmCreationResourceGroup\":\"xwczbyscnp\",\"publicIpId\":\"uhivyqniw\",\"loadBalancerId\":\"br\",\"networkSecurityGroupId\":\"vd\",\"extendedProperties\":{},\"provisioningState\":\"grtfwvu\",\"uniqueIdentifier\":\"gaudcc\"},\"location\":\"nhsjcnyej\",\"tags\":{\"kkvnipjox\":\"yhtnapczwlokjye\",\"podmailzydehojwy\":\"jnchgej\",\"qwixjspro\":\"huxinpmqnj\",\"wmfdatscmdvpjhul\":\"vcputegj\"},\"id\":\"uuvmkjozkrwfnd\",\"name\":\"odjpslwejd\",\"type\":\"vwryoqpso\"},{\"properties\":{\"defaultStorageAccount\":\"tazak\",\"defaultPremiumStorageAccount\":\"lahbcryff\",\"artifactsStorageAccount\":\"dosyg\",\"premiumDataDiskStorageAccount\":\"paojakhmsbzjh\",\"vaultName\":\"zevdphlx\",\"labStorageType\":\"StandardSSD\",\"mandatoryArtifactsResourceIdsLinux\":[],\"mandatoryArtifactsResourceIdsWindows\":[],\"createdDate\":\"2021-05-12T15:20:54Z\",\"premiumDataDisks\":\"Enabled\",\"environmentPermission\":\"Reader\",\"vmCreationResourceGroup\":\"zfsinzgvf\",\"publicIpId\":\"rwzoxxjtfelluwf\",\"loadBalancerId\":\"tonpe\",\"networkSecurityGroupId\":\"pjkjlxofpdv\",\"extendedProperties\":{},\"provisioningState\":\"xxypininmay\",\"uniqueIdentifier\":\"ybb\"},\"location\":\"podepoo\",\"tags\":{\"eotusivyevc\":\"uvamiheognarxzxt\",\"un\":\"iqihn\",\"fygxgispemvtzfk\":\"bwjzr\"},\"id\":\"fublj\",\"name\":\"fxqeof\",\"type\":\"aeqjhqjbasvms\"},{\"properties\":{\"defaultStorageAccount\":\"ulngsntn\",\"defaultPremiumStorageAccount\":\"bkzgcwrwclx\",\"artifactsStorageAccount\":\"rljdouskcqv\",\"premiumDataDiskStorageAccount\":\"cr\",\"vaultName\":\"dkwt\",\"labStorageType\":\"StandardSSD\",\"mandatoryArtifactsResourceIdsLinux\":[],\"mandatoryArtifactsResourceIdsWindows\":[],\"createdDate\":\"2021-08-22T09:01:35Z\",\"premiumDataDisks\":\"Enabled\",\"environmentPermission\":\"Contributor\",\"vmCreationResourceGroup\":\"ssainqpjwnzll\",\"publicIpId\":\"mppeebvmgxs\",\"loadBalancerId\":\"kyqduujit\",\"networkSecurityGroupId\":\"czdzev\",\"extendedProperties\":{},\"provisioningState\":\"krwpdap\",\"uniqueIdentifier\":\"sbdkvwr\"},\"location\":\"jfeusnh\",\"tags\":{\"xhocdgeablgphuti\":\"eltmrldhugjzzdat\"},\"id\":\"ndv\",\"name\":\"aozwyiftyhxhu\",\"type\":\"okftyxolniwpwcuk\"}],\"nextLink\":\"kgiawxklryplwck\"}")
                .toObject(LabList.class);
        Assertions.assertEquals("nhsjcnyej", model.value().get(0).location());
        Assertions.assertEquals("yhtnapczwlokjye", model.value().get(0).tags().get("kkvnipjox"));
        Assertions.assertEquals(StorageType.STANDARD_SSD, model.value().get(0).labStorageType());
        Assertions.assertEquals(PremiumDataDisk.ENABLED, model.value().get(0).premiumDataDisks());
        Assertions.assertEquals(EnvironmentPermission.CONTRIBUTOR, model.value().get(0).environmentPermission());
        Assertions.assertEquals("kgiawxklryplwck", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        LabList model =
            new LabList()
                .withValue(
                    Arrays
                        .asList(
                            new LabInner()
                                .withLocation("nhsjcnyej")
                                .withTags(
                                    mapOf(
                                        "kkvnipjox",
                                        "yhtnapczwlokjye",
                                        "podmailzydehojwy",
                                        "jnchgej",
                                        "qwixjspro",
                                        "huxinpmqnj",
                                        "wmfdatscmdvpjhul",
                                        "vcputegj"))
                                .withLabStorageType(StorageType.STANDARD_SSD)
                                .withMandatoryArtifactsResourceIdsLinux(Arrays.asList())
                                .withMandatoryArtifactsResourceIdsWindows(Arrays.asList())
                                .withPremiumDataDisks(PremiumDataDisk.ENABLED)
                                .withEnvironmentPermission(EnvironmentPermission.CONTRIBUTOR)
                                .withExtendedProperties(mapOf()),
                            new LabInner()
                                .withLocation("podepoo")
                                .withTags(
                                    mapOf("eotusivyevc", "uvamiheognarxzxt", "un", "iqihn", "fygxgispemvtzfk", "bwjzr"))
                                .withLabStorageType(StorageType.STANDARD_SSD)
                                .withMandatoryArtifactsResourceIdsLinux(Arrays.asList())
                                .withMandatoryArtifactsResourceIdsWindows(Arrays.asList())
                                .withPremiumDataDisks(PremiumDataDisk.ENABLED)
                                .withEnvironmentPermission(EnvironmentPermission.READER)
                                .withExtendedProperties(mapOf()),
                            new LabInner()
                                .withLocation("jfeusnh")
                                .withTags(mapOf("xhocdgeablgphuti", "eltmrldhugjzzdat"))
                                .withLabStorageType(StorageType.STANDARD_SSD)
                                .withMandatoryArtifactsResourceIdsLinux(Arrays.asList())
                                .withMandatoryArtifactsResourceIdsWindows(Arrays.asList())
                                .withPremiumDataDisks(PremiumDataDisk.ENABLED)
                                .withEnvironmentPermission(EnvironmentPermission.CONTRIBUTOR)
                                .withExtendedProperties(mapOf())))
                .withNextLink("kgiawxklryplwck");
        model = BinaryData.fromObject(model).toObject(LabList.class);
        Assertions.assertEquals("nhsjcnyej", model.value().get(0).location());
        Assertions.assertEquals("yhtnapczwlokjye", model.value().get(0).tags().get("kkvnipjox"));
        Assertions.assertEquals(StorageType.STANDARD_SSD, model.value().get(0).labStorageType());
        Assertions.assertEquals(PremiumDataDisk.ENABLED, model.value().get(0).premiumDataDisks());
        Assertions.assertEquals(EnvironmentPermission.CONTRIBUTOR, model.value().get(0).environmentPermission());
        Assertions.assertEquals("kgiawxklryplwck", 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;
    }
}
