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

package com.azure.resourcemanager.paloaltonetworks.ngfw.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.paloaltonetworks.ngfw.fluent.models.LocalRulestackResourceInner;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.AzureResourceManagerManagedIdentityProperties;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.DefaultMode;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.LocalRulestackResourceListResult;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.ManagedIdentityType;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.ScopeType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class LocalRulestackResourceListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        LocalRulestackResourceListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"panEtag\":\"kixrj\",\"panLocation\":\"irgzp\",\"scope\":\"LOCAL\",\"associatedSubscriptions\":[],\"description\":\"szrnwo\",\"defaultMode\":\"IPS\",\"minAppIdVersion\":\"fpwpjylwbt\",\"provisioningState\":\"Deleted\"},\"identity\":{\"tenantId\":\"cdhszf\",\"principalId\":\"fbgofeljagrqmqh\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{}},\"location\":\"iiiojnalghf\",\"tags\":{\"hhahhxvrhmzkwpjg\":\"vsexsowuelu\",\"j\":\"wspughftqsxhqx\",\"fzdm\":\"ukndxdigrjgu\"},\"id\":\"yqtfihwh\",\"name\":\"otzi\",\"type\":\"gamv\"},{\"properties\":{\"panEtag\":\"ho\",\"panLocation\":\"qzudphq\",\"scope\":\"GLOBAL\",\"associatedSubscriptions\":[],\"description\":\"fwynwcvtbvkay\",\"defaultMode\":\"FIREWALL\",\"minAppIdVersion\":\"vyqia\",\"provisioningState\":\"Accepted\"},\"identity\":{\"tenantId\":\"npwzcjaes\",\"principalId\":\"v\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{}},\"location\":\"ajguqf\",\"tags\":{\"emdwzrmuhapfc\":\"gzlvdnkfxu\"},\"id\":\"dpsqx\",\"name\":\"vpsvuoymgcce\",\"type\":\"vezrypqlmfeo\"},{\"properties\":{\"panEtag\":\"rqwky\",\"panLocation\":\"ob\",\"scope\":\"LOCAL\",\"associatedSubscriptions\":[],\"description\":\"dkow\",\"defaultMode\":\"FIREWALL\",\"minAppIdVersion\":\"pc\",\"provisioningState\":\"Failed\"},\"identity\":{\"tenantId\":\"csnjvcdwxlpqekft\",\"principalId\":\"htjsying\",\"type\":\"None\",\"userAssignedIdentities\":{}},\"location\":\"tmtdhtmdvypgik\",\"tags\":{\"rryuzhlhkjo\":\"zywkb\",\"nrvgoupmfiibfgg\":\"rvqqaatj\",\"wjygvjayvblmhvk\":\"ioolvrwxkvtkkgll\"},\"id\":\"uhbxvvy\",\"name\":\"gsopbyrqufegxu\",\"type\":\"wz\"},{\"properties\":{\"panEtag\":\"nhlmctlpdng\",\"panLocation\":\"vgbmhr\",\"scope\":\"LOCAL\",\"associatedSubscriptions\":[],\"description\":\"yijejvegrhbpnaix\",\"defaultMode\":\"NONE\",\"minAppIdVersion\":\"b\",\"provisioningState\":\"Creating\"},\"identity\":{\"tenantId\":\"cexdrrvqa\",\"principalId\":\"kghtpwijnh\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{}},\"location\":\"f\",\"tags\":{\"fvoow\":\"z\"},\"id\":\"rvmtgjq\",\"name\":\"pyostronzmyhgfi\",\"type\":\"nsxkmcwaekrrjr\"}],\"nextLink\":\"fxtsgum\"}")
                .toObject(LocalRulestackResourceListResult.class);
        Assertions.assertEquals("iiiojnalghf", model.value().get(0).location());
        Assertions.assertEquals("vsexsowuelu", model.value().get(0).tags().get("hhahhxvrhmzkwpjg"));
        Assertions.assertEquals(ManagedIdentityType.USER_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("kixrj", model.value().get(0).panEtag());
        Assertions.assertEquals("irgzp", model.value().get(0).panLocation());
        Assertions.assertEquals(ScopeType.LOCAL, model.value().get(0).scope());
        Assertions.assertEquals("szrnwo", model.value().get(0).description());
        Assertions.assertEquals(DefaultMode.IPS, model.value().get(0).defaultMode());
        Assertions.assertEquals("fpwpjylwbt", model.value().get(0).minAppIdVersion());
        Assertions.assertEquals("fxtsgum", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        LocalRulestackResourceListResult model =
            new LocalRulestackResourceListResult()
                .withValue(
                    Arrays
                        .asList(
                            new LocalRulestackResourceInner()
                                .withLocation("iiiojnalghf")
                                .withTags(
                                    mapOf(
                                        "hhahhxvrhmzkwpjg",
                                        "vsexsowuelu",
                                        "j",
                                        "wspughftqsxhqx",
                                        "fzdm",
                                        "ukndxdigrjgu"))
                                .withIdentity(
                                    new AzureResourceManagerManagedIdentityProperties()
                                        .withType(ManagedIdentityType.USER_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withPanEtag("kixrj")
                                .withPanLocation("irgzp")
                                .withScope(ScopeType.LOCAL)
                                .withAssociatedSubscriptions(Arrays.asList())
                                .withDescription("szrnwo")
                                .withDefaultMode(DefaultMode.IPS)
                                .withMinAppIdVersion("fpwpjylwbt"),
                            new LocalRulestackResourceInner()
                                .withLocation("ajguqf")
                                .withTags(mapOf("emdwzrmuhapfc", "gzlvdnkfxu"))
                                .withIdentity(
                                    new AzureResourceManagerManagedIdentityProperties()
                                        .withType(ManagedIdentityType.SYSTEM_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withPanEtag("ho")
                                .withPanLocation("qzudphq")
                                .withScope(ScopeType.GLOBAL)
                                .withAssociatedSubscriptions(Arrays.asList())
                                .withDescription("fwynwcvtbvkay")
                                .withDefaultMode(DefaultMode.FIREWALL)
                                .withMinAppIdVersion("vyqia"),
                            new LocalRulestackResourceInner()
                                .withLocation("tmtdhtmdvypgik")
                                .withTags(
                                    mapOf(
                                        "rryuzhlhkjo",
                                        "zywkb",
                                        "nrvgoupmfiibfgg",
                                        "rvqqaatj",
                                        "wjygvjayvblmhvk",
                                        "ioolvrwxkvtkkgll"))
                                .withIdentity(
                                    new AzureResourceManagerManagedIdentityProperties()
                                        .withType(ManagedIdentityType.NONE)
                                        .withUserAssignedIdentities(mapOf()))
                                .withPanEtag("rqwky")
                                .withPanLocation("ob")
                                .withScope(ScopeType.LOCAL)
                                .withAssociatedSubscriptions(Arrays.asList())
                                .withDescription("dkow")
                                .withDefaultMode(DefaultMode.FIREWALL)
                                .withMinAppIdVersion("pc"),
                            new LocalRulestackResourceInner()
                                .withLocation("f")
                                .withTags(mapOf("fvoow", "z"))
                                .withIdentity(
                                    new AzureResourceManagerManagedIdentityProperties()
                                        .withType(ManagedIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withPanEtag("nhlmctlpdng")
                                .withPanLocation("vgbmhr")
                                .withScope(ScopeType.LOCAL)
                                .withAssociatedSubscriptions(Arrays.asList())
                                .withDescription("yijejvegrhbpnaix")
                                .withDefaultMode(DefaultMode.NONE)
                                .withMinAppIdVersion("b")))
                .withNextLink("fxtsgum");
        model = BinaryData.fromObject(model).toObject(LocalRulestackResourceListResult.class);
        Assertions.assertEquals("iiiojnalghf", model.value().get(0).location());
        Assertions.assertEquals("vsexsowuelu", model.value().get(0).tags().get("hhahhxvrhmzkwpjg"));
        Assertions.assertEquals(ManagedIdentityType.USER_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("kixrj", model.value().get(0).panEtag());
        Assertions.assertEquals("irgzp", model.value().get(0).panLocation());
        Assertions.assertEquals(ScopeType.LOCAL, model.value().get(0).scope());
        Assertions.assertEquals("szrnwo", model.value().get(0).description());
        Assertions.assertEquals(DefaultMode.IPS, model.value().get(0).defaultMode());
        Assertions.assertEquals("fpwpjylwbt", model.value().get(0).minAppIdVersion());
        Assertions.assertEquals("fxtsgum", 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;
    }
}
