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

package com.azure.resourcemanager.hybridcompute.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.hybridcompute.fluent.models.HybridComputePrivateLinkScopeInner;
import com.azure.resourcemanager.hybridcompute.models.HybridComputePrivateLinkScopeListResult;
import com.azure.resourcemanager.hybridcompute.models.HybridComputePrivateLinkScopeProperties;
import com.azure.resourcemanager.hybridcompute.models.PublicNetworkAccessType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class HybridComputePrivateLinkScopeListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        HybridComputePrivateLinkScopeListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"publicNetworkAccess\":\"Enabled\",\"provisioningState\":\"e\",\"privateLinkScopeId\":\"a\"},\"location\":\"uhrzayvvt\",\"tags\":{\"ftutqxlngxlefgu\":\"dfgiot\",\"qmi\":\"nxkrx\"},\"id\":\"tthzrvqd\",\"name\":\"abhjybi\",\"type\":\"ehoqfbowskan\"},{\"properties\":{\"publicNetworkAccess\":\"Disabled\",\"provisioningState\":\"cuiywgqyw\",\"privateLinkScopeId\":\"drvyn\"},\"location\":\"gpphrcgyn\",\"tags\":{\"vmmcoofs\":\"pec\",\"y\":\"lzevgbmqjqab\",\"wnfnbacf\":\"mivkwlzuvcc\",\"bqqwxrj\":\"onlebxetqgtzxdpn\"},\"id\":\"eallnwsubisnj\",\"name\":\"mpmngnzscxaqwoo\",\"type\":\"hcbonqvpkvlr\"},{\"properties\":{\"publicNetworkAccess\":\"Enabled\",\"provisioningState\":\"seiphe\",\"privateLinkScopeId\":\"lokeyy\"},\"location\":\"nj\",\"tags\":{\"masxazjpqyegu\":\"wtgrhpdjpj\",\"wdslfhotwmcy\":\"lhbxxhejjzzvdud\",\"cftadeh\":\"pwlbjnpg\"},\"id\":\"nltyfsoppusuesnz\",\"name\":\"dejbavo\",\"type\":\"xzdmohctb\"}],\"nextLink\":\"udwxdndnvowguj\"}")
                .toObject(HybridComputePrivateLinkScopeListResult.class);
        Assertions.assertEquals("uhrzayvvt", model.value().get(0).location());
        Assertions.assertEquals("dfgiot", model.value().get(0).tags().get("ftutqxlngxlefgu"));
        Assertions
            .assertEquals(PublicNetworkAccessType.ENABLED, model.value().get(0).properties().publicNetworkAccess());
        Assertions.assertEquals("udwxdndnvowguj", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        HybridComputePrivateLinkScopeListResult model =
            new HybridComputePrivateLinkScopeListResult()
                .withValue(
                    Arrays
                        .asList(
                            new HybridComputePrivateLinkScopeInner()
                                .withLocation("uhrzayvvt")
                                .withTags(mapOf("ftutqxlngxlefgu", "dfgiot", "qmi", "nxkrx"))
                                .withProperties(
                                    new HybridComputePrivateLinkScopeProperties()
                                        .withPublicNetworkAccess(PublicNetworkAccessType.ENABLED)),
                            new HybridComputePrivateLinkScopeInner()
                                .withLocation("gpphrcgyn")
                                .withTags(
                                    mapOf(
                                        "vmmcoofs",
                                        "pec",
                                        "y",
                                        "lzevgbmqjqab",
                                        "wnfnbacf",
                                        "mivkwlzuvcc",
                                        "bqqwxrj",
                                        "onlebxetqgtzxdpn"))
                                .withProperties(
                                    new HybridComputePrivateLinkScopeProperties()
                                        .withPublicNetworkAccess(PublicNetworkAccessType.DISABLED)),
                            new HybridComputePrivateLinkScopeInner()
                                .withLocation("nj")
                                .withTags(
                                    mapOf(
                                        "masxazjpqyegu",
                                        "wtgrhpdjpj",
                                        "wdslfhotwmcy",
                                        "lhbxxhejjzzvdud",
                                        "cftadeh",
                                        "pwlbjnpg"))
                                .withProperties(
                                    new HybridComputePrivateLinkScopeProperties()
                                        .withPublicNetworkAccess(PublicNetworkAccessType.ENABLED))))
                .withNextLink("udwxdndnvowguj");
        model = BinaryData.fromObject(model).toObject(HybridComputePrivateLinkScopeListResult.class);
        Assertions.assertEquals("uhrzayvvt", model.value().get(0).location());
        Assertions.assertEquals("dfgiot", model.value().get(0).tags().get("ftutqxlngxlefgu"));
        Assertions
            .assertEquals(PublicNetworkAccessType.ENABLED, model.value().get(0).properties().publicNetworkAccess());
        Assertions.assertEquals("udwxdndnvowguj", 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;
    }
}
