// 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.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.LocalRulestackResourceUpdate;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.LocalRulestackResourceUpdateProperties;
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 LocalRulestackResourceUpdateTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        LocalRulestackResourceUpdate model =
            BinaryData
                .fromString(
                    "{\"identity\":{\"tenantId\":\"flnorwmduvwp\",\"principalId\":\"vxwmygd\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"crxgibb\":{\"clientId\":\"chisze\",\"principalId\":\"nb\"},\"vnuuepzl\":{\"clientId\":\"xconfozauors\",\"principalId\":\"okwbqplh\"},\"vmnnrw\":{\"clientId\":\"hw\",\"principalId\":\"oldweyuqdu\"}}},\"tags\":{\"alywjhhgdn\":\"ork\"},\"properties\":{\"panEtag\":\"sivfomilo\",\"panLocation\":\"gdufiqnd\",\"scope\":\"GLOBAL\",\"associatedSubscriptions\":[\"ofjchvcyyysf\"],\"description\":\"otcubi\",\"defaultMode\":\"FIREWALL\",\"minAppIdVersion\":\"pwoqo\",\"securityServices\":{\"vulnerabilityProfile\":\"cje\",\"antiSpywareProfile\":\"izsh\",\"antiVirusProfile\":\"cimpevfg\",\"urlFilteringProfile\":\"lrri\",\"fileBlockingProfile\":\"ywdxsmic\",\"dnsSubscription\":\"rwfscjfnynszquj\",\"outboundUnTrustCertificate\":\"dvoqyt\",\"outboundTrustCertificate\":\"yo\"}}}")
                .toObject(LocalRulestackResourceUpdate.class);
        Assertions.assertEquals(ManagedIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, model.identity().type());
        Assertions.assertEquals("chisze", model.identity().userAssignedIdentities().get("crxgibb").clientId());
        Assertions.assertEquals("nb", model.identity().userAssignedIdentities().get("crxgibb").principalId());
        Assertions.assertEquals("ork", model.tags().get("alywjhhgdn"));
        Assertions.assertEquals("sivfomilo", model.properties().panEtag());
        Assertions.assertEquals("gdufiqnd", model.properties().panLocation());
        Assertions.assertEquals(ScopeType.GLOBAL, model.properties().scope());
        Assertions.assertEquals("ofjchvcyyysf", model.properties().associatedSubscriptions().get(0));
        Assertions.assertEquals("otcubi", model.properties().description());
        Assertions.assertEquals(DefaultMode.FIREWALL, model.properties().defaultMode());
        Assertions.assertEquals("pwoqo", model.properties().minAppIdVersion());
        Assertions.assertEquals("cje", model.properties().securityServices().vulnerabilityProfile());
        Assertions.assertEquals("izsh", model.properties().securityServices().antiSpywareProfile());
        Assertions.assertEquals("cimpevfg", model.properties().securityServices().antiVirusProfile());
        Assertions.assertEquals("lrri", model.properties().securityServices().urlFilteringProfile());
        Assertions.assertEquals("ywdxsmic", model.properties().securityServices().fileBlockingProfile());
        Assertions.assertEquals("rwfscjfnynszquj", model.properties().securityServices().dnsSubscription());
        Assertions.assertEquals("dvoqyt", model.properties().securityServices().outboundUnTrustCertificate());
        Assertions.assertEquals("yo", model.properties().securityServices().outboundTrustCertificate());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        LocalRulestackResourceUpdate model =
            new LocalRulestackResourceUpdate()
                .withIdentity(
                    new AzureResourceManagerManagedIdentityProperties()
                        .withType(ManagedIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)
                        .withUserAssignedIdentities(
                            mapOf(
                                "crxgibb",
                                new AzureResourceManagerUserAssignedIdentity()
                                    .withClientId("chisze")
                                    .withPrincipalId("nb"),
                                "vnuuepzl",
                                new AzureResourceManagerUserAssignedIdentity()
                                    .withClientId("xconfozauors")
                                    .withPrincipalId("okwbqplh"),
                                "vmnnrw",
                                new AzureResourceManagerUserAssignedIdentity()
                                    .withClientId("hw")
                                    .withPrincipalId("oldweyuqdu"))))
                .withTags(mapOf("alywjhhgdn", "ork"))
                .withProperties(
                    new LocalRulestackResourceUpdateProperties()
                        .withPanEtag("sivfomilo")
                        .withPanLocation("gdufiqnd")
                        .withScope(ScopeType.GLOBAL)
                        .withAssociatedSubscriptions(Arrays.asList("ofjchvcyyysf"))
                        .withDescription("otcubi")
                        .withDefaultMode(DefaultMode.FIREWALL)
                        .withMinAppIdVersion("pwoqo")
                        .withSecurityServices(
                            new SecurityServices()
                                .withVulnerabilityProfile("cje")
                                .withAntiSpywareProfile("izsh")
                                .withAntiVirusProfile("cimpevfg")
                                .withUrlFilteringProfile("lrri")
                                .withFileBlockingProfile("ywdxsmic")
                                .withDnsSubscription("rwfscjfnynszquj")
                                .withOutboundUnTrustCertificate("dvoqyt")
                                .withOutboundTrustCertificate("yo")));
        model = BinaryData.fromObject(model).toObject(LocalRulestackResourceUpdate.class);
        Assertions.assertEquals(ManagedIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, model.identity().type());
        Assertions.assertEquals("chisze", model.identity().userAssignedIdentities().get("crxgibb").clientId());
        Assertions.assertEquals("nb", model.identity().userAssignedIdentities().get("crxgibb").principalId());
        Assertions.assertEquals("ork", model.tags().get("alywjhhgdn"));
        Assertions.assertEquals("sivfomilo", model.properties().panEtag());
        Assertions.assertEquals("gdufiqnd", model.properties().panLocation());
        Assertions.assertEquals(ScopeType.GLOBAL, model.properties().scope());
        Assertions.assertEquals("ofjchvcyyysf", model.properties().associatedSubscriptions().get(0));
        Assertions.assertEquals("otcubi", model.properties().description());
        Assertions.assertEquals(DefaultMode.FIREWALL, model.properties().defaultMode());
        Assertions.assertEquals("pwoqo", model.properties().minAppIdVersion());
        Assertions.assertEquals("cje", model.properties().securityServices().vulnerabilityProfile());
        Assertions.assertEquals("izsh", model.properties().securityServices().antiSpywareProfile());
        Assertions.assertEquals("cimpevfg", model.properties().securityServices().antiVirusProfile());
        Assertions.assertEquals("lrri", model.properties().securityServices().urlFilteringProfile());
        Assertions.assertEquals("ywdxsmic", model.properties().securityServices().fileBlockingProfile());
        Assertions.assertEquals("rwfscjfnynszquj", model.properties().securityServices().dnsSubscription());
        Assertions.assertEquals("dvoqyt", model.properties().securityServices().outboundUnTrustCertificate());
        Assertions.assertEquals("yo", model.properties().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;
    }
}
