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

package com.azure.resourcemanager.machinelearning.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.machinelearning.fluent.models.PrivateLinkResourceListResultInner;
import com.azure.resourcemanager.machinelearning.models.ManagedServiceIdentity;
import com.azure.resourcemanager.machinelearning.models.ManagedServiceIdentityType;
import com.azure.resourcemanager.machinelearning.models.PrivateLinkResource;
import com.azure.resourcemanager.machinelearning.models.Sku;
import com.azure.resourcemanager.machinelearning.models.SkuTier;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class PrivateLinkResourceListResultInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        PrivateLinkResourceListResultInner model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"groupId\":\"c\",\"requiredMembers\":[],\"requiredZoneNames\":[]},\"identity\":{\"principalId\":\"7350756a-3e63-4658-9b36-a4c2e5f3a6d9\",\"tenantId\":\"02570bb2-e352-4d93-9bd1-d3451723dd5b\",\"type\":\"None\",\"userAssignedIdentities\":{}},\"location\":\"jkbegibtnmxiebww\",\"tags\":{\"tzjuzgwyzmhtxo\":\"ayqcgw\",\"nftguvriuhpr\":\"gmtsavjcbpwxqpsr\"},\"sku\":{\"name\":\"dyvxqtayriww\",\"tier\":\"Premium\",\"size\":\"bexrmcq\",\"family\":\"ycnojvknmefqsg\",\"capacity\":488274582},\"id\":\"apj\",\"name\":\"zhpvgqzcjrvxd\",\"type\":\"zlmwlxkvugfhz\"},{\"properties\":{\"groupId\":\"wjvzunluthnn\",\"requiredMembers\":[],\"requiredZoneNames\":[]},\"identity\":{\"principalId\":\"6cd9bb2d-0450-4976-a3e0-e2008cd6e042\",\"tenantId\":\"9dd771d6-e628-44bb-a9c6-f9185d3fbc61\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{}},\"location\":\"pjzu\",\"tags\":{\"kzbbtd\":\"xdult\",\"bsjyofdx\":\"umveekgpwozuhkf\",\"oekqvk\":\"uusdttouwa\",\"vbxwyjsflhh\":\"lns\"},\"sku\":{\"name\":\"aln\",\"tier\":\"Premium\",\"size\":\"sxyawjoyaqcs\",\"family\":\"jpkiidzyexznelix\",\"capacity\":705550222},\"id\":\"tfolhbnx\",\"name\":\"nalaulppg\",\"type\":\"dtpnapnyiropuhp\"},{\"properties\":{\"groupId\":\"pgylg\",\"requiredMembers\":[],\"requiredZoneNames\":[]},\"identity\":{\"principalId\":\"87b8d495-467b-4407-881f-0443f65da17d\",\"tenantId\":\"79df8e42-2e01-42d2-92af-39e2c1627e59\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{}},\"location\":\"v\",\"tags\":{\"rmgucnap\":\"ynqwwncwzzhxgk\",\"oellwp\":\"t\",\"qrhhu\":\"fdygpfqbuaceopz\"},\"sku\":{\"name\":\"pppcqeqxo\",\"tier\":\"Standard\",\"size\":\"hzxct\",\"family\":\"gbkdmoizpos\",\"capacity\":1176728044},\"id\":\"cfbu\",\"name\":\"rmfqjhhkxbpvj\",\"type\":\"mjh\"}]}")
                .toObject(PrivateLinkResourceListResultInner.class);
        Assertions.assertEquals(ManagedServiceIdentityType.NONE, model.value().get(0).identity().type());
        Assertions.assertEquals("jkbegibtnmxiebww", model.value().get(0).location());
        Assertions.assertEquals("ayqcgw", model.value().get(0).tags().get("tzjuzgwyzmhtxo"));
        Assertions.assertEquals("dyvxqtayriww", model.value().get(0).sku().name());
        Assertions.assertEquals(SkuTier.PREMIUM, model.value().get(0).sku().tier());
        Assertions.assertEquals("bexrmcq", model.value().get(0).sku().size());
        Assertions.assertEquals("ycnojvknmefqsg", model.value().get(0).sku().family());
        Assertions.assertEquals(488274582, model.value().get(0).sku().capacity());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        PrivateLinkResourceListResultInner model =
            new PrivateLinkResourceListResultInner()
                .withValue(
                    Arrays
                        .asList(
                            new PrivateLinkResource()
                                .withIdentity(
                                    new ManagedServiceIdentity()
                                        .withType(ManagedServiceIdentityType.NONE)
                                        .withUserAssignedIdentities(mapOf()))
                                .withLocation("jkbegibtnmxiebww")
                                .withTags(mapOf("tzjuzgwyzmhtxo", "ayqcgw", "nftguvriuhpr", "gmtsavjcbpwxqpsr"))
                                .withSku(
                                    new Sku()
                                        .withName("dyvxqtayriww")
                                        .withTier(SkuTier.PREMIUM)
                                        .withSize("bexrmcq")
                                        .withFamily("ycnojvknmefqsg")
                                        .withCapacity(488274582))
                                .withRequiredZoneNames(Arrays.asList()),
                            new PrivateLinkResource()
                                .withIdentity(
                                    new ManagedServiceIdentity()
                                        .withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withLocation("pjzu")
                                .withTags(
                                    mapOf(
                                        "kzbbtd",
                                        "xdult",
                                        "bsjyofdx",
                                        "umveekgpwozuhkf",
                                        "oekqvk",
                                        "uusdttouwa",
                                        "vbxwyjsflhh",
                                        "lns"))
                                .withSku(
                                    new Sku()
                                        .withName("aln")
                                        .withTier(SkuTier.PREMIUM)
                                        .withSize("sxyawjoyaqcs")
                                        .withFamily("jpkiidzyexznelix")
                                        .withCapacity(705550222))
                                .withRequiredZoneNames(Arrays.asList()),
                            new PrivateLinkResource()
                                .withIdentity(
                                    new ManagedServiceIdentity()
                                        .withType(ManagedServiceIdentityType.USER_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withLocation("v")
                                .withTags(
                                    mapOf("rmgucnap", "ynqwwncwzzhxgk", "oellwp", "t", "qrhhu", "fdygpfqbuaceopz"))
                                .withSku(
                                    new Sku()
                                        .withName("pppcqeqxo")
                                        .withTier(SkuTier.STANDARD)
                                        .withSize("hzxct")
                                        .withFamily("gbkdmoizpos")
                                        .withCapacity(1176728044))
                                .withRequiredZoneNames(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(PrivateLinkResourceListResultInner.class);
        Assertions.assertEquals(ManagedServiceIdentityType.NONE, model.value().get(0).identity().type());
        Assertions.assertEquals("jkbegibtnmxiebww", model.value().get(0).location());
        Assertions.assertEquals("ayqcgw", model.value().get(0).tags().get("tzjuzgwyzmhtxo"));
        Assertions.assertEquals("dyvxqtayriww", model.value().get(0).sku().name());
        Assertions.assertEquals(SkuTier.PREMIUM, model.value().get(0).sku().tier());
        Assertions.assertEquals("bexrmcq", model.value().get(0).sku().size());
        Assertions.assertEquals("ycnojvknmefqsg", model.value().get(0).sku().family());
        Assertions.assertEquals(488274582, model.value().get(0).sku().capacity());
    }

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