// 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.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 LocalRulestackResourceInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        LocalRulestackResourceInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"panEtag\":\"glikkxwslolb\",\"panLocation\":\"vuzlm\",\"scope\":\"LOCAL\",\"associatedSubscriptions\":[\"ktgplcr\",\"wjxeznoigbr\"],\"description\":\"w\",\"defaultMode\":\"FIREWALL\",\"minAppIdVersion\":\"nbsazejjoqkag\",\"provisioningState\":\"Accepted\",\"securityServices\":{\"vulnerabilityProfile\":\"taugzxnfaa\",\"antiSpywareProfile\":\"xdtnkdmkqjjlw\",\"antiVirusProfile\":\"nvrk\",\"urlFilteringProfile\":\"ou\",\"fileBlockingProfile\":\"bre\",\"dnsSubscription\":\"aays\",\"outboundUnTrustCertificate\":\"ixqtn\",\"outboundTrustCertificate\":\"tezlwff\"}},\"identity\":{\"tenantId\":\"kpj\",\"principalId\":\"qmt\",\"type\":\"None\",\"userAssignedIdentities\":{\"cwxqu\":{\"clientId\":\"mjihyeozphv\",\"principalId\":\"uyqncygupkvipmd\"},\"c\":{\"clientId\":\"vzhfstotxhoj\",\"principalId\":\"bypel\"},\"ttpkiwkkbnujrywv\":{\"clientId\":\"hixbjxyfwnyl\",\"principalId\":\"ool\"}}},\"location\":\"lbfpncurd\",\"tags\":{\"xcbihw\":\"iithtywu\",\"twjchrdg\":\"knfd\",\"uu\":\"ihxumwctondzj\"},\"id\":\"fdlwg\",\"name\":\"ytsbwtovv\",\"type\":\"gseinq\"}")
                .toObject(LocalRulestackResourceInner.class);
        Assertions.assertEquals("lbfpncurd", model.location());
        Assertions.assertEquals("iithtywu", model.tags().get("xcbihw"));
        Assertions.assertEquals(ManagedIdentityType.NONE, model.identity().type());
        Assertions.assertEquals("mjihyeozphv", model.identity().userAssignedIdentities().get("cwxqu").clientId());
        Assertions
            .assertEquals("uyqncygupkvipmd", model.identity().userAssignedIdentities().get("cwxqu").principalId());
        Assertions.assertEquals("glikkxwslolb", model.panEtag());
        Assertions.assertEquals("vuzlm", model.panLocation());
        Assertions.assertEquals(ScopeType.LOCAL, model.scope());
        Assertions.assertEquals("ktgplcr", model.associatedSubscriptions().get(0));
        Assertions.assertEquals("w", model.description());
        Assertions.assertEquals(DefaultMode.FIREWALL, model.defaultMode());
        Assertions.assertEquals("nbsazejjoqkag", model.minAppIdVersion());
        Assertions.assertEquals("taugzxnfaa", model.securityServices().vulnerabilityProfile());
        Assertions.assertEquals("xdtnkdmkqjjlw", model.securityServices().antiSpywareProfile());
        Assertions.assertEquals("nvrk", model.securityServices().antiVirusProfile());
        Assertions.assertEquals("ou", model.securityServices().urlFilteringProfile());
        Assertions.assertEquals("bre", model.securityServices().fileBlockingProfile());
        Assertions.assertEquals("aays", model.securityServices().dnsSubscription());
        Assertions.assertEquals("ixqtn", model.securityServices().outboundUnTrustCertificate());
        Assertions.assertEquals("tezlwff", model.securityServices().outboundTrustCertificate());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        LocalRulestackResourceInner model =
            new LocalRulestackResourceInner()
                .withLocation("lbfpncurd")
                .withTags(mapOf("xcbihw", "iithtywu", "twjchrdg", "knfd", "uu", "ihxumwctondzj"))
                .withIdentity(
                    new AzureResourceManagerManagedIdentityProperties()
                        .withType(ManagedIdentityType.NONE)
                        .withUserAssignedIdentities(
                            mapOf(
                                "cwxqu",
                                new AzureResourceManagerUserAssignedIdentity()
                                    .withClientId("mjihyeozphv")
                                    .withPrincipalId("uyqncygupkvipmd"),
                                "c",
                                new AzureResourceManagerUserAssignedIdentity()
                                    .withClientId("vzhfstotxhoj")
                                    .withPrincipalId("bypel"),
                                "ttpkiwkkbnujrywv",
                                new AzureResourceManagerUserAssignedIdentity()
                                    .withClientId("hixbjxyfwnyl")
                                    .withPrincipalId("ool"))))
                .withPanEtag("glikkxwslolb")
                .withPanLocation("vuzlm")
                .withScope(ScopeType.LOCAL)
                .withAssociatedSubscriptions(Arrays.asList("ktgplcr", "wjxeznoigbr"))
                .withDescription("w")
                .withDefaultMode(DefaultMode.FIREWALL)
                .withMinAppIdVersion("nbsazejjoqkag")
                .withSecurityServices(
                    new SecurityServices()
                        .withVulnerabilityProfile("taugzxnfaa")
                        .withAntiSpywareProfile("xdtnkdmkqjjlw")
                        .withAntiVirusProfile("nvrk")
                        .withUrlFilteringProfile("ou")
                        .withFileBlockingProfile("bre")
                        .withDnsSubscription("aays")
                        .withOutboundUnTrustCertificate("ixqtn")
                        .withOutboundTrustCertificate("tezlwff"));
        model = BinaryData.fromObject(model).toObject(LocalRulestackResourceInner.class);
        Assertions.assertEquals("lbfpncurd", model.location());
        Assertions.assertEquals("iithtywu", model.tags().get("xcbihw"));
        Assertions.assertEquals(ManagedIdentityType.NONE, model.identity().type());
        Assertions.assertEquals("mjihyeozphv", model.identity().userAssignedIdentities().get("cwxqu").clientId());
        Assertions
            .assertEquals("uyqncygupkvipmd", model.identity().userAssignedIdentities().get("cwxqu").principalId());
        Assertions.assertEquals("glikkxwslolb", model.panEtag());
        Assertions.assertEquals("vuzlm", model.panLocation());
        Assertions.assertEquals(ScopeType.LOCAL, model.scope());
        Assertions.assertEquals("ktgplcr", model.associatedSubscriptions().get(0));
        Assertions.assertEquals("w", model.description());
        Assertions.assertEquals(DefaultMode.FIREWALL, model.defaultMode());
        Assertions.assertEquals("nbsazejjoqkag", model.minAppIdVersion());
        Assertions.assertEquals("taugzxnfaa", model.securityServices().vulnerabilityProfile());
        Assertions.assertEquals("xdtnkdmkqjjlw", model.securityServices().antiSpywareProfile());
        Assertions.assertEquals("nvrk", model.securityServices().antiVirusProfile());
        Assertions.assertEquals("ou", model.securityServices().urlFilteringProfile());
        Assertions.assertEquals("bre", model.securityServices().fileBlockingProfile());
        Assertions.assertEquals("aays", model.securityServices().dnsSubscription());
        Assertions.assertEquals("ixqtn", model.securityServices().outboundUnTrustCertificate());
        Assertions.assertEquals("tezlwff", 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;
    }
}
