// 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.FirewallResourceInner;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.AzureResourceManagerManagedIdentityProperties;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.BooleanEnum;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.FirewallResourceListResult;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.ManagedIdentityType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class FirewallResourceListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        FirewallResourceListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"panEtag\":\"elpcirelsfeaenwa\",\"isPanoramaManaged\":\"FALSE\",\"frontEndSettings\":[],\"provisioningState\":\"Deleting\"},\"identity\":{\"tenantId\":\"jhwuaanozjos\",\"principalId\":\"youlp\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{}},\"location\":\"ag\",\"tags\":{\"itc\":\"imjwosyt\",\"ekkezzikhlyfjh\":\"kfcktqum\"},\"id\":\"gqggebdunygae\",\"name\":\"idb\",\"type\":\"fatpxllrxcyjmoa\"},{\"properties\":{\"panEtag\":\"uvarmywdmjsjq\",\"isPanoramaManaged\":\"TRUE\",\"frontEndSettings\":[],\"provisioningState\":\"Deleting\"},\"identity\":{\"tenantId\":\"yc\",\"principalId\":\"uhpkxkgymar\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{}},\"location\":\"jxqugjhky\",\"tags\":{\"mzqa\":\"eddgssofw\",\"nbyxbaaabjyv\":\"krmnjijpxacqqud\",\"xnevfdnwn\":\"yffimrzrtuzqogs\"},\"id\":\"mewzsyyc\",\"name\":\"uzsoi\",\"type\":\"judpfrxt\"},{\"properties\":{\"panEtag\":\"hzv\",\"isPanoramaManaged\":\"TRUE\",\"frontEndSettings\":[],\"provisioningState\":\"Creating\"},\"identity\":{\"tenantId\":\"ubpaxhe\",\"principalId\":\"i\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{}},\"location\":\"dtiirqt\",\"tags\":{\"xrxxlep\":\"axoruzfgsquy\",\"uqlcvydy\":\"ramxjezwlwnw\",\"oo\":\"atdooaojkniod\"},\"id\":\"bw\",\"name\":\"ujhemmsbvdkcrodt\",\"type\":\"infwjlfltkacjve\"}],\"nextLink\":\"dlfoakggkfp\"}")
                .toObject(FirewallResourceListResult.class);
        Assertions.assertEquals("ag", model.value().get(0).location());
        Assertions.assertEquals("imjwosyt", model.value().get(0).tags().get("itc"));
        Assertions
            .assertEquals(ManagedIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("elpcirelsfeaenwa", model.value().get(0).panEtag());
        Assertions.assertEquals(BooleanEnum.FALSE, model.value().get(0).isPanoramaManaged());
        Assertions.assertEquals("dlfoakggkfp", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        FirewallResourceListResult model =
            new FirewallResourceListResult()
                .withValue(
                    Arrays
                        .asList(
                            new FirewallResourceInner()
                                .withLocation("ag")
                                .withTags(mapOf("itc", "imjwosyt", "ekkezzikhlyfjh", "kfcktqum"))
                                .withIdentity(
                                    new AzureResourceManagerManagedIdentityProperties()
                                        .withType(ManagedIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withPanEtag("elpcirelsfeaenwa")
                                .withIsPanoramaManaged(BooleanEnum.FALSE)
                                .withFrontEndSettings(Arrays.asList()),
                            new FirewallResourceInner()
                                .withLocation("jxqugjhky")
                                .withTags(
                                    mapOf(
                                        "mzqa",
                                        "eddgssofw",
                                        "nbyxbaaabjyv",
                                        "krmnjijpxacqqud",
                                        "xnevfdnwn",
                                        "yffimrzrtuzqogs"))
                                .withIdentity(
                                    new AzureResourceManagerManagedIdentityProperties()
                                        .withType(ManagedIdentityType.USER_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withPanEtag("uvarmywdmjsjq")
                                .withIsPanoramaManaged(BooleanEnum.TRUE)
                                .withFrontEndSettings(Arrays.asList()),
                            new FirewallResourceInner()
                                .withLocation("dtiirqt")
                                .withTags(
                                    mapOf("xrxxlep", "axoruzfgsquy", "uqlcvydy", "ramxjezwlwnw", "oo", "atdooaojkniod"))
                                .withIdentity(
                                    new AzureResourceManagerManagedIdentityProperties()
                                        .withType(ManagedIdentityType.SYSTEM_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withPanEtag("hzv")
                                .withIsPanoramaManaged(BooleanEnum.TRUE)
                                .withFrontEndSettings(Arrays.asList())))
                .withNextLink("dlfoakggkfp");
        model = BinaryData.fromObject(model).toObject(FirewallResourceListResult.class);
        Assertions.assertEquals("ag", model.value().get(0).location());
        Assertions.assertEquals("imjwosyt", model.value().get(0).tags().get("itc"));
        Assertions
            .assertEquals(ManagedIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("elpcirelsfeaenwa", model.value().get(0).panEtag());
        Assertions.assertEquals(BooleanEnum.FALSE, model.value().get(0).isPanoramaManaged());
        Assertions.assertEquals("dlfoakggkfp", 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;
    }
}
