// 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.GlobalRulestackResourceInner;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.AzureResourceManagerManagedIdentityProperties;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.AzureResourceManagerUserAssignedIdentity;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.DefaultMode;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.ManagedIdentityType;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.ScopeType;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.SecurityServices;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class GlobalRulestackResourceInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        GlobalRulestackResourceInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"panEtag\":\"hdbihan\",\"panLocation\":\"hfcbjysa\",\"scope\":\"LOCAL\",\"associatedSubscriptions\":[\"qhabifpikxwcz\",\"yscnpqxu\"],\"description\":\"vyq\",\"defaultMode\":\"IPS\",\"minAppIdVersion\":\"ybrk\",\"provisioningState\":\"Deleted\",\"securityServices\":{\"vulnerabilityProfile\":\"jgrtfwvukxga\",\"antiSpywareProfile\":\"ccsnhsjc\",\"antiVirusProfile\":\"ejhkry\",\"urlFilteringProfile\":\"napczwlokjy\",\"fileBlockingProfile\":\"kkvnipjox\",\"dnsSubscription\":\"nchgej\",\"outboundUnTrustCertificate\":\"odmailzyd\",\"outboundTrustCertificate\":\"o\"}},\"location\":\"wyahuxinpmqnja\",\"identity\":{\"tenantId\":\"xj\",\"principalId\":\"r\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"ozkrwfndiodjpslw\":{\"clientId\":\"utegjvwmfdats\",\"principalId\":\"dvpjhulsuuvmk\"},\"bcryffdfd\":{\"clientId\":\"dpvwryoqpsoaccta\",\"principalId\":\"kljla\"},\"hlxaolthqtr\":{\"clientId\":\"ygexpaojakhmsb\",\"principalId\":\"hcrzevd\"},\"tfell\":{\"clientId\":\"jbp\",\"principalId\":\"fsinzgvfcjrwzoxx\"}}},\"id\":\"fziton\",\"name\":\"eqfpj\",\"type\":\"jlxofpdvhpfxxyp\"}")
                .toObject(GlobalRulestackResourceInner.class);
        Assertions.assertEquals("wyahuxinpmqnja", model.location());
        Assertions.assertEquals(ManagedIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, model.identity().type());
        Assertions
            .assertEquals(
                "utegjvwmfdats", model.identity().userAssignedIdentities().get("ozkrwfndiodjpslw").clientId());
        Assertions
            .assertEquals(
                "dvpjhulsuuvmk", model.identity().userAssignedIdentities().get("ozkrwfndiodjpslw").principalId());
        Assertions.assertEquals("hdbihan", model.panEtag());
        Assertions.assertEquals("hfcbjysa", model.panLocation());
        Assertions.assertEquals(ScopeType.LOCAL, model.scope());
        Assertions.assertEquals("qhabifpikxwcz", model.associatedSubscriptions().get(0));
        Assertions.assertEquals("vyq", model.description());
        Assertions.assertEquals(DefaultMode.IPS, model.defaultMode());
        Assertions.assertEquals("ybrk", model.minAppIdVersion());
        Assertions.assertEquals("jgrtfwvukxga", model.securityServices().vulnerabilityProfile());
        Assertions.assertEquals("ccsnhsjc", model.securityServices().antiSpywareProfile());
        Assertions.assertEquals("ejhkry", model.securityServices().antiVirusProfile());
        Assertions.assertEquals("napczwlokjy", model.securityServices().urlFilteringProfile());
        Assertions.assertEquals("kkvnipjox", model.securityServices().fileBlockingProfile());
        Assertions.assertEquals("nchgej", model.securityServices().dnsSubscription());
        Assertions.assertEquals("odmailzyd", model.securityServices().outboundUnTrustCertificate());
        Assertions.assertEquals("o", model.securityServices().outboundTrustCertificate());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        GlobalRulestackResourceInner model =
            new GlobalRulestackResourceInner()
                .withLocation("wyahuxinpmqnja")
                .withIdentity(
                    new AzureResourceManagerManagedIdentityProperties()
                        .withType(ManagedIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)
                        .withUserAssignedIdentities(
                            mapOf(
                                "ozkrwfndiodjpslw",
                                new AzureResourceManagerUserAssignedIdentity()
                                    .withClientId("utegjvwmfdats")
                                    .withPrincipalId("dvpjhulsuuvmk"),
                                "bcryffdfd",
                                new AzureResourceManagerUserAssignedIdentity()
                                    .withClientId("dpvwryoqpsoaccta")
                                    .withPrincipalId("kljla"),
                                "hlxaolthqtr",
                                new AzureResourceManagerUserAssignedIdentity()
                                    .withClientId("ygexpaojakhmsb")
                                    .withPrincipalId("hcrzevd"),
                                "tfell",
                                new AzureResourceManagerUserAssignedIdentity()
                                    .withClientId("jbp")
                                    .withPrincipalId("fsinzgvfcjrwzoxx"))))
                .withPanEtag("hdbihan")
                .withPanLocation("hfcbjysa")
                .withScope(ScopeType.LOCAL)
                .withAssociatedSubscriptions(Arrays.asList("qhabifpikxwcz", "yscnpqxu"))
                .withDescription("vyq")
                .withDefaultMode(DefaultMode.IPS)
                .withMinAppIdVersion("ybrk")
                .withSecurityServices(
                    new SecurityServices()
                        .withVulnerabilityProfile("jgrtfwvukxga")
                        .withAntiSpywareProfile("ccsnhsjc")
                        .withAntiVirusProfile("ejhkry")
                        .withUrlFilteringProfile("napczwlokjy")
                        .withFileBlockingProfile("kkvnipjox")
                        .withDnsSubscription("nchgej")
                        .withOutboundUnTrustCertificate("odmailzyd")
                        .withOutboundTrustCertificate("o"));
        model = BinaryData.fromObject(model).toObject(GlobalRulestackResourceInner.class);
        Assertions.assertEquals("wyahuxinpmqnja", model.location());
        Assertions.assertEquals(ManagedIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, model.identity().type());
        Assertions
            .assertEquals(
                "utegjvwmfdats", model.identity().userAssignedIdentities().get("ozkrwfndiodjpslw").clientId());
        Assertions
            .assertEquals(
                "dvpjhulsuuvmk", model.identity().userAssignedIdentities().get("ozkrwfndiodjpslw").principalId());
        Assertions.assertEquals("hdbihan", model.panEtag());
        Assertions.assertEquals("hfcbjysa", model.panLocation());
        Assertions.assertEquals(ScopeType.LOCAL, model.scope());
        Assertions.assertEquals("qhabifpikxwcz", model.associatedSubscriptions().get(0));
        Assertions.assertEquals("vyq", model.description());
        Assertions.assertEquals(DefaultMode.IPS, model.defaultMode());
        Assertions.assertEquals("ybrk", model.minAppIdVersion());
        Assertions.assertEquals("jgrtfwvukxga", model.securityServices().vulnerabilityProfile());
        Assertions.assertEquals("ccsnhsjc", model.securityServices().antiSpywareProfile());
        Assertions.assertEquals("ejhkry", model.securityServices().antiVirusProfile());
        Assertions.assertEquals("napczwlokjy", model.securityServices().urlFilteringProfile());
        Assertions.assertEquals("kkvnipjox", model.securityServices().fileBlockingProfile());
        Assertions.assertEquals("nchgej", model.securityServices().dnsSubscription());
        Assertions.assertEquals("odmailzyd", model.securityServices().outboundUnTrustCertificate());
        Assertions.assertEquals("o", model.securityServices().outboundTrustCertificate());
    }

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