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

package com.azure.resourcemanager.purview.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.purview.fluent.models.AccountInner;
import com.azure.resourcemanager.purview.models.CloudConnectors;
import com.azure.resourcemanager.purview.models.Identity;
import com.azure.resourcemanager.purview.models.PublicNetworkAccess;
import com.azure.resourcemanager.purview.models.Type;
import com.azure.resourcemanager.purview.models.UserAssignedIdentity;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class AccountInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AccountInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"cloudConnectors\":{\"awsExternalId\":\"azakl\"},\"createdAt\":\"2021-04-01T05:22:51Z\",\"createdBy\":\"bcryffdfd\",\"createdByObjectId\":\"ygexpaojakhmsb\",\"endpoints\":{\"catalog\":\"crzevdphlx\",\"guardian\":\"lthqtrgqjbp\",\"scan\":\"fsinzgvfcjrwzoxx\"},\"friendlyName\":\"felluwfzitonpe\",\"managedResourceGroupName\":\"pjkjlxofpdv\",\"managedResources\":{\"eventHubNamespace\":\"xxypininmay\",\"resourceGroup\":\"ybb\",\"storageAccount\":\"odepoogin\"},\"privateEndpointConnections\":[{\"id\":\"iheogna\",\"name\":\"xzxtheo\",\"type\":\"usivye\"},{\"id\":\"ciqihnhung\",\"name\":\"wjzrnfygxgisp\",\"type\":\"mvtzfkufub\"},{\"id\":\"ofx\",\"name\":\"eofjaeqjh\",\"type\":\"jbasvmsmjqulngs\"}],\"provisioningState\":\"Failed\",\"publicNetworkAccess\":\"NotSpecified\"},\"sku\":{\"capacity\":1557726477,\"name\":\"Standard\"},\"identity\":{\"principalId\":\"wclxxwrl\",\"tenantId\":\"ouskcqvkocrc\",\"type\":\"None\",\"userAssignedIdentities\":{\"jfm\":{\"clientId\":\"hxbnjbiksqrg\",\"principalId\":\"sainqpjwnzl\"},\"vndhkrwpdapp\":{\"clientId\":\"eebvmgxsab\",\"principalId\":\"qduujitcjczdz\"}}},\"location\":\"bdkvwrwjf\",\"tags\":{\"zdatqxhocdg\":\"nhutjeltmrldhugj\"},\"id\":\"ablgphuticndvk\",\"name\":\"ozwyiftyhxhuro\",\"type\":\"ftyxolniw\"}")
                .toObject(AccountInner.class);
        Assertions.assertEquals("bdkvwrwjf", model.location());
        Assertions.assertEquals("nhutjeltmrldhugj", model.tags().get("zdatqxhocdg"));
        Assertions.assertEquals(Type.NONE, model.identity().type());
        Assertions.assertEquals("pjkjlxofpdv", model.managedResourceGroupName());
        Assertions.assertEquals(PublicNetworkAccess.NOT_SPECIFIED, model.publicNetworkAccess());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AccountInner model =
            new AccountInner()
                .withLocation("bdkvwrwjf")
                .withTags(mapOf("zdatqxhocdg", "nhutjeltmrldhugj"))
                .withIdentity(
                    new Identity()
                        .withType(Type.NONE)
                        .withUserAssignedIdentities(
                            mapOf("jfm", new UserAssignedIdentity(), "vndhkrwpdapp", new UserAssignedIdentity())))
                .withCloudConnectors(new CloudConnectors())
                .withManagedResourceGroupName("pjkjlxofpdv")
                .withPublicNetworkAccess(PublicNetworkAccess.NOT_SPECIFIED);
        model = BinaryData.fromObject(model).toObject(AccountInner.class);
        Assertions.assertEquals("bdkvwrwjf", model.location());
        Assertions.assertEquals("nhutjeltmrldhugj", model.tags().get("zdatqxhocdg"));
        Assertions.assertEquals(Type.NONE, model.identity().type());
        Assertions.assertEquals("pjkjlxofpdv", model.managedResourceGroupName());
        Assertions.assertEquals(PublicNetworkAccess.NOT_SPECIFIED, model.publicNetworkAccess());
    }

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